Initial port to python3
[htsworkflow.git] / htsworkflow / pipelines / srf2fastq.py
old mode 100755 (executable)
new mode 100644 (file)
index 61f93c7..4000fa0
@@ -7,7 +7,7 @@ from subprocess import Popen, PIPE
 import sys
 
 from htsworkflow.util.opener import autoopen
-from htsworkflow.version import version
+from htsworkflow.util.version import version
 
 LOGGER = logging.getLogger(__name__)
 
@@ -27,7 +27,7 @@ def main(cmdline=None):
         logging.basicConfig(level=logging.WARN)
 
     if opts.version:
-        print version()
+        print(version())
         return 0
 
     if len(args) != 1:
@@ -46,7 +46,7 @@ def main(cmdline=None):
 
     # open the srf, fastq, or compressed fastq
     if is_srf(args[0]):
-        source = srf_open(args[0], opts.cnf1)
+        source = srf_open(args[0], opts.srf2fastq, opts.cnf1)
     else:
         source = autoopen(args[0])
 
@@ -81,14 +81,18 @@ You can also force the flowcell ID to be added to the header.""")
                       help="Report software version")
     parser.add_option('--cnf1', default=False, action="store_true",
                       help="Force cnf1 mode in srf2fastq")
+    parser.add_option('--srf2fastq', default='srf2fastq',
+                      help='specify srf2fastq command')
     return parser
 
 
-def srf_open(filename, cnf1=False):
+def srf_open(filename, srf2fastq_cmd, cnf1=False):
     """
     Make a stream from srf file using srf2fastq
     """
-    cmd = ['srf2fastq']
+    if not os.path.exists(srf2fastq_cmd):
+        LOGGER.error("srf command: %s doesn't exist" % (srf2fastq_cmd,))
+    cmd = [srf2fastq_cmd]
     if cnf1 or is_cnf1(filename):
         cmd.append('-c')
     cmd.append(filename)
@@ -99,7 +103,6 @@ def srf_open(filename, cnf1=False):
 
 
 def convert_single_to_fastq(instream, target1, header=''):
-
     state = FASTQ_HEADER
     for line in instream:
         line = line.strip()
@@ -238,7 +241,7 @@ def foo():
     target2_name = base + '_r2.fastq'
 
     for target_name in [target1_name, target2_name]:
-        print 'target name', target_name
+        print('target name', target_name)
         if os.path.exists(target_name):
             raise RuntimeError("%s exists" % (target_name,))