gn_crossmap 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 143661fa671afbd77e8f666ef883df2e127356fa
4
- data.tar.gz: a809d9b2472bb8577fffc9df78b72557f7ff3200
3
+ metadata.gz: 622626c52d655a7b098dc7d6f6e36bb861f2efa3
4
+ data.tar.gz: f28718b24dada45b2caeafd6f9a86b2807910e48
5
5
  SHA512:
6
- metadata.gz: 6dbc394ee6ae8e673f455dba4f789bc0ccded1b5c68ca51e19d1549233effeac417b26f7faa6fcac8a7b7db06f4a4d26e7f0944b5f9553673f82a752452e9048
7
- data.tar.gz: 6e4be322cbd94e014ee70c9f009fe28c2da4f1b9012cf5cdfa2c0c8b62772dd69ed41ae1c42e917d2648ba3852a3c819add1f2813f85800156dff93f0d7111c0
6
+ metadata.gz: 302d0ece173f9d542aeaeabdff469656528a682696ab7cfac5de13d40a55a81f4de691cc6a1948989f40418e6a566751f5c7a8efecbe8fe92cb00ae2bd1dcaad
7
+ data.tar.gz: a91e936f6e8e003b99fb24a9036f7d64e789780ca57cb7a3bf22ef69274e23dc802c3698dac6255782f4fe82723a9e25ec50aef4b53f4dd18fcddb2228d3e7ae
data/.gitignore CHANGED
@@ -12,3 +12,4 @@ output.csv
12
12
  t
13
13
  gn_crossmap-*.gem
14
14
  .byebug_history
15
+ .nvimlog
@@ -7,7 +7,7 @@ AllCops:
7
7
  - exe/crossmap
8
8
  - "**/Gemfile"
9
9
  - "**/Rakefile"
10
+ Layout/DotPosition:
11
+ EnforcedStyle: trailing
10
12
  Style/StringLiterals:
11
13
  EnforcedStyle: double_quotes
12
- Style/DotPosition:
13
- EnforcedStyle: trailing
@@ -1,5 +1,10 @@
1
1
  # ``gn_crossmap`` CHANGELOG
2
2
 
3
+ ## 3.0.1
4
+
5
+ * @dimus - fixes #31 bug: prevent csv row to get squashed
6
+ when original or alternative headers are not unique to each other
7
+
3
8
  ## 3.0.0
4
9
 
5
10
  * @dimus - allow lists without taxonID
data/Rakefile CHANGED
@@ -8,4 +8,4 @@ end
8
8
 
9
9
  RuboCop::RakeTask.new
10
10
 
11
- task default: %i(rubocop rspec)
11
+ task default: %i[rubocop rspec]
@@ -41,6 +41,7 @@ Gem::Specification.new do |gem|
41
41
  gem.add_development_dependency "rspec", "~> 3.2"
42
42
  gem.add_development_dependency "rubocop", "~> 0.31"
43
43
  gem.add_development_dependency "coveralls", "~> 0.8"
44
+ gem.add_development_dependency "byebug", "~> 9.0"
44
45
  end
45
46
 
46
47
  # rubocop:enable Metrics/BlockLength:
@@ -30,15 +30,16 @@ module GnCrossmap
30
30
  end
31
31
 
32
32
  def collect_data
33
- @row = @fields.zip(@row).to_h
34
- data = @collector.id_name_rank(@row)
33
+ @row = @fields.zip(@row)
34
+ @row_hash = @row.to_h
35
+ data = @collector.id_name_rank(@row_hash)
35
36
  return unless data
36
37
  data[:original] = prepare_original
37
38
  @data << data
38
39
  end
39
40
 
40
41
  def prepare_original
41
- @skip_original ? [@row[:taxonid]] : @row.values
42
+ @skip_original ? [@row_hash[:taxonid]] : @row.map(&:last)
42
43
  end
43
44
 
44
45
  def collector_factory
@@ -1,11 +1,11 @@
1
1
  module GnCrossmap
2
2
  # Assemble data from CSV reader by checking column fields
3
3
  class ColumnCollector
4
- RANKS = %i(kingdom subkingdom phylum subphylum superclass class
4
+ RANKS = %i[kingdom subkingdom phylum subphylum superclass class
5
5
  subclass cohort superorder order suborder infraorder superfamily
6
6
  family subfamily tribe subtribe genus subgenus section species
7
- subspecies variety form).freeze
8
- SPECIES_RANKS = %i(genus species subspecies variety form).freeze
7
+ subspecies variety form].freeze
8
+ SPECIES_RANKS = %i[genus species subspecies variety form].freeze
9
9
 
10
10
  def initialize(fields)
11
11
  @fields = fields
@@ -70,10 +70,20 @@ module GnCrossmap
70
70
 
71
71
  def process_headers(row)
72
72
  @original_fields = headers(row)
73
- row = @alt_headers unless @alt_headers.empty?
73
+ row = produce_alt_headers(row) if @alt_headers && !@alt_headers.empty?
74
74
  row
75
75
  end
76
76
 
77
+ def produce_alt_headers(row)
78
+ tail_size = row.size - @alt_headers.size
79
+ if tail_size <= 0
80
+ @alt_headers = @alt_headers[0..row.size - 1]
81
+ else
82
+ tail_size.times { @alt_headers << "" }
83
+ end
84
+ @alt_headers = @alt_headers.map { |h| h.nil? ? "" : h }
85
+ end
86
+
77
87
  def log_progress(count)
78
88
  return false unless (count % 1_000).zero?
79
89
  GnCrossmap.log("Ingesting csv row #{count + 1}")
@@ -1,6 +1,6 @@
1
1
  # Namespace module for crossmapping checklists to GN sources
2
2
  module GnCrossmap
3
- VERSION = "3.0.0".freeze
3
+ VERSION = "3.0.1".freeze
4
4
 
5
5
  def self.version
6
6
  VERSION
@@ -22,10 +22,10 @@ module GnCrossmap
22
22
  private
23
23
 
24
24
  def output_fields(original_fields)
25
- original_fields + %i(matchedType inputName matchedName
25
+ original_fields + %i[matchedType inputName matchedName
26
26
  matchedCanonicalForm inputRank matchedRank
27
27
  synonymStatus acceptedName matchedEditDistance
28
- matchedScore matchTaxonID)
28
+ matchedScore matchTaxonID]
29
29
  end
30
30
  end
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gn_crossmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Mozzherin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-31 00:00:00.000000000 Z
11
+ date: 2017-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trollop
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0.8'
153
+ - !ruby/object:Gem::Dependency
154
+ name: byebug
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '9.0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '9.0'
153
167
  description: Gem uses a checklist in a comma-separated format as an input, and returns
154
168
  back a new comma-separated list crossmapping the scientific names to one of the
155
169
  data sources from http://resolver.globalnames.org
@@ -204,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
218
  version: '0'
205
219
  requirements: []
206
220
  rubyforge_project:
207
- rubygems_version: 2.5.1
221
+ rubygems_version: 2.6.11
208
222
  signing_key:
209
223
  specification_version: 4
210
224
  summary: Crossmaps a list of scientific names to names from a data source in GN Index