Mercurial > repos > bgruening > prepare_ligands_for_docking
comparison ob_addh.py @ 0:06340f46ecb8 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 72df8ae9b8fd9910b3d24aa0836b9b3c9d43f4fb
author | bgruening |
---|---|
date | Fri, 10 May 2019 08:55:09 -0400 |
parents | |
children | de4c80d17527 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:06340f46ecb8 |
---|---|
1 #!/usr/bin/env python | |
2 """ | |
3 Input: Molecule file | |
4 Output: Molecule file with hydrogen atoms added at the target pH. | |
5 """ | |
6 import sys, os | |
7 import argparse | |
8 import openbabel | |
9 openbabel.obErrorLog.StopLogging() | |
10 import pybel | |
11 | |
12 def parse_command_line(argv): | |
13 parser = argparse.ArgumentParser() | |
14 parser.add_argument('--iformat', type=str, default='sdf' , help='input file format') | |
15 parser.add_argument('-i', '--input', type=str, required=True, help='input file name') | |
16 parser.add_argument('-o', '--output', type=str, required=True, help='output file name') | |
17 parser.add_argument('--polar', action="store_true", default=False, help='Add hydrogen atoms only to polar atoms') | |
18 parser.add_argument('--pH', type=float, default="7.4", help='Specify target pH value') | |
19 return parser.parse_args() | |
20 | |
21 def addh(args): | |
22 outfile = pybel.Outputfile(args.iformat, args.output, overwrite=True) | |
23 for mol in pybel.readfile(args.iformat, args.input): | |
24 if mol.OBMol.NumHvyAtoms() > 5: | |
25 mol.removeh() | |
26 mol.OBMol.AddHydrogens(args.polar, True, args.pH) | |
27 outfile.write(mol) | |
28 outfile.close() | |
29 | |
30 def __main__(): | |
31 """ | |
32 Add hydrogen atoms at a certain pH value | |
33 """ | |
34 args = parse_command_line(sys.argv) | |
35 addh(args) | |
36 | |
37 if __name__ == "__main__" : | |
38 __main__() |