This is a short tutorial for helping chemists and medical doctors retrieve entity information about drugs belonging to a specific class within Wolfram knowledge base. Since the introduction of the Entity-based framework in Wolfram Language, its functionalities have been significantly expanded in the chemistry section, as far as the subdivision of chemicals into different categories is concerned. While retrieving the set of chemicals belonging to a specific entity subclass (e. g. alcohols) from the Wolfram knowledge base is rather straightforward (just type EntityList[EntityClass[“Chemical”,”Alcohols”]]), this is not the case for drugs belonging to a given family (e.g. statins for the lowering of cholesterol). In this case, one has to resort to the coding flexibility of the Wolfram Language, since such implementation is still not available natively. This primer can be considered a blueprint for a string-based classification of some of the most prescribed drugs all over the world. As featured examples, drugs for the treatment of cardiovascular diseases with a specific suffix in their chemical name will be considered, so that a whole set of drugs belonging to that family can be listed without ambiguity.
Classes of Drugs for Cardiovascular Diseases
Classes of Drugs for Cardiovascular Diseases
Hypertension and hypercholesterolemia, also known as high blood pressure and cholesterol, are the two major risk factors and cause of premature death worldwide. Over the years, especially between the 70s and 80s of the 20th century, significant progress has been done in the development of drugs for lowering cholesterol values in the blood and keeping blood pressure in the normal range.
For treating high cholesterol levels, medical doctors often prescribe drugs belonging to the class of statins [1] , besides advising for a change in the patient’s lifestyle. All statins have their chemical name ending with suffix -vastatin .
For the treatment of high blood pressure and arrhythmias several classes of drugs are available as detailed in [2]: thiazide diuretics, calcium channel blockers, angiotensin-converting enzyme inhibitors (ACE inhibitors), angiotensin II receptor blockers (ARBs) and betablockers.
For instance, Captopril was the first ACE inhibitor ever synthesized and marketed. All ACE inhibitors derived from further development of Captopril have their chemical name ending with -pril suffix. On the same line, one of the most prescribed calcium channel blockers is amlodipine which belongs to the dihydropyridine family just like other drugs ending with suffix -dipine.
As you can see below, Wolfram knowledge base already provides the chemical names of such drugs and allows for a quick visualization of their molecular structure.
For the treatment of high blood pressure and arrhythmias several classes of drugs are available as detailed in [2]: thiazide diuretics, calcium channel blockers, angiotensin-converting enzyme inhibitors (ACE inhibitors), angiotensin II receptor blockers (ARBs) and betablockers.
For instance, Captopril was the first ACE inhibitor ever synthesized and marketed. All ACE inhibitors derived from further development of Captopril have their chemical name ending with -pril suffix. On the same line, one of the most prescribed calcium channel blockers is amlodipine which belongs to the dihydropyridine family just like other drugs ending with suffix -dipine.
As you can see below, Wolfram knowledge base already provides the chemical names of such drugs and allows for a quick visualization of their molecular structure.
In[]:=
captopril=Entity["Chemical","Captopril"]
Out[]=
In[]:=
MoleculePlot[Molecule@captopril]
Out[]=
In[]:=
EntityValue[captopril,"Name"]
Out[]=
captopril
In[]:=
EntityTypeName[captopril]
Out[]=
Chemical
How to correctly retrieve drug subclasses with Entity
How to correctly retrieve drug subclasses with Entity
In order to retrieve from Wolfram knowledge base a subclass of chemicals belonging to one of the above mentioned drug classes, one can think of building up a FilteredEntityClass exploiting a string-based search over “Chemical” class combined with EntityFunction and EntityValue.
The code below allows to find all chemicals having their name ending with -pril suffix.
The code below allows to find all chemicals having their name ending with -pril suffix.
Note that the first time the cell is executed, it may take a little longer because of prefetching all chemical entities
In[]:=
ACEpril=FilteredEntityClass["Chemical",EntityFunction[m,StringMatchQ[EntityValue[m,"Name"],___~~"pril"~~EndOfString]]]["Name"]
Out[]=
{benazepril,captopril,cilazapril,enalapril,fosinopril,lisinopril,moexipril,perindopril,quinapril,ramipril,spirapril,trandolapril}
One can effectively check that the obtained list of chemicals is actually complete with most ACE inhibitors reported in literature [4].
The following gives the list of all the commonest statins as reported in literature [1]
In[]:=
statins=FilteredEntityClass["Chemical",EntityFunction[m,StringMatchQ[EntityValue[m,"Name"],___~~"vastatin"~~EndOfString]]]["Name"]
Out[]=
{atorvastatin,cerivastatin,fluvastatin,lovastatin,pravastatin,rosuvastatin,simvastatin}
Some spurious chemicals can actually appear in the list if one attempt at searching for beta blockers like the widely prescribed bisoprolol or atenolol, since the suffix -olol is closely related to some other chemicals which do not belong act as beta blockers (for example magnolol).
In[]:=
betablocker=FilteredEntityClass["Chemical",EntityFunction[m,StringMatchQ[EntityValue[m,"Name"],___~~"olol"~~EndOfString]]]["Name"]
Out[]=
{2-methyl-5-benzothiazolol,acebutolol,alprenolol,atenolol,betaxolol,bevantolol,bisabolol,bisoprolol,carteolol,esmolol,levobunolol,magnolol,metipranolol,metoprolol,nadolol,oxprenolol,penbutolol,pindolol,practolol,propranolol,(R)-(+)-atenolol,(S)-(-)-atenolol,stanozolol,timolol}
In[]:=
%//Length
Out[]=
24
The ambiguity may be removed by enforcing the use of EntityClass[“Chemical”,”Drugs”]
In[]:=
betablocker=FilteredEntityClass[EntityList[EntityClass["Chemical","Drugs"]],EntityFunction[m,StringMatchQ[EntityValue[m,"Name"],___~~"olol"~~EndOfString]]]["Name"]//Sort
Out[]=
{acebutolol,alprenolol,atenolol,betaxolol,bevantolol,bisoprolol,carteolol,esmolol,levobunolol,metipranolol,metoprolol,nadolol,oxprenolol,penbutolol,pindolol,practolol,propranolol,timolol}
as confirmed by the shortened list, so that all effective beta blockers are included, with most of them reported in literature as well [5].
In[]:=
%//Length
Out[]=
18
Here it is the list of calcium channel blockers used for their vasodilator action as reported here [6]
In[]:=
calciumchblocker=FilteredEntityClass[EntityList[EntityClass["Chemical","Drugs"]],EntityFunction[m,StringMatchQ[EntityValue[m,"Name"],___~~"dipine"~~EndOfString]]]["Name"]
Out[]=
{nifedipine,nitrendipine,isradipine,felodipine,nisoldipine,amlodipine,nimodipine,nicardipine,lercanidipine}
Example: tracking historical development of ACE inhibitors and statins by computing their molecule similarity
Example: tracking historical development of ACE inhibitors and statins by computing their molecule similarity
In order to track the evolution in the drug design of ACE inhibitors it can be useful to build up the clustering tree of the corresponding molecular distance function.
Some of the first marketed drugs are quite relevant in the history of drug chemistry, since they have been synthesized from natural sources such as the fungal specie Aspergillus terreus in the case of Lovastatin [1] for lowering cholesterol in 1979. In the following, the first patent year of each drug were found by a simple web-search and reported in the clustering graph
Some of the first marketed drugs are quite relevant in the history of drug chemistry, since they have been synthesized from natural sources such as the fungal specie Aspergillus terreus in the case of Lovastatin [1] for lowering cholesterol in 1979. In the following, the first patent year of each drug were found by a simple web-search and reported in the clustering graph
In[]:=
statinsCap=Capitalize/@statins
Out[]=
{Atorvastatin,Cerivastatin,Fluvastatin,Lovastatin,Pravastatin,Rosuvastatin,Simvastatin}
In[]:=
statinsYear={1985,1997,1982,1979,1980,1991,1980};
In[]:=
statinsEnt=Map[Entity["Chemical",#]&,statinsCap];
In[]:=
datastatins=AssociationThread[statinsEnt->statinsYear]
Out[]=
1985,1997,1982,1979,1980,1991,1980
In[]:=
ClusteringTree[statinsEnt,ImageSize->Medium,DistanceFunction->MoleculeFeatureDistance,VertexLabels{{1->"statins molecular distance tree"},{2->Placed[Rotate[Row[{"(",datastatins[Entity["Chemical","Atorvastatin"]],") "}],π/3],Right]},{4->Placed[Rotate[Row[{" (",datastatins[Entity["Chemical","Fluvastatin"]],")"}],-Pi/3],Left]},{5->Placed[{Rotate[Row[{"(",datastatins[Entity["Chemical","Cerivastatin"]],")\t"}],Pi/3],Rotate[Row[{" (",datastatins[Entity["Chemical","Rosuvastatin"]],")"}],-Pi/3]},{Right,Left}]},{11->Placed[{Rotate[Row[{"(",datastatins[Entity["Chemical","Simvastatin"]],") "}],Pi/3],Rotate[Row[{" (",datastatins[Entity["Chemical","Lovastatin"]],")"}],-Pi/3]},{Right,Left}]},{9->Placed[Rotate[Row[{"(",datastatins[Entity["Chemical","Pravastatin"]],")\t"}],Pi/3],Right]}},VertexLabelStyle->{1->{Directive[13]},11->{Directive[Red,Italic,14]},12->Directive[Red,Italic,14],13->Directive[Red,Italic,14]}]
Out[]=
As for antihypertensive drug, the investigation of venom of the South American pit viper Bothrops jararaca was crucial in the synthesis of Captopril [2].
In[]:=
ACEpril=Capitalize/@FilteredEntityClass["Chemical",EntityFunction[m,StringMatchQ[EntityValue[m,"Name"],___~~"pril"~~EndOfString]]]["Name"]
Out[]=
{Benazepril,Captopril,Cilazapril,Enalapril,Fosinopril,Lisinopril,Moexipril,Perindopril,Quinapril,Ramipril,Spirapril,Trandolapril}
In[]:=
ACEyear={1981,1975,1982,1978,1980,1978,1982,1980,1980,1981,1980,1981};
In[]:=
ACElistEnt=Map[Entity["Chemical",#]&,ACEpril];
In[]:=
dataACE=AssociationThread[ACElistEnt->ACEyear]
Out[]=
1981,1975,1982,1978,1980,1978,1982,1980,1980,1981,1980,1981
Captopril can be considered the common “ancestor” of all ACE inhibitors as it was the first one patented in 1975; all synthesis development actually started from this drug, with the aim of reducing most of its adverse effects (e.g. cough) brought by the thiol (-SH) group. The development of captopril is actually one of the most prominent in the history of drug design [7]. The most prescribed ACE inhibitors, almost all patented at the beginning of the 80s are found at the bottom of the clustering tree (e.g. ramipril); they actually stem from the development of the benazepril and lisinopril, which contain a carboxylic (-COOH) group, which clearly improved their tolerability, whereas fosinopril is clearly an early departure from captopril since it contains a fosfinic (-PH) group.
In[]:=
ClusteringTree[ACElistEnt,ImageSize->Large,DistanceFunction->MoleculeFeatureDistance,VertexLabels{{1->"other -PH derivatives"},{3->Placed[{"first ACE inhibitor",Row[{"(",dataACE[Entity["Chemical","Captopril"]],")"}]},{Right,Left}]},{2->Placed[{Row[{" (",dataACE[Entity["Chemical","Fosinopril"]],")"}]},Left]},{5->Placed[{Row[{"(",dataACE[Entity["Chemical","Benazepril"]],") "}]},Right]},{6->Placed[{Row[{"(",dataACE[Entity["Chemical","Lisinopril"]],")"}]},Left]},{12->Placed[{Row[{"(",dataACE[Entity["Chemical","Enalapril"]],") "}]},Right]},{17->Placed[{Row[{"(",dataACE[Entity["Chemical","Perindopril"]],") "}]},Right]}},VertexLabelStyle->{3->Directive[Red,Italic,14],22->Directive[Red,Italic,14],6->Directive[Red,Italic,14],21->Directive[Red,Italic,14],11->Directive[Red,Italic,14],12->Directive[Red,Italic,14]}]
Out[]=
Building a hierarchical Entity Store for Drugs
Building a hierarchical Entity Store for Drugs
Following the Wolfram Workflow guide for setting up an Entity Store it is possible to devise a hierarchical structure for some classes of drugs with related information such as the year of the synthesis/first patent or whatever data you are interested into (e.g. trade name in a given country or continent) as outlined below
Summary
Summary
A tutorial for drug classification has been proposed for further structuring of the Wolfram knowledge base, which can be helpful for tracking milestones in drug design.
References
References
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
Drug classification with Wolfram Entity framework: a primer
By Jessica Alfonsi
Wolfram Community, STAFF PICKS, October 10, 2025
https://community.wolfram.com/groups/-/m/t/3559309
By Jessica Alfonsi
Wolfram Community, STAFF PICKS, October 10, 2025
https://community.wolfram.com/groups/-/m/t/3559309