Skip to content

Commit

Permalink
Merge pull request #497 from zargham-ahmad/qcxms_changes
Browse files Browse the repository at this point in the history
QCxMS New Version
  • Loading branch information
hechth committed Mar 8, 2024
2 parents b33d814 + 9260390 commit 4018b84
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 36 deletions.
2 changes: 1 addition & 1 deletion tools/qcxms/msp_out.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

molname=`sed -n '2{p;q}' TMPQCXMS/TMP.1/start.xyz`
molname=`sed -n '1{p;q}' molname.txt`
kword=$(grep 'NPOINTS' result.jdx)
num_peaks=$(echo "$kword" | sed 's/^[^=]*=//')
echo `pwd`
Expand Down
75 changes: 75 additions & 0 deletions tools/qcxms/qcxms_getres.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<tool id="qcxms_getres" name="QCxMS get results" version="@TOOL_VERSION@+galaxy0" profile="22.09">
<description>Get result of the Production run to obtain a QCxMS simulated mass spectrum</description>

<macros>
<import>macros.xml</import>
</macros>
<expand macro="edam"/>
<expand macro="creator"/>
<expand macro="requirements"/>

<command detect_errors="exit_code"><![CDATA[
python3 '${get_res}' &&
/plotms_bin/PlotMS.v.6.2.0/plotms &&
sh ${__tool_directory__}/msp_out.sh
]]></command>

<configfiles>
<configfile name="get_res">
#set res_collection = str("', '").join([str($f) for $f in $res_files])

with open('$mol', 'r') as file:
lines = file.readlines()
molname = lines[1]

with open('molname.txt', 'w') as file:
file.write(molname)

input_files = '$res_collection'
output_file = 'tmpqcxms.res'

with open(output_file, 'w') as output:
for file_path in input_files:
with open(file_path, 'r') as input_file:
output.write(input_file.read())

</configfile>
</configfiles>

<inputs>
<param type="data" name="mol" label="Molecule 3D structure [.xzy]" format="xyz" />
<param type="data_collection" collection_type="list" name="res_files" label="res files [.res]" format="txt,text"/>
</inputs>

<outputs>
<data name="msp_output" format="msp" from_work_dir="simulated_spectra.msp" label="simulated_spectra.msp generated by ${tool.name} on ${on_string}"/>
</outputs>

<tests>
<test>
<param name="mol" value="mol.xyz" ftype="xyz"/>
<param name="res_files">
<collection type="list">
<element name="res_files_1" value="res_files/TMP.1_qcxms.txt" />
<element name="res_files_2" value="res_files/TMP.2_qcxms.txt" />
<element name="res_files_3" value="res_files/TMP.3_qcxms.txt" />
</collection>
</param>
<output name="msp_output" file="output.msp" ftype="msp"/>
</test>
</tests>

<help><![CDATA[
The QCxMS getres tool is used to simulate mass spectra for a given molecule.
This tool take res and molecules files and generates simulated mass spectra.
]]>
</help>

<citations>
<citation type="doi">10.1002/anie.201300158</citation>
<citation type="doi">10.1039/C4OB01668H</citation>
<citation type="doi">10.1021/jp5096618</citation>
<citation type="doi">10.1255/ejms.1313</citation>
<citation type="doi">10.1021/acs.jpca.6b02907</citation>
</citations>
</tool>
14 changes: 7 additions & 7 deletions tools/qcxms/qcxms_neutral_run.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="qcxms_neutral_run" name="QCxMS neutral run" version="@TOOL_VERSION@+galaxy0" profile="21.05">
<tool id="qcxms_neutral_run" name="QCxMS neutral run" version="@TOOL_VERSION@+galaxy1" profile="22.09">
<description>required as first step to prepare for the production runs</description>

<macros>
Expand Down Expand Up @@ -56,10 +56,10 @@ rename_files_with_folder_name(path)
</configfiles>

