Class: Match::Otu::MorphospeciesName
- Inherits:
-
Object
- Object
- Match::Otu::MorphospeciesName
- Includes:
- NameBatchMatcher
- Defined in:
- lib/match/otu/morphospecies_name.rb
Constant Summary
Constants included from NameBatchMatcher
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#project_id ⇒ Object
readonly
Returns the value of attribute project_id.
-
#taxon_name_id ⇒ Object
readonly
Returns the value of attribute taxon_name_id.
Instance Method Summary collapse
-
#initialize(names:, project_id:, taxon_name_id: nil) ⇒ MorphospeciesName
constructor
A new instance of MorphospeciesName.
- #match_name(name) ⇒ Hash private
- #no_match ⇒ Hash private
Methods included from NameBatchMatcher
Constructor Details
#initialize(names:, project_id:, taxon_name_id: nil) ⇒ MorphospeciesName
Returns a new instance of MorphospeciesName.
36 37 38 39 40 |
# File 'lib/match/otu/morphospecies_name.rb', line 36 def initialize(names:, project_id:, taxon_name_id: nil) @names = names.first(NameBatchMatcher::MAX_NAMES) @project_id = project_id @taxon_name_id = taxon_name_id end |
Instance Attribute Details
#names ⇒ Object (readonly)
Returns the value of attribute names.
31 32 33 |
# File 'lib/match/otu/morphospecies_name.rb', line 31 def names @names end |
#project_id ⇒ Object (readonly)
Returns the value of attribute project_id.
31 32 33 |
# File 'lib/match/otu/morphospecies_name.rb', line 31 def project_id @project_id end |
#taxon_name_id ⇒ Object (readonly)
Returns the value of attribute taxon_name_id.
31 32 33 |
# File 'lib/match/otu/morphospecies_name.rb', line 31 def taxon_name_id @taxon_name_id end |
Instance Method Details
#match_name(name) ⇒ Hash (private)
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/match/otu/morphospecies_name.rb', line 46 def match_name(name) genus_term, otu_term = ::Otu.split_morphospecies_name(name) return no_match unless genus_term otus = ::Queries::Otu::Filter.new( genus_name: genus_term, name: otu_term, name_exact: true, taxon_name_id:, descendants: taxon_name_id.present?, project_id: ).all.eager_load(:taxon_name).to_a return no_match if otus.empty? { taxon_name_id: otus.first.taxon_name_id, taxon_name: otus.first.taxon_name, otus:, ambiguous: otus.map(&:taxon_name_id).uniq.size > 1, # homonym genera, or stray duplicate Otu rows matched: true } end |
#no_match ⇒ Hash (private)
71 72 73 |
# File 'lib/match/otu/morphospecies_name.rb', line 71 def no_match { taxon_name_id: nil, taxon_name: nil, otus: [], ambiguous: false, matched: false } end |