view trj.xml @ 7:16fad30d566a draft

"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/gromacs commit 2f3d14b4f200100881e362b0f3b97f0e8a36d1f3"
author chemteam
date Wed, 29 Sep 2021 07:42:39 +0000
parents 6dcfdac2dcae
children 72459c3ea5f6
line wrap: on
line source

<tool id="gmx_trj" name="Modify/convert GROMACS trajectories" version="@TOOL_VERSION@+galaxy@GALAXY_VERSION@">
    <description>using trjconv and trjcat</description>
    <macros>
        <import>macros.xml</import>
        <token name="@GALAXY_VERSION@">0</token>
        <xml name="fit_when" token_option="none">
            <when value="@OPTION@">
                <param name="index_fit" type="text" label="Index of group to use for fitting" help="Index of group to use for fitting - i.e. the group's position in the ndx file (using zero-based numbering, so the first group has index 0).">
                    <validator type="regex" message="Only numeric values allowed">^[0-9]*$</validator>
                </param>
            </when>
        </xml>
    </macros>

    <expand macro="requirements" />

    <command detect_errors="exit_code"><![CDATA[
    #if $trj.trj_op == 'trjcat':
        mkdir trajs &&
        #for $value, $file in enumerate($trj_input):
            ln -s '$file' trajs/traj_${value}.${file.ext} &&
        #end for

        gmx trjcat
            -f trajs/traj* ## here we assume that they all have the same ext, probably reasonable
            $trj.cat
            -e '$time.e'

    #elif $trj.trj_op == 'trjconv':
        ln -s '$ndx_input' ./index.ndx &&
        ln -s '$str_input' ./str.${str_input.ext} &&
        ln -s '$trj_input' ./traj.${trj_input.ext} &&

    echo ## optionally pipe in the following
	#if $trj.fit.fit != 'none':
	    '$trj.fit.index_fit'
    #end if
    #if $trj.pbc.pbc == 'cluster':
	    '$trj.pbc.index_cluster'
    #end if
    '$trj.index_center'	'$trj.index_output' | gmx trjconv
      	-f ./traj.${trj_input.ext}
        -s ./str.${str_input.ext}
        #if $ndx_input:
            -n ./index.ndx
        #end if
        #if $trj.index_center:
            -center
        #end if
        #if $trj.sep:
            -sep
            -nzero 9  ## hopefully the traj has < 1 bn frames, or collection order will be wrong
        #end if
        -pbc $trj.pbc.pbc
        -ur $trj.ur
        -boxcenter $trj.boxcenter
        -fit $trj.fit.fit
        #if $time.e != -1:
            -e '$time.e'
        #end if
    #end if

    -b '$time.b'
    -dt '$time.dt'
    -o ./output.${output_format} &&
    &>> verbose.txt
    #if not $trj.sep:
        &&
        mv ./output.${output_format} '$output'
    #end if
    ]]></command>

    <inputs>
        <conditional name="trj">
            <param name="trj_op" type="select" label="Modify a trajectory or concatenate multiple trajectories?">
                <option value="trjconv">Modify (trjconv)</option>
                <option value="trjcat">Concatenate (trjcat)</option>
            </param>
            <when value="trjconv">
                <param name="trj_input" type="data" format='xtc,trr,pdb,gro' label="Input trajectory" help="In XTC or TRR format; structure files with PDB or GRO format can also be used."/>
                <param name="str_input" type="data" format='pdb,gro,tpr' label="Input structure" help="In PDB, GRO or TPR format."/>
                <param name="ndx_input" type="data" format='ndx' label="Index (NDX) file" optional="true" help="In NDX format. Optional."/>
                <param name="index_output" value="0" type="text" label="Index of group to save in the output" help="Index of group to save in the output - i.e. the group's position in the ndx file (using zero-based numbering, so the first group has index 0).">
                    <validator type="regex" message="Only numeric values allowed">^[0-9]*$</validator>
                </param>
                <param name="index_center" type="text" label="Index of group for centering" optional="true" help="Index of group for centering - i.e. the group's position in the ndx file (using zero-based numbering, so the first group has index 0). Leave blank if centering is not required.">
                    <validator type="regex" message="Only numeric values allowed">^[0-9]*$</validator>
                </param>
                <param name="sep" type="select" label="Write each trajectory frame to a separate GRO or PDB file?" help="Results will be stored as a Galaxy collection. Only has effect with PDB or GRO output, otherwise ignored">
                    <option value="" selected="true">No</option>
                    <option value="sep">Yes, write each frame separately</option>
                </param>
                <conditional name="pbc">
                    <param name="pbc" type="select" label="PBC treatment" >
                        <option value="none">none</option>
                        <option value="mol">mol</option>
                        <option value="res">res</option>
                        <option value="atom">atom</option>
                        <option value="nojump">nojump</option>
                        <option value="cluster">cluster</option>
                        <option value="whole">whole</option>
                    </param>
                    <when value="cluster">
                        <param name="index_cluster" type="text" label="Index of group to use for clustering" help="Index of group to use for clustering - i.e. the group's position in the ndx file (using zero-based numbering, so the first group has index 0).">
                            <validator type="regex" message="Only numeric values allowed">^[0-9]*$</validator>
                        </param>
                    </when>
                    <when value="none" />
                    <when value="mol" />
                    <when value="res" />
                    <when value="atom" />
                    <when value="nojump" />
                    <when value="whole" />
                </conditional>
                <param name="ur" type="select" label="Unit cell representation" help="Only has effect in combination with PBC treatment of mol, res or atom">
                    <option value="rect" selected="true">rect</option>
                    <option value="tric">tric</option>
                    <option value="compact">compact</option>
                </param>
                <param name="boxcenter" type="select" label="Center for PBC and centering treatment" >
                    <option value="rect">rect</option>
                    <option value="tric" selected="true">tric</option>
                    <option value="zero">zero</option>
                </param>
                <conditional name="fit">
                    <param name="fit" type="select" label="Fit molecule to reference structure in the reference file?" >
                        <option value="none" selected="true">No fitting</option>
                        <option value="rot+trans">rot+trans</option>
                        <option value="rotxy+transxy">rotxy+transxy</option>
                        <option value="translation">translation</option>
                        <option value="transxy">transxy</option>
                        <option value="progressive">progressive</option>
                    </param>
                    <when value="none"/>
                    <expand macro="fit_when" option="rot+trans"/>
                    <expand macro="fit_when" option="rotxy+transxy"/>
                    <expand macro="fit_when" option="translation"/>
                    <expand macro="fit_when" option="transxy"/>
                    <expand macro="fit_when" option="progressive"/>
                </conditional>
            </when>
            <when value="trjcat">
                <param name="trj_input" type="data" format='xtc,trr' label="Input trajectories" help="In XTC or TRR format, but please do not mix the two. Please note this tool does not currently take order into account when concatenating." multiple="true"/>
                <param name="cat" type="boolean" label="Do not discard double time frames" truevalue="-cat" falsevalue="-nocat"/>
                <param name="sep" type="hidden" value="" />
            </when>
        </conditional>
        <param name="output_format" type="select" label="Output format" >
            <option value="xtc">XTC</option>
            <option value="trr">TRR</option>
            <option value="pdb">PDB</option>
            <option value="gro">GRO</option>
        </param>
        <section title="Time" name='time' expanded="true">
            <param name="b" type="integer" label="Start time" help="Time (ps) of first frame to read from trajectory" value="0" min="0"/>
            <param name="e" type="integer" label="End time" help="Time (ps) of last frame to read from trajectory" value="-1"  min="-1"/> <!-- stupidly this has different default values for trjconv and trjcat -->
            <param name="dt" type="integer" label="Write frames at this time interval (ps)" help="Only write frame when t is exactly divisible by this value. Leave as 0 to record all frames." value="0"  min="0"/>
        </section>
        <expand macro="log" />
    </inputs>
    <outputs>
        <data name="output" format="xtc">
            <filter>not trj.get("sep") or output_format in ["xtc", "trr"]</filter>
            <change_format>
                <when input="output_format" value="trr" format="trr"/>
                <when input="output_format" value="xtc" format="xtc"/>
                <when input="output_format" value="gro" format="gro"/>
                <when input="output_format" value="pdb" format="pdb"/>
            </change_format>
        </data>
        <collection type="list" name="gro_frames" label="Trajectory frames">
            <filter>trj.get("sep") and output_format == "gro"</filter>
            <discover_datasets pattern="(?P&lt;designation&gt;^output[0-9]{9}\.gro$)" ext="gro"/>
        </collection>
        <collection type="list" name="pdb_frames" label="Trajectory frames">
            <filter>trj.get("sep") and output_format == 'pdb'</filter>
            <discover_datasets pattern="(?P&lt;designation&gt;^output[0-9]{9}\.pdb$)" ext="pdb"/>
        </collection>
        <expand macro="log_outputs" />
    </outputs>
    <tests>
        <test>
            <!-- gmx trjcat -f npt.xtc nvt.xtc -cat -o test.xtc -->
            <param name="trj_op" value="trjcat" />
            <param name="trj_input" value="npt.xtc,nvt.xtc" />
            <param name="b" value="0" />
            <param name="e" value="-1" />
            <param name="dt" value="0" />
            <param name="cat" value="true" />
            <output name="output" file="trjcat.xtc" ftype="xtc"/>
        </test>
        <test>
            <!-- echo '1 1' | gmx trjconv -f npt.xtc -s npt.tpr -n -center -pbc mol -ur compact -o npt_c.xtc -->
            <!-- <param name="trj_op" value="trjconv" /> -->
            <param name="trj_input" value="npt.xtc" />
            <param name="str_input" value="npt.tpr" ftype="tpr"/>
            <param name="ndx_input" value="index.ndx" />
            <param name="b" value="0" />
            <param name="e" value="-1" />
            <param name="dt" value="0" />
            <param name="index_output" value="1" />
            <param name="index_center" value="1" />
            <param name="pbc" value="mol" />
            <param name="ur" value="tric" />
            <output name="output" file="trjconv.xtc" ftype="xtc"/>
        </test>
        <test>
            <!-- test sep flag -->
            <param name="trj_input" value="npt.xtc" />
            <param name="str_input" value="npt.tpr" ftype="tpr"/>
            <param name="ndx_input" value="index.ndx" />
            <param name="b" value="0" />
            <param name="e" value="-1" />
            <param name="dt" value="0" />
            <param name="index_output" value="0" />
            <param name="sep" value="sep" />
            <param name="output_format" value="pdb" />
            <output_collection name="pdb_frames" type="list">
                <element name="output000000007.pdb" ftype="pdb" file="frame7.pdb"/>
            </output_collection>
        </test>
    </tests>
    <help><![CDATA[

.. class:: infomark

**What it does**

This tool allows manipulation of GROMACS trajectories, drawing on the trjcat and trjconv commands.

_____


.. class:: infomark

**Input**

       - One or more trajectory files (XTC or TRR)
       - Structure file (optional)
       - Various options can be set

_____

        
.. class:: infomark

**Output**

       - GROMACS trajectory or structure file (XTC, TRR, PDB, GRO)


    ]]></help>
    <expand macro="citations" />
</tool>