3434 import structure_threader .plotter .structplot as sp
3535 import structure_threader .sanity_checks .sanity as sanity
3636
37+
3738def gracious_exit (* args ):
3839 """Graciously exit the program."""
3940 print ("\r Exiting graciously, murdering child processes and cleaning output"
@@ -53,13 +54,13 @@ def runprogram(wrapped_prog, iterations):
5354
5455 K , rep_num = iterations
5556
56- if wrapped_prog == "structure" : # Run STRUCTURE
57+ if wrapped_prog == "structure" : # Run STRUCTURE
5758 # Keeps correct directory separator across OS's
5859 output_file = os .path .join (arg .outpath , "K" + str (K ) + "_rep" +
5960 str (rep_num ))
6061 cli = [arg .structure_bin , "-K" , str (K ), "-i" , arg .infile , "-o" ,
6162 output_file ]
62- else : # Run fastStructure
63+ else : # Run fastStructure
6364 # Keeps correct directory separator across OS's
6465 output_file = os .path .join (arg .outpath , "fS_run_K" )
6566 if arg .infile .endswith ((".bed" , ".fam" , ".bim" )):
@@ -77,7 +78,6 @@ def runprogram(wrapped_prog, iterations):
7778 else :
7879 infile = arg .infile [:- 4 ]
7980
80-
8181 cli = ["python2" , arg .faststructure_bin , "-K" , str (K ), "--input" ,
8282 infile , "--output" , output_file , "--format" , file_format ,
8383 arg .extra_options ]
@@ -86,7 +86,6 @@ def runprogram(wrapped_prog, iterations):
8686 if arg .faststructure_bin .endswith (".py" ) is False :
8787 cli = cli [1 :]
8888
89-
9089 print ("Running: " + " " .join (cli ))
9190 program = subprocess .Popen (cli , bufsize = 64 , shell = False ,
9291 stdout = subprocess .PIPE ,
@@ -122,7 +121,6 @@ def structure_threader(Ks, replicates, threads, wrapped_prog):
122121 else :
123122 os .chdir (os .path .dirname (arg .infile ))
124123
125-
126124 jobs = list (itertools .product (Ks , replicates ))[::- 1 ]
127125
128126 # This allows us to pass partial arguments to a function so we can later
@@ -281,7 +279,6 @@ def argument_parser(args):
281279 arguments .extra_options = "--{0}" .format (arguments .extra_options )
282280 arguments .extra_options = " --" .join (arguments .extra_options .split ())
283281
284-
285282 return arguments
286283
287284
@@ -301,17 +298,16 @@ def main():
301298 arg .outpath = os .path .abspath (arg .outpath )
302299
303300 # Figure out which program we are wrapping
304- if arg .faststructure_bin != None :
301+ if arg .faststructure_bin is not None :
305302 wrapped_prog = "fastStructure"
306303 external = arg .faststructure_bin
307304 else :
308305 wrapped_prog = "structure"
309306 external = arg .structure_bin
310307
311-
312308 # Check the existance of several files:
313309 # Popfile
314- if arg .popfile != None :
310+ if arg .popfile is not None :
315311 sanity .file_checker (arg .popfile , "The specified popfile '{}' does not "
316312 "exist." .format (arg .popfile ))
317313 # External program
@@ -343,5 +339,6 @@ def main():
343339 if arg .noplot is False :
344340 create_plts (arg .outpath , wrapped_prog )
345341
342+
346343if __name__ == "__main__" :
347344 main ()
0 commit comments