Fingerprint Types¶
A fingerprint is a bitvector. To reflect this the OEFingerPrint class derives from the OEBitVector class. The difference is that OEFingerPrint has a type that represents how the fingerprint is generated. Fingerprints may only be compared if they are generated in the same way. Therefore, the following restriction is introduced:
Warning
When two fingerprints are subjected to similarity calculation their type has to be identical.
Listing 1
shows how to create different fingerprint
objects (OEFingerPrint) and identify or
compare their types.
Listing 1: Fingerprint type
public class FPType
{
public static int Main(string[] args)
{
OEFingerPrint fpA = new OEFingerPrint();
OEFingerPrint fpB = new OEFingerPrint();
if (!fpA.IsValid())
{
Console.WriteLine("uninitialized fingerprint");
}
OEGraphMol mol = new OEGraphMol();
OEChem.OESmilesToMol(mol, "c1ccccc1");
OEGraphSim.OEMakeFP(fpA, mol, OEFPType.Path);
OEGraphSim.OEMakeFP(fpB, mol, OEFPType.Lingo);
if (OEGraphSim.OEIsFPType(fpA, OEFPType.Lingo))
{
Console.WriteLine("Lingo");
}
if (OEGraphSim.OEIsFPType(fpA, OEFPType.Path))
{
Console.WriteLine("Path");
}
if (OEGraphSim.OEIsSameFPType(fpA, fpB))
{
Console.WriteLine("same fingerprint types");
}
else
{
Console.WriteLine("different fingerprint types");
}
return 0;
}
}
The output of Listing 1
is the following:
uninitialized fingerprint
Path
different fingerprint types
Two fingerprints are considered to be equivalent only if they have the same fingerprint type (OEFPTypeBase) and have identical bit-vectors (OEBitVector). The following code snippet shows how to compare two OEFingerPrint objects.
if (fpA == fpB)
{
Console.WriteLine("same fingerprints");
}
else
{
Console.WriteLine("different fingerprints");
}
The following code snippet shows how to initialize a
OEFingerPrint object by
using the type of another fingerprint.
The type of a fingerprint is accessed by the
OEFingerPrint.GetFPTypeBase
method.
OEFingerPrint fpA = new OEFingerPrint();
OEGraphSim.OEMakePathFP(fpA, mol);
OEFingerPrint fpB = new OEFingerPrint();
OEGraphSim.OEMakeFP(fpB, mol, fpA.GetFPTypeBase());
Fingerprint parameters¶
The User-defined Fingerprint chapter gives examples of how user defined fingerprints can be generated by defining, for example, the atom and bond properties that will be encoded into the fingerprints.
In order to ensure that only equivalent fingerprints can be compared,
the fingerprint type stores the parameters being used in the
generation process.
The OEFPTypeBase.GetFPTypeString
method returns
the string representation of the fingerprint type that includes
information about the parameters being used.
OEFingerPrint fpA = new OEFingerPrint();
OEGraphSim.OEMakeFP(fpA, mol, OEFPType.Path);
Console.WriteLine(fpA.GetFPTypeBase().GetFPTypeString());
The output of the preceding snippet is the following:
Path,ver=2.0.0,size=4096,bonds=0-5,atype=AtmNum|Arom|Chiral|FCharge|HvyDeg|Hyb|EqHalo,
btype=Order|Chiral
Note
The returned string does not include newline characters, the string was broken into two separate lines here only for better readability.
The following Listing 2
shows how to extract
the parameters of a fingerprint from a string representation by
using the OEFPTypeParams class.
Listing 2: Fingerprint parameters
public class FPTypeParams
{
public static int Main(string[] args)
{
OEFPTypeBase fptype = OEGraphSim.OEGetFPType(OEFPType.Path);
OEFPTypeParams prms = new OEFPTypeParams(fptype.GetFPTypeString());
Console.WriteLine("version = " + OEGraphSim.OEGetFingerPrintVersionString(prms.GetVersion()));
Console.WriteLine("number of bits = " + prms.GetNumBits());
Console.WriteLine("min bonds = " + prms.GetMinDistance());
Console.WriteLine("max bonds = " + prms.GetMaxDistance());
Console.WriteLine("atom types = " + OEGraphSim.OEGetFPAtomType(prms.GetAtomTypes()));
Console.WriteLine("bond types = " + OEGraphSim.OEGetFPBondType(prms.GetBondTypes()));
return 0;
}
}
The output of Listing 2
is the following:
version = 2.0.0
number of bits = 4096
min bonds = 0
max bonds = 5
atom types = AtmNum|Arom|Chiral|FCharge|HvyDeg|Hyb|EqHalo
bond types = Order|Chiral
See also
User-defined Fingerprint chapter
OEIsValidFPTypeString
functionOEGetFPType
functionOEFPAtomType
namespaceOEGetFPAtomType
functionOEFPBondType
namespaceOEGetFPBondType
function
Fingerprint version number¶
Each fingerprint type additionally has a version number. Version
numbers are introduced in order to keep track of changes in the
fingerprint generation algorithm itself.
The OEFPTypeBase.GetFPVersionString
method
returns the string representation of the fingerprint version.
OEFingerPrint fpB = new OEFingerPrint();
OEGraphSim.OEMakeFP(fpB, mol, OEFPType.Circular);
Console.WriteLine(fpB.GetFPTypeBase().GetFPVersionString());
The output of the preceding snippet is the following:
2.0.0
Warning
The version number of the fingerprints will not be changed with each release. It will be incremented only if modifications or bug fixes to the corresponding algorithm would result in generating a different bit-vector for the same molecules.
Fingerprints with an old version number will be still readable and comparable with each other but not with fingerprints which have different version number.