From 9763504c4bc8b2222ddfb00e023b97d6b5e1fb14 Mon Sep 17 00:00:00 2001 From: jmrodriguezc Date: Wed, 13 Nov 2024 19:35:02 +0100 Subject: [PATCH] deleting the suffix for the outputs --- add_scanid.py | 15 +++++++++++---- mz_extractor.py | 10 +++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/add_scanid.py b/add_scanid.py index 4624fd0..b82c55d 100644 --- a/add_scanid.py +++ b/add_scanid.py @@ -54,10 +54,17 @@ def main(args): # get the base name of the input file # construct output file path with "_XXX" appended to the filename # log files - outdir = args.outdir if args.outdir else os.path.dirname(ifile) - basename = os.path.splitext(os.path.basename(ifile))[0] - extension = os.path.splitext(os.path.basename(ifile))[1] - ofile = os.path.join(outdir, f"{basename}_ScanID{extension}") + + # outdir = args.outdir if args.outdir else os.path.dirname(ifile) + # basename = os.path.splitext(os.path.basename(ifile))[0] + # extension = os.path.splitext(os.path.basename(ifile))[1] + # ofile = os.path.join(outdir, f"{basename}_ScanID{extension}") + + outdir = args.outdir if args.outdir else os.path.join(os.path.dirname(ifile), script_name.lower()) + os.makedirs(outdir, exist_ok=False) + basename = os.path.basename(ifile) + ofile = os.path.join(outdir, basename) + # get the list of column names that compose the ScanID ids = re.split(r'\s*,\s*', args.ids) diff --git a/mz_extractor.py b/mz_extractor.py index e2fd850..41601a0 100644 --- a/mz_extractor.py +++ b/mz_extractor.py @@ -200,10 +200,12 @@ def print_by_experiment(df, outdir): # create workspace if not os.path.exists(outdir): os.makedirs(outdir, exist_ok=False) - # remove obsolete file + # create temporal file name = os.path.splitext(os.path.basename(exp))[0] ext = os.path.splitext(os.path.basename(exp))[-1] or '.tsv' - ofile = f"{outdir}/{name}_quant{ext}.tmp" + ofile = f"{outdir}/{name}{ext}.tmp" + # basename = os.path.basename(exp) + # ofile = os.path.join(outdir, f"{basename}.tmp") if os.path.isfile(ofile): os.remove(ofile) # print @@ -253,10 +255,12 @@ def main(args): logging.info("print the ID files by experiments") + # get the outputdir. The filename by default + outdir = args.outdir if args.outdir else os.path.join(os.path.dirname(ifile), script_name.lower()) with concurrent.futures.ProcessPoolExecutor(max_workers=args.n_workers) as executor: tmpfiles = executor.map( print_by_experiment, list(ddf.groupby("Spectrum_File")), - itertools.repeat(args.outdir) ) + itertools.repeat(outdir) ) [common.rename_tmpfile(f) for f in list(tmpfiles)] # rename tmp file deleting before the original file # # begin: for debugging in Spyder # tmpfile = print_by_experiment(list(ddf.groupby("Spectrum_File"))[0], args.outdir)