The molecular weight (also called molecular mass) is the sum of the atomic masses of all atoms in a molecule, normally reported in daltons (g·mol⁻¹). It’s a fundamental physicochemical property used in filtering libraries and in drug-likeness rules. It provides crucial information about the size and bulk of a molecule.
Descriptors.MolWt() is the function that is used to calculate the molecular weight of a compound.
You can access the Google Colab here; it contains all the code used in this tutorial: Google Colab
Before calculating the molecular weight, we need to import the correct modules first.
from rdkit import Chem
from rdkit.Chem import Descriptors
Calculate the molecular weight of Butane (Figure 1).
Code:
butane_smiles = "CCCC"
butane_mol = Chem.MolFromSmiles(butane_smiles)
# Calculate Molecular Weight
butane_mw = Descriptors.MolWt(butane_mol)
print(f"Molecular Weight of Butane: {butane_mw:.2f} g/mol")
Figure 1: Molecular weight of Butane
2. Calculate the molecular weight of Benzene (Figure 2).
Code:
benzene_smiles = "c1ccccc1"
benzene_mol = Chem.MolFromSmiles(benzene_smiles)
# Calculate Molecular Weight
benzene_mw = Descriptors.MolWt(benzene_mol)
print(f"Molecular Weight of Benzene: {benzene_mw:.2f} g/mol")
Figure 2: Molecular weight of Benzene
3. Calculate the Aspirin (Figure 3).
Code:
M = "CC(=O)OC1=CC=CC=C1C(=O)O"
aspirin_mol = Chem.MolFromSmiles(aspirin_smiles)
# Calculate Molecular Weight
aspirin_mw = Descriptors.MolWt(aspirin_mol)
print(f"Molecular Weight of Aspirin: {aspirin_mw:.2f} g/mol")
Figure 3: Molecular weight of Aspirin
4. Calculate the Aspirin (Figure 4).
Code:
butanol_smiles = "CCCCO"
butanol_mol = Chem.MolFromSmiles(butanol_smiles)
# Calculate Molecular Weight
butanol_mw = Descriptors.MolWt(butanol_mol)
print(f"Molecular Weight of Butanol: {butanol_mw:.2f} g/mol")
Figure 4: Molecular weight of Butanol
5. Calculate the Sodium propionate (Figure 5).
Code:
sodiumpropionate_smiles = "CCC(=O)[O-].[Na+]"
sodiumpropionate_mol = Chem.MolFromSmiles(sodiumpropionate_smiles)
# Calculate Molecular Weight
sodiumpropionate_mw = Descriptors.MolWt(sodiumpropionate_mol)
print(f"Molecular Weight of Sodium propionate: {sodiumpropionate_mw:.2f} g/mol")
Figure 5: Molecular weight of Sodium propionate