comparison gmxtras_extract_top.py @ 0:5521a057ed6a 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:16:37 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:5521a057ed6a
1 #!/usr/bin/env python3
2 import argparse
3
4
5 def __main__():
6 parser = argparse.ArgumentParser(
7 description='Adds New topologies to gromacs topology file')
8 parser.add_argument(
9 '--top_file', default=None,
10 help="Topologies input")
11 parser.add_argument(
12 '--out_bondparam', default=None,
13 help='moleculetype section')
14 parser.add_argument(
15 '--out_nonbondparam', default=None,
16 help='atomtypes section')
17
18 args = parser.parse_args()
19 # extracts the atom types with nonbonded terms from
20 # the new molecules and puts them in a new file
21 with open(args.top_file) as inFile:
22 with open(args.out_nonbondparam, "w") as outFile:
23 buffer = []
24 for line in inFile:
25 if line.startswith(";name bond_type"):
26 buffer = ['']
27 elif line.startswith("[ moleculetype ]"):
28 outFile.write("".join(buffer))
29 buffer = []
30 elif buffer:
31 buffer.append(line)
32
33 # extracts the molecule types (rest of the force field parameters)
34 # with bonded terms and puts them in a new file
35 with open(args.top_file) as inFile:
36 with open(args.out_bondparam, "w") as outFile:
37 buffer = []
38 for line in inFile:
39 if line.startswith("[ moleculetype ]"):
40 buffer = ["\n[ moleculetype ]\n"]
41 elif line.startswith("[ system ]"):
42 outFile.write("".join(buffer))
43 buffer = []
44 elif buffer:
45 buffer.append(line)
46
47
48 if __name__ == "__main__":
49 __main__()