Skip to content

Commit

Permalink
Adding docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dasunpubudumal committed Sep 24, 2024
1 parent db77c2c commit 7de2230
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
6 changes: 0 additions & 6 deletions features/support/step_definitions/plate_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,6 @@
plate_purpose = PlatePurpose.find_by!(name: name)
# binding.pry
plate_purpose.create!(name: plate_name)

# Create requests for the wells of the plate
plate = Plate.find_by(name: plate_name)
plate.wells.each do |well|
FactoryBot.create(:customer_request, asset: well, sti_type: 'Request::LibraryCreation', state: 'pending')
end
end

Given(/^a plate called "([^"]*)" exists with purpose "([^"]*)"$/) do |name, purpose_name|
Expand Down
18 changes: 18 additions & 0 deletions features/support/step_definitions/tag_layout_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,27 +112,45 @@ def check_tag2_layout(name, well_range, expected_wells_to_oligos) # rubocop:todo
set_uuid_for(TagLayout.find(id).plate, uuid_value)
end

# Pooling from source plate ("Testing the API") to destination plate ("Testing the tagging") with a specified pooling
# strategy
#
# rubocop:todo Metrics/MethodLength
def pool_by_strategy(source, destination, pooling_strategy) # rubocop:todo Metrics/AbcSize
unless pooling_strategy.sum == source.size
Rails.logger.info("Pooling strategy does not fit plate size #{source.size}: #{pooling_strategy.inspect}")
end

# Column major: reads columns from left to right, top to bottom
# Row major: reads rows from top to bottom, left to right
# For example, a 96-well plate would be read as: A1, B1, C1, D1, E1, F1, G1, H1, A2, B2, C2, D2, E2, F2, G2, H2, ...
source_wells = source.wells.in_column_major_order.to_a
destination_wells = destination.wells.in_column_major_order.to_a

pooling_strategy.each_with_index do |pool, _old_submission_id|
# This will generate a new submission for each pool. So the number of submissions will be equal to the number of
# pools. For example, for a pooling strategy of [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8], there will be 12 submissions.
submission_id = Submission.create!(user: User.first || User.create!(login: 'a')).id
# Slice operation cuts the array in place (i.e., removes the elements cut from the well array),
# so we need to assign the result to a new variable
wells_for_source, wells_for_destination = source_wells.slice!(0, pool), destination_wells.slice!(0, pool)
wells_for_source
.zip(wells_for_destination)
.each do |w|
# Because of the way we use zip w.first would be the source, w.last would be the destination
# This is the transfer request that would be created by the API
TransferRequest.create!(asset: w.first, target_asset: w.last, submission_id: submission_id)
FactoryBot.create :request_without_submission,
asset: w.first,
target_asset: w.last,
submission_id: submission_id
end
end

# Create a request for each well in the destination plate
destination.wells.each do |well|
FactoryBot.create(:customer_request, asset: well, sti_type: 'Request::LibraryCreation', state: 'pending')
end
end
# rubocop:enable Metrics/MethodLength
# This fakes out the transfers so that they look like they came from different submissions, effectively meaning
Expand Down

0 comments on commit 7de2230

Please sign in to comment.