Skip to content

Commit

Permalink
FIX: fix time format for BAM and FASTQ extractors
Browse files Browse the repository at this point in the history
  • Loading branch information
alihamraoui committed Aug 22, 2024
1 parent 8d41352 commit 4043ad6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 5 additions & 3 deletions toulligqc/extractor_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,11 @@ def add_image_to_result(quiet, image_list, start_time, image):
def timeISO_to_float(iso_datetime, format):
"""
"""
if '+' in iso_datetime:
iso_datetime = iso_datetime.split('+')[0]
dt = datetime.strptime(iso_datetime, format)
try:
dt = datetime.strptime(iso_datetime, format)
except:
format = '%Y-%m-%dT%H:%M:%SZ'
dt = datetime.strptime(iso_datetime, format)
unix_timestamp = dt.timestamp()
return unix_timestamp

Expand Down
5 changes: 1 addition & 4 deletions toulligqc/fastq_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,7 @@ def _extract_info_from_name(self, name):
"""
"""
metadata = dict(x.split("=") for x in name.split(" ")[1:])
try:
start_time = timeISO_to_float(metadata['start_time'], '%Y-%m-%dT%H:%M:%SZ')
except:
start_time = timeISO_to_float(metadata['start_time'], '%Y-%m-%dT%H:%M:%S.%f')
start_time = timeISO_to_float(metadata['start_time'], '%Y-%m-%dT%H:%M:%S.%f%z')
if self.is_barcode:
return start_time, metadata['ch'], metadata['barcode']
return start_time, metadata['ch']

0 comments on commit 4043ad6

Please sign in to comment.