Skip to content

Commit 85e333a

Browse files
committed
update chars to the libr format to fix LectinOracle_flex
1 parent 870af95 commit 85e333a

File tree

6 files changed

+38
-36
lines changed

6 files changed

+38
-36
lines changed

build/lib/glycowork/ml/models.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,14 @@ def forward(self, prot, nodes, edge_index, batch, inference = False):
291291
# Fully connected part
292292
h_n = self.act1_n(self.bn1_n(self.fc1_n(h_n)))
293293

294-
x1 = self.fc2(self.dp1(h_n))
295-
x2 = self.fc2(self.dp1(h_n))
296-
x3 = self.fc2(self.dp1(h_n))
297-
x4 = self.fc2(self.dp1(h_n))
298-
x5 = self.fc2(self.dp1(h_n))
299-
x6 = self.fc2(self.dp1(h_n))
300-
x7 = self.fc2(self.dp1(h_n))
301-
x8 = self.fc2(self.dp1(h_n))
294+
x1 = self.fc2_n(self.dp1(h_n))
295+
x2 = self.fc2_n(self.dp1(h_n))
296+
x3 = self.fc2_n(self.dp1(h_n))
297+
x4 = self.fc2_n(self.dp1(h_n))
298+
x5 = self.fc2_n(self.dp1(h_n))
299+
x6 = self.fc2_n(self.dp1(h_n))
300+
x7 = self.fc2_n(self.dp1(h_n))
301+
x8 = self.fc2_n(self.dp1(h_n))
302302

303303
out = self.sigmoid(torch.mean(torch.stack([x1, x2, x3, x4, x5, x6, x7, x8]), dim = 0))
304304

@@ -345,25 +345,25 @@ def prep_model(model_type, num_classes, libr = None,
345345
model = SweetNet(len(libr), num_classes = num_classes)
346346
model = model.apply(lambda module: init_weights(module, mode = 'sparse'))
347347
if trained:
348-
model.load_state_dict(torch.load(trained_SweetNet))
348+
model.load_state_dict(torch.load(trained_SweetNet, map_location = device))
349349
model = model.to(device)
350350
elif model_type == 'LectinOracle':
351351
model = LectinOracle(len(libr), num_classes = num_classes)
352352
model = model.apply(lambda module: init_weights(module, mode = 'xavier'))
353353
if trained:
354-
model.load_state_dict(torch.load(trained_LectinOracle))
354+
model.load_state_dict(torch.load(trained_LectinOracle, map_location = device))
355355
model = model.to(device)
356356
elif model_type == 'LectinOracle_flex':
357357
model = LectinOracle_flex(len(libr), num_classes = num_classes)
358358
model = model.apply(lambda module: init_weights(module, mode = 'xavier'))
359359
if trained:
360-
model.load_state_dict(torch.load(trained_LectinOracle_flex))
360+
model.load_state_dict(torch.load(trained_LectinOracle_flex, map_location = device))
361361
model = model.to(device)
362362
elif model_type == 'NSequonPred':
363363
model = NSequonPred()
364364
model = model.apply(lambda module: init_weights(module, mode = 'xavier'))
365365
if trained:
366-
model.load_state_dict(torch.load(trained_NSequonPred))
366+
model.load_state_dict(torch.load(trained_NSequonPred, map_location = device))
367367
model = model.to(device)
368368
else:
369369
print("Invalid Model Type")

build/lib/glycowork/motif/tokenization.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
from glycowork.motif.processing import min_process_glycans, canonicalize_iupac
1515
from glycowork.motif.graph import compare_glycans, glycan_to_nxGraph, graph_to_string
1616

17-
chars = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T',
18-
'V', 'W', 'Y', 'X', 'Z'] + ['z']
17+
chars = {'A':1, 'B':2, 'C':3, 'D':4, 'E':5, 'F':6, 'G':7, 'H':8, 'I':9, 'J':10, 'K':11,
18+
'L':12, 'M':13, 'N':14, 'P':15, 'Q':16, 'R':17, 'S':18, 'T':19,
19+
'V':20, 'W':21, 'Y':22, 'X':23, 'Z':24, 'z':25}
1920

2021
io = pkg_resources.resource_stream(__name__, "mz_to_composition.csv")
2122
mapping_file = pd.read_csv(io)
@@ -35,7 +36,7 @@ def constrain_prot(proteins, libr = None):
3536
if libr is None:
3637
libr = chars
3738
# Check whether any character is not in libr and replace it with a 'z' placeholder character
38-
forbidden = [k for k in set(list(''.join(proteins))) if k not in libr]
39+
forbidden = [k for k in set(list(''.join(proteins))) if k not in libr.keys()]
3940
for k in forbidden:
4041
proteins = [j.replace(k, 'z') for j in proteins]
4142
return proteins

glycowork.egg-info/PKG-INFO

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.1
22
Name: glycowork
3-
Version: 0.8.0
3+
Version: 0.8.1
44
Summary: Package for processing and analyzing glycans
55
Home-page: https://github.com/BojarLab/glycowork
66
Author: Daniel Bojar
@@ -70,10 +70,10 @@ alternative: <br>
7070
Note that we have optional extra installs for specialized use (even
7171
further instructions can be found in the `Examples` tab), such as: <br>
7272
*deep learning* <br> `pip install glycowork[ml]` <br> *drawing glycan
73-
images with GlycoDraw* <br> `pip install glycowork[draw]` <br>
74-
*analyzing atomic/chemical properties of glycans* <br>
75-
`pip install glycowork[chem]` <br> *everything* <br>
76-
`pip install glycowork[all]` <br>
73+
images with GlycoDraw (see install instructions in the `Examples` tab)*
74+
<br> `pip install glycowork[draw]` <br> *analyzing atomic/chemical
75+
properties of glycans* <br> `pip install glycowork[chem]` <br>
76+
*everything* <br> `pip install glycowork[all]` <br>
7777

