Introduction to Cheminformatics with Python
Learn how to use Python for basic cheminformatics tasks, including RDKit integration and data visualization.
Welcome to the first post on AstroZephyrus! Today we are looking at how to represent molecules in code.
Standard Code Blocks
You can use standard Markdown code blocks for snippets:
from rdkit import Chem
# Create a molecule from SMILES
mol = Chem.MolFromSmiles('c1ccccc1')
print(f"Atoms in benzene: {mol.GetNumAtoms()}")Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
File-like Code Blocks
Sometimes you want to show code as it would appear in a specific file. We can do this by adding a filename header.
from rdkit import Chem
def get_molecule(smiles):
"""Returns a molecule object from SMILES."""
return Chem.MolFromSmiles(smiles)Conclusion
This setup allows for clear documentation of code and file structures in your cheminformatics projects.
Lead developer at cheminfo.dev, passionate about the intersection of chemistry and software engineering.