1919from glyles .glycans .utils import ParseError
2020from glyles .gwb .GWBLexer import GWBLexer
2121from glyles .iupac .IUPACLexer import IUPACLexer
22+ from glyles .utils import smiles2mol
2223
2324if not hasattr (IUPACLexer , "MOD" ):
2425 IUPACLexer .MOD = IUPACLexer .QMARK + 1
@@ -154,7 +155,7 @@ def summary(self):
154155 raise ValueError ("SMILES string for this glycan is empty, check if the IUPAC is convertable." )
155156
156157 # generate molecule with RDKit and check it's not None
157- mol = Chem . MolFromSmiles (smiles )
158+ mol = smiles2mol (smiles )
158159 if mol is None :
159160 raise ValueError ("Generated SMILES is invalid, rdkit couldn't read it in." )
160161
@@ -240,7 +241,7 @@ def count_protonation(self, grouping):
240241 raise ValueError ("SMILES string for this glycan is empty, check if the IUPAC is convertable." )
241242
242243 # generate molecule with RDKit and check it's not None
243- mol = Chem . MolFromSmiles (smiles )
244+ mol = smiles2mol (smiles )
244245 if mol is None :
245246 raise ValueError ("Generated SMILES is invalid, rdkit couldn't read it in." )
246247
@@ -254,7 +255,7 @@ def count_protonation(self, grouping):
254255 matched_atoms = set ()
255256 for g , val in group :
256257 # compute the matches against this glycan
257- matches = mol .GetSubstructMatches (Chem . MolFromSmiles (g ))
258+ matches = mol .GetSubstructMatches (smiles2mol (g ))
258259 for match in matches :
259260 for aid in match :
260261 # find the core atom of each match, add it to the list of covered atoms and increase the count
@@ -285,17 +286,17 @@ def count_functional_groups(self, groups):
285286 raise ValueError ("SMILES string for this glycan is empty, check if the IUPAC is convertable." )
286287
287288 # generate molecule with RDKit and check it's not None
288- mol = Chem . MolFromSmiles (smiles )
289+ mol = smiles2mol (smiles )
289290 if mol is None :
290291 raise ValueError ("Generated SMILES is invalid, rdkit couldn't read it in." )
291292
292293 fgs = []
293294 for group in groups :
294295 # convert the functional group into a RDKit molecule
295296 if group in functional_groups :
296- tmp = Chem . MolFromSmiles (functional_groups [group ])
297+ tmp = smiles2mol (functional_groups [group ])
297298 else :
298- tmp = Chem . MolFromSmiles (group , sanitize = False )
299+ tmp = smiles2mol (group , sanitize = False )
299300
300301 # check the functional groups for validity
301302 if tmp is None :
0 commit comments