Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mol support #157

Merged
merged 43 commits into from
Apr 19, 2022
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
105a2eb
add mol support
yuanqidu Apr 13, 2022
2554e24
add rdkit as optional dependency
a-r-j Apr 14, 2022
8d55f67
lint atomic edges
a-r-j Apr 14, 2022
ea8c50e
lint distance
a-r-j Apr 14, 2022
eb3d634
lint graphs
a-r-j Apr 14, 2022
299d69c
lint atom type
a-r-j Apr 14, 2022
9ef623c
lint tests
a-r-j Apr 14, 2022
968b9ee
additional node features from rdkit
a-r-j Apr 14, 2022
a1cdce5
additional vocabularies to atoms
a-r-j Apr 14, 2022
9a52956
add more RDKit constants
a-r-j Apr 15, 2022
d2ae675
refactor config matching utils to reduce duplication
a-r-j Apr 15, 2022
02227d9
add molecule graph config to yaml parser
a-r-j Apr 15, 2022
b66c418
lint edge funcs
a-r-j Apr 15, 2022
e3fe2c5
add bond-based edge feature funcs
a-r-j Apr 15, 2022
1d657c5
add additional Rdkit node features
a-r-j Apr 15, 2022
e5a47e1
add feature __init__
a-r-j Apr 15, 2022
88fdd88
add molecule __init__
a-r-j Apr 15, 2022
be1b30c
lint graphs
a-r-j Apr 15, 2022
9d1374a
fix rdkit constants
a-r-j Apr 15, 2022
d2a4277
add molecule module to docs
a-r-j Apr 15, 2022
0a167b8
fix rdkit constants
a-r-j Apr 15, 2022
748cb1b
fix rdkit type hint
a-r-j Apr 15, 2022
d1e2bed
refactor config utils to prevent circular import
a-r-j Apr 15, 2022
ad2ecb1
add names to graphs
a-r-j Apr 15, 2022
140954b
add global mol descriptors
a-r-j Apr 15, 2022
cd15a36
add add_hs flag
a-r-j Apr 15, 2022
bbe9f0a
fix feature funcs
a-r-j Apr 15, 2022
b5f50a0
add descriptor vocab
a-r-j Apr 15, 2022
b5b793c
update changelog
a-r-j Apr 15, 2022
fe77069
add molecule tutorial
a-r-j Apr 15, 2022
bb62ea6
add molecule tutorial to docs
a-r-j Apr 15, 2022
828644a
Merge branch 'master' into master
a-r-j Apr 15, 2022
5a52f9c
update path to config parser utils
a-r-j Apr 15, 2022
a65f81b
resolve merge
a-r-j Apr 15, 2022
78aa744
add additional molecular graph tests
a-r-j Apr 16, 2022
0e9a1ee
Merge branch 'master' into master
a-r-j Apr 16, 2022
a48483d
add plotting functions for molecules
a-r-j Apr 17, 2022
619957c
:wqMerge branch 'master' of https://github.com/yuanqidu/graphein into…
a-r-j Apr 17, 2022
2cfd8e8
update mol tutorial with 3d plots
a-r-j Apr 17, 2022
b7caf16
add molecule visualisation to docs
a-r-j Apr 17, 2022
3470357
fix molecule notebooks in docs
a-r-j Apr 17, 2022
7f25b92
update docs with refactored config
a-r-j Apr 17, 2022
7a0d1a5
update node naming to including element symbol
a-r-j Apr 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add add_hs flag
a-r-j committed Apr 15, 2022
commit cd15a369142bab8de84f5ec4369b7c339ee9d24c
6 changes: 3 additions & 3 deletions graphein/molecule/config.py
Original file line number Diff line number Diff line change
@@ -45,8 +45,8 @@ class MoleculeGraphConfig(BaseModel):

:param verbose: Specifies verbosity of graph creation process.
:type verbose: bool
:param deprotonate: Specifies whether or not to remove ``H`` atoms from the graph.
:type deprotonate: bool
:param add_hs: Specifies whether hydrogens should be added to the graph.
:type add_hs: bool
:param edge_construction_functions: List of functions that take an ``nx.Graph`` and return an ``nx.Graph`` with desired
edges added. Prepared edge constructions can be found in :ref:`graphein.protein.edges`
:type edge_construction_functions: List[Callable]
@@ -60,7 +60,7 @@ class MoleculeGraphConfig(BaseModel):
"""

verbose: bool = False
deprotonate: bool = False
add_hs: bool = False
# Graph construction functions
edge_construction_functions: List[Union[Callable, str]] = [
add_fully_connected_edges,
8 changes: 5 additions & 3 deletions graphein/molecule/graphs.py
Original file line number Diff line number Diff line change
@@ -46,9 +46,7 @@ def initialise_graph_with_metadata(
:rtype: nx.Graph
"""
return nx.Graph(
name=name,
rdmol=rdmol,
coords=coords,
name=name, rdmol=rdmol, coords=coords, smiles=Chem.MolToSmiles(rdmol)
)


@@ -175,6 +173,9 @@ def construct_graph(
for idx in range(rdmol.GetNumAtoms())
]

if config.add_hs:
rdmol = Chem.AddHs(rdmol)

if coords is None:
# If no coords are provided, add edges by bonds
config.edge_construction_functions = [add_atom_bonds]
@@ -192,6 +193,7 @@ def construct_graph(
)

g = initialise_graph_with_metadata(
name=name,
rdmol=rdmol,
coords=np.asarray(coords),
)