Skip to content

Commit cb76237

Browse files
strip topup libraries
1 parent 38c0fb6 commit cb76237

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

lib/workload/stateless/stacks/sample-sheet-check/sample-sheet-check-lambda/src/samplesheet.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def set_metadata_row_for_sample(self, metadata_df):
174174
"""
175175
library_id_column_var = METADATA_COLUMN_NAMES["library_id"]
176176
sample_id_column_var = METADATA_COLUMN_NAMES["sample_id"]
177-
library_id_var = self.library_id
177+
library_id_var = SAMPLE_REGEX_OBJS["topup"].sub('', self.library_id)
178178
sample_id_var = self.sample_id
179179

180180
# Query for specific dataframe value
@@ -457,27 +457,25 @@ def set_metadata_from_api(self, auth_header):
457457
library_id_array = []
458458

459459
for sample in self:
460-
library_id_array.append(sample.library_id)
461460

462461
# check that the primary library for the topup exists
463462
if SAMPLE_REGEX_OBJS["topup"].search(sample.library_id) is not None:
464463
logger.info("{} is a top up sample. Investigating the previous sample".format(sample.unique_id))
465464
orig_unique_id = SAMPLE_REGEX_OBJS["topup"].sub('', sample.unique_id)
466-
467465
unique_id_regex_obj = SAMPLE_REGEX_OBJS["unique_id"].match(orig_unique_id)
468466

469467
# Sample ID is the first group and the library ID is the second group
470468
topup_sample_id = unique_id_regex_obj.group(1)
471469
topup_library_id = unique_id_regex_obj.group(2)
472-
473470
# Appending these original sample/library id to the search query
474471
library_id_array.append(topup_library_id)
472+
else:
473+
library_id_array.append(sample.library_id)
475474

476475
try:
477476
metadata_response = get_metadata_record_from_array_of_field_name(auth_header=auth_header,
478477
field_name='library_id',
479478
value_list=library_id_array)
480-
481479
except Exception as e:
482480
raise ApiCallError("Fail to fetch metadata api for library id in the sample sheet")
483481

lib/workload/stateless/stacks/sample-sheet-check/sample-sheet-check-lambda/src/v2_samplesheet_builder.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
V2_SAMPLESHEET_BCLCONVERT_ADAPTER_SETTINGS_BY_ASSAY_TYPE,
2222
V2_ADAPTER_SETTINGS, V2_DATA_ROWS, V2_SAMPLESHEET_GLOBAL_SETTINGS, V2_SAMPLESHEET_DATA_SETTINGS,
2323
V2_BCLCONVERT_BASESPACE_URN, V2_BCLCONVERT_BASESPACE_SOFTWARE_VERSION,
24-
EXPERIMENT_REGEX_STR
24+
EXPERIMENT_REGEX_STR, SAMPLE_REGEX_OBJS
2525
)
2626
from v2_samplesheet_maker.functions.v2_samplesheet_writer import v2_samplesheet_writer
2727

@@ -46,7 +46,8 @@ def get_bclconvert_adapter_setting_by_type_and_assay(sample_type: str, sample_as
4646
if setting_value is not None:
4747
return setting_value
4848
else:
49-
logger.debug(f"Could not get the bclconvert settings for this type / assay combination '{sample_type}' / '{sample_assay}'")
49+
logger.debug(
50+
f"Could not get the bclconvert settings for this type / assay combination '{sample_type}' / '{sample_assay}'")
5051

5152

5253
def get_bclconvert_settings_by_library_id(library_id: str, samplesheet: SampleSheet) -> Dict:
@@ -259,11 +260,11 @@ def get_bclconvert_data_list(samplesheet: SampleSheet) -> List:
259260
for index, data_row in samplesheet.data.iterrows():
260261
# Drop datadict
261262
data_dict = dict(data_row)
262-
263+
library_id = SAMPLE_REGEX_OBJS["topup"].sub('', data_dict["Sample_Name"])
263264
# Add bclconvert settings
264265
data_dict.update(
265266
get_bclconvert_settings_by_library_id(
266-
library_id=data_dict["Sample_Name"],
267+
library_id=library_id,
267268
samplesheet=samplesheet
268269
)
269270
)

0 commit comments

Comments
 (0)