This file is indexed.

/usr/lib/python2.7/dist-packages/chemfp/commandline/oe2fps.py is in python-chemfp 1.1p1-2.1.

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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
from __future__ import absolute_import
import sys
import itertools
import textwrap

from .. import ParseError
from .. import argparse, types, io
from .. import openeye as oe
from . import cmdsupport

##### Handle command-line argument parsing

# Build up some help text based on the atype and btype fields
atype_options = "\n  ".join(textwrap.wrap(" ".join(sorted(dict(oe._atype_flags)))))
btype_options = "\n  ".join(textwrap.wrap(" ".join(sorted(dict(oe._btype_flags)))))
if oe.OEGRAPHSIM_API_VERSION == "1":
    from openeye.oegraphsim import (OEGetFPAtomType, OEFPAtomType_DefaultAtom, OEFPAtomType_DefaultAtom,
                                    OEGetFPBondType, OEFPBondType_DefaultBond, OEFPBondType_DefaultBond)
    type_help = """\
ATYPE is one or more of the following, separated by the '|' character.
  %(atype_options)s
The terms 'Default' and 'DefaultAtom' are expanded to OpenEye's
suggested default of %(defaultatom)s.
Examples:
  --atype Default
  --atype AtomicNumber|HvyDegree
(Note that most atom type names change in OEGraphSim 2.0.0.)

BTYPE is one or more of the following, separated by the '|' character
  %(btype_options)s
The terms 'Default' and 'DefaultBond' are expanded to OpenEye's
suggested default of %(defaultbond)s.
Examples:
  --btype Default
  --btype BondOrder
(Note that "BondOrder" changes to "Order" in OEGraphSim 2.0.0.)

For simpler Unix command-line compatibility, a comma may be used
instead of a '|' to separate different fields. Example:
  --atype AtomicNumber,HvyDegree
""" % dict(atype_options=atype_options,
           btype_options=btype_options,
           defaultatom = OEGetFPAtomType(OEFPAtomType_DefaultAtom),
           defaultbond = OEGetFPBondType(OEFPBondType_DefaultBond))
else:
    from openeye.oegraphsim import (
        OEGetFPAtomType, OEFPAtomType_DefaultPathAtom,
        OEFPAtomType_DefaultCircularAtom, OEFPAtomType_DefaultTreeAtom,
        OEGetFPBondType, OEFPBondType_DefaultPathBond,
        OEFPBondType_DefaultCircularBond, OEFPBondType_DefaultTreeBond,
        )
    type_help = """\
ATYPE is one or more of the following, separated by the '|' character
  %(atype_options)s
The following shorthand terms and expansions are also available:
 DefaultPathAtom = %(defaultpathatom)s
 DefaultCircularAtom = %(defaultcircularatom)s
 DefaultTreeAtom = %(defaulttreeatom)s
and 'Default' selects the correct value for the specified fingerprint.
Examples:
  --atype Default
  --atype Arom|AtmNum|FCharge|HCount

BTYPE is one or more of the following, separated by the '|' character
  %(btype_options)s
The following shorthand terms and expansions are also available:
 DefaultPathBond = %(defaultpathbond)s
 DefaultCircularBond = %(defaultcircularbond)s
 DefaultTreeBond = %(defaulttreebond)s
and 'Default' selects the correct value for the specified fingerprint.
Examples:
   --btype Default
   --btype Order|InRing

To simplify command-line use, a comma may be used instead of a '|' to
separate different fields. Example:
  --atype AtmNum,HvyDegree
""" % dict(atype_options=atype_options,
           btype_options=btype_options,
           defaultpathatom=OEGetFPAtomType(OEFPAtomType_DefaultPathAtom),
           defaultcircularatom=OEGetFPAtomType(OEFPAtomType_DefaultCircularAtom),
           defaulttreeatom=OEGetFPAtomType(OEFPAtomType_DefaultTreeAtom),
           defaultpathbond=OEGetFPBondType(OEFPBondType_DefaultPathBond),
           defaultcircularbond=OEGetFPBondType(OEFPBondType_DefaultCircularBond),
           defaulttreebond=OEGetFPBondType(OEFPBondType_DefaultTreeBond),

)


