the filename templates were moved from condorfastq to fastqname a while ago
[htsworkflow.git] / htsworkflow / submission / condorfastq.py
index 01fe6c5a19274869b22e41821011135ee8ccb6ae..b6c22348f581f5148eeaa33cacfafe65f6ebc963 100644 (file)
@@ -13,9 +13,10 @@ from htsworkflow.pipelines.samplekey import SampleKey
 from htsworkflow.pipelines import qseq2fastq
 from htsworkflow.pipelines import srf2fastq
 from htsworkflow.pipelines import desplit_fastq
+from htsworkflow.submission.fastqname import FastqName
 from htsworkflow.util.rdfhelp import get_model, dump_model, load_into_model, \
      fromTypedNode, \
-     stripNamespace
+     strip_namespace
 from htsworkflow.util.rdfns import *
 from htsworkflow.util.conversion import parse_flowcell_id
 
@@ -99,8 +100,8 @@ class CondorFastqExtract(object):
                 conversion = conversion_funcs.get(condor_type, None)
                 if conversion is None:
                     errmsg = "Unrecognized type: {0} for {1}"
-                    print errmsg.format(condor_type,
-                                        pformat(available_sources))
+                    LOGGER.error(errmsg.format(condor_type,
+                                        pformat(available_sources)))
                     continue
                 sources = available_sources.get(condor_type, None)
 
@@ -108,7 +109,7 @@ class CondorFastqExtract(object):
                     condor_entries.setdefault(condor_type, []).append(
                         conversion(sources, target_pathname))
             else:
-                print " need file", target_pathname
+                LOGGER.warn(" need file %s", target_pathname)
 
         return condor_entries
 
@@ -195,7 +196,6 @@ WHERE {
             imported = False
             a_lane = self.model.get_target(r['flowcell'],
                                            libraryOntology['has_lane'])
-            print a_lane
             if a_lane is None:
                 imported = True
                 # we lack information about which lanes were on this flowcell
@@ -220,8 +220,6 @@ WHERE {
         Also update model with link between illumina result files
         and our target fastq file.
         """
-        fastq_paired_template = '%(lib_id)s_%(flowcell)s_c%(cycle)s_l%(lane)s_r%(read)s.fastq'
-        fastq_single_template = '%(lib_id)s_%(flowcell)s_c%(cycle)s_l%(lane)s.fastq'
         # find what targets we're missing
         needed_targets = {}
         for seq in raw_files:
@@ -232,18 +230,14 @@ WHERE {
                 'lib_id': seq.library_id,
                 'lane': seq.lane_number,
                 'read': seq.read,
-                'cycle': seq.cycle
+                'cycle': seq.cycle,
+                'is_paired': seq.ispaired
             }
 
-            if seq.ispaired:
-                target_name = fastq_paired_template % \
-                              filename_attributes
-            else:
-                target_name = fastq_single_template % \
-                              filename_attributes
+            fqName = FastqName(**filename_attributes)
 
             result_dir = result_map[seq.library_id]
-            target_pathname = os.path.join(result_dir, target_name)
+            target_pathname = os.path.join(result_dir, fqName.filename)
             if self.force or not os.path.exists(target_pathname):
                 t = needed_targets.setdefault(target_pathname, {})
                 t.setdefault(seq.filetype, []).append(seq)
@@ -351,7 +345,7 @@ class SequenceResult(object):
     ispaired = property(_get_ispaired)
 
     def _get_filetype(self):
-        return stripNamespace(libraryOntology, self._filetype)
+        return strip_namespace(libraryOntology, self._filetype)
     filetype = property(_get_filetype)
 
     def _get_path(self):