@@ -311,6 +311,49 @@ def _ti_test(outdir, log_evidence_ti):
311311 return bestk
312312
313313
314+ def plots_only (arg ):
315+ """
316+ Handles arrugments and wraps things up for drawing the plots without Running
317+ any wrapped programs.
318+ """
319+ # Get all files matching the provided prefix
320+ prefix_dir , prefix_name = os .path .split (arg .prefix )
321+
322+ # TODO: Implement sanity checks on the inputs.
323+ if prefix_dir == "" :
324+ prefix_dir = "."
325+
326+ if arg .program == "faststructure" :
327+ infiles = [os .path .join (prefix_dir , x )
328+ for x in os .listdir (prefix_dir ) if
329+ x .startswith (prefix_name ) and
330+ x .endswith (".meanQ" )]
331+ elif arg .program == "structure" :
332+ infiles = [os .path .join (prefix_dir , x )
333+ for x in os .listdir (prefix_dir ) if
334+ x .startswith (prefix_name ) and
335+ "rep1_" in x ]
336+ else :
337+ infiles = [os .path .join (prefix_dir , x )
338+ for x in os .listdir (prefix_dir ) if
339+ x .startswith (prefix_name ) and
340+ x .endswith (".csv" )]
341+
342+ if not infiles :
343+ logging .error ("No input files that match the provided prefix. "
344+ "Aborting." )
345+ raise SystemExit
346+
347+ if not os .path .exists (arg .outpath ):
348+ os .makedirs (arg .outpath )
349+
350+ bestk = [int (x ) for x in arg .bestk ]
351+
352+ sp .main (infiles , arg .program , arg .outpath , bestk , popfile = arg .popfile ,
353+ indfile = arg .indfile , filter_k = bestk , bw = arg .blacknwhite ,
354+ use_ind = arg .use_ind )
355+
356+
314357def argument_parser (args ):
315358 """
316359 Parses the list of arguments as implemented in argparse.
@@ -593,30 +636,7 @@ def main():
593636 # Perform only plotting operation
594637 if arg .main_op == "plot" :
595638
596- # Get all files matching the provided prefix
597- if arg .program == "faststructure" :
598- infiles = [x for x in os .listdir ("." ) if x .startswith (arg .prefix )
599- and x .endswith (".meanQ" )]
600- elif arg .program == "structure" :
601- infiles = [x for x in os .listdir ("." ) if x .startswith (arg .prefix )
602- and "rep1_" in x ]
603- else :
604- infiles = [x for x in os .listdir ("." ) if x .startswith (arg .prefix )
605- and x .endswith (".csv" )]
606-
607- if not infiles :
608- print ("ERROR: There are no input files that match the"
609- " provided prefix" )
610- raise SystemExit
611-
612- if not os .path .exists (arg .outpath ):
613- os .makedirs (arg .outpath )
614-
615- bestk = [int (x ) for x in arg .bestk ]
616-
617- sp .main (infiles , arg .program , arg .outpath , bestk , popfile = arg .popfile ,
618- indfile = arg .indfile , filter_k = bestk , bw = arg .blacknwhite ,
619- use_ind = arg .use_ind )
639+ plots_only (arg )
620640
621641
622642if __name__ == "__main__" :
0 commit comments