# Extra help text after the parameter descriptions
epilog = type_help + """\

OEChem guesses the input structure format based on the filename
extension and assumes SMILES for structures read from stdin.
Use "--in FORMAT" to select an alternative, where FORMAT is one of:
 
  File Type      Valid FORMATs (use gz if compressed)
  ---------      ------------------------------------
   SMILES        smi, ism, can, smi.gz, ism.gz, can.gz
   SDF           sdf, mol, sdf.gz, mol.gz
   SKC           skc, skc.gz
   CDK           cdk, cdk.gz
   MOL2          mol2, mol2.gz
   PDB           pdb, ent, pdb.gz, ent.gz
   MacroModel    mmod, mmod.gz
   OEBinary v2   oeb, oeb.gz
   old OEBinary  bin
"""

parser = argparse.ArgumentParser(
    description="Generate FPS fingerprints from a structure file using OEChem",
    epilog=epilog,
    formatter_class=argparse.RawDescriptionHelpFormatter,    
    )
if oe.OEGRAPHSIM_API_VERSION == "1":
    PathFamily = oe.OpenEyePathFingerprintFamily_v1
    path_group = parser.add_argument_group("path fingerprints")
    path_group.add_argument(
        "--path", action="store_true", help="generate path fingerprints (default)")
    PathFamily.add_argument_to_argparse("numbits", path_group)
    PathFamily.add_argument_to_argparse("minbonds", path_group)
    PathFamily.add_argument_to_argparse("maxbonds", path_group)
else:
    CircularFamily = oe.OpenEyeCircularFingerprintFamily_v2
    path_group = parser.add_argument_group("path, circular, and tree fingerprints")
    path_group.add_argument(
        "--path", action="store_true", help="generate path fingerprints (default)")
    path_group.add_argument(
        "--circular", action="store_true", help="generate circular fingerprints")
    path_group.add_argument(
        "--tree", action="store_true", help="generate tree fingerprints")

    path_group.add_argument(
        "--numbits", action="store", type=int, metavar="INT", default=4096,
        help="number of bits in the fingerprint (default=4096)")
    path_group.add_argument(
        "--minbonds", action="store", type=int, metavar="INT", default=0,
        help="minimum number of bonds in the path or tree fingerprint (default=0)")
    path_group.add_argument(
        "--maxbonds", action="store", type=int, metavar="INT", default=None,
        help="maximum number of bonds in the path or tree fingerprint (path default=5, tree default=4)")
    CircularFamily.add_argument_to_argparse("minradius", path_group)
    CircularFamily.add_argument_to_argparse("maxradius", path_group)

# The expansion of 'Default' differs based on the fingerprint type
path_group.add_argument(
    "--atype", metavar="ATYPE", default="Default",
    help="atom type flags, described below (default=Default)")
path_group.add_argument(
    "--btype", metavar="BTYPE", default="Default",
    help="bond type flags, described below (default=Default)")

maccs_group = parser.add_argument_group("166 bit MACCS substructure keys")
maccs_group.add_argument(
    "--maccs166", action="store_true", help="generate MACCS fingerprints")

substruct_group = parser.add_argument_group("881 bit ChemFP substructure keys")
substruct_group.add_argument(
    "--substruct", action="store_true", help="generate ChemFP substructure fingerprints")

rdmaccs_group = parser.add_argument_group("ChemFP version of the 166 bit RDKit/MACCS keys")
rdmaccs_group.add_argument(
    "--rdmaccs", action="store_true", help="generate 166 bit RDKit/MACCS fingerprints")

parser.add_argument(
    "--aromaticity", metavar="NAME", choices=oe._aromaticity_flavor_names,
    default="openeye",
    help="use the named aromaticity model")

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 guesses from filename)")
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 _get_atype_and_btype(args, atom_description_to_value, bond_description_to_value):
    try:
        atype = atom_description_to_value(args.atype)
    except ValueError, err:
        parser.error("--atype must contain '|' separated atom terms: %s" % (err,))
    try:
        btype = bond_description_to_value(args.btype)
    except ValueError, err:
        parser.error("--btype must contain '|' separated atom terms: %s" % (err,))
    return atype, btype

