Skip to content

Commit

Permalink
feature_set robustification & warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Bribak committed Jun 27, 2024
1 parent 21049e1 commit 3098e80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions build/lib/glycowork/motif/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ def annotate_dataset(glycans, motifs = None, feature_set = ['known'],
"""
if any([k in ''.join(glycans) for k in [';', '-D-', 'RES', '=']]):
raise Exception
if difference := [item for item in feature_set if item not in ['known', 'graph', 'terminal', 'terminal1',
'terminal2', 'terminal3', 'custom', 'chemical']]:
print(f"Warning: {difference} not recognized as features.")
if motifs is None:
motifs = motif_list
# Checks whether termini information is provided
Expand Down Expand Up @@ -231,9 +234,9 @@ def annotate_switchboard(glycan):
shopping_cart.append(temp)
if 'chemical' in feature_set:
shopping_cart.append(get_molecular_properties(glycans, placeholder = True))
if 'terminal' or 'terminal2' in feature_set:
if 'terminal' or 'terminal1' or 'terminal2' in feature_set:
bag1, bag2 = [], []
if 'terminal' in feature_set:
if 'terminal' or 'terminal1' in feature_set:
bag1 = list(map(get_terminal_structures, glycans))
if 'terminal2' in feature_set:
bag2 = [get_terminal_structures(glycan, size = 2) for glycan in glycans]
Expand Down
7 changes: 5 additions & 2 deletions glycowork/motif/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ def annotate_dataset(glycans, motifs = None, feature_set = ['known'],
"""
if any([k in ''.join(glycans) for k in [';', '-D-', 'RES', '=']]):
raise Exception
if difference := [item for item in feature_set if item not in ['known', 'graph', 'terminal', 'terminal1',
'terminal2', 'terminal3', 'custom', 'chemical']]:
print(f"Warning: {difference} not recognized as features.")
if motifs is None:
motifs = motif_list
# Checks whether termini information is provided
Expand Down Expand Up @@ -231,9 +234,9 @@ def annotate_switchboard(glycan):
shopping_cart.append(temp)
if 'chemical' in feature_set:
shopping_cart.append(get_molecular_properties(glycans, placeholder = True))
if 'terminal' or 'terminal2' in feature_set:
if 'terminal' or 'terminal1' or 'terminal2' in feature_set:
bag1, bag2 = [], []
if 'terminal' in feature_set:
if 'terminal' or 'terminal1' in feature_set:
bag1 = list(map(get_terminal_structures, glycans))
if 'terminal2' in feature_set:
bag2 = [get_terminal_structures(glycan, size = 2) for glycan in glycans]
Expand Down

0 comments on commit 3098e80

Please sign in to comment.