X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=blobdiff_plain;f=htsworkflow%2Fsubmission%2Ffastqname.py;h=0ef67da8f0f9c2a1833903bf44101493f0250ec1;hp=ac3d5fc4ed59a4ff944588c015ae402fba1b0e53;hb=1f296ab3a9c3e7de3270704f789d9e123b0cb69e;hpb=4db6d9f86b96b7b289dc9e6a15b1379418c865ea diff --git a/htsworkflow/submission/fastqname.py b/htsworkflow/submission/fastqname.py index ac3d5fc..0ef67da 100644 --- a/htsworkflow/submission/fastqname.py +++ b/htsworkflow/submission/fastqname.py @@ -7,7 +7,7 @@ SINGLE_TEMPLATE = '{lib_id}_{flowcell}_c{cycle}_l{lane}.fastq{compression_extens FASTQ_RE = re.compile( '(?P[^_]+)_(?P[^_]+)_'\ - 'c(?P[\d]+)_l(?P[\d]+)(_r(?P[\d]))?\.fastq') + 'c(?P[\d]+)_l(?P[\d]+)(_r(?P[\d]))?\.fastq(?P.[\w]+)?') class FastqName(collections.Mapping): """Utility class to convert to the standardized submission fastq name. @@ -58,7 +58,10 @@ class FastqName(collections.Mapping): for k in self.keys(): if k == 'read': continue - if self[k] is None: + elif k == 'compression_extension': + if self[k] not in (None, '', '.gz', '.bz2'): + return False + elif self[k] is None: return False return True is_valid = property(_is_valid) @@ -69,7 +72,11 @@ class FastqName(collections.Mapping): "Please set all needed variables before generating a filename") T = PAIRED_TEMPLATE if self.is_paired else SINGLE_TEMPLATE - return T.format(**self) + attributes = {} + for k in self: + v = self[k] + attributes[k] = v if v is not None else '' + return T.format(**attributes) filename = property(_get_filename) def __iter__(self):