Module: Export::Coldp::Files::VernacularName
- Defined in:
- lib/export/coldp/files/vernacular_name.rb
Overview
taxon_id name - ORIGINAL LANGUAGE transliteration language country area lifestage sex reference_id
Class Method Summary collapse
- .area(common_name) ⇒ Object
- .generate(otus, reference_csv = nil) ⇒ Object
-
.life_stage(common_name) ⇒ Object
TODO: Map to biocuration attribute via URI.
-
.reference_id(common_name) ⇒ String?
“supporting the taxonomic concept” Potentially- all other Citations tied to OTU, what exactly supports a concept? Not used internally within CoLDP, for reference only.
-
.sex(common_name) ⇒ Object
TODO: Map to biocuration attribute via URI.
-
.transliteration(common_name) ⇒ String?
The 'English' translation(s) if available.
Class Method Details
.area(common_name) ⇒ Object
24 25 26 |
# File 'lib/export/coldp/files/vernacular_name.rb', line 24 def self.area(common_name) common_name.geographic_area&.self_and_ancestors&.collect{|a| a.name}&.join('; ') end |
.generate(otus, reference_csv = nil) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/export/coldp/files/vernacular_name.rb', line 48 def self.generate(otus, reference_csv = nil ) CSV.generate(col_sep: "\t") do |csv| # TODO: Biocuration attributes on these two # lifestage # sex csv << %w{ taxonID name transliteration language country area referenceID } otus.joins(:common_names).each do |o| o.common_names.each do |n| sources = n.sources.load csv << [ o.id, n.name, transliteration(n), n.language&.alpha_3_bibliographic, n.geographic_area&.level0&.iso_3166_a2, area(n), sources.collect{|a| a.id}.join(',') # reference_id ] Export::Coldp::Files::Reference.add_reference_rows(sources, reference_csv) if reference_csv && sources.any? end end end end |
.life_stage(common_name) ⇒ Object
TODO: Map to biocuration attribute via URI
29 30 31 |
# File 'lib/export/coldp/files/vernacular_name.rb', line 29 def self.life_stage(common_name) nil end |
.reference_id(common_name) ⇒ String?
“supporting the taxonomic concept” Potentially- all other Citations tied to OTU, what exactly supports a concept?
Not used internally within CoLDP, for reference only. TODO: confirm.
42 43 44 45 46 |
# File 'lib/export/coldp/files/vernacular_name.rb', line 42 def self.reference_id(common_name) i = common_name.sources.pluck(:id) return i.join(',') if i.any? nil end |
.sex(common_name) ⇒ Object
TODO: Map to biocuration attribute via URI
34 35 36 |
# File 'lib/export/coldp/files/vernacular_name.rb', line 34 def self.sex(common_name) nil end |
.transliteration(common_name) ⇒ String?
Returns the 'English' translation(s) if available.
15 16 17 18 19 20 21 22 |
# File 'lib/export/coldp/files/vernacular_name.rb', line 15 def self.transliteration(common_name) n = common_name.alternate_values.where(type: 'AlternateValue::Translation', alternate_value_object_attribute: :name).load if n.any? n.collect{|a| a.language.name == 'English' ? a.language.name : nil}.compact.join('; ') else nil end end |