99import tempfile
1010from os .path import abspath
1111
12- template = """contigs_fasta:
13- class: File
14- format: edam:format_1929
15- path: {}
16- proteins_fasta:
17- class: File
18- format: edam:format_1929
19- path: {}
20- {}
2112
22- $namespaces:
23- edam: http://edamontology.org/
24- $schemas:
25- - http://edamontology.org/EDAM_1.18.owl
26- """
13+ def build_template (
14+ contig_path : str ,
15+ protein_path : str ,
16+ species_table : str = "" ,
17+ max_intron : str = "" ,
18+ min_intron : str = "" ,
19+ ):
20+ template = f"""
21+ contigs_fasta:
22+ class: File
23+ format: edam:format_1929
24+ path: { contig_path }
25+ proteins_fasta:
26+ class: File
27+ format: edam:format_1929
28+ path: { protein_path }
29+ { max_intron }
30+ { min_intron }
31+ { species_table }
32+
33+ $namespaces:
34+ edam: http://edamontology.org/
35+ $schemas:
36+ - http://edamontology.org/EDAM_1.18.owl
37+ """
38+ return template
2739
2840
2941def is_fasta (input_filename ):
@@ -45,6 +57,8 @@ def is_fasta(input_filename):
4557 )
4658 parser .add_argument ("--output_filename" , default = "spaln_out.gff3" )
4759 parser .add_argument ("--workflow_dir" , default = cwl_workflow_dir )
60+ parser .add_argument ("--max_intron" , type = int , help = "Maximum intron length" )
61+ parser .add_argument ("--min_intron" , type = int , help = "Minimum intron length" )
4862 parser .add_argument ("contigs_filename" , help = "File with genomic contigs" )
4963 parser .add_argument ("proteins_filename" , help = "File with proteins to map" )
5064 parser .add_argument ("--species_table" , help = "spaln species table to use" )
@@ -53,15 +67,21 @@ def is_fasta(input_filename):
5367 sys .exit ("Error: Input files must be in FASTA format" )
5468
5569 cwl_input_file = tempfile .NamedTemporaryFile (delete = False , mode = "w" )
70+
71+ species_table = max_intron = min_intron = ""
5672 if args .species_table is not None :
57- species_table_string = "species_table: {}" .format (args .species_table )
58- else :
59- species_table_string = ""
73+ species_table = "species_table: {}" .format (args .species_table )
74+ if args .max_intron is not None :
75+ max_intron = f"max_intron: { args .max_intron } \n "
76+ if args .min_intron is not None :
77+ min_intron = f"min_intron: { args .min_intron } \n "
6078 cwl_input_file .write (
61- template . format (
79+ build_template (
6280 abspath (args .contigs_filename ),
6381 abspath (args .proteins_filename ),
64- species_table_string ,
82+ species_table = species_table ,
83+ max_intron = max_intron ,
84+ min_intron = min_intron ,
6585 )
6686 )
6787 cwl_input_file .close ()
0 commit comments