#######

def main(args=None):
    args = parser.parse_args(args)

    supported_fingerprints = ("maccs166", "path", "substruct", "rdmaccs")
    if oe.OEGRAPHSIM_API_VERSION != "1":
        supported_fingerprints += ("circular", "tree")
    else:
        args.circular = False
        args.tree = False
    cmdsupport.mutual_exclusion(parser, args, "path", supported_fingerprints)

    if args.maccs166:
        # Create the MACCS keys fingerprinter
        opener = types.get_fingerprint_family("OpenEye-MACCS166")()
    elif args.path:
        if not (16 <= args.numbits <= 65536):
            parser.error("--numbits must be between 16 and 65536 bits")

        if not (0 <= args.minbonds):
            parser.error("--minbonds must be 0 or greater")
        if args.maxbonds is None:
            args.maxbonds = 5
        if not (args.minbonds <= args.maxbonds):
            parser.error("--maxbonds must not be smaller than --minbonds")
        atype, btype = _get_atype_and_btype(args, oe.path_atom_description_to_value,
                                            oe.path_bond_description_to_value)
        opener = types.get_fingerprint_family("OpenEye-Path")(
            numbits = args.numbits,
            minbonds = args.minbonds,
            maxbonds = args.maxbonds,
            atype = atype,
            btype = btype)
    elif args.circular:
        if not (16 <= args.numbits <= 65536):
            parser.error("--numbits must be between 16 and 65536 bits")

        if not (0 <= args.minradius):
            parser.error("--minradius must be 0 or greater")
        if not (args.minradius <= args.maxradius):
            parser.error("--maxradius must not be smaller than --minradius")
        atype, btype = _get_atype_and_btype(args, oe.circular_atom_description_to_value,
                                            oe.circular_bond_description_to_value)

        opener = types.get_fingerprint_family("OpenEye-Circular")(
            numbits = args.numbits,
            minradius = args.minradius,
            maxradius = args.maxradius,
            atype = atype,
            btype = btype)
    elif args.tree:
        if not (16 <= args.numbits <= 65536):
            parser.error("--numbits must be between 16 and 65536 bits")

        if not (0 <= args.minbonds):
            parser.error("--minbonds must be 0 or greater")
        if args.maxbonds is None:
            args.maxbonds = 4
        if not (args.minbonds <= args.maxbonds):
            parser.error("--maxbonds must not be smaller than --minbonds")
        atype, btype = _get_atype_and_btype(args, oe.tree_atom_description_to_value,
                                            oe.tree_bond_description_to_value)

        opener = types.get_fingerprint_family("OpenEye-Tree")(
            numbits = args.numbits,
            minbonds = args.minbonds,
            maxbonds = args.maxbonds,
            atype = atype,
            btype = btype)
        
    elif args.substruct:
        opener = types.get_fingerprint_family("ChemFP-Substruct-OpenEye")()
    elif args.rdmaccs:
        opener = types.get_fingerprint_family("RDMACCS-OpenEye")()
        
    else:
        parser.error("ERROR: fingerprint not specified?")

    if args.format is not None:
        if args.filenames:
            filename = args.filenames[0]
        else:
            filename = None
        if not oe.is_valid_format(filename, args.format):
            parser.error("Unsupported format specifier: %r" % (args.format,))

    if not oe.is_valid_aromaticity(args.aromaticity):
        parser.error("Unsupported aromaticity specifier: %r" % (args.aromaticity,))

    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, args.format, args.id_tag, args.aromaticity, args.errors)
    
    try:
        io.write_fps1_output(reader, args.output, metadata)
    except ParseError, err:
        sys.stderr.write("ERROR: %s. Exiting.\n" % (err,))
        raise SystemExit(1)
    
if __name__ == "__main__":
    main()