<inputs>
<param type="data" name="mol" label="Molecule 3D structure [.xzy]" format="xyz,txt" />
<param type="data" name="mol" label="Molecule 3D structure [.xzy]" format="xyz" />
<param name="QC_Level" type="select" display="radio" label="QC Method">
<option value="xtb2" selected="true">GFN2-xTB</option>
<option value="xtb">GFN-xTB</option>
<option value="xtb1">GFN1-xTB</option>
</param>
<section name="keywords" title="Advanced method parameters" expanded="false"
help="List of advanced keywords to specify the method - for more information see [1].">
Expand All @@ -84,20 +84,20 @@ rename_files_with_folder_name(path)
<filter>store_extended_output</filter>
</data>

<collection name="coords1" format="txt" type="list" label="coords in files generated by ${tool.name} on ${on_string}" >
<collection name="coords1" format="txt" type="list" label="input in files generated by ${tool.name} on ${on_string}" >
<discover_datasets pattern="(?P&lt;designation&gt;.+)\.in" format="txt" directory="TMPQCXMS" recurse="true"/>
</collection>
<collection name="coords2" format="txt" type="list" label="coords start files generated by ${tool.name} on ${on_string}" >
<collection name="coords2" format="txt" type="list" label="input start files generated by ${tool.name} on ${on_string}" >
<discover_datasets pattern="(?P&lt;designation&gt;.+)\.start" format="txt" directory="TMPQCXMS" recurse="true"/>
</collection>
<collection name="coords3" format="txt" type="list" label="coords xyz files generated by ${tool.name} on ${on_string}" >
<collection name="coords3" format="txt" type="list" label="input xyz files generated by ${tool.name} on ${on_string}" >
<discover_datasets pattern="(?P&lt;designation&gt;.+)\.xyz" format="txt" directory="TMPQCXMS" recurse="true"/>
</collection>
</outputs>

<tests>
<test expect_num_outputs="6">
<param name="mol" value="mol.xyz" ftype="txt"/>
<param name="mol" value="mol.xyz" ftype="xyz"/>
<section name="keywords">
<param name="ntraj" value="2"/>
</section>
Expand Down
49 changes: 21 additions & 28 deletions tools/qcxms/qcxms_prod_run.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="qcxms_production_run" name="QCxMS production run" version="@TOOL_VERSION@+galaxy1" profile="21.05">
<tool id="qcxms_production_run" name="QCxMS production run" version="@TOOL_VERSION@+galaxy2" profile="22.09">
<description>Production run to obtain a QCxMS simulated mass spectrum</description>

<macros>
Expand All @@ -10,10 +10,7 @@

<command detect_errors="exit_code"><![CDATA[
python3 '${create_folder_structure}' &&
find TMPQCXMS/*/ -type d | xargs -I {} -P \${GALAXY_SLOTS:-1} sh -c 'cd {} && /qcxms_bin/qcxms --prod >> $log' &&
/qcxms_bin/getres &&
/plotms_bin/PlotMS.v.6.2.0/plotms &&
sh ${__tool_directory__}/msp_out.sh
(cd TMPQCXMS/*/ && /qcxms_bin/qcxms --prod) >> $log
]]></command>

<environment_variables>
Expand All @@ -25,54 +22,50 @@
import os
import shutil

#set in_collection = str("', '").join([str($f) for $f in $in_files])
#set start_collection = str("', '").join([str($f) for $f in $start_files])
#set xyz_collection = str("', '").join([str($f) for $f in $xyz_files])
names = '$xyz_file.name'
folder_name = names.split("_")[0]

#set names = str("', '").join([str($f.name) for $f in $xyz_files])
names = '$names'
folder_names = [x.split("_")[0] for x in names]

in_collection = '$in_collection'
start_collection = '$start_collection'
xyz_collection = '$xyz_collection'

# Create a new output folder to store the result
output_path = 'TMPQCXMS'
os.makedirs(output_path, exist_ok=True)

for folder_name, in_file, start_file, xyz_file in zip(folder_names, in_collection, start_collection, xyz_collection):
new_folder_path = os.path.join(output_path, folder_name)
os.makedirs(new_folder_path, exist_ok=True)
new_folder_path = os.path.join(output_path, folder_name)
os.makedirs(new_folder_path, exist_ok=True)

