Skip to content

Commit

Permalink
Safeguard barcode extraction logic in SS3Sample class
Browse files Browse the repository at this point in the history
  • Loading branch information
glrs committed Nov 29, 2024
1 parent 4a40f68 commit 47e5418
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/realms/smartseq3/ss3_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,18 @@ def get_barcode(self):
Returns:
str: The barcode of the sample.
"""
barcode = self.sample_data["library_prep"]["A"].get("barcode", None)
if barcode:
return barcode.split("-")[-1]
else:
logging.warning(f"No barcode found in StatusDB for sample {self.id}.")
return None # Or handle more appropriately based on your application's requirements
try:
library_prep = self.sample_data.get("library_prep", {})
prep_A = library_prep.get("A", {})
barcode = prep_A.get("barcode", None)
if barcode:
return barcode.split("-")[-1]
else:
logging.warning(f"No barcode found for sample {self.id}.")
return None # Or handle more appropriately based on your application's requirements
except Exception as e:
logging.error(f"Error extracting barcode for sample {self.id}: {e}")
return None

def _collect_yaml_metadata(self):
"""
Expand Down

0 comments on commit 47e5418

Please sign in to comment.