@@ -43,22 +43,18 @@ def parse_args(args=None):
4343 """
4444 parser = argparse .ArgumentParser ()
4545
46- parser .add_argument ("--dir" , dest = "dir" , type = str , default = os .getcwd ())
46+ parser .add_argument ("--dir" , dest = "dir" , type = str , default = os .getcwd (), help = "Directory containining pipeline output files" )
4747 parser .add_argument ("--input_config" , dest = "input_config" , type = str )
4848 parser .add_argument (
49- "-O" , "--output_dir" , dest = "output_dir" , type = str , default = os .getcwd ()
49+ "-O" , "--output_dir" , dest = "output_dir" , type = str , default = os .path . join ( os . getcwd (), "output" )
5050 )
51- parser .add_argument ("-M" , "--mem" , dest = "memory" , type = str , default = "2000 " )
52- parser .add_argument ("-t" , "--time" , dest = "time" , type = str , default = "01 :00:00" )
51+ parser .add_argument ("-M" , "--mem" , dest = "memory" , type = str , default = "6000 " )
52+ parser .add_argument ("-t" , "--time" , dest = "time" , type = str , default = "05 :00:00" )
5353 parser .add_argument (
5454 "-p" , "--partition" , dest = "partition" , type = str , default = "production"
5555 )
56- parser .add_argument (
57- "--mail-user" ,
58- dest = "mail_user" ,
59- type = str ,
60- default = getpass .getuser () + "@ebi.ac.uk" ,
61- )
56+ parser .add_argument ("--mail-user" , dest = "mail_user" , type = str )
57+ parser .add_argument ("--skip-xfail" , dest = "skip_xfail" , action = "store_true" )
6258 parser .add_argument (type = str , nargs = "?" , dest = "tests" , default = "./" )
6359
6460 return parser .parse_args (args )
@@ -134,15 +130,16 @@ def main(args=None):
134130 input_config = args .input_config or None
135131 dir = args .dir
136132 output_dir = args .output_dir
133+ tmp_dir = os .path .join (os .getcwd (), "tmp" )
137134
138135 # create output directory if not already exist
139136 os .makedirs (output_dir , exist_ok = True )
137+ os .makedirs (tmp_dir , exist_ok = True )
140138
141139 species_metadata = {}
142140 if input_config is not None :
143141 species_metadata = get_species_metadata (input_config )
144142
145- vcf_files = []
146143 api_outdir = os .path .join (dir , "api" )
147144 track_outdir = os .path .join (dir , "tracks" )
148145 for genome_uuid in os .listdir (api_outdir ):
@@ -159,20 +156,26 @@ def main(args=None):
159156 bigbed = os .path .join (track_outdir , genome_uuid , "variant-details.bb" )
160157 bigwig = os .path .join (track_outdir , genome_uuid , "variant-summary.bw" )
161158
162- timestamp = int (datetime .datetime .now ().timestamp ())
163- with open (f"dc_{ timestamp } .sh" , "w" ) as file :
159+ skip_xfail_arg = ""
160+ if args .skip_xfail :
161+ skip_xfail_arg = "--skip_xfail"
162+
163+ script_file = os .path .join (tmp_dir , f"dc_{ species } .sh" )
164+ with open (script_file , "w" ) as file :
164165 file .write ("#!/bin/bash\n \n " )
165166
166167 file .write (f"#SBATCH --time={ args .time } \n " )
167168 file .write (f"#SBATCH --mem={ args .memory } \n " )
168169 file .write (f"#SBATCH --partition={ args .partition } \n " )
169- file .write (f"#SBATCH --mail-user={ args .mail_user } \n " )
170- file .write (f"#SBATCH --mail-type=END\n " )
171- file .write (f"#SBATCH --mail-type=FAIL\n " )
170+ if args .mail_user is not None :
171+ file .write (f"#SBATCH --mail-user={ args .mail_user } \n " )
172+ file .write ("#SBATCH --mail-type=END\n " )
173+ file .write ("#SBATCH --mail-type=FAIL\n " )
172174 file .write ("\n " )
173175
176+ file .write ("module load bcftools\n " )
174177 file .write (
175- f"pytest --source_vcf={ source_vcf } --bigbed={ bigbed } --bigwig={ bigwig } --vcf={ vcf } --species={ species } { args .tests } \n "
178+ f"pytest --tap --tb=short { skip_xfail_arg } -- source_vcf={ source_vcf } --bigbed={ bigbed } --bigwig={ bigwig } --vcf={ vcf } --species={ species } { args .tests } \n "
176179 )
177180
178181 subprocess .run (
@@ -184,27 +187,10 @@ def main(args=None):
184187 f"{ output_dir } /dc_{ species } .out" ,
185188 "--error" ,
186189 f"{ output_dir } /dc_{ species } .err" ,
187- f"dc_ { timestamp } .sh" ,
190+ script_file ,
188191 ]
189192 )
190193
191- # subprocess.run([
192- # "bsub",
193- # f"-M{args.memory}",
194- # "-q", f"{args.parition}",
195- # "-J", f"dc_{species}",
196- # "-oo", f"{output_dir}/dc_{species}.out",
197- # "-eo", f"{output_dir}/dc_{species}.err",
198- # f"pytest " + \
199- # f"--source_vcf={source_vcf} " + \
200- # f"--bigbed={bigbed} " + \
201- # f"--bigwig={bigwig} " + \
202- # f"--vcf={vcf} " + \
203- # f"--species={species} " + \
204- # f"{args.tests}"
205- # ]
206- # )
207-
208194
209195if __name__ == "__main__" :
210196 sys .exit (main ())
0 commit comments