shutil.copy2(os.path.join(os.path.dirname(in_collection[0]), in_file), os.path.join(new_folder_path, 'qcxms.in'))
shutil.copy2(os.path.join(os.path.dirname(start_collection[0]), start_file), os.path.join(new_folder_path, 'qcxms.start'))
shutil.copy2(os.path.join(os.path.dirname(xyz_collection[0]), xyz_file), os.path.join(new_folder_path, 'start.xyz'))
shutil.copy2(os.path.join(os.path.dirname('$in_file'), '$in_file'), os.path.join(new_folder_path, 'qcxms.in'))
shutil.copy2(os.path.join(os.path.dirname('$start_file'), '$start_file'), os.path.join(new_folder_path, 'qcxms.start'))
shutil.copy2(os.path.join(os.path.dirname('$xyz_file'), '$xyz_file'), os.path.join(new_folder_path, 'start.xyz'))

</configfile>
</configfiles>

<inputs>
<param type="data_collection" collection_type="list" name="in_files" label="in files [.in]" format="in,txt,text"/>
<param type="data_collection" collection_type="list" name="start_files" label="start files [.start]" format="start,txt,text"/>
<param type="data_collection" collection_type="list" name="xyz_files" label="xyz files [.xyz]" format="xyz,txt,text"/>
<param type="data" name="in_file" label="in files [.in]" format="txt,text"/>
<param type="data" name="start_file" label="start files [.start]" format="txt,text"/>
<param type="data" name="xyz_file" label="xyz files [.xyz]" format="xyz,txt,text"/>
<param name="store_extended_output" type="boolean" value="false" label="Store additional outputs" help="Output the logfile."/>
</inputs>

<outputs>
<data name="msp_output" format="msp" from_work_dir="simulated_spectra.msp" label="simulated_spectra.msp generated by ${tool.name} on ${on_string}"/>
<data name="log" format="txt" label="logfile of ${tool.name} on ${on_string}">
<data name="log" format="txt" label="logfile_of_${tool.id}_on_${on_string}">
<filter>store_extended_output</filter>
</data>
<data name="res_files" format="txt" from_work_dir="TMPQCXMS/*/qcxms.res" label="res files generated by ${tool.name} on ${on_string}"/>
</outputs>

<tests>
<test expect_failure="true"/>
<test expect_num_outputs="1">
<param name="in_file" value="TMP.1_qcxms_in.txt" ftype="txt"/>
<param name="start_file" value="TMP.1_qcxms_start.txt" ftype="txt"/>
<param name="xyz_file" value="TMP.1_start_xyz.txt" ftype="txt"/>
<output name="res_files" file="res_out.txt" ftype="txt"/>
</test>
</tests>

<help><![CDATA[
The QCxMS production run tool is used to simulate mass spectra for a given molecule using the QCxMS (Quantum Chemistry by Mass Spectrometry) method.
This tool generates simulated mass spectra based on the equilibrium structure of a molecule and allows you to perform QCxMS production runs.
This tool allows you to perform QCxMS production runs and generates res files which are further used by QCxMS get results tool to produce the simulated mass spectra.
For detail information visit the documentation at https://xtb-docs.readthedocs.io/en/latest/qcxms_doc/qcxms_run.html#excecuting-the-production-runs
]]>
</help>
Expand Down
7 changes: 7 additions & 0 deletions tools/qcxms/test-data/TMP.1_qcxms_in.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

xtb2
ntraj 2
tmax 20.0
tinit 500.0
ieeatm 0.6

