NumHAcceptors() is the function that is used to calculate the molecular weight of a compound.
Calculate the HBA of Butane (Figure 1).
Code:
butane_smiles = "CCCC"
butane_mol = Chem.MolFromSmiles(butane_smiles)
# HBA
butane_mw = Descriptors.NumHAcceptors(butane_mol)
print(f"Number of Hydrogen bond acceptors of Butane: {butane_mw:.2f}")
Figure 1: HBA of Butane
2. Calculate the HBA of Benzene (Figure 2).
Code:
benzene_smiles = "c1ccccc1"
benzene_mol = Chem.MolFromSmiles(benzene_smiles)
# HBA
benzene_mw = Descriptors.NumHAcceptors(benzene_mol)
print(f"Number of Hydrogen bond acceptors of Benzene: {benzene_mw:.2f}")
Figure 2: HBA of Benzene
3. Calculate the HBA of Aspirin (Figure 3).
Code:
aspirin_smiles = "CC(=O)OC1=CC=CC=C1C(=O)O"
aspirin_mol = Chem.MolFromSmiles(aspirin_smiles)
# HBA
aspirin_mw = Descriptors.NumHAcceptors(aspirin_mol)
print(f"Number of Hydrogen bond acceptors of Benzene: {aspirin_mw:.2f}")
Figure 3: HBA of Aspirin
4. Calculate the HBA of Butanol (Figure 4).
Code:
#Butanol
butanol_smiles = "CCCCO"
butanol_mol = Chem.MolFromSmiles(butanol_smiles)
# HBA
butanol_mw = Descriptors.NumHAcceptors(butanol_mol)
print(f"Number of Hydrogen bond acceptors of Butanol: {butanol_mw:.2f}")
Figure 4: HBA of Butanol
5. Calculate the HBA of Sodium Propionate (Figure 5).
Code:
sodiumpropionate_smiles = "CCC(=O)[O-].[Na+]"
sodiumpropionate_mol = Chem.MolFromSmiles(sodiumpropionate_smiles)
# HBA
sodiumpropionate_mw = Descriptors.NumHAcceptors(sodiumpropionate_mol)
print(f"Number of Hydrogen bond acceptors of Sodium propionate: {sodiumpropionate_mw:.2f}")
Figure 5: HBA of Sodium Propionate