Skip to content

Commit

Permalink
v4.9.8+galaxy4 (#23)
Browse files Browse the repository at this point in the history
v4.9.8+Galaxy4:

Troubleshooted web-api (problem now fixed)
Remove confidence and rank filter
Add all structures as output
  • Loading branch information
Tomnl committed Feb 16, 2022
1 parent 3d2543f commit c2fc3de
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 57 deletions.
7 changes: 6 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Source code: https://github.com/boecker-lab/sirius
Version
------

v4.9.8+Galaxy3
v4.9.8+Galaxy4

Galaxy
------
Expand All @@ -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

Expand Down
69 changes: 31 additions & 38 deletions tools/sirius_csifingerid/sirius_csifingerid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
31 changes: 13 additions & 18 deletions tools/sirius_csifingerid/sirius_csifingerid.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<tool id="sirius_csifingerid" name="SIRIUS-CSI:FingerID"
version="4.9.8+galaxy3" profile="19.05">
version="4.9.8+galaxy4" profile="19.05">
<description>is used to identify metabolites using single and
tandem mass spectrometry</description>
<requirements>
Expand All @@ -8,7 +8,7 @@
</requirements>
<command detect_errors="exit_code">
<![CDATA[
export _JAVA_OPTIONS=-Duser.home=$__new_file_path__ &&
python '$__tool_directory__/sirius_csifingerid.py'
--input_pth '$input'
--database $database
Expand All @@ -19,7 +19,9 @@
--out_dir $__new_file_path__
--canopus_result_pth canopus_all_summary.tsv
--annotations_result_pth annotations_all_summary.tsv
--all_structures_result_pth structures_all_summary.tsv
--cores_top_level 1
--cores_sirius \${GALAXY_SLOTS:-4}
--meta_select_col $meta_select_col
--min_MSMS_peaks $min_MSMS_peaks
--schema $schema
Expand Down Expand Up @@ -47,9 +49,6 @@
#end if
#end if
--rank_filter $rank_filter
--confidence_filter $confidence_filter
]]></command>
Expand Down Expand Up @@ -136,20 +135,22 @@
</when>
</conditional>

<param argument="--rank_filter" type="integer" value="0"
label="Only show the top ranked annotations less than or equal
to this value (default to show all annotations)"/>
<!-- <param argument="&#45;&#45;rank_filter" type="integer" value="0"-->
<!-- label="Only show the top ranked annotations less than or equal-->
<!-- to this value (default to show all annotations)"/>-->

<param argument="--confidence_filter" type="float" value="0"
label="Only show annotations greater than or or equal
to this value (default to show all annotations)"/>
<!-- <param argument="&#45;&#45;confidence_filter" type="float" value="0"-->
<!-- label="Only show annotations greater than or or equal-->
<!-- to this value (default to show all annotations)"/>-->

</inputs>
<outputs>
<data name="canopus_results" format="tsv" label="${tool.name} on ${on_string}: CANOPUS"
from_work_dir="canopus_all_summary.tsv"/>
<data name="annotation_results" format="tsv" label="${tool.name} on ${on_string}: Annotations"
from_work_dir="annotations_all_summary.tsv"/>
<data name="structure_results" format="tsv" label="${tool.name} on ${on_string}: All structures"
from_work_dir="structures_all_summary.tsv"/>
</outputs>
<tests>
<test>
Expand Down Expand Up @@ -195,13 +196,7 @@
<output name="annotation_results" file="annotation_RP022611_result_all_adducts.tsv"/>
<output name="canopus_results" file="canopus_RP022611_result_all_adducts.tsv"/>
</test>
<test>
<!-- Test confidence filter -->
<param name="input" value="generic.msp" ftype="msp"/>
<param name="confidence_filter" value="0.7"/>
<output name="annotation_results" file="cf_annotation_generic_msp_result.tsv"/>
<output name="canopus_results" file="cf_canopus_generic_msp_result.tsv"/>
</test>

</tests>
<help>
----------------
Expand Down

0 comments on commit c2fc3de

Please sign in to comment.