9 changes: 9 additions & 0 deletions tools/qcxms/test-data/TMP.1_qcxms_start.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
1
0.23866896224151D+00
0.89173254224222D+04
-0.18091580000000D-03 0.53537546000000D-04 0.34508200000000D-04 0.50383142501519D+00
0.10322794000000D-03 -0.29410216000000D-03 -0.13830620000000D-03 0.50383142501512D+00
-0.12351298000000D-02 0.10941877000000D-02 -0.68662608000000D-03 0.10000000000000D+01
0.39194769000000D-04 -0.86113874000000D-03 -0.14824698000000D-03 0.99998640424089D+00
0.73344203000000D-03 0.11470574000000D-02 -0.89203254000000D-04 0.99998640424076D+00
0.13882303000000D-02 -0.37015395000000D-03 0.30430224000000D-03 0.99999999999989D+00
8 changes: 8 additions & 0 deletions tools/qcxms/test-data/TMP.1_start_xyz.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
6
6325
C -0.59857822001968 -0.02215985716365 0.13568410610374
C 0.61205863904343 -0.05505705225983 -0.22393772541246
H -1.05122375889205 0.99067995917981 0.32453382107060
H -1.32624440512690 -0.87343794346470 0.13238115658175
H 1.30113828028591 0.80217555351015 -0.27588079204055
H 1.17175212384004 -1.04560876534258 -0.26477384393492
52 changes: 52 additions & 0 deletions tools/qcxms/test-data/output.msp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
NAME: Lindane
Num Peaks: 49
95.953354 29.195388847147174971
96.956708 0.668804095247536257
96.959630 0.006270038392945652
97.950404 18.872816291174281389
97.960062 0.002090012797648551
98.953758 0.408597509163542982
98.956680 0.006270038392945652
99.947454 3.027383551460257394
99.957112 0.001045006398824275
100.950808 0.060610371892150218
100.953730 0.001045006398824275
112.007977 100.000000000000000000
113.011331 6.469344248109893947
113.014253 0.062015503068284489
114.005027 31.968992563911168503
114.014685 0.191684279973595856
114.017607 0.002818886409876120
115.008381 2.170542578675819456
115.011303 0.016913318459256720
116.011735 0.056377728197522396
116.014657 0.002818886409876120
117.015089 0.002818886409876120
121.969004 48.616737474503565863
122.972358 2.314913873279450307
122.975280 0.028382084687048212
123.966054 31.214972837163390551
123.975712 0.030155965625322630
123.978634 0.003547760585881026
124.969408 1.333958011267293520
124.972330 0.010643281757643079
125.963104 4.931387222118633673
125.972762 0.017738802929405131
126.966458 0.184483555628484647
126.969380 0.005321640878821540
127.969812 0.001773880292940513
147.984654 75.667375851606607284
148.988008 4.978153862789445938
148.990930 0.042283303452986920
149.981704 48.524317372305198148
149.991362 0.157857662942868432
149.994284 0.002818886691764789
150.985058 3.038759966527995626
150.987980 0.036645528018447289
151.978754 7.912614881227955976
151.988412 0.087385490521223547
151.991334 0.005637773383529577
152.982108 0.467935188781944900
152.985030 0.002818886691764789
153.985462 0.019732207867858554

5 changes: 5 additions & 0 deletions tools/qcxms/test-data/res_files/TMP.1_qcxms.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
0.0000000 1 1 1 1 1 17 1
0.0000000 1 1 1 3 1 17 1
0.0000000 1 1 2 2 1 17 1
0.0000000 1 1 3 2 1 17 1
1.0000000 1 1 4 1 3 1 6 6 6 17 2
6 changes: 6 additions & 0 deletions tools/qcxms/test-data/res_files/TMP.2_qcxms.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
0.0000000 1 2 1 2 1 17 1
0.0000000 1 2 1 3 1 17 1
0.0000000 1 2 1 4 1 17 1
0.0000001 1 2 2 1 2 1 1 17 1
0.0000000 1 2 2 3 1 17 1
0.9999999 1 2 3 1 3 1 5 6 6 17 1
4 changes: 4 additions & 0 deletions tools/qcxms/test-data/res_files/TMP.3_qcxms.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0.3707160 1 3 1 1 3 1 2 6 2 17 2
0.0000000 1 3 1 3 1 17 1
0.0000000 1 3 2 2 1 17 1
0.6292840 1 3 3 1 3 1 4 6 4 17 2
3 changes: 3 additions & 0 deletions tools/qcxms/test-data/res_out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
0.2874820 1 1 1 2 1 1 1
0.2874820 1 1 1 3 1 1 1
0.4250359 1 1 2 1 2 1 2 6 2

0 comments on commit 4018b84

Please sign in to comment.