From c2fc3de462ef4bd1a225c41624b094c3b5874736 Mon Sep 17 00:00:00 2001 From: Thomas N Lawson Date: Wed, 16 Feb 2022 16:04:43 +0000 Subject: [PATCH] v4.9.8+galaxy4 (#23) v4.9.8+Galaxy4: Troubleshooted web-api (problem now fixed) Remove confidence and rank filter Add all structures as output --- README.rst | 7 +- .../sirius_csifingerid/sirius_csifingerid.py | 69 +++++++++---------- .../sirius_csifingerid/sirius_csifingerid.xml | 31 ++++----- 3 files changed, 50 insertions(+), 57 deletions(-) diff --git a/README.rst b/README.rst index b59d2ec..135e068 100644 --- a/README.rst +++ b/README.rst @@ -12,7 +12,7 @@ Source code: https://github.com/boecker-lab/sirius Version ------ -v4.9.8+Galaxy3 +v4.9.8+Galaxy4 Galaxy ------ @@ -34,6 +34,11 @@ Developers & Contributors Changes ------- +v4.9.8+Galaxy4: + - Troubleshooted web-api (problems) + - Remove confidence and rank filter + - Add all structures as output + v4.9.8+Galaxy3: - Version bump for toolshed installation diff --git a/tools/sirius_csifingerid/sirius_csifingerid.py b/tools/sirius_csifingerid/sirius_csifingerid.py index 1e0b441..ba0b639 100644 --- a/tools/sirius_csifingerid/sirius_csifingerid.py +++ b/tools/sirius_csifingerid/sirius_csifingerid.py @@ -14,6 +14,7 @@ parser.add_argument('--input_pth') parser.add_argument('--canopus_result_pth') parser.add_argument('--annotations_result_pth') +parser.add_argument('--all_structures_result_pth') parser.add_argument('--database') parser.add_argument('--profile') parser.add_argument('--candidates') @@ -25,10 +26,9 @@ parser.add_argument('--temp_dir') parser.add_argument('--meta_select_col', default='all') parser.add_argument('--cores_top_level', default=1) +parser.add_argument('--cores_sirius', default=4) parser.add_argument('--chunks', default=1) parser.add_argument('--min_MSMS_peaks', default=1) -parser.add_argument('--rank_filter', default=0) -parser.add_argument('--confidence_filter', default=0) parser.add_argument('--schema', default='msp') parser.add_argument('-a', '--adducts', action='append', nargs=1, required=False, default=[], help='Adducts used') @@ -137,6 +137,7 @@ def parse_meta(meta_regex, meta_info=None): def init_paramd(args): paramd = defaultdict() paramd["cli"] = {} + paramd["cli"]["--cores"] = args.cores_sirius paramd["cli"]["--database"] = args.database paramd["cli"]["--profile"] = args.profile paramd["cli"]["--candidates"] = args.candidates @@ -216,9 +217,11 @@ def run_sirius(meta_info, peaklist, args, wd, spectrac): paramd['additional_details']['adduct'] = adduct # ============== Create CLI cmd for metfrag =============================== - cmd = "sirius --no-citations --ms2 {} --adduct {} --precursor {} -o {} " \ + cmd = "sirius --cores {} --no-citations --ms2 {} --adduct {} " \ + "--precursor {} -o {} " \ "formula -c {} --ppm-max {} --profile {} " \ "structure --database {} canopus".format( + paramd["cli"]["--cores"], paramd["cli"]["--ms2"], adduct, paramd["cli"]["--precursor"], @@ -347,16 +350,18 @@ def work(cmds): # outputs might have different headers. Need to get a list of all the headers # before we start merging the files outfiles = [os.path.join(wd, f) for f in # glob.glob(os.path.join(wd, "*_metfrag_result.csv"))] -def concat_output(filename, result_pth, - rank_filter, confidence_filter): - outfiles = glob.glob(os.path.join(wd, '*', '*{}'.format(filename))) - - # sort files nicely - outfiles.sort(key=lambda s: int(re.match(r'^.*/(' - r'\d+).*{}'.format(filename), - s).group(1))) - print(outfiles) +def concat_output(wd, filename, result_pth, level=2): + + if level == 2: + outfiles = glob.glob(os.path.join(wd, '*', filename)) + else: + outfiles = glob.glob(os.path.join(wd, '*', '*', filename)) + outfiles.sort( + key=lambda s: int( + re.match(r'.*/([0-9]+).*/{}$'.format(filename), + s).group(1))) + print(outfiles) if len(outfiles) == 0: print('No results') sys.exit() @@ -385,36 +390,24 @@ def concat_output(filename, result_pth, with open(fn) as infile: reader = csv.DictReader(infile, delimiter='\t') - ad = paramds[fn.split(os.sep)[-2]]['additional_details'] + ad = paramds[fn.split(os.sep)[-level]]['additional_details'] for line in reader: - if 'rank' in line \ - and 0 < int(rank_filter) < int(line['rank']): - # filter out those annotations greater than rank filter - # If rank_filter is zero then skip - continue - - if 'ConfidenceScore' in line: - if isinstance(line['ConfidenceScore'], str): - # Value is NA or N/A - continue - - if (0 < float(confidence_filter) - and float(line['ConfidenceScore']) - < float(confidence_filter)): - # filter out those annotations that are less than - # the confidence filter value - continue + line.update(ad) dwriter.writerow(line) -concat_output('compound_identifications.tsv', - args.annotations_result_pth, - args.rank_filter, - args.confidence_filter) -concat_output('canopus_summary.tsv', - args.canopus_result_pth, - 0, - 0) +concat_output(wd, + 'compound_identifications.tsv', + args.annotations_result_pth) + +concat_output(wd, + 'canopus_summary.tsv', + args.canopus_result_pth) + +concat_output(wd, + 'structure_candidates.tsv', + args.all_structures_result_pth, + level=3) diff --git a/tools/sirius_csifingerid/sirius_csifingerid.xml b/tools/sirius_csifingerid/sirius_csifingerid.xml index d3c44d7..24f8110 100644 --- a/tools/sirius_csifingerid/sirius_csifingerid.xml +++ b/tools/sirius_csifingerid/sirius_csifingerid.xml @@ -1,5 +1,5 @@ + version="4.9.8+galaxy4" profile="19.05"> is used to identify metabolites using single and tandem mass spectrometry @@ -8,7 +8,7 @@ @@ -136,13 +135,13 @@ - + + + - + + + @@ -150,6 +149,8 @@ from_work_dir="canopus_all_summary.tsv"/> + @@ -195,13 +196,7 @@ - - - - - - - + ----------------