Skip to content

Commit

Permalink
support glycan graphs as input in get_match
Browse files Browse the repository at this point in the history
  • Loading branch information
Bribak committed Mar 11, 2024
1 parent a29925b commit 893e3cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
5 changes: 1 addition & 4 deletions build/lib/glycowork/motif/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ def annotate_glycan(glycan, motifs = None, termini_list = [], gmotifs = None):
out = pd.DataFrame(columns = motifs.motif_name if isinstance(motifs, pd.DataFrame) else motifs)
out.loc[0] = res
out.loc[0] = out.loc[0].astype('int')
if isinstance(glycan, str):
out.index = [glycan]
else:
out.index = [graph_to_string(glycan)]
out.index = [glycan] if isinstance(glycan, str) else [graph_to_string(glycan)]
return out


Expand Down
5 changes: 1 addition & 4 deletions glycowork/motif/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ def annotate_glycan(glycan, motifs = None, termini_list = [], gmotifs = None):
out = pd.DataFrame(columns = motifs.motif_name if isinstance(motifs, pd.DataFrame) else motifs)
out.loc[0] = res
out.loc[0] = out.loc[0].astype('int')
if isinstance(glycan, str):
out.index = [glycan]
else:
out.index = [graph_to_string(glycan)]
out.index = [glycan] if isinstance(glycan, str) else [graph_to_string(glycan)]
return out


Expand Down
6 changes: 5 additions & 1 deletion glycowork/motif/regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,11 @@ def get_match(pattern, glycan, return_matches = True):
lookahead_snuck_in = False
if any([k in glycan for k in [';', '-D-', 'RES', '=']]):
glycan = canonicalize_iupac(glycan)
ggraph = glycan_to_nxGraph(glycan)
if isinstance(glycan, str):
ggraph = glycan_to_nxGraph(glycan)
else:
ggraph = glycan
glycan = graph_to_string(ggraph)
pattern_components = preprocess_pattern(pattern) if isinstance(pattern, str) else pattern
pattern_matches = match_it_up(pattern_components, glycan, ggraph)
if pattern_matches:
Expand Down

0 comments on commit 893e3cc

Please sign in to comment.