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