Commit 61fa1721 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

from python2 to python3 > ok from command line

parent 1dd4412b
......@@ -54,7 +54,7 @@ class MobyleParser(ExternalParser):
return
def fn_define_parameters(self, **kwargs):
for userarg in kwargs.keys():
for userarg in list(kwargs.keys()):
if userarg not in parameters_names :
raise Exception("Invalid argument '%s' for %s"%(userarg, self.get_nameid()))
......@@ -63,14 +63,14 @@ class MobyleParser(ExternalParser):
pname = param['name']
param['value'] = param.get('vdef')
if kwargs.has_key(pname) :
if pname in kwargs:
param['value'] = kwargs[pname]
printval = param['value']
if param['type'] == 'file' or type(param['value']) == str :
printval = "'" + str(param['value']) + "'"
exec "%s = %s"%(pname, printval) in globals(), locals()
exec ("%s = %s"%(pname, printval), globals(), locals())
if param['isfilename'] :
filenames_parameters.append(param)
......@@ -93,7 +93,7 @@ class MobyleParser(ExternalParser):
param['value'] = None
elif param['flist'] :
vlist = param['flist'].keys()
vlist = list(param['flist'].keys())
# custom string type depending on vlist for keys and convert to flist
class flist_type(jflow.extparser._serializable_nested_function):
......@@ -183,7 +183,7 @@ class MobyleParser(ExternalParser):
continue # next parameter, no need to add this one
# regexp to match all filenames
regexp = "|".join([ fnmatch.translate(e) for e in param['filenames']])
print ">>regex for %s %s"%(pname,regexp)
print((">>regex for %s %s"%(pname,regexp)))
self.add_output_file_pattern( pname, param['help'], regexp, **arguments )
else :
......@@ -284,7 +284,7 @@ class MobyleParser(ExternalParser):
if len(vdefs) == 1 :
param['vdef'] = casting(vdefs[0]) if casting else vdefs[0]
else :
param['vdef'] = map(casting, vdefs) if casting else vdefs
param['vdef'] = list(map(casting, vdefs)) if casting else vdefs
# vlist : choices
if parameterNode.find( './vlist' ) is not None :
......
......@@ -15,9 +15,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
--reference-genome
--fasta-file
workflows/mobyle/data/reference.fasta
\ No newline at end of file
--read-1
workflows/mobyle/data/lib_172.1.fastq.gz
--read-2
workflows/mobyle/data/lib_172.2.fastq.gz
\ No newline at end of file
......@@ -108,14 +108,14 @@ class Test (Workflow):
def process(self):
sys.stdout = open(os.path.join(self.directory, "wf_stdout"), 'w')
print "###################### Workflow ############################"
print ("###################### Workflow ############################")
for attr in self.params_order:
value = getattr(self, attr)
print attr
print value
print "class : " + value.__class__.__name__
print "== None : " + str(value == None)
print ""
print (attr)
print (value)
print(("class : " + value.__class__.__name__))
print(("== None : " + str(value == None)))
print ("")
sys.stdout.close()
# test_parameters = self.add_component("TestComponentParameters", [
# self.test_B1,
......
......@@ -50,15 +50,15 @@ class TestComponentParameters (Component):
self.add_input_file("test_C13", "Multiple InputFile default application.properties.", default=test_C13)
def process(self):
print "###################### Component ############################"
print ("###################### Component ############################")
for attr in self.params_order:
value = getattr(self, attr)
print attr
print value
print "class : " + value.__class__.__name__
print (attr)
print (value)
print(("class : " + value.__class__.__name__))
# print "is None : " + str(value is None)
print "== None : " + str(value == None)
print ""
print(("== None : " + str(value == None)))
print ("")
def get_version(self):
return "-"
......@@ -19,8 +19,8 @@ from jflow.workflow import Workflow
import os
import sys
import StringIO
from ConfigParser import ConfigParser
from io import StringIO
from configparser import ConfigParser
from jflow import seqio
......@@ -67,7 +67,7 @@ class VariantCalling (Workflow):
single_fastq, pair1_fastq, pair2_fastq = [], [], []
single_librairies_sequencers, pair_librairies_sequencers = [], []
for lib_arg in self.library:
if lib_arg["sample"] != None and not samples.has_key( lib_arg["sample"] ):
if lib_arg["sample"] != None and not lib_arg["sample"] in samples:
samples[lib_arg["sample"]] = { "paired": list(), "single": list() }
if lib_arg["R2"] != None and lib_arg["R2"] != "":
if lib_arg["sample"] != None:
......@@ -154,7 +154,7 @@ class VariantCalling (Workflow):
gatk_preprocess_bams = list()
processed_idx_paired = dict()
processed_idx_single = dict()
for sample_name in samples.keys():
for sample_name in list(samples.keys()):
current_sample = samples[sample_name]
bams = list()
for idx_bam in current_sample['paired']:
......@@ -167,11 +167,11 @@ class VariantCalling (Workflow):
gatk_preprocess_bams.append( merged_bam.merged_bam )
if len(pair2_fastq) > 0:
for idx, bam_path in enumerate(gatk_preprocess_paired.output_files):
if not processed_idx_paired.has_key(idx):
if not idx in processed_idx_paired:
gatk_preprocess_bams.append( bam_path )
if len(single_fastq) > 0:
for idx, bam_path in enumerate(gatk_preprocess_single.output_files):
if not processed_idx_single.has_key(idx):
if not idx in processed_idx_single:
gatk_preprocess_bams.append( bam_path )
# Variant calling
......@@ -199,7 +199,7 @@ class VariantCalling (Workflow):
@staticmethod
def config_parser(arg_lines):
config = ConfigParser()
config.readfp(StringIO.StringIO('\n'.join(arg_lines)))
config.readfp(StringIO('\n'.join(arg_lines)))
arguments = []
section = 'General'
......@@ -223,7 +223,7 @@ class VariantCalling (Workflow):
items = config.items(section)
for tag, value in items:
lib_id, param = tag.split('.')
if not libraries.has_key( lib_id ):
if not lib_id in libraries:
libraries[lib_id] = list()
if param == 'r1':
libraries[lib_id].append( 'R1=' + value )
......@@ -248,3 +248,4 @@ class VariantCalling (Workflow):
arguments.extend( [ '--two-steps-calling' ] )
return arguments
\ No newline at end of file
......@@ -42,7 +42,7 @@ def create_dictionary(exec_path, dict, input_fasta, databank, stdout_path, stder
stdeh = open(stderr_path)
error_msg = "".join( map(str, stdeh.readlines()) )
stdeh.close()
raise StandardError( "Error in subprocess create_dictionary.\n\tCmd : " + " ".join(cmd) + "\n\tError : " + error_msg )
raise Exception( "Error in subprocess create_dictionary.\n\tCmd : " + " ".join(cmd) + "\n\tError : " + error_msg )
def samtools_faidx(exec_path, databank, fai, stdout_path, stderr_path):
from subprocess import Popen, PIPE
......@@ -63,7 +63,7 @@ def samtools_faidx(exec_path, databank, fai, stdout_path, stderr_path):
stdeh = open(stderr_path)
error_msg = "".join( map(str, stdeh.readlines()) )
stdeh.close()
raise StandardError( "Error in subprocess samtools_faidx.\n\tCmd : " + " ".join(cmd) + "\n\tError : " + error_msg )
raise Exception( "Error in subprocess samtools_faidx.\n\tCmd : " + " ".join(cmd) + "\n\tError : " + error_msg )
class IndexFaiDict (Component):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment