Mercurial > repos > bgruening > openbabel_addh
comparison remove_protonation_state.py @ 0:ada6daa717d2 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit 01da22e4184a5a6f6a3dd4631a7b9c31d1b6d502
author | bgruening |
---|---|
date | Sat, 20 May 2017 08:37:26 -0400 |
parents | |
children | 43167f164076 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ada6daa717d2 |
---|---|
1 #!/usr/bin/env python | |
2 """ | |
3 Input: molecular input file. | |
4 Output: Molecule file with removed ions and fragments. | |
5 Copyright 2013, Bjoern Gruening and Xavier Lucas | |
6 """ | |
7 import sys, os | |
8 import argparse | |
9 import openbabel | |
10 openbabel.obErrorLog.StopLogging() | |
11 import pybel | |
12 | |
13 def parse_command_line(): | |
14 parser = argparse.ArgumentParser() | |
15 parser.add_argument('--iformat', default='sdf' , help='input file format') | |
16 parser.add_argument('-i', '--input', required=True, help='input file name') | |
17 parser.add_argument('-o', '--output', required=True, help='output file name') | |
18 return parser.parse_args() | |
19 | |
20 def remove_protonation( args ): | |
21 outfile = pybel.Outputfile(args.iformat, args.output, overwrite=True) | |
22 for mol in pybel.readfile(args.iformat, args.input): | |
23 [atom.OBAtom.SetFormalCharge(0) for atom in mol.atoms] | |
24 outfile.write( mol ) | |
25 outfile.close() | |
26 | |
27 def __main__(): | |
28 """ | |
29 Remove any protonation state from each atom in each molecule. | |
30 """ | |
31 args = parse_command_line() | |
32 remove_protonation( args ) | |
33 | |
34 if __name__ == "__main__" : | |
35 __main__() |