Mercurial > repos > bgruening > prepare_ligands_for_docking
diff remove_protonation_state.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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/remove_protonation_state.py Fri May 10 08:55:09 2019 -0400 @@ -0,0 +1,35 @@ +#!/usr/bin/env python +""" + Input: molecular input file. + Output: Molecule file with removed ions and fragments. + Copyright 2013, Bjoern Gruening and Xavier Lucas +""" +import sys, os +import argparse +import openbabel +openbabel.obErrorLog.StopLogging() +import pybel + +def parse_command_line(): + parser = argparse.ArgumentParser() + parser.add_argument('--iformat', default='sdf' , help='input file format') + parser.add_argument('-i', '--input', required=True, help='input file name') + parser.add_argument('-o', '--output', required=True, help='output file name') + return parser.parse_args() + +def remove_protonation( args ): + outfile = pybel.Outputfile(args.iformat, args.output, overwrite=True) + for mol in pybel.readfile(args.iformat, args.input): + [atom.OBAtom.SetFormalCharge(0) for atom in mol.atoms] + outfile.write( mol ) + outfile.close() + +def __main__(): + """ + Remove any protonation state from each atom in each molecule. + """ + args = parse_command_line() + remove_protonation( args ) + +if __name__ == "__main__" : + __main__()