diff --git a/docs/source/Classes.rst b/docs/source/Classes.rst index 053cc5dd..5f202478 100644 --- a/docs/source/Classes.rst +++ b/docs/source/Classes.rst @@ -22,7 +22,7 @@ mol3D Class Mol2D Class -------------------------------- -.. automodule:: molSimplify.Classes.mol3D +.. automodule:: molSimplify.Classes.mol2D :members: :undoc-members: :show-inheritance: diff --git a/molSimplify/Classes/mol2D.py b/molSimplify/Classes/mol2D.py index aa5c396b..ae5ce866 100644 --- a/molSimplify/Classes/mol2D.py +++ b/molSimplify/Classes/mol2D.py @@ -1,6 +1,6 @@ import networkx as nx import numpy as np -from typing import List +from typing import List, Union from packaging import version from molSimplify.Classes.globalvars import globalvars @@ -28,7 +28,7 @@ def __repr__(self): return f"Mol2D({formula})" @classmethod - def from_smiles(cls, smiles): + def from_smiles(cls, smiles: str): """Create a Mol2D object from a SMILES string. Parameters @@ -44,6 +44,7 @@ def from_smiles(cls, smiles): Examples -------- Create a furan molecule from SMILES: + >>> mol = Mol2D.from_smiles("o1cccc1") >>> mol Mol2D(O1C4H4) @@ -121,7 +122,7 @@ def from_mol_file(cls, filename): return mol - def graph_hash(self): + def graph_hash(self) -> str: """Calculates the node attributed graph hash of the molecule. Returns @@ -132,9 +133,11 @@ def graph_hash(self): Examples -------- Create a furan molecule from SMILES: + >>> mol = Mol2D.from_smiles("o1cccc1") - and calculate its graph hash: + and calculate the node attributed graph hash: + >>> mol.graph_hash() 'f6090276d7369c0c0a535113ec1d97cf' """ @@ -144,7 +147,7 @@ def graph_hash(self): assert version.parse(nx.__version__) >= version.parse("2.7") return nx.weisfeiler_lehman_graph_hash(self, node_attr="symbol") - def graph_hash_edge_attr(self): + def graph_hash_edge_attr(self) -> str: """Calculates the edge attributed graph hash of the molecule. Returns @@ -155,9 +158,11 @@ def graph_hash_edge_attr(self): Examples -------- Create a furan molecule from SMILES: + >>> mol = Mol2D.from_smiles("o1cccc1") - and calculate its graph hash: + and calculate the edge attributed graph hash: + >>> mol.graph_hash_edge_attr() 'a9b6fbc7b5f53613546d5e91a7544ed6' """ @@ -174,7 +179,7 @@ def graph_hash_edge_attr(self): return nx.weisfeiler_lehman_graph_hash(G, edge_attr="label") - def graph_determinant(self, return_string=True): + def graph_determinant(self, return_string: bool = True) -> Union[str, float]: """Calculates the molecular graph determinant. Parameters @@ -184,15 +189,17 @@ def graph_determinant(self, return_string=True): Returns ------- - str - edge attributed graph hash + str | float + graph determinant Examples -------- Create a furan molecule from SMILES: + >>> mol = Mol2D.from_smiles("o1cccc1") - and calculate its graph hash: + and calculate the graph determinant: + >>> mol.graph_determinant() '-19404698740' """ @@ -224,7 +231,7 @@ def graph_determinant(self, return_string=True): def find_metal(self, transition_metals_only: bool = True) -> List[int]: """ - Find metal(s) in a Mol2D class. + Find indices of metal(s) in a Mol2D class. Parameters ---------- @@ -239,8 +246,8 @@ def find_metal(self, transition_metals_only: bool = True) -> List[int]: Examples -------- Build Vanadyl acetylacetonate from SMILES: - >>> mol = Mol2D.from_smiles("CC(=[O+]1)C=C(C)O[V-3]12(#[O+])OC(C)=CC(C)=[O+]2") + >>> mol = Mol2D.from_smiles("CC(=[O+]1)C=C(C)O[V-3]12(#[O+])OC(C)=CC(C)=[O+]2") >>> mol.find_metal() [7] """