annotate gmxtras_add_restraints.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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 END_OF_MOL = ('[ moleculetype ]', '[ system ]')
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
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
6 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
7 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
8 description='Add restriction 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
9 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
10 '--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
11 help="Topology file input")
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
12 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
13 '--res_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
14 help='Restraint input')
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
15 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
16 '--molecule', 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
17 help='Target Molecule Name you restrained')
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
18 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
19 '--out', 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
20 help='Path to output')
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
21 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
22 with open(args.out, 'w') as fh_out:
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
23 with open(args.top_file, 'r') as fh:
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 now, we will avoid using 'for line in fh:',
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
25 # since we have multiple places where we might want
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
26 # to read the next line
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
27 while True:
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
28 line = fh.readline()
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
29 if not line:
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
30 # eof
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
31 break
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
32 # always write out the line
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
33 fh_out.write(line)
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
34 # check if line matches molecule, then check if
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
35 # molecule name matches args.molecule
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
36 if line.strip().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
37 not_found_molecule = True
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
38 while not_found_molecule:
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
39 line = fh.readline()
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
40 if not line:
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
41 # eof
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
42 break
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
43 # always write this line
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
44 fh_out.write(line)
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
45 if not line.strip().startswith(';') or (line.strip()
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
46 and not line.strip().startswith(';')):
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
47 # this line should be the name line,
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
48 fields = line.strip().split()
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
49 if fields[0] == args.molecule:
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
50 # found our molecule!
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
51 while True:
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
52 line = fh.readline()
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
53 if not line:
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
54 # eof
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
55 break
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
56 if line.strip().startswith(END_OF_MOL):
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
57 fh_out.write("\n#ifdef POSRES\n")
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
58 with open(args.res_file, 'r') as fh_re:
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
59 for line2 in fh_re:
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
60 fh_out.write(line2)
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
61 fh_out.write("#endif\n\n")
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
62 fh_out.write(line)
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
63 not_found_molecule = False
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
64 break
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
65 fh_out.write(line)
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
66 else:
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
67 break
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
68
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
69
5521a057ed6a "planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/buildtools/topologyeditors commit ae026d4ea6fe2ebaa53611b86f9047941c7b899b"
chemteam
parents:
diff changeset
70 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
71 __main__()