-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4331 from sanger/y24-055-2
Y24-055 Take 2
- Loading branch information
Showing
15 changed files
with
518 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
app/sequencescape_excel/sequencescape_excel/specialised_field/dual_index_tag_set.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
module SequencescapeExcel | ||
module SpecialisedField | ||
## | ||
# DualIndexTagSet | ||
class DualIndexTagSet | ||
include Base | ||
include ValueRequired | ||
|
||
validate :dual_index_tag_set | ||
|
||
def tag_set_id | ||
@tag_set_id ||= ::TagSet.dual_index.visible.find_by(name: value)&.id | ||
end | ||
|
||
private | ||
|
||
# Check the Dual Index Tag Set with a visible tag_group and tag2_group exists here | ||
# Check the TagSet/TagWell combination in DualIndexTagWell | ||
def dual_index_tag_set | ||
return if tag_set_id.present? | ||
|
||
errors.add(:base, "could not find a visible dual index Tag Set with name '#{value}'.") | ||
end | ||
end | ||
end | ||
end |
76 changes: 76 additions & 0 deletions
76
app/sequencescape_excel/sequencescape_excel/specialised_field/dual_index_tag_well.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# frozen_string_literal: true | ||
|
||
module SequencescapeExcel | ||
module SpecialisedField | ||
## | ||
# DualIndexTagWell | ||
class DualIndexTagWell | ||
include Base | ||
include ValueRequired | ||
|
||
# ValueToUpcase converts the `value` to uppercase | ||
# For exqmple the `value` used in the well_index method would be 'A1' instead of 'a1' | ||
# This is important because the description_to_vertical_plate_position method | ||
# returns a different value for 'A1' vs 'a1', where the upcase version is correct | ||
include ValueToUpcase | ||
|
||
attr_accessor :sf_dual_index_tag_set | ||
|
||
validates :well_index, presence: { message: 'is not valid' } | ||
validates :tag, presence: { message: 'does not have associated i7 tag' }, if: :well_index | ||
validates :tag2, presence: { message: 'does not have associated i5 tag' }, if: :well_index | ||
|
||
PLATE_SIZE = 96 | ||
|
||
def update(_attributes = {}) | ||
return unless valid? | ||
|
||
raise StandardError, 'Tag aliquot mismatch' unless asset.aliquots.one? | ||
|
||
# For dual index tags, tag is a i7 oligo and tag2 is a i5 oligo | ||
asset.aliquots.first.update(tag: tag, tag2: tag2) | ||
end | ||
|
||
def link(other_fields) | ||
self.sf_dual_index_tag_set = other_fields[SequencescapeExcel::SpecialisedField::DualIndexTagSet] | ||
end | ||
|
||
# From the validation in DualIndexTagSet, we know this tag set is a valid dual index tag set | ||
# with a visible tag group and visible tag2 group | ||
def dual_index_tag_set | ||
@dual_index_tag_set = TagSet.find(sf_dual_index_tag_set.tag_set_id) if sf_dual_index_tag_set&.tag_set_id | ||
end | ||
|
||
def tag_group_id | ||
@tag_group_id ||= ::TagGroup.find_by(id: dual_index_tag_set.tag_group_id, visible: true).id | ||
end | ||
|
||
def tag2_group_id | ||
@tag2_group_id ||= ::TagGroup.find_by(id: dual_index_tag_set.tag2_group_id, visible: true).id | ||
end | ||
|
||
private | ||
|
||
# This assumes that the tags within a tag group for dual index tags are listed in 'column' order, | ||
# i.e. the first tag is the one in the first column, the second tag is the one in the second column, etc. | ||
# therefore description_to_vertical_plate_position is used to get the correct map_id | ||
# A1 --> 1 | ||
# B1 --> 2 | ||
# ... | ||
# H12 --> 96 | ||
def well_index | ||
@well_index = Map::Coordinate.description_to_vertical_plate_position(value, PLATE_SIZE) | ||
end | ||
|
||
# i7 tag | ||
def tag | ||
Tag.find_by(tag_group_id: tag_group_id, map_id: well_index) | ||
end | ||
|
||
# i5 tag | ||
def tag2 | ||
Tag.find_by(tag_group_id: tag2_group_id, map_id: well_index) | ||
end | ||
end | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
app/sequencescape_excel/sequencescape_excel/specialised_field/value_to_upcase.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module SequencescapeExcel | ||
module SpecialisedField | ||
## | ||
# ValueToUpcase | ||
module ValueToUpcase | ||
def value=(value) | ||
@value = value.upcase if value.present? | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.