from pprint import pformat,pprint
import sys
import types
-from urlparse import urljoin, urlparse
+from urllib.parse import urljoin, urlparse
from htsworkflow.pipelines.sequences import scan_for_sequences, \
update_model_sequence_library
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
if pythonpath is not None:
env = "PYTHONPATH=%s" % (pythonpath,)
condor_entries = self.build_condor_arguments(result_map)
- for script_type in template_map.keys():
+ for script_type in list(template_map.keys()):
template = loader.get_template(template_map[script_type])
variables = {'python': sys.executable,
'logdir': self.log_path,
sequences = self.find_archive_sequence_files(result_map)
needed_targets = self.update_fastq_targets(result_map, sequences)
- for target_pathname, available_sources in needed_targets.items():
+ for target_pathname, available_sources in list(needed_targets.items()):
LOGGER.debug(' target : %s' % (target_pathname,))
LOGGER.debug(' candidate sources: %s' % (available_sources,))
- for condor_type in available_sources.keys():
+ for condor_type in list(available_sources.keys()):
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)
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
return results
def import_libraries(self, result_map):
- for lib_id in result_map.keys():
+ for lib_id in list(result_map.keys()):
lib_id_encoded = lib_id.encode('utf-8')
liburl = urljoin(self.host, 'library/%s/' % (lib_id_encoded,))
library = RDF.Node(RDF.Uri(liburl))
'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)
self.cycle = fromTypedNode(result['cycle'])
self.lane_number = fromTypedNode(result['lane_number'])
self.read = fromTypedNode(result['read'])
- if type(self.read) in types.StringTypes:
+ if type(self.read) in str:
self.read = 1
self.library = result['library']
self.library_id = fromTypedNode(result['library_id'])
if url.scheme == 'file':
return url.path
else:
- errmsg = u"Unsupported scheme {0} for {1}"
- raise ValueError(errmsg.format(url.scheme, unicode(url)))
+ errmsg = "Unsupported scheme {0} for {1}"
+ raise ValueError(errmsg.format(url.scheme, str(url)))
path = property(_get_path)
def __repr__(self):