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