Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Old-Shatterhand committed Oct 15, 2024
1 parent 815aa7a commit 3989518
Show file tree
Hide file tree
Showing 6 changed files with 350 additions and 236 deletions.
4 changes: 2 additions & 2 deletions glyles/glycans/mono/enum_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def enumerate_c_atoms(monomer, c_atoms, ringo):

children = np.where(np.array(monomer.adjacency[c_id, :] == 1) & (monomer.x[:, 0] == 6) & (monomer.x[:, 3] == 1))[0]
for c in children:
if int(c) not in c_tree.nodes:
stack.append((c_id, int(c)))
if c.item() not in c_tree.nodes:
stack.append((c_id, c.item()))

# find the deepest node and rehang the tree to this node
deepest_id, _ = c_tree.deepest_node()
Expand Down
14 changes: 7 additions & 7 deletions glyles/glycans/mono/reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
"A": "OC(=O)C",
"Allyl": "CC=C",
"Ac": "C(=O)C",
"Ang": "OC(=O)C/(C)=C\C",
"Ang": "OC(=O)C/(C)=C\\C",
"Bz": "C(=O)c2ccccc2",
"Bn": "Cc2ccccc2",
"cdPam": "OC(=O)CCCCCCC/C=C\CCCCCC",
"cdPam": "OC(=O)CCCCCCC/C=C\\CCCCCC",
"Cet": "CCC(=O)O",
"Cin": "OC(=O)/C=C/c2ccccc2",
"Coum": "OC(=O)/C=C/c1ccc(O)ccc1",
Expand All @@ -72,7 +72,7 @@
"Gro": "OCC(O)CO",
"He": "C(O)C",
"Lac": "OC(=O)C(O)C",
"Lin": "OC(=O)CCCCCCC/C=C\C/C=C\CCCCC",
"Lin": "OC(=O)CCCCCCC/C=C\\C/C=C\\CCCCC",
"Mal": "O[C@H](C(=O)O)CC(=O)O",
"Ole": "OC(=O)CCCCCCC/C=C\CCCCCCCC",
"Ph": "c2ccccc2",
Expand All @@ -93,9 +93,9 @@

# some special cases
"3oxoMyr": "OC(=O)CC(=O)CCCCCCCCCCC",
"17HOLin": "OC(=O)CCCCCCC/C=C\C/C=C\CCCC(O)C",
"17HOLin": "OC(=O)CCCCCCC/C=C\\C/C=C\\CCCC(O)C",
"aLnn": "OC(=O)CCCCCCCC=CCC=CCC=CCC",
"cVac": "OC(=O)CCCCCCCCC/C=C\CCCCCC",
"cVac": "OC(=O)CCCCCCCCC/C=C\\CCCCCC",
"d2Ach": "OC(=O)CCCCCCC=CCC=CCCCCCCCC",
"d3Ach": "OC(=O)CCCC=CCC=CCC=CCCCCCCCC",
"d4Ach": "OC(=O)CCCC=CCC=CCC=CCC=CCCCCC",
Expand Down Expand Up @@ -147,7 +147,7 @@
"Geddic": "OC(=O)" + "C" * 33,
"Ceroplastic": "OC(=O)" + "C" * 35,
"Phthi": "OC(=O)C(C)=CC(C)CC(C)" + "C" * 18,
"Ner": "OC(=O)" + "C" * 13 + "/C=C\C" + "C" * 7,
"Ner": "OC(=O)" + "C" * 13 + "/C=C\\C" + "C" * 7,
}

# list of functional groups that preserve the atom it is attached to instead of replacing it
Expand Down Expand Up @@ -524,7 +524,7 @@ def add_to_carbon(self, chain, i, placeholder):

# identify a hydrogen bound to the carbon atom to attach the functional group to
h = None
for n in tmp.GetAtomWithIdx(int(np.where(self.monomer.x[:, 1] == i)[0])).GetNeighbors():
for n in tmp.GetAtomWithIdx(np.where(self.monomer.x[:, 1] == i)[0].item()).GetNeighbors():
if n.GetAtomicNum() == 1:
h = n.GetIdx()
break
Expand Down
4 changes: 2 additions & 2 deletions glyles/glycans/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,8 @@ def find_longest_c_chain(c_atoms, adjacency, a_type):

children = np.argwhere(np.array(adjacency[c_id, :] == 1) & (a_type == 6))
for c in children:
if int(c) not in c_tree.nodes:
stack.append((c_id, int(c)))
if c.item() not in c_tree.nodes:
stack.append((c_id, c.item()))

# find the deepest node and rehang the tree to this node
deepest_id, _ = c_tree.deepest_node()
Expand Down
3 changes: 2 additions & 1 deletion glyles/grammar/Glycan.g4
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ branch:
| deriv con LBRACE branch RBRACE LBRACE branch RBRACE branch
| deriv con LBRACE branch RBRACE LBRACE branch RBRACE LBRACE branch RBRACE branch;
deriv:
modi* saci+ modi* RING? modi* TYPE?;
modi* saci+ modi* RING? modi* TYPE? modi*
| modi* saci+ modi* TYPE? modi* RING? modi*;
saci: COUNT | SAC;
con:
LPAR typi NUM DASH qnum RPAR
Expand Down
Loading

0 comments on commit 3989518

Please sign in to comment.