MoleculeFeatureDistance[mol1,mol2]
gives a distance measure between mol1 and mol2.
MoleculeFeatureDistance
MoleculeFeatureDistance[mol1,mol2]
gives a distance measure between mol1 and mol2.
Details and Options
- MoleculeFeatureDistance is also known as molecule fingerprint distance.
- The following options can be given:
-
FeatureExtractor Automatic method to use to convert a Molecule object to a numeric feature vector DistanceFunction Automatic function to compute the distance between feature vectors - Possible values for FeatureExtractor include:
-
"AtomPairs" Boolean vector from pairs of atoms and the path lengths between them "MoleculeExtendedConnectivity" Boolean vector from circular atom neighborhoods "MoleculeTopologicalFeatures" Boolean vector from enumerated molecule subgraphs - The DistanceFunction is typically JaccardDissimilarity or DiceDissimilarity.
Examples
open all close allBasic Examples (1)
Find the distance between two molecules:
MoleculeFeatureDistance[Molecule[{"C", "O", "C", "C", "C", "C", "C", "C", "P", "C", "C", "C", "C", "C", "C", "O", "C", "C",
"C", "C", "C", "C", "C", "O", "C"}, {Bond[{1, 2}, "Single"], Bond[{2, 3}, "Single"],
Bond[{3, 4}, "Aromatic"], Bond[{4, 5}, "Aromatic"], Bond[ ... }, "Aromatic"], Bond[{20, 21}, "Aromatic"],
Bond[{21, 22}, "Aromatic"], Bond[{22, 23}, "Aromatic"], Bond[{21, 24}, "Single"],
Bond[{24, 25}, "Single"], Bond[{8, 3}, "Aromatic"], Bond[{15, 10}, "Aromatic"],
Bond[{23, 18}, "Aromatic"]}, {}], Molecule[{"C", "O", "C", "C", "C", "C", "C", "C", "C", "C", "N", "C", "O", "C", "C", "C", "C", "C",
"C", "C", "C", "C", "C", "C", "C", "C", "O"}, {Bond[{1, 2}, "Single"], Bond[{2, 3}, "Single"],
Bond[{3, 4}, "Aromatic"], Bond[{4, 5}, "Aromati ... 24}, "Aromatic"],
Bond[{24, 25}, "Aromatic"], Bond[{25, 26}, "Single"], Bond[{26, 27}, "Double"],
Bond[{8, 3}, "Aromatic"], Bond[{13, 9}, "Aromatic"], Bond[{19, 14}, "Aromatic"],
Bond[{25, 20}, "Aromatic"], Bond[{26, 18}, "Single"]}, {}]]Find the distance between two less similar molecules:
MoleculeFeatureDistance[Molecule[{"C", "O", "C", "C", "C", "C", "C", "C", "P", "C", "C", "C", "C", "C", "C", "O", "C", "C",
"C", "C", "C", "C", "C", "O", "C"}, {Bond[{1, 2}, "Single"], Bond[{2, 3}, "Single"],
Bond[{3, 4}, "Aromatic"], Bond[{4, 5}, "Aromatic"], Bond[ ... }, "Aromatic"], Bond[{20, 21}, "Aromatic"],
Bond[{21, 22}, "Aromatic"], Bond[{22, 23}, "Aromatic"], Bond[{21, 24}, "Single"],
Bond[{24, 25}, "Single"], Bond[{8, 3}, "Aromatic"], Bond[{15, 10}, "Aromatic"],
Bond[{23, 18}, "Aromatic"]}, {}], Molecule[{"O", "C", "O", "C", "C", "C", "C", "O", "O", "F", "F"},
{Bond[{1, 2}, "Single"], Bond[{2, 3}, "Double"], Bond[{2, 4}, "Single"], Bond[{4, 5}, "Single"],
Bond[{5, 6}, "Single"], Bond[{6, 7}, "Single"], Bond[{7, 8}, "Double"], Bond[{7, 9}, "Single"],
Bond[{6, 10}, "Single"], Bond[{6, 11}, "Single"]}, {}]]Scope (2)
Find the molecule distance between two "Chemical" entities:
MoleculeFeatureDistance[Entity["Chemical", "Caffeine"], Entity["Chemical", "Adenosine"]]Find the five entities in a list that are most similar to a target:
TakeSmallestBy[EntityList[EntityClass["Chemical", "Alkenes"]], MoleculeFeatureDistance[Molecule[{"C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C",
"C", "C", "C", "C", "C"}, {Bond[{1, 2}, "Single"], Bond[{2, 3}, "Single"],
Bond[{3, 4}, "Single"], Bond[{4, 5}, "Single"], Bond[{5, 6}, "Doubl ... ssociation["StereoType" -> "DoubleBond",
"StereoBond" -> {13, 14}, "Ligands" -> {12, 15}, "Value" -> "Opposite"],
Association["StereoType" -> "DoubleBond", "StereoBond" -> {20, 21}, "Ligands" -> {19, 22},
"Value" -> "Opposite"]}}], #]&, 5]Neat Examples (1)
Create a NearestFunction to find the entities most similar to any molecule:
nf = Nearest[DeleteMissing[EntityValue[EntityList["Chemical"], "Molecule", "EntityAssociation"]], DistanceFunction -> MoleculeFeatureDistance]Use the nearest function on an input molecule:
nf[Molecule["2-(2-nitrophenyl)sulfanyl-5-phenylcyclohexane-1,3-dione"]]MoleculePlot[First[%]]Find the five nearest molecules to a given molecule:
nf[Molecule[{"C", "O", "C", "C", "C", "C", "N", "C", "C", "C", "C", "C", "O", "C", "C", "N", "C", "C",
"O", "C", "C", "C", "C", "C", "C", "O", "C", "N"}, {Bond[{1, 2}, "Single"],
Bond[{2, 3}, "Single"], Bond[{3, 4}, "Aromatic"], Bond[{4, 5}, "Ar ... ingle"], Bond[{12, 3}, "Aromatic"], Bond[{25, 20}, "Aromatic"],
Bond[{10, 5}, "Aromatic"]},
{StereochemistryElements -> {Association["StereoType" -> "DoubleBond", "StereoBond" -> {15, 16},
"Ligands" -> {7, 17}, "Value" -> "Opposite"]}}], 5]MoleculePlot /@ %History
Text
Wolfram Research (2025), MoleculeFeatureDistance, Wolfram Language function, https://reference.wolfram.com/language/ref/MoleculeFeatureDistance.html.
CMS
Wolfram Language. 2025. "MoleculeFeatureDistance." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MoleculeFeatureDistance.html.
APA
Wolfram Language. (2025). MoleculeFeatureDistance. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MoleculeFeatureDistance.html
BibTeX
@misc{reference.wolfram_2026_moleculefeaturedistance, author="Wolfram Research", title="{MoleculeFeatureDistance}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/MoleculeFeatureDistance.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_moleculefeaturedistance, organization={Wolfram Research}, title={MoleculeFeatureDistance}, year={2025}, url={https://reference.wolfram.com/language/ref/MoleculeFeatureDistance.html}, note=[Accessed: 13-June-2026]}