Skip to content

Commit

Permalink
deleting the suffix for the outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrodriguezc committed Nov 13, 2024
1 parent 6f6464d commit 9763504
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
15 changes: 11 additions & 4 deletions add_scanid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 7 additions & 3 deletions mz_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9763504

Please sign in to comment.