comparison traj_select_and_merge.xml @ 0:f4a1e92ca3d2 draft

"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit 7d8024bb5f0c425b5a2b37e389802ac250b73c60"
author chemteam
date Thu, 11 Mar 2021 19:54:32 +0000
parents
children 8740338fdff4
comparison
equal deleted inserted replaced
-1:000000000000 0:f4a1e92ca3d2
1 <tool id="traj_selections_and_merge" name="Trajectory select and merge" version="@TOOL_VERSION@+galaxy@GALAXY_VERSION@">
2 <description>- select specific molecules and merge multiple trajectories.</description>
3 <macros>
4 <import>macros.xml</import>
5 <token name="@GALAXY_VERSION@">0</token>
6 </macros>
7 <expand macro="requirements" />
8 <command detect_errors="exit_code"><![CDATA[
9 ln -s '$strin' str.${strin.ext} &&
10 #for $trj in $trajs:
11 ln -s '$trj' `basename '$trj'`.${select.traj_fmt} &&
12 #end for
13 python '$mdtraj_script'
14 --istr str.${strin.ext}
15 --itraj *.${select.traj_fmt}
16 --isele '$selection'
17 --o_str output.${strin.ext}
18 --o_trj output.${select.traj_fmt} &&
19 mv output.${strin.ext} '$outputstr' &&
20 mv output.${select.traj_fmt} '$outputtraj'
21 ]]></command>
22 <configfiles>
23 <configfile name="mdtraj_script"><![CDATA[
24 import mdtraj as md
25 import sys
26 import argparse
27
28 def parse_command_line(argv):
29 parser = argparse.ArgumentParser()
30 parser.add_argument('--istr', help='input str')
31 parser.add_argument('--itraj', nargs='+', help='input traj')
32 parser.add_argument('--isele', help='selection')
33 parser.add_argument('--o_str', help='MDA Ramachandran plot')
34 parser.add_argument('--o_trj', help='Seaborn Ramachandran plot')
35 return parser.parse_args()
36
37 args = parse_command_line(sys.argv)
38 list_of_traj = []
39 if args.itraj is not None:
40 list_of_traj.extend(args.itraj)
41
42 try:
43 traj = md.load(list_of_traj, top=args.istr)
44 except Exception as einstance:
45 print(type(einstance))
46 print(einstance.args)
47 print(einstance)
48 topology = traj.topology
49 try:
50 atoms_to_keep = topology.select(str(args.isele))
51 except Exception as einstance:
52 print("Error: Check the selection is valid for the dataset chosen")
53 print(type(einstance))
54 print(einstance.args)
55 print(einstance)
56 traj.restrict_atoms(atoms_to_keep)
57 newstruct = traj.slice(1)
58 newstruct.save(args.o_str)
59 traj.save(args.o_trj)
60 ]]></configfile>
61 </configfiles>
62 <inputs>
63 <param format="pdb,gro" name="strin" type="data" label="PDB/GRO input" />
64 <conditional name="select">
65 <param name="traj_fmt" type="select" label="Trajectory format" help="Select the trajectory format to filter by">
66 <option selected="True" value="dcd">dcd</option>
67 <option value="xtc">xtc</option>
68 <option value="netcdf">netcdf</option>
69 <option value="trr">trr</option>
70 </param>
71 <when value="dcd">
72 <param name="trajs" multiple="True" type="data" format="dcd" label="trajectory file(s) input" />
73 </when>
74 <when value="xtc">
75 <param name="trajs" multiple="True" type="data" format="xtc" label="trajectory file(s) input" />
76 </when>
77 <when value="netcdf">
78 <param name="trajs" multiple="True" type="data" format="netcdf" label="trajectory file(s) input" />
79 </when>
80 <when value="trr">
81 <param name="trajs" multiple="True" type="data" format="trr" label="trajectory file(s) input" />
82 </when>
83 </conditional>
84 <param name="selection" type="text" value="not water and not segname POT and not segname CLA" label="selection to keep" help="A valid mdtraj style selection string that selects atoms to keep in structure and trajectory file output">
85 <validator type="regex" message="Maximum of 60 characters and space allowed.">^[a-zA-Z0-9 ]{1,60}$</validator>
86 </param>
87 </inputs>
88 <outputs>
89 <data name="outputstr" format_source="strin" />
90 <data name="outputtraj" format_source="trajs" />
91 </outputs>
92 <tests>
93 <test>
94 <param name="strin" value="test.pdb" ftype="pdb" />
95 <conditional name="select">
96 <param name="traj_fmt" value="dcd" />
97 <param name="trajs" value="test.dcd" />
98 </conditional>
99 <param name="selection" value="not water and not segname SOD and not segname CLA" />
100 <output name="outputstr">
101 <assert_contents>
102 <has_text text="ATOM 1 C1 BGL A 1 " />
103 <has_text text="ATOM 24 HO6 BGL A 1" />
104 </assert_contents>
105 </output>
106 <output name="outputtraj">
107 <assert_contents>
108 <has_size value="4000" delta="100" />
109 </assert_contents>
110 </output>
111 </test>
112 <test>
113 <param name="strin" value="test.gro" ftype="gro" />
114 <conditional name="select">
115 <param name="traj_fmt" value="xtc" />
116 <param name="trajs" value="test.xtc" />
117 </conditional>
118 <param name="selection" value="resname BGLC" />
119 <output name="outputstr">
120 <assert_contents>
121 <has_text text=" 1BGLC C1 1" />
122 <has_text text=" 1BGLC HO6 24" />
123 </assert_contents>
124 </output>
125 <output name="outputtraj">
126 <assert_contents>
127 <has_size value="1940" delta="100" />
128 </assert_contents>
129 </output>
130 </test>
131 </tests>
132 <help><![CDATA[
133 .. class:: infomark
134
135 **What it does**
136
137 This tool is a filter and multijoin for trajectory files. You can select specific molecules (or atoms) and save out a new structure and trajectory file. If there are multiple trajectories selected, then these will all be combined into a single trajectory output.
138
139 Use this tool to:
140 - reduce the size of trajectories for later analysis and help with selections where analysis tools may not have selection features that you need.
141 - combine trajectories for analysis, this is imperative for proper molecular dynamics analysis.
142
143 _____
144
145
146 .. class:: infomark
147
148 **Input**
149
150 - Structure file (pdb,gro)
151 - Choose a format of trajectory file (trr,xtc, dcd, netcdf)
152 - Trajectory file(s) (the files displayed are filtered by the trajectory type chosen).
153 - A valid mdtraj selection for the system under consideration. For example: not water and segname CARA and not type H
154
155 _____
156
157
158 .. class:: infomark
159
160 **Output**
161
162 - Structure file (same as input format)
163 - Trajectory file (same as input format)
164 ]]></help>
165 <expand macro="citations" />
166 </tool>