Skip to content

Commit

Permalink
Fixed issue with taxon assignment during isolate import.
Browse files Browse the repository at this point in the history
  • Loading branch information
SarahW91 committed May 26, 2023
1 parent d6102bc commit e120966
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ GEM
yard (0.9.34)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
Expand Down
17 changes: 14 additions & 3 deletions app/models/isolate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/models/ngs_run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down

0 comments on commit e120966

Please sign in to comment.