annotate gmxtras_extract_top.py @ 0:9faa4f4b8b76 draft default tip

"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
author chemteam
date Thu, 27 Jan 2022 18:17:05 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
1 #!/usr/bin/env python3
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
2 import argparse
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
3
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
4
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
5 def __main__():
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
6 parser = argparse.ArgumentParser(
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
7 description='Adds New topologies to gromacs topology file')
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
8 parser.add_argument(
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
9 '--top_file', default=None,
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
10 help="Topologies input")
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
11 parser.add_argument(
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
12 '--out_bondparam', default=None,
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
13 help='moleculetype section')
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
14 parser.add_argument(
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
15 '--out_nonbondparam', default=None,
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
16 help='atomtypes section')
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
17
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
18 args = parser.parse_args()
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
19 # extracts the atom types with nonbonded terms from
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
20 # the new molecules and puts them in a new file
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
21 with open(args.top_file) as inFile:
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
22 with open(args.out_nonbondparam, "w") as outFile:
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
23 buffer = []
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
24 for line in inFile:
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
25 if line.startswith(";name bond_type"):
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
26 buffer = ['']
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
27 elif line.startswith("[ moleculetype ]"):
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
28 outFile.write("".join(buffer))
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
29 buffer = []
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
30 elif buffer:
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
31 buffer.append(line)
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
32
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
33 # extracts the molecule types (rest of the force field parameters)
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
34 # with bonded terms and puts them in a new file
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
35 with open(args.top_file) as inFile:
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
36 with open(args.out_bondparam, "w") as outFile:
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
37 buffer = []
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
38 for line in inFile:
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
39 if line.startswith("[ moleculetype ]"):
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
40 buffer = ["\n[ moleculetype ]\n"]
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
41 elif line.startswith("[ system ]"):
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
42 outFile.write("".join(buffer))
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
43 buffer = []
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
44 elif buffer:
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
45 buffer.append(line)
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
46
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
47
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
48 if __name__ == "__main__":
9faa4f4b8b76 "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
49 __main__()