/usr/share/pyshared/chemfp/commandline/ob2fps.py is in python-chemfp 1.1p1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | import sys
from chemfp import openbabel as ob
from chemfp import argparse, io, types
from .. import ParseError
from . import cmdsupport
############ Command-line parser definition
epilog = """\
OpenBabel autodetects the input structure format based on the filename
extension. The default format for structures read from stdin is
SMILES. Use"--in FORMAT" to select an alternative, where FORMAT is
one of the extensions at http://openbabel.org/wiki/List_of_extensions .
For a short list of some common formats:
File Type Valid FORMATs
--------- -------------
SMILES smi, can, smiles
SDF sdf, mol, sd, mdl
MOL2 mol2, ml2
PDB pdb, ent
MacroModel mmod
If OpenBabel is compiled with zlib support then it will automatically
handle gzip'ed input data if the filename ends with ".gz". You may
optionally include that suffix in the format name.
"""
parser = argparse.ArgumentParser(
description="Generate FPS fingerprints from a structure file using OpenBabel",
)
group = parser.add_mutually_exclusive_group()
group.add_argument("--FP2", action="store_true",
# help=ob._fingerprinter_table["FP2"].description + "(default)"
)
group.add_argument("--FP3", action="store_true",
# help=ob._fingerprinter_table["FP3"].description
)
group.add_argument("--FP4", action="store_true",
# help=ob._fingerprinter_table["FP4"].description
)
if ob.HAS_MACCS:
# Added in OpenBabel 2.3
group.add_argument("--MACCS", action="store_true",
# help=ob._fingerprinter_table["MACCS"].description
)
else:
group.add_argument("--MACCS", action="store_true",
help="(Not available using your version of OpenBabel)")
group.add_argument(
"--substruct", action="store_true", help="generate ChemFP substructure fingerprints")
group.add_argument(
"--rdmaccs", action="store_true", help="generate 166 bit RDKit/MACCS fingerprints")
parser.add_argument(
"--id-tag", metavar="NAME",
help="tag name containing the record id (SD files only)")
parser.add_argument(
"--in", metavar="FORMAT", dest="format",
help="input structure format (default autodetects from the filename extension)")
parser.add_argument(
"-o", "--output", metavar="FILENAME",
help="save the fingerprints to FILENAME (default=stdout)")
parser.add_argument(
"--errors", choices=["strict", "report", "ignore"], default="strict",
help="how should structure parse errors be handled? (default=strict)")
parser.add_argument(
"filenames", nargs="*", help="input structure files (default is stdin)")
#########
def main(args=None):
args = parser.parse_args(args)
outfile = sys.stdout
cmdsupport.mutual_exclusion(parser, args, "FP2",
("FP2", "FP3", "FP4", "MACCS", "substruct", "rdmaccs"))
if args.FP2:
opener = types.get_fingerprint_family("OpenBabel-FP2")()
elif args.FP3:
opener = types.get_fingerprint_family("OpenBabel-FP3")()
elif args.FP4:
opener = types.get_fingerprint_family("OpenBabel-FP4")()
elif args.MACCS:
if not ob.HAS_MACCS:
parser.error(
"--MACCS is not supported in your OpenBabel installation (%s)" % (
ob.GetReleaseVersion(),))
opener = types.get_fingerprint_family("OpenBabel-MACCS")()
elif args.substruct:
opener = types.get_fingerprint_family("ChemFP-Substruct-OpenBabel")()
elif args.rdmaccs:
opener = types.get_fingerprint_family("RDMACCS-OpenBabel")()
else:
parser.error("should not get here")
if not ob.is_valid_format(args.format):
parser.error("Unsupported format specifier: %r" % (args.format,))
if not cmdsupport.is_valid_tag(args.id_tag):
parser.error("Invalid id tag: %r" % (args.id_tag,))
missing = cmdsupport.check_filenames(args.filenames)
if missing:
parser.error("Structure file %r does not exist" % (missing,))
# Ready the input reader/iterator
metadata, reader = cmdsupport.read_multifile_structure_fingerprints(
opener, args.filenames, format = args.format,
id_tag = args.id_tag, aromaticity = None, errors = args.errors)
try:
io.write_fps1_output(reader, args.output, metadata)
except ParseError, err:
sys.stderr.write("ERROR: %s. Exiting." % (err,))
raise SystemExit(1)
if __name__ == "__main__":
main()
|