diff --git a/Gemfile.lock b/Gemfile.lock index 82ec78b9..3c1c5792 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -484,6 +484,7 @@ GEM yard (0.9.34) PLATFORMS + ruby x86_64-linux DEPENDENCIES diff --git a/app/models/isolate.rb b/app/models/isolate.rb index 96ed364b..ce25e30c 100644 --- a/app/models/isolate.rb +++ b/app/models/isolate.rb @@ -108,11 +108,22 @@ def self.import(file_path, project_id) collection ||= Collection.find_by(acronym: row['Collection']) individual.collection = collection if collection + if row['Family'] + family = Taxon.find_or_create_by(scientific_name: row['Family'], taxonomic_rank: :is_family) if row['Family'] + taxon = family + end + if row['Genus'] && row['Species'] + species = Taxon.find_or_create_by(scientific_name: [row['Genus'], row['Species']].join(' '), + taxonomic_rank: :is_species) + species.update(parent: family) + + taxon = species + if row['Subspecies'] - taxon = Taxon.find_or_create_by(scientific_name: [row['Genus'], row['Species'], row['Subspecies']].join(' ')) - else - taxon = Taxon.find_or_create_by(scientific_name: [row['Genus'], row['Species']].join(' ')) + taxon = Taxon.find_or_create_by(scientific_name: [row['Genus'], row['Species'], row['Subspecies']].join(' '), + taxonomic_rank: :is_subspecies) + taxon.update(parent: species) end end diff --git a/app/models/ngs_run.rb b/app/models/ngs_run.rb index 0410482b..faca0203 100644 --- a/app/models/ngs_run.rb +++ b/app/models/ngs_run.rb @@ -185,7 +185,7 @@ def import(results_path) # Download result file sftp.download!(results_path, "#{Rails.root}/#{self.name}_out.zip") - #TODO: Maybe add possibility to use AWS copy here in case of a reimport of data at a later point + #TODO: Maybe add possibility to use local/AWS copy here in case of a reimport of data at a later point # Unzip results Zip::File.open("#{Rails.root}/#{self.name}_out.zip") do |zip_file|