Mercurial > repos > chemteam > gromacs_modify_topology
annotate 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 |
rev | line source |
---|---|
0
5521a057ed6a
"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 |
5521a057ed6a
"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 |
5521a057ed6a
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff
changeset
|
3 |
5521a057ed6a
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff
changeset
|
4 |
5521a057ed6a
"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__(): |
5521a057ed6a
"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( |
5521a057ed6a
"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') |
5521a057ed6a
"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( |
5521a057ed6a
"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, |
5521a057ed6a
"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") |
5521a057ed6a
"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( |
5521a057ed6a
"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, |
5521a057ed6a
"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') |
5521a057ed6a
"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( |
5521a057ed6a
"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, |
5521a057ed6a
"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') |
5521a057ed6a
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff
changeset
|
17 |
5521a057ed6a
"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() |
5521a057ed6a
"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 |
5521a057ed6a
"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 |
5521a057ed6a
"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: |
5521a057ed6a
"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: |
5521a057ed6a
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff
changeset
|
23 buffer = [] |
5521a057ed6a
"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: |
5521a057ed6a
"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"): |
5521a057ed6a
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff
changeset
|
26 buffer = [''] |
5521a057ed6a
"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 ]"): |
5521a057ed6a
"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)) |
5521a057ed6a
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff
changeset
|
29 buffer = [] |
5521a057ed6a
"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: |
5521a057ed6a
"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) |
5521a057ed6a
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff
changeset
|
32 |
5521a057ed6a
"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) |
5521a057ed6a
"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 |
5521a057ed6a
"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: |
5521a057ed6a
"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: |
5521a057ed6a
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff
changeset
|
37 buffer = [] |
5521a057ed6a
"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: |
5521a057ed6a
"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 ]"): |
5521a057ed6a
"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"] |
5521a057ed6a
"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 ]"): |
5521a057ed6a
"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)) |
5521a057ed6a
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff
changeset
|
43 buffer = [] |
5521a057ed6a
"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: |
5521a057ed6a
"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) |
5521a057ed6a
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff
changeset
|
46 |
5521a057ed6a
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff
changeset
|
47 |
5521a057ed6a
"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__": |
5521a057ed6a
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff
changeset
|
49 __main__() |