diff --git a/doc/source/universe.rst b/doc/source/universe.rst index 5af0a8fe5..d40a4c95b 100644 --- a/doc/source/universe.rst +++ b/doc/source/universe.rst @@ -126,6 +126,34 @@ For example, to construct a universe with 6 atoms in 2 residues: `See this notebook tutorial for more information. `_ +Constructing from SMILES +------------------------ + +Thanks to the interoperability with RDKit, a Universe can be constructed from a SMILES string with :meth:`Universe.from_smiles`. Since the SMILES string usually contains information about heavy atoms only, this method automatically adds the appropriate number of hydrogens on all atoms, by setting :code:`addHs=True`. It is also possible to generate coordinates with :code:`generate_coordinates=True`. This will allow RDKit to generate one or more conformers for the given molecule. For example, setting :code:`numConfs=10` will generate 10 conformers, and each conformer will be read as a frame by the Universe. + +Here is a minimal example to create a Universe from one conformer of ethanol: + +.. ipython:: python + + u = mda.Universe.from_smiles("CCO") + u + u.trajectory + +Internally, calling the :meth:`Universe.from_smiles` method does the following: + +.. ipython:: python + + from rdkit import Chem + from rdkit.Chem import AllChem + + mol = Chem.MolFromSmiles("CCO") # ethanol + mol = Chem.AddHs(mol) + confids = AllChem.EmbedMultipleConfs(mol, numConfs=1) # 1 conformer + u = mda.Universe(mol, format="RDKIT") + u + u.trajectory + + Guessing topology attributes ---------------------------- diff --git a/environment.yml b/environment.yml index 2767eea46..2c0bfbee4 100644 --- a/environment.yml +++ b/environment.yml @@ -21,6 +21,7 @@ dependencies: - sphinxcontrib-bibtex<2.0.0 - sphinx_rtd_theme - tabulate + - rdkit - pip: - msmb_theme==1.2.0 - sphinx-sitemap==1.0.2 diff --git a/requirements.txt b/requirements.txt index 674fd3f0b..088c13cb2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,4 +14,5 @@ sphinx-rtd-theme==0.4.3 sphinx-sitemap==1.0.2 tabulate==0.8.5 pybtex==0.22.2 -plotly==4.5.1 \ No newline at end of file +plotly==4.5.1 +rdkit==2020.03.3 \ No newline at end of file