Skip to content

Commit f96e451

Browse files
committed
added wurcs index function
1 parent b6d85dc commit f96e451

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

glycompare/extract_substructures.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,46 @@
77
from . import __init__
88
from . import json_utility
99

10+
from glypy.io import wurcs
11+
from glypy.io import glycoct
12+
13+
14+
#### proposed function
15+
16+
def extract_substructure_wurcs_idx(a_glycan,sub_gly, branch=5,linkage_specific=True):
17+
"""
18+
:param a_glycan: Glycan obj
19+
:param sub_gly: dictionary of substructures. WURCS substructure index. Values are dictionary of matched glycans with the number of times each glycan appears.
20+
:param branch:
21+
:return:
22+
"""
23+
if linkage_specific:
24+
gw = wurcs.dumps(a_glycan)
25+
else:
26+
# strip linkage information
27+
gct = glycoct.dumps(a_glycan)
28+
# replace all linkages with -1
29+
gct = re.sub('\(\d','(-1',gct)
30+
a_glycan = glycoct.loads(gct)
31+
gw = wurcs.dumps(a_glycan)
32+
33+
# iterate over glycan fragments
34+
for i in a_glycan.fragments(max_cleavages=branch):
35+
# print('aaa')
36+
_frag_gly = wurcs.dumps(fragment_to_substructure(i, a_glycan))
37+
38+
# print('aab')
39+
#add substructure 1st
40+
try:
41+
sub_gly[_frag_gly][gw] += 1
42+
except:
43+
try:
44+
sub_gly[_frag_gly][gw] = 1
45+
except:
46+
sub_gly[_frag_gly] = {}
47+
48+
49+
#######
1050

1151
def clean_duplicate(a_substructure_dict, linkage_specific):
1252
"""

0 commit comments

Comments
 (0)