Mercurial > repos > bgruening > openbabel_svg_depiction
view remove_protonation_state.py @ 11:ba2d56f16904 draft
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/openbabel commit cda909c5e0b88fa3d12abe43fc72b8dd0729417a"
author | bgruening |
---|---|
date | Thu, 09 Apr 2020 10:03:18 -0400 |
parents | 88f229c63734 |
children | d3b48303045b |
line wrap: on
line source
#!/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__()