Mercurial > repos > chemteam > gromacs_modify_topology
comparison gmxtras_add_newmolparam.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="Topology file input") | |
11 parser.add_argument( | |
12 '--mol_file', default=None, | |
13 help='molecule type and bonded parameters input') | |
14 parser.add_argument( | |
15 '--atom_file', default=None, | |
16 help='atomtype and nonbonded parameters input') | |
17 parser.add_argument( | |
18 '--out', default=None, | |
19 help='Path to output') | |
20 args = parser.parse_args() | |
21 with open(args.out, 'w') as fh_out: | |
22 with open(args.top_file, 'r') as fh: | |
23 # these two short loop takes care of | |
24 # adding the atom types and molecule types. | |
25 for line in fh: | |
26 fh_out.write(line) | |
27 if ';name bond_type' in line: | |
28 for contents in open(args.atom_file): | |
29 fh_out.write(contents) | |
30 break | |
31 for line in fh: | |
32 if '[ system ]' in line: | |
33 fh_out.write("\n; Begin NewTopologyInfo\n") | |
34 for contents in open(args.mol_file): | |
35 fh_out.write(contents) | |
36 fh_out.write("; end NewTopologyInfo\n\n") | |
37 fh_out.write(line) | |
38 break | |
39 fh_out.write(line) | |
40 for line in fh: | |
41 fh_out.write(line) | |
42 | |
43 | |
44 if __name__ == "__main__": | |
45 __main__() |