view @ 11:78640d0127ce draft

"planemo upload for repository commit 944ea4bb8a9cd4244152a4a4fecd0485fabc2ad0"
author bgruening
date Tue, 28 Jul 2020 08:36:19 -0400
parents b0311f002a5f
children 2912ebf12ef2
line wrap: on
line source

#!/usr/bin/env python
    Input:  Molecule file
    Output: Molecule file with hydrogen atoms added at the target pH.
import sys, os
import argparse

from openbabel import openbabel, pybel

def parse_command_line(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument('--iformat', type=str, default='sdf' , help='input file format')
    parser.add_argument('-i', '--input', type=str, required=True, help='input file name')
    parser.add_argument('-o', '--output', type=str, required=True, help='output file name')
    parser.add_argument('--polar', action="store_true", default=False, help='Add hydrogen atoms only to polar atoms')
    parser.add_argument('--pH', type=float, default="7.4", help='Specify target pH value')
    return parser.parse_args()

def addh(args):
    outfile = pybel.Outputfile(args.iformat, args.output, overwrite=True)
    for mol in pybel.readfile(args.iformat, args.input):
        if mol.OBMol.NumHvyAtoms() > 5:
            mol.OBMol.AddHydrogens(args.polar, True, args.pH)

def __main__():
        Add hydrogen atoms at a certain pH value
    args = parse_command_line(sys.argv)

if __name__ == "__main__" :