-
Notifications
You must be signed in to change notification settings - Fork 8
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 #1293 from sanger/bioscan-tube-label
DPL-749 Bioscan - traction compatible tube label class
- Loading branch information
Showing
21 changed files
with
493 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# frozen_string_literal: true | ||
|
||
# This label class provides attributes for Bioscan 384-well plate labels, | ||
# which have only a single sticker. The placement of barcode and text fields | ||
# is similar to 96-well plate labels. Note that other 384-well plate labels | ||
# have double stickers. | ||
# | ||
# The label contains a barcode image in the middle and text on the corners. | ||
# * The barcode image in the middle contains human barcode in code128, which | ||
# is more compact and readable than code39. It needs empty space on both | ||
# sides for readabilty. | ||
# * Top-left contains date of printing | ||
# * Bottom-left contains human barcode of the plate | ||
# * Top-right contains the barcode of the an ancestor stock plate. For Bioscan | ||
# 384-well plates, we show the first LILYS barcode, or the first LYSATE | ||
# barcode; not last. | ||
# | ||
# We show an ancestor stock plate barcode; not the parent. The algorithm | ||
# below is generic to handle the cases when ancestor plates with the same | ||
# purpose can be stock plates or non stock plates because of alternative | ||
# pipeline paths and/or when ancestor plates from different paths are used | ||
# together to make a plate. We show the first of the configured alternative | ||
# or the first of closest stock plate ancestors. | ||
# | ||
# Only Squix printers are used for printing 384-well plate labels. We do not | ||
# send print requests to PMB service, instead we send them directly to SPrint | ||
# service, which talks to Squix printers. | ||
# | ||
class Labels::Plate384SingleLabel < Labels::PlateLabelBase | ||
def attributes | ||
{ | ||
top_left: date_today, | ||
bottom_left: labware.barcode.human, | ||
top_right: workline_identifier, | ||
bottom_right: labware.purpose_name, | ||
barcode: labware.barcode.human | ||
} | ||
end | ||
|
||
def workline_identifier | ||
workline_reference&.barcode&.human | ||
end | ||
|
||
# Returns stock plate with fallbacks | ||
def workline_reference | ||
# Find the plates with configured purpose (using alternative_workline_identifier setting) and return the first. | ||
plate = first_of_configured_purpose | ||
return plate if plate.present? | ||
|
||
# Find the plates of the last purpose (using input_plate setting) and return the first. | ||
plate = first_of_last_purpose(SearchHelper.stock_plate_names) | ||
return plate if plate.present? | ||
|
||
# Find the plates of last purpose (using stock_plate setting) and return the first. | ||
first_of_last_purpose(SearchHelper.stock_plate_names_with_flag) | ||
end | ||
|
||
# Returns the first stock plate of the configured purpose | ||
def first_of_configured_purpose | ||
alternative_workline_identifier_purpose = SearchHelper.alternative_workline_reference_name(labware) | ||
return if alternative_workline_identifier_purpose.blank? | ||
|
||
labware.ancestors.where(purpose_name: alternative_workline_identifier_purpose).first | ||
end | ||
|
||
# Returns the first stock plate of the last purpose | ||
def first_of_last_purpose(purpose_names) | ||
return if purpose_names.blank? | ||
|
||
last_purpose_name = labware.ancestors.where(purpose_name: purpose_names).order(id: :asc).last&.purpose&.name | ||
|
||
return if last_purpose_name.blank? | ||
|
||
labware.ancestors.where(purpose_name: [last_purpose_name]).order(id: :asc).first | ||
end | ||
|
||
# There are no defaults configured for this label in the label_templates config. | ||
# It is configured using its section in there. The following methods are to make | ||
# sure that inherited defaults are not captured accidentially. | ||
|
||
def default_printer_type | ||
default_printer_type_for(:plate_384_single) | ||
end | ||
|
||
def default_label_template | ||
default_label_template_for(:plate_384_single) | ||
end | ||
|
||
def default_sprint_label_template | ||
default_sprint_label_template_for(:plate_384_single) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# frozen_string_literal: true | ||
|
||
# This label class provides attributes for Bioscan tube labels. The labels have | ||
# two stickers, side and cap. | ||
# | ||
# The side contain a 2D barcode image and four text lines. | ||
# * The barcode image contains human barcode. | ||
# * The first line contains parent barcode and well range for PCR2 Pool tube | ||
# and only the parent parcode for others. | ||
# * The second line contains current tube barcode without prefix and number of | ||
# pooled samples, the third line contains the labware purpose. | ||
# * The third line contains current tube labware purpose | ||
# # The last line contains date of printing. | ||
# | ||
# The cap contains two text lines. | ||
# * The first contains barcode prefix. | ||
# * The last contains current tube barcode without prefix. | ||
# | ||
# Initially, this arrangement was only intended for Traction compatibility of | ||
# Lib PCR XP (final) tube. However, difficulty of printing 1D barcodes for PCR2 | ||
# and Lib PCR tubes made us using 2D barcodes for all three Bioscan tubes. | ||
# | ||
# Only Squix printers are used for printing labels for Bioscan labware from | ||
# Limber. We do not send the print requests to PMB service, instead we send them | ||
# directly to SPrint service, which talks to Squix printers. | ||
# | ||
class Labels::TubeLabelTractionCompatible < Labels::TubeLabel | ||
def attributes | ||
{ | ||
first_line: first_line, | ||
second_line: second_line, | ||
third_line: labware.purpose_name, | ||
fourth_line: date_today, | ||
round_label_top_line: labware.barcode.prefix, | ||
round_label_bottom_line: barcode_human_without_prefix, | ||
barcode: labware.barcode.human | ||
} | ||
end | ||
|
||
def first_line | ||
# Parent barcode for PCR 2 Pool tube. | ||
# This is the asset name (plate barcode and well range) | ||
barcode_and_wells_format = /^.+?\s[A-Z]\d{1,2}:[A-Z]\d{1,2}$/ | ||
return labware.name if labware.name&.match?(barcode_and_wells_format) | ||
|
||
# Parent barcode for Lib PCR Pool and Lib PCR XP tubes | ||
labware.parents[0].barcode.human | ||
end | ||
|
||
def second_line | ||
pools_size = @options[:pool_size] || labware.aliquots.count | ||
"#{barcode_human_without_prefix}, P#{pools_size}" | ||
end | ||
|
||
def barcode_human_without_prefix | ||
labware.barcode.human.sub(/\A#{Regexp.escape(labware.barcode.prefix)}/, '') | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Presenters | ||
# This presenter enables printing labels for 'Tag Plate - 384' plates. | ||
class TagPlate384Presenter < UnknownPlatePresenter | ||
def label | ||
label_class = purpose_config.fetch(:label_class) || 'Labels::Plate384SingleLabel' | ||
label_class.constantize.new(labware) | ||
end | ||
|
||
def add_unknown_plate_warnings | ||
errors.add( | ||
:plate, | ||
"type '#{labware.purpose_name}' is not a limber plate. " \ | ||
'You can still use this page to print labels.' | ||
) | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
# Tag Plate - 384 is not a Limber plate. This config is used for printing. | ||
Tag Plate - 384: | ||
:asset_type: plate | ||
:presenter_class: Presenters::TagPlate384Presenter | ||
:size: 384 | ||
:label_template: plate_384_single |
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,44 @@ | ||
[ | ||
{ | ||
"barcodeFields": [ | ||
{ | ||
"x": 17, | ||
"y": 1, | ||
"cellWidth": 0.2, | ||
"barcodeType": "code128", | ||
"value": "<%= merge_fields[:barcode] %>", | ||
"height": 5 | ||
} | ||
], | ||
"textFields": [ | ||
{ | ||
"x": 1, | ||
"y": 2, | ||
"value": "<%= merge_fields[:top_left] %>", | ||
"fontSize": 1.5, | ||
"font": "proportional" | ||
}, | ||
{ | ||
"x": 1, | ||
"y": 5, | ||
"value": "<%= merge_fields[:bottom_left] %>", | ||
"fontSize": "1.5", | ||
"font": "proportional" | ||
}, | ||
{ | ||
"x": 55, | ||
"y": 2, | ||
"value": "<%= merge_fields[:top_right] %>", | ||
"fontSize": 1.5, | ||
"font": "proportional" | ||
}, | ||
{ | ||
"x": 55, | ||
"y": 5, | ||
"value": "<%= merge_fields[:bottom_right] %>", | ||
"fontSize": 1.5, | ||
"font": "proportional" | ||
} | ||
] | ||
} | ||
] |
Oops, something went wrong.