Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rake task for fixing mit sample links to assays #2101

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions lib/tasks/seek_dev.rake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,38 @@ namespace :seek_dev do
printer.print(STDOUT, {})
end

# to fix an issue where MIT samples didn't link to assay following a job timeout
task(:linked_missed_mit_samples_to_assays, [:data_file_id, :assay_ids] => :environment) do |_t, args|
data_file_id = args.data_file_id
assay_ids = args.assay_ids

unless assay_ids.blank? || data_file_id.blank?
data_file = DataFile.find(data_file_id)
samples = data_file.extracted_samples
requested_assays = Assay.find(assay_ids.split(' '))
matching_assays = requested_assays & data_file.assays
puts "About to link assays: #{matching_assays.collect(&:id).join(', ')} with #{samples.count} samples extracted from data file #{data_file.id}"
puts "Enter y to continue, or anything else to exit"
if STDIN.gets.chomp == 'y'
samples.each do |sample|
if sample.assays.empty?
disable_authorization_checks do
data_file.copy_assay_associations([sample], matching_assays)
end
puts "Updated sample #{sample.id}"
else
puts "Assays already linked for sample #{sample.id}"
end
end
else
puts "exited"
end
else
puts "Both data file id and assay ids needed needed. Assay ids should be a space seprated list"
puts "Usage: bundle exec rake seek_dev:linked_missed_mit_samples_to_assays['<df_id>','<assay_id_1> <assay_id_2> ...']"
puts "e.g: bundle exec rake seek_dev:linked_missed_mit_samples_to_assays['1','5 6 7']"
end
end

task(:dump_controlled_vocab, [:id] => :environment) do |_t, args|
vocab = SampleControlledVocab.find(args.id)
Expand Down
Loading