7878
## Data & Models
7979

glycowork/ml/models.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,14 @@ def forward(self, prot, nodes, edge_index, batch, inference = False):
291291
# Fully connected part
292292
h_n = self.act1_n(self.bn1_n(self.fc1_n(h_n)))
293293

294-
x1 = self.fc2(self.dp1(h_n))
295-
x2 = self.fc2(self.dp1(h_n))
296-
x3 = self.fc2(self.dp1(h_n))
297-
x4 = self.fc2(self.dp1(h_n))
298-
x5 = self.fc2(self.dp1(h_n))
299-
x6 = self.fc2(self.dp1(h_n))
300-
x7 = self.fc2(self.dp1(h_n))
301-
x8 = self.fc2(self.dp1(h_n))
294+
x1 = self.fc2_n(self.dp1(h_n))
295+
x2 = self.fc2_n(self.dp1(h_n))
296+
x3 = self.fc2_n(self.dp1(h_n))
297+
x4 = self.fc2_n(self.dp1(h_n))
298+
x5 = self.fc2_n(self.dp1(h_n))
299+
x6 = self.fc2_n(self.dp1(h_n))
300+
x7 = self.fc2_n(self.dp1(h_n))
301+
x8 = self.fc2_n(self.dp1(h_n))
302302

303303
out = self.sigmoid(torch.mean(torch.stack([x1, x2, x3, x4, x5, x6, x7, x8]), dim = 0))
304304

@@ -345,25 +345,25 @@ def prep_model(model_type, num_classes, libr = None,
345345
model = SweetNet(len(libr), num_classes = num_classes)
346346
model = model.apply(lambda module: init_weights(module, mode = 'sparse'))
347347
if trained:
348-
model.load_state_dict(torch.load(trained_SweetNet))
348+
model.load_state_dict(torch.load(trained_SweetNet, map_location = device))
349349
model = model.to(device)
350350
elif model_type == 'LectinOracle':
351351
model = LectinOracle(len(libr), num_classes = num_classes)
352352
model = model.apply(lambda module: init_weights(module, mode = 'xavier'))
353353
if trained:
354-
model.load_state_dict(torch.load(trained_LectinOracle))
354+
model.load_state_dict(torch.load(trained_LectinOracle, map_location = device))
355355
model = model.to(device)
356356
elif model_type == 'LectinOracle_flex':
357357
model = LectinOracle_flex(len(libr), num_classes = num_classes)
358358
model = model.apply(lambda module: init_weights(module, mode = 'xavier'))
359359
if trained:
360-
model.load_state_dict(torch.load(trained_LectinOracle_flex))
360+
model.load_state_dict(torch.load(trained_LectinOracle_flex, map_location = device))
361361
model = model.to(device)
362362
elif model_type == 'NSequonPred':
363363
model = NSequonPred()
364364
model = model.apply(lambda module: init_weights(module, mode = 'xavier'))
365365
if trained:
366-
model.load_state_dict(torch.load(trained_NSequonPred))
366+
model.load_state_dict(torch.load(trained_NSequonPred, map_location = device))
367367
model = model.to(device)
368368
else:
369369
print("Invalid Model Type")

glycowork/motif/tokenization.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
from glycowork.motif.processing import min_process_glycans, canonicalize_iupac
1515
from glycowork.motif.graph import compare_glycans, glycan_to_nxGraph, graph_to_string
1616

17-
chars = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T',
18-
'V', 'W', 'Y', 'X', 'Z'] + ['z']
17+
chars = {'A':1, 'B':2, 'C':3, 'D':4, 'E':5, 'F':6, 'G':7, 'H':8, 'I':9, 'J':10, 'K':11,
18+
'L':12, 'M':13, 'N':14, 'P':15, 'Q':16, 'R':17, 'S':18, 'T':19,
19+
'V':20, 'W':21, 'Y':22, 'X':23, 'Z':24, 'z':25}
1920

2021
io = pkg_resources.resource_stream(__name__, "mz_to_composition.csv")
2122
mapping_file = pd.read_csv(io)
@@ -35,7 +36,7 @@ def constrain_prot(proteins, libr = None):
3536
if libr is None:
3637
libr = chars
3738
# Check whether any character is not in libr and replace it with a 'z' placeholder character
38-
forbidden = [k for k in set(list(''.join(proteins))) if k not in libr]
39+
forbidden = [k for k in set(list(''.join(proteins))) if k not in libr.keys()]
3940
for k in forbidden:
4041
proteins = [j.replace(k, 'z') for j in proteins]
4142
return proteins

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="glycowork",
8-
version="0.8.0",
8+
version="0.8.1",
99
author="Daniel Bojar",
1010
author_email="daniel.bojar@gu.se",
1111
description="Package for processing and analyzing glycans",

0 commit comments

Comments
 (0)