Previous changeset 2:b500cc25dd15 (2021-02-16) Next changeset 4:267a70416daf (2021-06-09) |
Commit message:
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit cc13bd32ef2d80b01dc197a3ca120a4ff9f0dacc" |
modified:
parmconv.xml template_parmconv.j2 |
added:
parmconv.py |
b |
diff -r b500cc25dd15 -r 2b82fc7bec67 parmconv.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/parmconv.py Fri Mar 12 12:32:24 2021 +0000 |
[ |
@@ -0,0 +1,82 @@ +import argparse +import io +import sys +from contextlib import redirect_stdout + +import parmed +from parmed import amber, gromacs +from parmed.tools.changeradii import ChRad + + +def parse_command_line(argv): + parser = argparse.ArgumentParser() + parser.add_argument('--istr', help='input structure', required=True) + parser.add_argument('--itop', help='input topology file', required=True) + parser.add_argument('--istripmask', help='stripmask') + parser.add_argument('--iradii', required=True, help='parmed radii are \ + GB_RADII amber6,bondi, mbondi, mbondi2, mbondi3') + parser.add_argument('--removedihe', action='store_true', + default=False, help='remove dihedrals with zero \ + periodicity') + parser.add_argument('--removebox', action='store_true', + default=False, help='remove periodic box info') + parser.add_argument('--o_prmtop', help='AMBER output topology', + required=True) + return parser.parse_args() + + +def get_ids(dihedrals): + """ + goes through dihedrals and looks for any with per=0. + returns a reverse sorted list of ids to be removed. + """ + indices = [] + for k, v in enumerate(dihedrals): + f = io.StringIO() + with redirect_stdout(f): + print(v) + if f.getvalue().find("per=0") != -1: + indices.append(k) + indices.sort(reverse=True) + return indices + + +args = parse_command_line(sys.argv) + +gmx_top = gromacs.GromacsTopologyFile(args.itop) +gmx_gro = gromacs.GromacsGroFile.parse(args.istr) + +if not args.removebox: + # keep box info + gmx_top.box = gmx_gro.box + gmx_top.positions = gmx_gro.positions + + +if args.removedihe: + ids_to_remove = get_ids(gmx_top.dihedrals) + print("Original number of dihedrals %i" % len(gmx_top.dihedrals)) + for i in ids_to_remove: + gmx_top.dihedrals.pop(i) + print("Update number of dihedrals %i" % len(gmx_top.dihedrals)) + +if args.istripmask is not None: + if args.istripmask == "": + pass + else: + gmx_top.strip(args.istripmask) + +radii = str(args.iradii) +parmed.tools.changeRadii(gmx_top, radii) +amb_prm = amber.AmberParm.from_structure(gmx_top) +parmed.tools.changeRadii(amb_prm, radii) + +if args.removebox: + amb_prm.pointers['IFBOX'] = 0 + +ChRad(amb_prm, radii) +for i, atom in enumerate(amb_prm.atoms): + amb_prm.parm_data['RADII'][i] = atom.solvent_radius + amb_prm.parm_data['SCREEN'][i] = atom.screen + + +amb_prm.write_parm(args.o_prmtop) |
b |
diff -r b500cc25dd15 -r 2b82fc7bec67 parmconv.xml --- a/parmconv.xml Tue Feb 16 21:55:34 2021 +0000 +++ b/parmconv.xml Fri Mar 12 12:32:24 2021 +0000 |
[ |
b'@@ -1,8 +1,8 @@\n <tool id="parmconv" name="Convert Parameters" version="@TOOL_VERSION@+galaxy@GALAXY_VERSION@">\n- <description>to AMBER prmtop in preparation for MMPBSA</description>\n+ <description>to AMBER prmtop in preparation for MMGBSA/MMPBSA</description>\n <macros>\n <import>macros.xml</import>\n- <token name="@GALAXY_VERSION@">0</token>\n+ <token name="@GALAXY_VERSION@">1</token>\n </macros>\n <expand macro="requirements">\n <requirement type="package" version="3.2.0">parmed</requirement>\n@@ -11,15 +11,53 @@\n </expand>\n <command detect_errors="exit_code">\n <![CDATA[\n- python \'$templating_script\' \'$inputs\' &&\n- PATH_TO_PARMED=\\$(dirname `which parmed`) &&\n- export AMBERHOME=\\$(dirname \\$PATH_TO_PARMED) &&\n- export GMXDATA=\\$AMBERHOME/share/gromacs/top/ &&\n- parmed -i ligand.script -O &&\n- parmed -i receptor.script -O &&\n- parmed -i complex.script -O &&\n- parmed -i solvatedcomplex.script -O\n-\n+ #if $param_inputs.fmt == "GROMACS":\n+ python \'$__tool_directory__/parmconv.py\'\n+ --istr \'$param_inputs.str_in\'\n+ --itop \'$param_inputs.top_in\'\n+ $param_inputs.modbehaviour.removedihe\n+ $param_inputs.modbehaviour.removebox\n+ --iradii \'$param_inputs.modbehaviour.radii\'\n+ --istripmask \'$stripmask_ligand\'\n+ --o_prmtop \'$prmtop_ligand\'\n+ 2>&1 &&\n+ python \'$__tool_directory__/parmconv.py\'\n+ --istr \'$param_inputs.str_in\'\n+ --itop \'$param_inputs.top_in\'\n+ $param_inputs.modbehaviour.removedihe\n+ $param_inputs.modbehaviour.removebox\n+ --iradii \'$param_inputs.modbehaviour.radii\'\n+ --istripmask \'$stripmask_receptor\'\n+ --o_prmtop \'$prmtop_receptor\'\n+ 2>&1 &&\n+ python \'$__tool_directory__/parmconv.py\'\n+ --istr \'$param_inputs.str_in\'\n+ --itop \'$param_inputs.top_in\'\n+ $param_inputs.modbehaviour.removedihe\n+ $param_inputs.modbehaviour.removebox\n+ --iradii \'$param_inputs.modbehaviour.radii\'\n+ --istripmask \'$stripmask_complex\'\n+ --o_prmtop \'$prmtop_complex\'\n+ 2>&1 &&\n+ python \'$__tool_directory__/parmconv.py\'\n+ --istr \'$param_inputs.str_in\'\n+ --itop \'$param_inputs.top_in\'\n+ $param_inputs.modbehaviour.removedihe\n+ $param_inputs.modbehaviour.removebox\n+ --iradii \'$param_inputs.modbehaviour.radii\'\n+ --istripmask \'$stripmask_solvatedcomplex\'\n+ --o_prmtop \'$prmtop_solvatedcomplex\'\n+ 2>&1\n+ #else\n+ python \'$templating_script\' \'$inputs\' &&\n+ PATH_TO_PARMED=\\$(dirname `which parmed`) &&\n+ export AMBERHOME=\\$(dirname \\$PATH_TO_PARMED) &&\n+ export GMXDATA=\\$AMBERHOME/share/gromacs/top/ &&\n+ parmed -i ligand.script -O &&\n+ parmed -i receptor.script -O &&\n+ parmed -i complex.script -O &&\n+ parmed -i solvatedcomplex.script -O\n+ #end if\n ]]>\n </command>\n <configfiles>\n@@ -93,7 +131,7 @@\n </configfiles>\n <inputs>\n <conditional name="param_inputs">\n- <param name="fmt" type="select" label="Force Field format">\n+ <param name="fmt" type="select" label="Input format">\n <option selected="True" value="AMBER">AMBER</option>\n <option value="GROMACS">GROMACS</option>\n </param>\n@@ -103,46 +141,45 @@\n <when value="GROMACS">\n <param name="top_in" type="data" label="Input topology (top) file" format="top"/>\n <param name="str_in" type="data" label="Input structure (gro) file" format="gro"/>\n+ <section name="modbehaviour" title="Modify behaviour" expanded="false">\n+ <param name="removedihe" type="boolean" truevalue="--removedihe" falsevalue="" checked="false" label="Remove all zero period dihedrals" help="This will remove zero period dihedrals from the generated topology"/>\n+ <param name="removebox" type="boolean" truevalue="--removebox" falsevalue="" checked="false" label="Remove periodic box information" help="This will remove periodic information from the generat'..b'le">\n- <remove value="&"/>\n+ <add value="&"/>\n </valid>\n- <mapping initial="none">\n- <add source="&" target="__and__"/>\n- </mapping>\n </sanitizer>\n </param>\n </inputs>\n@@ -200,24 +237,68 @@\n <param name="stripmask_solvatedcomplex" value=":1-500@O&!(:WAT|:LYS,ARG)"/>\n <output name="prmtop_ligand">\n <assert_contents>\n- <has_text text=" 8 59"/>\n <has_text text="%FLAG MASS"/>\n <has_text text="CL"/>\n+ <has_text text="SOLVENT_POINTERS"/>\n+ <has_text text="BOX_DIMENSIONS"/>\n </assert_contents>\n </output>\n <output name="prmtop_receptor">\n <assert_contents>\n- <has_text text=" 1960 59"/>\n <has_text text="%FLAG MASS"/>\n <has_text text="LYS VAL PHE "/>\n+ <has_text text="SOLVENT_POINTERS"/>\n+ <has_text text="BOX_DIMENSIONS"/>\n <not_has_text text="CL "/>\n </assert_contents>\n </output>\n <output name="prmtop_solvatedcomplex">\n <assert_contents>\n- <has_text text=" 38265 59"/>\n <has_text text="%FLAG MASS"/>\n <has_text text="LYS VAL PHE"/>\n+ <has_text text="SOLVENT_POINTERS"/>\n+ <has_text text="BOX_DIMENSIONS"/>\n+ </assert_contents>\n+ </output>\n+ </test>\n+ <test>\n+ <!-- test with removing dihedrals and periodicity -->\n+ <param name="fmt" value="GROMACS"/>\n+ <conditional name="param_inputs">\n+ <param name="top_in" value="topol_solv.top"/>\n+ <param name="str_in" value="solv_ions.gro"/>\n+ </conditional>\n+ <!-- dihedrals and periodicity -->\n+ <param name="removedihe" value="--removedihe"/>\n+ <param name="removebox" value="--removebox"/>\n+ <!-- pretending CL is a ligand -->\n+ <param name="stripmask_ligand" value="!:CL"/>\n+ <param name="stripmask_receptor" value=":NA,CL,SOL,WAT"/>\n+ <!-- test a fairly complex selection. All backbone oxygens in residues 1-500 but not in water, lysine or arginine -->\n+ <param name="stripmask_solvatedcomplex" value=":1-500@O&!(:WAT|:LYS,ARG)"/>\n+ <output name="prmtop_ligand">\n+ <assert_contents>\n+ <has_text text="%FLAG MASS"/>\n+ <has_text text="CL"/>\n+ <not_has_text text="SOLVENT_POINTERS"/>\n+ <not_has_text text="BOX_DIMENSIONS"/>\n+ </assert_contents>\n+ </output>\n+ <output name="prmtop_receptor">\n+ <assert_contents>\n+ <has_text text="%FLAG MASS"/>\n+ <has_text text="LYS VAL PHE "/>\n+ <not_has_text text="CL "/>\n+ <not_has_text text="SOLVENT_POINTERS"/>\n+ <not_has_text text="BOX_DIMENSIONS"/>\n+ </assert_contents>\n+ </output>\n+ <output name="prmtop_solvatedcomplex">\n+ <assert_contents>\n+ <has_text text="%FLAG MASS"/>\n+ <has_text text="LYS VAL PHE"/>\n+ <not_has_text text="SOLVENT_POINTERS"/>\n+ <not_has_text text="BOX_DIMENSIONS"/>\n </assert_contents>\n </output>\n </test>\n@@ -228,13 +309,13 @@\n \n **What it does**\n \n- This tool converts parameter and topology files that represent a solvated complex into parameter files for the ligand, receptor, complex and solvated complex in AMBER prmtop format. These files are needed for MMPBSA calculations.\n+ This tool converts parameter and topology files that represent a solvated complex into parameter files for the ligand, receptor, complex and solvated complex in AMBER prmtop format. These files are needed for MMGBSA/MMPBSA calculations.\n \n .. class:: infomark\n \n **How it works**\n \n- AmberTools ParmEd is used to strip unneeded atoms and save out the parameter files. The stripmasks are defined by the user.\n+ AmberTools\' ParmEd is used to strip unneeded atoms and save the parameter files. The stripmasks are defined by the user.\n \n .. class:: infomark\n \n' |
b |
diff -r b500cc25dd15 -r 2b82fc7bec67 template_parmconv.j2 --- a/template_parmconv.j2 Tue Feb 16 21:55:34 2021 +0000 +++ b/template_parmconv.j2 Fri Mar 12 12:32:24 2021 +0000 |
b |
@@ -2,9 +2,9 @@ {% if fmt == 'AMBER' %} parm {{ top_in }} {% elif fmt == 'GROMACS' %} -gromber {{ top_in }} {{gro_in}} +gromber {{ top_in }} {{str_in}} {% elif fmt == 'CHARMM' %} -chamber {{ top_in }} {{gro_in}} +chamber {{ top_in }} {{str_in}} {% else %} parm {{ top_in }} {% endif %} |