CandyCrunch 0.3.0__tar.gz → 0.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/CandyCrunch/analysis.py +222 -312
  2. CandyCrunch-0.4.1/CandyCrunch/merged_analysis.py +1490 -0
  3. CandyCrunch-0.4.1/CandyCrunch/multi_file_workflow_utils.py +375 -0
  4. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/CandyCrunch/prediction.py +69 -79
  5. CandyCrunch-0.4.1/CandyCrunch/test_CandyCrumbs.py +38 -0
  6. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/CandyCrunch.egg-info/PKG-INFO +2 -2
  7. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/CandyCrunch.egg-info/SOURCES.txt +3 -0
  8. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/CandyCrunch.egg-info/requires.txt +2 -2
  9. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/PKG-INFO +2 -2
  10. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/README.md +1 -1
  11. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/setup.py +3 -3
  12. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/CandyCrunch/__init__.py +0 -0
  13. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/CandyCrunch/candycrunch.pt +0 -0
  14. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/CandyCrunch/cli.py +0 -0
  15. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/CandyCrunch/glycans.pkl +0 -0
  16. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/CandyCrunch/glytoucan_mapping.pkl +0 -0
  17. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/CandyCrunch/model.py +0 -0
  18. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/CandyCrunch/tester.py +0 -0
  19. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/CandyCrunch.egg-info/dependency_links.txt +0 -0
  20. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/CandyCrunch.egg-info/entry_points.txt +0 -0
  21. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/CandyCrunch.egg-info/top_level.txt +0 -0
  22. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/LICENSE +0 -0
  23. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/LICENSE.txt +0 -0
  24. {CandyCrunch-0.3.0 → CandyCrunch-0.4.1}/setup.cfg +0 -0
@@ -10,119 +10,104 @@ import networkx as nx
10
10
  import networkx.algorithms.isomorphism as iso
11
11
  import numpy as np
12
12
  import pandas as pd
13
- from glycowork.glycan_data.loader import lib, unwrap
13
+ from glycowork.glycan_data.loader import unwrap
14
14
  from glycowork.motif.processing import (bracket_removal,
15
- min_process_glycans)
16
- try:
17
- from glycowork.glycan_data.stats import cohen_d
18
- except ModuleNotFoundError:
19
- from glycowork.motif.processing import cohen_d
15
+ min_process_glycans, rescue_glycans)
16
+ from glycowork.motif.tokenization import map_to_basic
17
+ from glycowork.glycan_data.stats import cohen_d
20
18
 
21
19
  from scipy.stats import ttest_ind
22
20
  from statsmodels.stats.multitest import multipletests
23
21
 
24
- mono_attributes = {'Gal': {'mass': {'03X': 72.0211, '02X': 42.0105, '15X': 27.9949, '13A': 60.0211, '24A': 60.0211,
25
- '04A': 60.0211, '35A': 74.0368, '25A': 104.0473, '02A': 120.0423, 'Gal': 162.0528},
26
- 'atoms': {'03X': [1, 2, 3], '02X': [1, 2], '15X': [1], '13A': [2, 3], '24A': [3, 4],
27
- '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6], '02A': [3, 4, 5, 6], 'Gal': [1, 2, 3, 4, 5, 6]}},
28
- 'Glc': {'mass': {'03X': 72.0211, '02X': 42.0105, '15X': 27.9949, '13A': 60.0211, '24A': 60.0211,
29
- '04A': 60.0211, '35A': 74.0368, '25A': 104.0473, '02A': 120.0423, 'Glc': 162.0528},
30
- 'atoms': {'03X': [1, 2, 3], '02X': [1, 2], '15X': [1], '13A': [2, 3], '24A': [3, 4],
31
- '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6], '02A': [3, 4, 5, 6], 'Glc': [1, 2, 3, 4, 5, 6]}},
32
- 'Man': {'mass': {'03X': 72.0211, '02X': 42.0105, '15X': 27.9949, '13A': 60.0211, '24A': 60.0211,
33
- '04A': 60.0211, '35A': 74.0368, '25A': 104.0473, '02A': 120.0423, 'Man': 162.0528},
34
- 'atoms': {'03X': [1, 2, 3], '02X': [1, 2], '15X': [1], '13A': [2, 3], '24A': [3, 4],
35
- '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6], '02A': [3, 4, 5, 6], 'Man': [1, 2, 3, 4, 5, 6]}},
36
- 'Hex': {'mass': {'03X': 72.0211, '02X': 42.0105, '15X': 27.9949, '13A': 60.0211, '24A': 60.0211,
37
- '04A': 60.0211, '35A': 74.0368, '25A': 104.0473, '02A': 120.0423, 'Hex': 162.0528},
38
- 'atoms': {'03X': [1, 2, 3], '02X': [1, 2], '15X': [1], '13A': [2, 3], '24A': [3, 4],
39
- '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6], '02A': [3, 4, 5, 6], 'Hex': [1, 2, 3, 4, 5, 6]}},
40
- 'GalNAc': {'mass': {'04A': 60.0211, '24A': 60.0211, '35A': 74.0368, '03A': 90.0317, '25A': 104.0473,
41
- '02A': 120.0423, '24X': 143, 'GalNAc': 203.0794},
42
- 'atoms': {'04A': [5, 6], '24A': [3, 4], '35A': [4, 5, 6], '03A': [4, 5, 6], '25A': [3, 4, 5, 6],
43
- '02A': [3, 4, 5, 6], '24X': [1,2,5,6], 'GalNAc': [1, 2, 3, 4, 5, 6]}},
44
- 'GlcNAc': {'mass': {'04A': 60.0211, '24A': 60.0211, '35A': 74.0368, '03A': 90.0317, '25A': 104.0473,
45
- '02A': 120.0423, '24X': 143, 'GlcNAc': 203.0794},
46
- 'atoms': {'04A': [5, 6], '24A': [3, 4], '35A': [4, 5, 6], '03A': [4, 5, 6], '25A': [3, 4, 5, 6],
47
- '02A': [3, 4, 5, 6], '24X': [1,2,5,6], 'GlcNAc': [1, 2, 3, 4, 5, 6]}},
48
- 'HexNAc': {'mass': {'04A': 60.0211, '24A': 60.0211, '35A': 74.0368, '03A': 90.0317, '25A': 104.0473,
49
- '02A': 120.0423, '24X': 143, 'HexNAc': 203.0794},
50
- 'atoms': {'04A': [5, 6], '24A': [3, 4], '35A': [4, 5, 6], '03A': [4, 5, 6], '25A': [3, 4, 5, 6],
51
- '02A': [3, 4, 5, 6], '24X': [1,2,5,6], 'HexNAc': [1, 2, 3, 4, 5, 6]}},
52
- 'Neu5Ac': {'mass': {'02X': 70.0055, '04X': 170.0453, 'Neu5Ac': 291.0954},
53
- 'atoms': {'02X': [1, 2, 3], '04X': [1, 2, 3, 4, 5], 'Neu5Ac': [1, 2, 3, 4, 5, 6, 7, 8, 9]}},
54
- 'Neu5Gc': {'mass': {'02X': 70.0055, '04X': 186.0402, 'Neu5Gc': 307.0903},
55
- 'atoms': {'02X': [1, 2, 3], '04X': [1, 2, 3, 4, 5], 'Neu5Gc': [1, 2, 3, 4, 5, 6, 7, 8, 9]}},
56
- 'Kdn': {'mass': {'02X': 70.0055, '04X': 129.0188, 'Kdn': 250.0689},
57
- 'atoms': {'02X': [1, 2, 3], '04X': [1, 2, 3, 4, 5], 'Kdn': [1, 2, 3, 4, 5, 6, 7, 8, 9]}},
58
- 'GlcA': {'mass': {'GlcA': 176.03209},
59
- 'atoms': {'GlcA': [1, 2, 3, 4, 5, 6]}},
60
- 'HexA': {'mass': {'HexA': 176.03209},
61
- 'atoms': {'HexA': [1, 2, 3, 4, 5, 6]}},
62
- 'Fuc': {'mass': {'Fuc': 146.0579},
63
- 'atoms': {'Fuc': [1, 2, 3, 4, 5, 6]}},
64
- 'dHex': {'mass': {'dHex': 146.0579},
65
- 'atoms': {'dHex': [1, 2, 3, 4, 5, 6]}},
66
- 'GlcNAc6S': {'mass': {'04A': 139.9779, '24A': 60.0211, '35A': 153.9936, '03A': 169.9885, '25A': 184.0041,
67
- '02A': 199.9991, 'GlcNAc6S': 283.0362},
68
- 'atoms': {'04A': [5, 6], '24A': [3, 4], '35A': [4, 5, 6], '03A': [4, 5, 6], '25A': [3, 4, 5, 6],
69
- '02A': [3, 4, 5, 6], 'GlcNAc6S': [1, 2, 3, 4, 5, 6]}},
70
- 'GlcNAcOS': {'mass': {'04A': 139.9779, '24A': 139.9779, '35A': 153.9936, '03A': 169.9885, '25A': 184.0041,
71
- '02A': 199.9991, 'GlcNAcOS': 283.0362},
72
- 'atoms': {'04A': [5, 6], '24A': [3, 4], '35A': [4, 5, 6], '03A': [4, 5, 6],
73
- '25A': [3, 4, 5, 6], '02A': [3, 4, 5, 6], 'GlcNAcOS': [1, 2, 3, 4, 5, 6]}},
74
- 'GalNAc6S': {'mass': {'04A': 139.9779, '24A': 60.0211, '35A': 153.9936, '03A': 169.9885, '25A': 184.0041,
75
- '02A': 199.9991, 'GalNAc6S': 283.0362},
76
- 'atoms': {'04A': [5, 6], '24A': [3, 4], '35A': [4, 5, 6], '03A': [4, 5, 6], '25A': [3, 4, 5, 6],
77
- '02A': [3, 4, 5, 6], 'GalNAc6S': [1, 2, 3, 4, 5, 6]}},
78
- 'GalNAcOS': {'mass': {'04A': 139.9779, '24A': 139.9779, '35A': 153.9936, '03A': 169.9885, '25A': 184.0041,
79
- '02A': 199.9991, 'GalNAcOS': 283.0362},
80
- 'atoms': {'04A': [5, 6], '24A': [3, 4], '35A': [4, 5, 6], '03A': [4, 5, 6], '25A': [3, 4, 5, 6],
81
- '02A': [3, 4, 5, 6], 'GalNAcOS': [1, 2, 3, 4, 5, 6]}},
82
- 'HexNAc6S': {'mass': {'04A': 139.9779, '24A': 60.0211, '35A': 153.9936, '03A': 169.9885, '25A': 184.0041,
83
- '02A': 199.9991, 'HexNAc6S': 283.0362},
84
- 'atoms': {'04A': [5, 6], '24A': [3, 4], '35A': [4, 5, 6], '03A': [4, 5, 6], '25A': [3, 4, 5, 6],
85
- '02A': [3, 4, 5, 6], 'HexNAc6S': [1, 2, 3, 4, 5, 6]}},
86
- 'HexNAcOS': {'mass': {'04A': 139.9779, '24A': 139.9779, '35A': 153.9936, '03A': 169.9885, '25A': 184.0041,
87
- '02A': 199.9991, 'HexNAcOS': 283.0362},
88
- 'atoms': {'04A': [5, 6], '24A': [3, 4], '35A': [4, 5, 6], '03A': [4, 5, 6], '25A': [3, 4, 5, 6],
89
- '02A': [3, 4, 5, 6], 'HexNAcOS': [1, 2, 3, 4, 5, 6]}},
90
- 'Gal6S': {'mass': {'13A': 60.0211, '24A': 60.0211, '04A': 139.9779, '35A': 153.9936, '25A': 184.0041,
91
- '02A': 199.9991, 'Gal6S': 242.0096},
92
- 'atoms': {'13A': [2, 3], '24A': [3, 4], '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6],
93
- '02A': [3, 4, 5, 6], 'Gal6S': [1, 2, 3, 4, 5, 6]}},
94
- 'Gal3S': {'mass': {'13A': 139.9779, '24A': 139.9779, '04A': 60.0211, '35A': 74.0368, '25A': 184.0041,
95
- '02A': 199.9991, 'Gal3S': 242.0096},
96
- 'atoms': {'13A': [2, 3], '24A': [3, 4], '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6],
97
- '02A': [3, 4, 5, 6], 'Gal3S': [1, 2, 3, 4, 5, 6]}},
98
- 'GalOS': {'mass': {'13A': 60.0211, '24A': 139.9779, '04A': 139.9779, '35A': 153.9936, '25A': 184.0041,
99
- '02A': 199.9991, 'GalOS': 242.0096},
100
- 'atoms': {'13A': [2, 3], '24A': [3, 4], '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6],
101
- '02A': [3, 4, 5, 6], 'GalOS': [1, 2, 3, 4, 5, 6]}},
102
- 'Glc6S': {'mass': {'13A': 60.0211, '24A': 60.0211, '04A': 139.9779, '35A': 153.9568, '25A': 184.0041,
103
- '02A': 199.9991, 'Glc6S': 242.0096},
104
- 'atoms': {'13A': [2, 3], '24A': [3, 4], '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6],
105
- '02A': [3, 4, 5, 6], 'Glc6S': [1, 2, 3, 4, 5, 6]}},
106
- 'Glc3S': {'mass': {'13A': 139.9779, '24A': 139.9779, '04A': 60.0211, '35A': 74.0368, '25A': 184.0041,
107
- '02A': 199.9991, 'Glc3S': 242.0096},
108
- 'atoms': {'13A': [2, 3], '24A': [3, 4], '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6],
109
- '02A': [3, 4, 5, 6], 'Glc3S': [1, 2, 3, 4, 5, 6]}},
110
- 'GlcOS': {'mass': {'13A': 60.0211, '24A': 139.9779, '04A': 139.9779, '35A': 153.9936, '25A': 184.0041,
111
- '02A': 199.9991, 'GlcOS': 242.0096},
112
- 'atoms': {'13A': [2, 3], '24A': [3, 4], '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6],
113
- '02A': [3, 4, 5, 6], 'GlcOS': [1, 2, 3, 4, 5, 6]}},
114
- 'HexOS': {'mass': {'13A': 60.0211, '24A': 139.9779, '04A': 139.9779, '35A': 153.9936, '25A': 184.0041,
115
- '02A': 199.9991, 'HexOS': 242.0096},
116
- 'atoms': {'13A': [2, 3], '24A': [3, 4], '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6],
117
- '02A': [3, 4, 5, 6], 'HexOS': [1, 2, 3, 4, 5, 6]}},
22
+ mono_attributes = {'Hex': {'mass': {'03X': 72.0211, '02X': 42.0106, '15X': 27.9949, '13A': 60.0211, '24A': 60.0211, '15A': 134.057859,
23
+ '04A': 60.0211, '35A': 74.0368, '25A': 104.0473, '02A': 120.0423, '03A': 74.0368, '24X': 102.0317, '04X': 102.0317,
24
+ '35X': 88.016, 'Hex': 162.0528},
25
+ 'atoms': {'03X': [1, 2, 3], '02X': [1, 2], '15X': [1], '13A': [2, 3], '24A': [3, 4], '15A': [2, 3, 4, 5, 6],
26
+ '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6], '02A': [3, 4, 5, 6], '03A': [4, 5, 6], '24X': [1, 2, 5, 6], '04X': [1, 2, 3, 4],
27
+ '35X': [1, 2, 3], 'Hex': [1, 2, 3, 4, 5, 6]}},
28
+ 'HexNAc': {'mass': {'04A': 60.0211, '24A': 60.0211, '35A': 74.0368, '03A': 90.0317, '25A': 104.0473, '25X': 99.0321,
29
+ '02A': 120.0423, '24X': 143.0583, '14A': 131.058244, '15A': 175.084458, '15X': 27.994941, '04X': 143.0583, '35X': 129.0426,
30
+ '14X': 72.021156, '13X': 102.031741, '13A': 101.047659, 'HexNAc': 203.0794},
31
+ 'atoms': {'04A': [5, 6], '24A': [3, 4], '35A': [4, 5, 6], '03A': [4, 5, 6], '25A': [3, 4, 5, 6], '25X': [1, 2],
32
+ '02A': [3, 4, 5, 6], '24X': [1, 2, 5, 6], '14A': [2, 3, 4], '15A': [2, 3, 4, 5, 6], '15X': [1], '04X': [1, 2, 3, 4], '35X': [1, 2, 3],
33
+ '14X': [1, 5, 6], '13X': [1, 4, 5, 6], '13A': [2, 3], 'HexNAc': [1, 2, 3, 4, 5, 6]}},
34
+ 'Neu5Ac': {'mass': {'02X': 70.0055, '04X': 170.0453, '24X': 191.0556, '02A': 221.0899,
35
+ '04A': 121.0501, '24A': 100.0398, 'Neu5Ac': 291.0954},
36
+ 'atoms': {'02X': [1, 2, 3], '04X': [1, 2, 3, 4, 5], '24X': [1, 2, 3, 6, 7, 8, 9], '02A': [4, 5, 6, 7, 8, 9],
37
+ '04A': [6, 7, 8, 9], '24A': [4, 5], 'Neu5Ac': [1, 2, 3, 4, 5, 6, 7, 8, 9]}},
38
+ 'Neu5Gc': {'mass': {'02X': 70.0055, '04X': 186.0402, '24X': 191.0556, '02A': 237.0848,
39
+ '04A': 121.0501, '24A': 116.0347, 'Neu5Gc': 307.0903},
40
+ 'atoms': {'02X': [1, 2, 3], '04X': [1, 2, 3, 4, 5], '24X': [1, 2, 3, 6, 7, 8, 9], '02A': [4, 5, 6, 7, 8, 9],
41
+ '04A': [6, 7, 8, 9], '24A': [4, 5], 'Neu5Gc': [1, 2, 3, 4, 5, 6, 7, 8, 9]}},
42
+ 'Neu5Ac8S': {'mass': {'02X': 70.0055, '04X': 170.0453, '24X': 271.0124, '02A': 301.0467,
43
+ '04A': 201.0069 , '24A': 100.0398, 'Neu5Ac8S': 371.0522 },
44
+ 'atoms': {'02X': [1, 2, 3], '04X': [1, 2, 3, 4, 5], '24X': [1, 2, 3, 6, 7, 8, 9], '02A': [4, 5, 6, 7, 8, 9],
45
+ '04A': [6, 7, 8, 9], '24A': [4, 5], 'Neu5Ac8S': [1, 2, 3, 4, 5, 6, 7, 8, 9]}},
46
+ 'Neu5Gc8S': {'mass': {'02X': 70.0055, '04X': 186.0402, '24X': 271.0124 , '02A': 317.0416,
47
+ '04A': 201.0069, '24A': 116.0347, 'Neu5Gc8S': 387.0471},
48
+ 'atoms': {'02X': [1, 2, 3], '04X': [1, 2, 3, 4, 5], '24X': [1, 2, 3, 6, 7, 8, 9], '02A': [4, 5, 6, 7, 8, 9],
49
+ '04A': [6, 7, 8, 9], '24A': [4, 5], 'Neu5Gc8S': [1, 2, 3, 4, 5, 6, 7, 8, 9]}},
50
+ 'Kdn': {'mass': {'02X': 70.0055, '04X': 129.0188, '24X': 191.0556, '02A': 180.0634,
51
+ '04A': 121.0501, '24A': 59.0133, 'Kdn': 250.0689},
52
+ 'atoms': {'02X': [1, 2, 3], '04X': [1, 2, 3, 4, 5], '24X': [1, 2, 3, 6, 7, 8, 9], '02A': [4, 5, 6, 7, 8, 9],
53
+ '04A': [6, 7, 8, 9], '24A': [4, 5], 'Kdn': [1, 2, 3, 4, 5, 6, 7, 8, 9]}},
54
+ 'HexA': {'mass': {'02X': 42.0106, '02A': 134.02159, '24X': 116.01099, '24A': 60.0211, 'HexA': 176.03209},
55
+ 'atoms': {'02X': [1, 2], '02A': [3, 4, 5, 6], '24X': [1, 2, 5, 6], '24A': [3, 4], 'HexA': [1, 2, 3, 4, 5, 6]}},
56
+ 'HexA3S': {'mass': {'02X': 42.0106, '02A': 213.97839, '24X': 116.01099, '24A': 139.9779, 'HexA3S': 255.98889},
57
+ 'atoms': {'02X': [1, 2], '02A': [3, 4, 5, 6], '24X': [1, 2, 5, 6], '24A': [3, 4], 'HexA3S': [1, 2, 3, 4, 5, 6]}},
58
+ 'dHex': {'mass': {'02X': 42.0106, '02A': 104.0474, '25X': 42.0106, '25A': 104.0474, 'dHex': 146.0579},
59
+ 'atoms': {'02X': [1, 2], '02A': [3, 4, 5, 6], '25X': [1, 2], '25A': [3, 4, 5, 6], 'dHex': [1, 2, 3, 4, 5, 6]}},
60
+ 'Pen': {'mass': {'01A': 102.0326, '02A': 72.022, '03A': 42.011, '15X': 27.994941, '15A': 104.047359,
61
+ '12X': 102.0326, '03X': 72.022, '02X': 42.011, 'Pen': 132.0423},
62
+ 'atoms': {'01A': [2, 3, 4, 5], '02A': [3, 4, 5], '03A': [4, 5], '15X': [1], '15A': [2, 3, 4, 5],
63
+ '12X': [1, 3, 4, 5], '03X': [1, 2, 3], '02X': [1, 2], 'Pen': [1, 2, 3, 4, 5]}},
64
+ 'HexNAc4S': {'mass': {'04A': 60.0211, '24A': 139.9779, '35A': 153.9936, '03A': 169.9885, '25A': 184.0041, '25X': 99.0321,
65
+ '02A': 199.9991, '24X': 223.0151, '14A': 211.015044, '15A': 255.041259, '15X': 27.994941, '04X': 223.0151, '35X': 129.0426,
66
+ '14X': 72.021156, '13X': 181.988541, '13A': 101.047659, 'HexNAc4S': 283.0362},
67
+ 'atoms': {'04A': [5, 6], '24A': [3, 4], '35A': [4, 5, 6], '03A': [4, 5, 6], '25A': [3, 4, 5, 6], '25X': [1, 2],
68
+ '02A': [3, 4, 5, 6], '24X': [1, 2, 5, 6], '14A': [2, 3, 4], '15A': [2, 3, 4, 5, 6], '15X': [1], '04X': [1, 2, 3, 4], '35X': [1, 2, 3],
69
+ '14X': [1, 5, 6], '13X': [1, 4, 5, 6], '13A': [2, 3], 'HexNAc4S': [1, 2, 3, 4, 5, 6]}},
70
+ 'HexNAc6S': {'mass': {'04A': 139.9779, '24A': 60.0211, '35A': 153.9936, '03A': 169.9885, '25A': 184.0041, '25X': 99.0321,
71
+ '02A': 199.9991, '24X': 223.0151, '14A': 131.058244, '15A': 255.041259, '15X': 27.994941, '04X': 143.0583, '35X': 129.0426,
72
+ '14X': 151.977956, '13X': 181.988541, '13A': 101.047659, 'HexNAc6S': 283.0362},
73
+ 'atoms': {'04A': [5, 6], '24A': [3, 4], '35A': [4, 5, 6], '03A': [4, 5, 6], '25A': [3, 4, 5, 6], '25X': [1, 2],
74
+ '02A': [3, 4, 5, 6], '24X': [1,2,5,6], '14A': [2, 3, 4], '15A': [2, 3, 4, 5, 6], '15X': [1], '04X': [1, 2, 3, 4], '35X': [1, 2, 3],
75
+ '14X': [1, 5, 6], '13X': [1, 4, 5, 6], '13A': [2, 3], 'HexNAc6S': [1, 2, 3, 4, 5, 6]}},
76
+ 'HexNAcOS': {'mass': {'04A': 139.9779, '24A': 139.9779, '35A': 153.9936, '03A': 169.9885, '25A': 184.0041, '25X': 99.0321,
77
+ '02A': 199.9991, '24X': 223.0151, '14A': 131.058244, '15A': 255.041259, '15X': 27.994941, '04X': 143.0583, '35X': 129.0426,
78
+ '14X': 151.977956, '13X': 181.988541, '13A': 101.047659, 'HexNAcOS': 283.0362},
79
+ 'atoms': {'04A': [5, 6], '24A': [3, 4], '35A': [4, 5, 6], '03A': [4, 5, 6], '25A': [3, 4, 5, 6], '25X': [1, 2],
80
+ '02A': [3, 4, 5, 6], '24X': [1,2,5,6], '14A': [2, 3, 4], '15A': [2, 3, 4, 5, 6], '15X': [1], '04X': [1, 2, 3, 4], '35X': [1, 2, 3],
81
+ '14X': [1, 5, 6],'13X': [1, 4, 5, 6], '13A': [2, 3], 'HexNAcOS': [1, 2, 3, 4, 5, 6]}},
82
+ 'Hex6S': {'mass': {'02X': 42.0106, '03X': 72.0211, '15X': 27.9949, '13A': 60.0211, '24A': 60.0211, '04A': 139.9779, '35A': 153.9936, '25A': 184.0041,
83
+ '02A': 199.9991, '03A': 153.9936, '15A': 214.014659, '24X': 181.9885, '04X': 102.0317, '35X': 88.016, 'Hex6S': 242.0096},
84
+ 'atoms': {'02X': [1, 2], '03X': [1, 2, 3], '15X': [1], '13A': [2, 3], '24A': [3, 4], '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6],
85
+ '02A': [3, 4, 5, 6], '03A': [4, 5, 6], '15A': [2, 3, 4, 5, 6], '24X': [1, 2, 5, 6], '04X': [1, 2, 3, 4], '35X': [1, 2, 3], 'Hex6S': [1, 2, 3, 4, 5, 6]}},
86
+ 'Hex3S': {'mass': {'02X': 42.0106, '03X': 151.9779, '15X': 27.9949, '13A': 139.9779, '24A': 139.9779, '04A': 60.0211, '35A': 74.0368, '25A': 184.0041,
87
+ '02A': 199.9991, '03A': 74.0368, '15A': 214.014659, '24X': 102.0317, '04X': 181.9885, '35X': 167.9728, 'Hex3S': 242.0096},
88
+ 'atoms': {'02X': [1, 2], '03X': [1, 2, 3], '15X': [1], '13A': [2, 3], '24A': [3, 4], '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6],
89
+ '02A': [3, 4, 5, 6], '03A': [4, 5, 6], '15A': [2, 3, 4, 5, 6], '24X': [1, 2, 5, 6], '04X': [1, 2, 3, 4], '35X': [1, 2, 3], 'Hex3S': [1, 2, 3, 4, 5, 6]}},
90
+ 'HexOS': {'mass': {'02X': 42.0106, '03X': 151.9779, '15X': 27.9949, '13A': 139.9779, '24A': 139.9779, '04A': 139.9779, '35A': 153.9936, '25A': 184.0041,
91
+ '02A': 199.9991, '03A': 153.9936, '15A': 214.014659, '24X': 181.9885, '04X': 181.9885, '35X': 167.9728, 'HexOS': 242.0096},
92
+ 'atoms': {'02X': [1, 2], '03X': [1, 2, 3], '15X': [1], '13A': [2, 3], '24A': [3, 4], '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6],
93
+ '02A': [3, 4, 5, 6], '03A': [4, 5, 6], '15A': [2, 3, 4, 5, 6], '24X': [1, 2, 5, 6], '04X': [1, 2, 3, 4], '35X': [1, 2, 3], 'HexOS': [1, 2, 3, 4, 5, 6]}},
94
+ 'Man6P': {'mass': {'03X': 72.0211, '02X': 42.0106, '15X': 27.9949, '13A': 60.0211, '24A': 60.0211, '03A': 154.0031, '15A': 214.024159,
95
+ '04A': 139.9874, '35A': 154.0031, '25A': 184.0136, '02A': 200.0086, '24X': 181.998, '04X': 102.0317, '35X': 88.016, 'Man6P': 242.0191},
96
+ 'atoms': {'03X': [1, 2, 3], '02X': [1, 2], '15X': [1], '13A': [2, 3], '24A': [3, 4], '03A': [4, 5, 6], '15A': [2, 3, 4, 5, 6],
97
+ '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6], '02A': [3, 4, 5, 6], '24X': [1, 2, 5, 6], '04X': [1, 2, 3, 4], '35X': [1, 2, 3], 'Man6P': [1, 2, 3, 4, 5, 6]}},
98
+ 'Hex6P': {'mass': {'03X': 72.0211, '02X': 42.0106, '15X': 27.9949, '13A': 60.0211, '24A': 60.0211, '03A': 154.0031, '15A': 214.024159,
99
+ '04A': 139.9874, '35A': 154.0031, '25A': 184.0136, '02A': 200.0086, '24X': 181.998, '04X': 102.0317, '35X': 88.016, 'Hex6P': 242.0191},
100
+ 'atoms': {'03X': [1, 2, 3], '02X': [1, 2], '15X': [1], '13A': [2, 3], '24A': [3, 4], '03A': [4, 5, 6], '15A': [2, 3, 4, 5, 6],
101
+ '04A': [5, 6], '35A': [4, 5, 6], '25A': [3, 4, 5, 6], '02A': [3, 4, 5, 6], '24X': [1, 2, 5, 6], '04X': [1, 2, 3, 4], '35X': [1, 2, 3], 'Hex6P': [1, 2, 3, 4, 5, 6]}},
118
102
  'Global': {'mass': {'H2O': -18.0105546, 'CH2O': -30.0106, 'C2H2O': -42.0106, 'CO2': -43.9898, 'C2H4O2': -60.0211,
119
- 'SO4': -79.9568, 'C3H8O4': -108.0423, '+Acetate': +42.0106, '+Na': +22.989218}}
103
+ 'SO4': -79.9568, 'PO4': -79.9663, 'C3H8O4': -108.0423, '+Acetonitrile': +41.0519, '+Acetate': 59.013851,
104
+ '+Na': +22.989218, '+K': 38.963707}}
120
105
  }
121
106
 
122
107
  bond_type_helper = {1: ['bond', 'no_bond'], 2: ['red_bond', 'red_no_bond']}
123
108
  cut_type_dict = {'bond': 'Y', 'no_bond': 'Z', 'red_bond': 'C', 'red_no_bond': 'B',
124
- '13A': '13A', '24A': '24A', '04A': '04A', '35A': '35A', '03A': '03A', '25A': '25A', '02A': '02A',
125
- '02X': '02X', '04X': '04X', '03X': '03X', '15X': '15X', '24X': '24X'}
109
+ '13A': '13A', '14A': '14A', '15A': '15A', '24A': '24A', '04A': '04A', '35A': '35A', '03A': '03A', '25A': '25A', '02A': '02A',
110
+ '02X': '02X', '03X': '03X', '04X': '04X', '12X': '12X', '13X': '13X', '14X': '14X', '15X': '15X', '24X': '24X', '35X': '35X'}
126
111
  A_cross_rings = {c for c in cut_type_dict if c[-1] == 'A'}
127
112
  X_cross_rings = {c for c in cut_type_dict if c[-1] == 'X'}
128
113
  ranks = ['Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta']
@@ -164,35 +149,27 @@ def glycan_to_graph_monos(glycan):
164
149
  bond_proc = min_process_glycans([glycan])[0]
165
150
  mono_proc = bond_proc[::2]
166
151
 
167
- all_mask_dic = {k: bond_proc[k] for k in range(len(bond_proc))}
168
- mono_mask_dic = {k: mono_proc[k] for k in range(len(mono_proc))}
152
+ all_mask_dic = {k: v for k, v in enumerate(bond_proc)}
153
+ mono_mask_dic = {k: v for k, v in enumerate(mono_proc)}
169
154
  for k, j in mono_mask_dic.items():
170
155
  glycan = glycan.replace(j, str(k), 1)
171
156
  glycan = ''.join(re.split(r'[()]', glycan)[::2])
172
157
  adj_matrix = np.zeros((len(mono_proc), len(mono_proc)), dtype = int)
173
158
 
174
159
  for k in range(len(mono_mask_dic)):
175
- for j in range(len(mono_mask_dic)):
176
- if k < j:
177
- if k >= 100:
178
- adjustment = 2
179
- elif k >= 10:
180
- adjustment = 1
181
- else:
182
- adjustment = 0
183
- k_idx, j_idx = glycan.find(str(k), k),glycan.find(str(j), j)
184
- glycan_part = glycan[k_idx+1:j_idx]
185
-
160
+ for j in range(k + 1, len(mono_mask_dic)):
161
+ adjustment = 2 if k >= 100 else 1 if k >= 10 else 0
162
+ k_idx, j_idx = glycan.find(str(k), k),glycan.find(str(j), j)
163
+ glycan_part = glycan[k_idx+1:j_idx]
164
+ if evaluate_adjacency_monos(glycan_part, adjustment):
165
+ adj_matrix[k, j] = 1
166
+ continue
167
+ if len(bracket_removal(glycan_part)) <= 1+adjustment:
168
+ glycan_part = bracket_removal(glycan_part)
186
169
  if evaluate_adjacency_monos(glycan_part, adjustment):
187
170
  adj_matrix[k, j] = 1
188
171
  continue
189
172
 
190
- if len(bracket_removal(glycan_part)) <= 1+adjustment:
191
- glycan_part = bracket_removal(glycan_part)
192
- if evaluate_adjacency_monos(glycan_part, adjustment):
193
- adj_matrix[k, j] = 1
194
- continue
195
-
196
173
  return mono_mask_dic, adj_matrix, all_mask_dic
197
174
 
198
175
 
@@ -206,41 +183,29 @@ def create_edge_labels(gr, all_dict):
206
183
  | :-
207
184
  | Returns a dict mapping each gr edge to its bond label
208
185
  """
209
- edge_dict = {}
210
- for e in gr.edges:
211
- edge_dict[e] = {'bond_label': all_dict[(e[0]*2)+1]}
186
+ return {(e[0], e[1]): {'bond_label': all_dict[(e[0]*2)+1]} for e in gr.edges}
212
187
 
213
- return edge_dict
214
188
 
215
-
216
- def mono_graph_to_nx(mono_graph, directed = True, libr = None):
189
+ def mono_graph_to_nx(mono_graph, directed = True):
217
190
  """Modified version of glycan_to_nxGraph, converts a mono adjacency matrix into a networkx graph, adds bonds as edge labels, and terminal,reducing end labels\n
218
191
  | Arguments:
219
192
  | :-
220
193
  | mono_graph (string): output of glycan_to_graph_monos
221
- | directed (bool): if True, creates a directed graph with bonds pointing from leaf to reducing end ; default:True
222
- | libr (list): library of monosaccharides; if you have one use it, otherwise a comprehensive lib will be used\n
194
+ | directed (bool): if True, creates a directed graph with bonds pointing from leaf to reducing end ; default:True\n
223
195
  | Returns:
224
196
  | :-
225
197
  | Returns networkx graph object of a glycan made up of only monosaccharides
226
198
  """
227
- if libr is None:
228
- libr = lib
229
- if directed:
230
- template = nx.DiGraph
231
- else:
232
- template = nx.Graph
233
- node_dict_mono = mono_graph[0]
234
- all_dict = mono_graph[2]
199
+ template = nx.DiGraph if directed else nx.Graph
200
+ node_dict_mono, adj_matrix, all_dict = mono_graph
235
201
 
236
202
  if len(node_dict_mono) > 1:
237
- gr = nx.from_numpy_array(mono_graph[1], create_using = template)
203
+ gr = nx.from_numpy_array(adj_matrix, create_using = template)
238
204
  for n1, n2, d in gr.edges(data = True):
239
205
  del d['weight']
240
206
  else:
241
207
  gr = nx.Graph()
242
208
  gr.add_node(0)
243
- nx.set_node_attributes(gr, {k: lib[v] for k,v in node_dict_mono.items()}, 'labels')
244
209
  nx.set_node_attributes(gr, node_dict_mono, 'string_labels')
245
210
  nx.set_node_attributes(gr, {k: 'terminal' if gr.degree[k] == 1 else 'internal' for k in gr.nodes()}, 'termini')
246
211
  nx.set_node_attributes(gr, {max(gr.nodes): 2}, 'reducing_end')
@@ -368,37 +333,6 @@ def get_terminals(subg, present_breakages, root_node):
368
333
  return terminals
369
334
 
370
335
 
371
- def calculate_mass(nx_mono):
372
- """Calculates the mass of a networkx glycan\n
373
- | Arguments:
374
- | :-
375
- | nx_mono (networkx_object): the original monosaccharide only graph\n
376
- | Returns:
377
- | :-
378
- | Returns a float of the monoisotopic mass of the glycan or fragment in negative mode
379
- """
380
- comp = nx.get_node_attributes(nx_mono, 'string_labels')
381
- mono_mods = nx.get_node_attributes(nx_mono, 'mod_labels')
382
- atom_dict = nx.get_node_attributes(nx_mono, 'atomic_mod_dict')
383
- all_atom_mods = Counter([m for d in [v.values() for v in atom_dict.values()] for m in d if m != 0])
384
- reducing_end = nx.get_node_attributes(nx_mono, 'reducing_end')
385
-
386
- mass = sum([mono_attributes[v]['mass'][v] for k, v in comp.items() if k not in mono_mods])-1.0078
387
- mass += sum([mono_attributes[comp[k]]['mass'][v] for k, v in mono_mods.items() if v in mono_attributes[comp[k]]['mass']])
388
- mass += sum([mono_attributes[comp[k]]['mass'][v] for k, v in mono_mods.items() if v not in mono_attributes[comp[k]]['mass']])
389
- mass += -18.0105546*all_atom_mods['no_bond']
390
- mass += +18.0105546*all_atom_mods['red_bond']
391
-
392
- if reducing_end:
393
- if mono_mods:
394
- reducing_end_node = next(iter(reducing_end))
395
- if mono_mods[reducing_end_node] == comp[reducing_end_node]:
396
- mass += 18.0105546+(2*1.0078)
397
- else:
398
- mass += 18.0105546
399
- return mass
400
-
401
-
402
336
  def atom_mods_init(subg, present_breakages, terminals, terminal_labels):
403
337
  """Creates the initial nested dict of each terminal node with floating bonds labelled 1 and the reducing end floating bond labelled 2\n
404
338
  | Arguments:
@@ -413,6 +347,7 @@ def atom_mods_init(subg, present_breakages, terminals, terminal_labels):
413
347
  """
414
348
  atomic_mod_dict = {}
415
349
  for terminal, terminal_label in zip(terminals, terminal_labels):
350
+ terminal_label = map_to_basic(terminal_label, obfuscate_ptm = False)
416
351
  atomic_mod_dict[terminal] = {y: 0 for y in mono_attributes[terminal_label]['atoms'][terminal_label]}
417
352
 
418
353
  for bond, bond_label in present_breakages.items():
@@ -421,10 +356,7 @@ def atom_mods_init(subg, present_breakages, terminals, terminal_labels):
421
356
  atomic_mod_dict[bond[0]][red_breakage] = 2
422
357
  else:
423
358
  # Current improvised way of providing '?' support
424
- try:
425
- breakage = int(bond_label[-1])
426
- except:
427
- breakage = random.choice([2, 3, 4, 5, 6])
359
+ breakage = int(bond_label[-1]) if bond_label[-1].isdigit() else random.choice([2, 3, 4, 5, 6])
428
360
  atomic_mod_dict[bond[1]][breakage] = 1
429
361
  return atomic_mod_dict
430
362
 
@@ -445,13 +377,14 @@ def get_mono_mods_list(root_node, subg, terminals, terminal_labels, nx_edge_dict
445
377
  """
446
378
  terminal_mods = []
447
379
  for node, label in zip(terminals, terminal_labels):
380
+ basic_label = map_to_basic(label, obfuscate_ptm = False)
448
381
  if node == root_node:
449
382
  valid_A_frags = get_valid_A_frags(subg, node, label, nx_edge_dict)
450
383
  terminal_mods.append(valid_A_frags)
451
384
  elif subg.degree()[node] > 1:
452
385
  terminal_mods.append([label])
453
386
  else:
454
- terminal_mods.append([x for x in mono_attributes[label]['mass'] if x in X_cross_rings or x == label])
387
+ terminal_mods.append([x for x in mono_attributes[basic_label]['mass'] if x in X_cross_rings or x == label])
455
388
  return terminal_mods
456
389
 
457
390
 
@@ -468,13 +401,13 @@ def get_valid_A_frags(subg, node, label, nx_edge_dict):
468
401
  | Returns a list of names of possible modifications
469
402
  """
470
403
  valid_A_mods_list = []
471
- A_mods_list = [x for x in mono_attributes[label]['mass'] if x in A_cross_rings or x == label]
472
- node_in_edges = [x for x in subg.in_edges(node)]
473
- for mod in A_mods_list:
474
- if not set([int(nx_edge_dict[bond]['bond_label'][-1]) for bond in node_in_edges if nx_edge_dict[bond]['bond_label'][-1] != '?']) <= set(mono_attributes[label]['atoms'][mod]):
475
- pass
476
- else:
477
- valid_A_mods_list.append(mod)
404
+ idx_label = map_to_basic(label, obfuscate_ptm = False)
405
+ A_mods_list = [x for x in mono_attributes[idx_label]['mass'] if x in A_cross_rings or x == label]
406
+ bond_numbers = set(int(nx_edge_dict[bond]['bond_label'][-1])
407
+ for bond in subg.in_edges(node)
408
+ if nx_edge_dict[bond]['bond_label'][-1].isdigit())
409
+ valid_A_mods_list = [mod for mod in A_mods_list
410
+ if bond_numbers <= set(mono_attributes[idx_label]['atoms'][mod])]
478
411
  return valid_A_mods_list
479
412
 
480
413
 
@@ -489,8 +422,8 @@ def create_dict_perms(dicty):
489
422
  """
490
423
  dict_perms = []
491
424
  modded_atoms = [k for k, v in dicty.items() if v in bond_type_helper]
492
- for mod_prod in product(*[bond_type_helper[dicty[y]] for y in modded_atoms]):
493
- dict_perms.append({**dicty, **dict(zip(modded_atoms, mod_prod))})
425
+ perms = product(*(bond_type_helper[dicty[y]] for y in modded_atoms))
426
+ dict_perms = [{**dicty, **dict(zip(modded_atoms, perm))} for perm in perms]
494
427
  return dict_perms
495
428
 
496
429
 
@@ -509,7 +442,8 @@ def generate_mod_permutations(terminals, terminal_labels, mono_mods_list, atomic
509
442
  """
510
443
  all_terminal_perms, all_mono_mods = [], []
511
444
  for node, label, mono_mods in zip(terminals, terminal_labels, mono_mods_list):
512
- possible_node_atoms = [{k: v for k, v in atomic_mod_dict_subg[node].items() if k in mono_attributes[label]['atoms'][mod]} for mod in mono_mods]
445
+ label = map_to_basic(label, obfuscate_ptm = False)
446
+ possible_node_atoms = [{k: v for k, v in atomic_mod_dict_subg[node].items() if k in mono_attributes[label]['atoms'][map_to_basic(mod, obfuscate_ptm = False)]} for mod in mono_mods]
513
447
  all_atom_dict_perms, all_mono_mod_perms = [], []
514
448
  for i, atom_dict in enumerate(possible_node_atoms):
515
449
  dict_perms = create_dict_perms(atom_dict)
@@ -534,22 +468,14 @@ def precalculate_mod_masses(all_mono_mods, all_terminal_perms, terminal_labels,
534
468
  | (2) a list of all possible mass combinations for each bond fragmentation combination
535
469
  | (3) a list of masses corresponding to each of the global mods
536
470
  """
537
- all_mono_mod_masses = []
538
- for node, label in zip(all_mono_mods, terminal_labels):
539
- node_mod_masses = []
540
- for mod in node:
541
- mass = mono_attributes[label]['mass'][mod]
542
- node_mod_masses.append(mass)
543
- all_mono_mod_masses.append(node_mod_masses)
471
+ all_mono_mod_masses = [[mono_attributes[map_to_basic(label, obfuscate_ptm = False)]['mass'][map_to_basic(mod, obfuscate_ptm = False)] for mod in mods] for mods, label in zip(all_mono_mods, terminal_labels)]
544
472
 
545
473
  all_atom_dict_masses = []
546
474
  for node in all_terminal_perms:
547
475
  node_dict_masses = []
548
476
  for mod in node:
549
477
  present_atom_mods = [x for x in mod.values() if x in ['no_bond', 'red_bond']]
550
- mass = -18.0105546*len([x for x in present_atom_mods if x == 'no_bond'])
551
- mass += +18.0105546*len([x for x in present_atom_mods if x == 'red_bond'])
552
- node_dict_masses.append(mass)
478
+ node_dict_masses.append(sum(-18.0105546 if v == 'no_bond' else 18.0105546 for v in present_atom_mods))
553
479
  all_atom_dict_masses.append(node_dict_masses)
554
480
 
555
481
  global_mods_mass = [mono_attributes['Global']['mass'][x] for x in global_mods[1:]]
@@ -558,7 +484,7 @@ def precalculate_mod_masses(all_mono_mods, all_terminal_perms, terminal_labels,
558
484
 
559
485
 
560
486
  def preliminary_calculate_mass(mono_mods_mass, atom_mods_mass, global_mods_mass, terminals,
561
- inner_mass, true_root_node, label_mass, mode):
487
+ inner_mass, true_root_node, label_mass, charge):
562
488
  """Determines the mass of every permutation of monosaccharide, atom, and global modification\n
563
489
  | Arguments:
564
490
  | :-
@@ -569,30 +495,21 @@ def preliminary_calculate_mass(mono_mods_mass, atom_mods_mass, global_mods_mass,
569
495
  | inner_mass (float): total mass of non-terminal nodes in subgraph
570
496
  | true_root_node (int): the node label corresponding to the root of the parent glycan
571
497
  | label_mass (float): mass of the glycan label or reducing end modification
572
- | mode (string): the mode in which the mass spectrometer was run, 'negative' or 'positive'\n
498
+ | charge (int): assumed charge of glycan\n
573
499
  | Returns:
574
500
  | :-
575
501
  | Returns a list every single mass of each modification combination for each cross ring combination
576
502
  """
577
- if mode == 'negative':
578
- mode_mass = -1.0078
579
- elif mode == 'positive':
580
- mode_mass = +1.0078
503
+ mode_mass = -1.0078 if charge < 0 else 1.0078
581
504
  masses_list = []
582
- root_presence = False
583
- if true_root_node in terminals:
584
- root_presence = True
585
- root_node_idx = terminals.index(true_root_node)
505
+ root_presence = true_root_node in terminals
506
+ root_node_idx = terminals.index(true_root_node) if root_presence else -1
586
507
  for mod_combo, atom_combo in zip(mono_mods_mass, atom_mods_mass):
587
- mass = inner_mass+mode_mass
588
- mass += sum(mod_combo)+sum(atom_combo)
589
- if root_presence:
590
- if mod_combo[root_node_idx] not in A_cross_rings:
591
- mass += 18.0105546+label_mass
508
+ mass = inner_mass + mode_mass + sum(mod_combo) + sum(atom_combo)
509
+ if root_presence and mod_combo[root_node_idx] not in A_cross_rings:
510
+ mass += 18.0105546 + label_mass
592
511
  masses_list.append(mass)
593
- for mod_mass in global_mods_mass:
594
- modded_mass = mass + mod_mass
595
- masses_list.append(modded_mass)
512
+ masses_list.extend([mass + mod_mass for mod_mass in global_mods_mass])
596
513
  return masses_list
597
514
 
598
515
 
@@ -608,34 +525,33 @@ def add_to_subgraph_fragments(subgraph_fragments, nx_mono_list, mass_list):
608
525
  | Returns an updated subgraph_fragments dict
609
526
  """
610
527
  for nx_mono, mass in zip(nx_mono_list, mass_list):
611
- if mass not in subgraph_fragments:
612
- subgraph_fragments[mass] = [nx_mono]
613
- else:
614
- subgraph_fragments[mass].append(nx_mono)
615
-
528
+ subgraph_fragments.setdefault(mass, []).append(nx_mono)
616
529
  return subgraph_fragments
617
530
 
618
531
 
619
- def get_global_mods(subg, node_dict, mode):
532
+ def get_global_mods(subg, node_dict, charge):
620
533
  """Returns the valid list of global modifications for a given subgraph\n
621
534
  | Arguments:
622
535
  | :-
623
536
  | subg (networkx_object): a subgraph
624
537
  | node_dict (dict): a dictionary relating the integer label of each node with the monosaccharide it represents\n
625
- | mode (string): the mode in which the mass spectrometer was run, 'negative' or 'positive'\n
538
+ | charge (int): the assumed charge of the glycan\n
626
539
  | Returns:
627
540
  | :-
628
541
  | Returns a a list of modification names
629
542
  """
630
543
  global_mods = sorted([x for x in mono_attributes['Global']['mass']])
631
- if not any(k in [node_dict[x] for x in subg.nodes()] for k in ['Neu5Ac', 'Neu5Gc', 'GlcA', 'HexA', 'Kdn']):
544
+ node_labels = ''.join(node_dict[x] for x in subg.nodes())
545
+ if not any(k in node_labels for k in ['Neu5Ac', 'Neu5Gc', 'GlcA', 'HexA', 'Kdn']):
632
546
  global_mods.remove('CO2')
633
- if 'S' not in ''.join([node_dict[x] for x in subg.nodes()]):
547
+ if 'S' not in node_labels:
634
548
  global_mods.remove('SO4')
635
- if mode == 'negative':
636
- global_mods.remove('+Na')
637
- if mode == 'positive':
638
- global_mods.remove('+Acetate')
549
+ if 'P' not in node_labels:
550
+ global_mods.remove('PO4')
551
+ positive_mods = {'+Na', '+K'}
552
+ negative_mods = {'+Acetate', '+Acetonitrile'}
553
+ mods_to_remove = positive_mods if charge < 0 else negative_mods
554
+ global_mods = [mod for mod in global_mods if mod not in mods_to_remove]
639
555
  return global_mods
640
556
 
641
557
 
@@ -649,9 +565,7 @@ def mod_count(node_mod, global_mod):
649
565
  | :-
650
566
  | Returns a sum of modifications
651
567
  """
652
- c = 0
653
- if global_mod is not None:
654
- c += 1
568
+ c = 1 if global_mod is not None else 0
655
569
  c += sum([1 for k in node_mod[0] if k in A_cross_rings or k in X_cross_rings])
656
570
  c += sum([1 for k in unwrap([list(n.values()) for n in node_mod[1]]) if isinstance(k, str)])
657
571
  return c
@@ -662,7 +576,7 @@ def extend_masses(fragment_masses, charge):
662
576
  | Arguments:
663
577
  | :-
664
578
  | fragment_masses (list): a list of observed masses to be searched for possible fragments
665
- | charge (int): the charge to use when calcualting multiply charged masses\n
579
+ | charge (int): the charge to use when calculating multiply charged masses\n
666
580
  | Returns:
667
581
  | :-
668
582
  | Returns a list containing both the input masses and the other masses at which to search to assign multiply charged fragments to the inital masses
@@ -671,7 +585,7 @@ def extend_masses(fragment_masses, charge):
671
585
  return fragment_masses
672
586
  modifier = np.sign(charge)
673
587
  for z in range(2, abs(charge)+1):
674
- charged_masses = fragment_masses + [(k*z)-(z*modifier-modifier) for k in fragment_masses]
588
+ charged_masses = fragment_masses + [(k*z) - (z - 1.0078)*modifier for k in fragment_masses]
675
589
  return charged_masses
676
590
 
677
591
 
@@ -688,16 +602,15 @@ def annotate_subgraph(subg,node_mod,global_mod,terminals):
688
602
  | Returns a copy of the input subgraph with networkx node attributes describing the modifications
689
603
  """
690
604
  mod_subg = subg.copy()
691
- mono_mods_dict = dict(zip(terminals, node_mod[0]))
692
- nx.set_node_attributes(mod_subg, mono_mods_dict, 'mod_labels')
693
- atoms_mods_dict = dict(zip(terminals, node_mod[1]))
694
- nx.set_node_attributes(mod_subg, atoms_mods_dict, 'atomic_mod_dict')
605
+ nx.set_node_attributes(mod_subg, dict(zip(terminals, node_mod[0])), 'mod_labels')
606
+ nx.set_node_attributes(mod_subg, dict(zip(terminals, node_mod[1])), 'atomic_mod_dict')
695
607
  if global_mod:
696
608
  nx.set_node_attributes(mod_subg, [global_mod], 'global_mod')
697
609
  return mod_subg
698
610
 
699
611
 
700
- def generate_atomic_frags(nx_mono, max_cleavages = 3, fragment_masses = None, threshold=None, label_mass=2.0156, charge = -1, mode = 'negative'):
612
+ def generate_atomic_frags(nx_mono, max_cleavages = 3, fragment_masses = [],
613
+ threshold = 0.5, label_mass = 2.0156, charge = -1):
701
614
  """Calculates the graph and mass of all possible fragments of the input\n
702
615
  | Arguments:
703
616
  | :-
@@ -706,8 +619,7 @@ def generate_atomic_frags(nx_mono, max_cleavages = 3, fragment_masses = None, th
706
619
  | fragment_masses (list): all masses which are to be annotated with a fragment name
707
620
  | threshold (float): the range around the observed mass in which constrain potential fragments
708
621
  | label_mass (float): mass of the glycan label or reducing end modification; default:2.0156
709
- | charge (int): the maximum possible charge on the fragments to be matched; default:-1
710
- | mode (string): the mode in which the mass spectrometer was run, 'negative' or 'positive'\n
622
+ | charge (int): the maximum possible charge on the fragments to be matched; default:-1\n
711
623
  | Returns:
712
624
  | :-
713
625
  | Returns a dict of lists of networkx subgraphs
@@ -718,32 +630,33 @@ def generate_atomic_frags(nx_mono, max_cleavages = 3, fragment_masses = None, th
718
630
  true_root_node = [v for v, d in nx_mono.out_degree() if d == 0][0]
719
631
  nx_edge_dict = {(node[0], node[1]): node[2] for node in nx_mono.edges(data = True)}
720
632
  node_dict = nx.get_node_attributes(nx_mono, 'string_labels')
633
+ node_dict_basic = {k: map_to_basic(v, obfuscate_ptm = False) for k, v in node_dict.items()}
721
634
  subgraph_fragments = {}
722
- subgraphs = enumerate_subgraphs(nx_mono)
723
- subgraphs.append(nx_mono)
635
+ subgraphs = enumerate_subgraphs(nx_mono) + [nx_mono]
636
+ max_global_mass = max(mono_attributes['Global']['mass'].values())
724
637
  for subg in subgraphs:
725
638
  present_breakages = get_broken_bonds(subg, nx_mono, nx_edge_dict)
726
639
  root_node = [v for v, d in subg.out_degree() if d == 0][0]
727
640
  terminals = get_terminals(subg, present_breakages, root_node)
728
- inner_mass = sum([mono_attributes[node_dict[m]]['mass'][node_dict[m]] for m in subg.nodes() if m not in terminals])
729
- max_mass = inner_mass + sum([mono_attributes[node_dict[m]]['mass'][node_dict[m]] for m in terminals]) + 18.0105546*len(terminals)
730
- max_mass += mono_attributes['Global']['mass']['+Acetate']
731
- if max_mass < min_mass:
641
+ inner_mass = sum([mono_attributes[node_dict_basic[m]]['mass'][node_dict_basic[m]] for m in subg.nodes() if m not in terminals])
642
+ max_mass = inner_mass + sum([mono_attributes[node_dict_basic[m]]['mass'][node_dict_basic[m]] for m in terminals]) + 18.0105546*len(terminals)
643
+ max_mass += max_global_mass
644
+ if max_mass < min_mass - threshold:
732
645
  continue
733
- terminal_labels = [node_dict[x] for x in terminals]
734
- global_mods = [None] + get_global_mods(subg, node_dict,mode)
646
+ terminal_labels = [node_dict_basic[x] for x in terminals]
647
+ global_mods = [None] + get_global_mods(subg, node_dict,charge)
735
648
  atomic_mod_dict_subg = atom_mods_init(subg, present_breakages, terminals, terminal_labels)
736
649
  mono_mods_list = get_mono_mods_list(root_node, subg, terminals, terminal_labels, nx_edge_dict)
737
650
  mono_mod_perms, atom_dict_perms = generate_mod_permutations(terminals, terminal_labels, mono_mods_list, atomic_mod_dict_subg)
738
651
  permutation_list = product(zip(product(*mono_mod_perms), product(*atom_dict_perms)), global_mods)
739
652
  mono_masses, atom_masses, global_masses = precalculate_mod_masses(mono_mod_perms, atom_dict_perms, terminal_labels, global_mods)
740
- initial_masses = preliminary_calculate_mass(mono_masses, atom_masses, global_masses, terminals, inner_mass, true_root_node, label_mass, mode)
653
+ initial_masses = preliminary_calculate_mass(mono_masses, atom_masses, global_masses, terminals, inner_mass, true_root_node, label_mass, charge)
741
654
  fragment_arr = np.array(charge_masses)
742
655
  for mass, (node_mod, global_mod) in zip(initial_masses, permutation_list):
743
656
  if not (abs(fragment_arr - mass) < threshold).any():
744
657
  continue
745
658
  if (m := mod_count(node_mod, global_mod)) <= max_cleavages:
746
- if m > 1 and global_mod in ['+Acetate','+Na']:
659
+ if m > 1 and global_mod in ['+Acetate', '+Acetonitrile', '+Na', '+K']:
747
660
  continue
748
661
  annotated_subg = annotate_subgraph(subg,node_mod,global_mod,terminals)
749
662
  annotated_subg_mass = round(mass, 5)
@@ -766,7 +679,8 @@ def rank_chains(nx_mono):
766
679
  leaf_chains = []
767
680
  for og_leaf in og_leaves:
768
681
  leaf_chains.append(nx.shortest_path(nx_mono, source = og_leaf))
769
- main_chains = sorted([branch_path[og_root] for branch_path in leaf_chains], key = lambda x: sum([mono_attributes[node_dict[n]]['mass'][node_dict[n]] for n in x]), reverse = True)
682
+ main_chains = sorted([branch_path[og_root] for branch_path in leaf_chains],
683
+ key = lambda x: sum([mono_attributes[map_to_basic(node_dict[n], obfuscate_ptm = False)]['mass'][map_to_basic(node_dict[n], obfuscate_ptm = False)] for n in x]), reverse = True)
770
684
  return zip(ranks, main_chains)
771
685
 
772
686
 
@@ -786,21 +700,23 @@ def domon_costello_to_node_labels(fragment, chain_rank):
786
700
  global_mod = None
787
701
  post_mono = None
788
702
  for cut in fragment:
789
- if cut[0] == 'M':
703
+ if cut.startswith('M'):
790
704
  global_mod = cut.split('_')[-1]
791
705
  continue
792
- split_cut = cut.split('_')
793
- chain = chain_rank[split_cut[2]]
794
- if split_cut[0][-1] in {'Y', 'Z'}:
795
- mono = chain[::-1][int(split_cut[1])]
796
- elif split_cut[0][-1] == 'X':
797
- mono = chain[::-1][int(split_cut[1])-1]
798
- elif split_cut[0][-1] in {'B', 'C'}:
799
- mono = chain[int(split_cut[1])]
800
- post_mono = chain[int(split_cut[1])-1]
801
- elif split_cut[0][-1] == 'A':
802
- mono = chain[int(split_cut[1])-1]
803
- skelly_dict[mono] = split_cut[0]
706
+ cut_type, cut_num, chain_label = cut.split('_')
707
+ cut_type_last_char = cut_type[-1]
708
+ cut_num = int(cut_num)
709
+ chain = chain_rank[chain_label]
710
+ if cut_type_last_char in 'YZ':
711
+ mono = chain[::-1][cut_num]
712
+ elif cut_type_last_char == 'X':
713
+ mono = chain[::-1][cut_num-1]
714
+ elif cut_type_last_char in 'BC':
715
+ mono = chain[cut_num]
716
+ post_mono = chain[cut_num-1]
717
+ elif cut_type_last_char == 'A':
718
+ mono = chain[cut_num-1]
719
+ skelly_dict[mono] = cut_type
804
720
  return skelly_dict, post_mono, global_mod
805
721
 
806
722
 
@@ -810,7 +726,7 @@ def node_labels_to_domon_costello(cuts, chain_rank, global_mods = {}):
810
726
  | :-
811
727
  | cuts (list): a list of tuples each containing the cleavage type, and related integer node labels
812
728
  | chain_rank (list): a list of tuples each containing rank and a list of integer node labels representing the glycan chain
813
- | global_mods (dict): the output of get_node_attributes(subg, 'global_mod') a dict containng integer node labels each pointing to a global mass change\n
729
+ | global_mods (dict): the output of get_node_attributes(subg, 'global_mod') a dict containing integer node labels each pointing to a global mass change\n
814
730
  | Returns:
815
731
  | :-
816
732
  | Returns a list containing all of the cleavages making up the fragment in Domon-Costello form
@@ -827,13 +743,11 @@ def node_labels_to_domon_costello(cuts, chain_rank, global_mods = {}):
827
743
  elif cut_type[-1] in {'X'}:
828
744
  cut_rank, cut_chain = [(rank, chain) for rank, chain in chain_rank if cut[1] in chain][0]
829
745
  cut_number = cut_chain[::-1].index(cut[1])+1
830
- dc_cuts.append('_'.join((cut_type, str(cut_number), cut_rank)))
746
+ dc_cuts.append(f"{cut_type}_{cut_number}_{cut_rank}")
831
747
  if global_mods:
832
- global_mods = list(global_mods.values())
833
- dc_cuts.append('_'.join(('M', global_mods[0][0])))
834
- if not dc_cuts:
835
- dc_cuts = ['M']
836
- return dc_cuts
748
+ global_mods = list(global_mods.values())[0][0]
749
+ dc_cuts.append(f"M_{global_mods}")
750
+ return dc_cuts or ['M']
837
751
 
838
752
 
839
753
  def find_main_chain(subgraph, leaves, root_node):
@@ -848,12 +762,10 @@ def find_main_chain(subgraph, leaves, root_node):
848
762
  | Returns a list of integer node labels representing the inputs main chain
849
763
  """
850
764
  bond_dict = nx.get_edge_attributes(subgraph, 'bond_label')
851
- main_chains = []
852
- for leaf in leaves:
853
- for path in nx.all_simple_paths(subgraph, source = leaf, target = root_node):
854
- main_chains.append(path)
855
- main_chain_len = max([len(x) for x in main_chains])
856
- main_chains = [k for k in main_chains if len(k) == main_chain_len]
765
+ all_paths = [path for leaf in leaves for path in nx.all_simple_paths(subgraph, source = leaf, target = root_node)]
766
+ main_chain = max(all_paths, key = len)
767
+ main_chain_len = len(main_chain)
768
+ main_chains = [k for k in all_paths if len(k) == main_chain_len]
857
769
  for i in range(main_chain_len)[::-1]:
858
770
  step = [c[i] for c in main_chains]
859
771
  if len(set(step)) == 1:
@@ -874,9 +786,8 @@ def subgraph_to_label_skeleton(sub_g):
874
786
  | Returns a list of integer node labels and branching brackets in the same order as the IUPAC condensed string
875
787
  """
876
788
  if len(sub_g.nodes) == 1:
877
- return [str(x) for x in sub_g.nodes]
878
- root_node = [k for k, v in sub_g.out_degree if v == 0]
879
- root_node = root_node[0]
789
+ return [str(next(iter(sub_g.nodes)))]
790
+ root_node = next(k for k, v in sub_g.out_degree if v == 0)
880
791
  leaves = [v for v, d in sub_g.in_degree() if d == 0]
881
792
  main_chain = []
882
793
  n_skelly = []
@@ -920,17 +831,15 @@ def label_skeleton_to_string(n_skelly, sub_g):
920
831
 
921
832
 
922
833
  def mono_frag_to_string(sub_g):
923
- """Converts a monsaccharide graph to a string\n
834
+ """Converts a monosaccharide graph to a string\n
924
835
  | Arguments:
925
836
  | :-
926
837
  | subg (networkx_object): a graph or subgraph of monosaccharides\n
927
838
  | Returns:
928
839
  | :-
929
- | Returns an IUPAC condesnsed representation of the input graph, in the case of fragment graphs it returns the closest canonical string representation
840
+ | Returns an IUPAC condensed representation of the input graph, in the case of fragment graphs it returns the closest canonical string representation
930
841
  """
931
- n_skelly = subgraph_to_label_skeleton(sub_g)
932
- glycan_string = label_skeleton_to_string(n_skelly, sub_g)
933
- return glycan_string
842
+ return label_skeleton_to_string(subgraph_to_label_skeleton(sub_g), sub_g)
934
843
 
935
844
 
936
845
  def domon_costello_to_fragIUPAC(glycan_string, fragment):
@@ -1023,6 +932,7 @@ def subgraphs_to_domon_costello(nx_mono, subgs):
1023
932
  """
1024
933
  ion_names = []
1025
934
  node_dict = nx.get_node_attributes(nx_mono, 'string_labels')
935
+ node_dict = {k: map_to_basic(v, obfuscate_ptm = False) for k, v in node_dict.items()}
1026
936
  chain_rank = list(rank_chains(nx_mono))
1027
937
 
1028
938
  for subg in subgs:
@@ -1038,9 +948,8 @@ def subgraphs_to_domon_costello(nx_mono, subgs):
1038
948
  cuts.append((atom_mod, cut_node[0], node))
1039
949
  if atom_mod in {'red_bond', 'red_no_bond'}:
1040
950
  cuts.append((atom_mod, node))
1041
- cross_rings = [(k, v) for k, v in mono_mod_dict.items() if (k, v) not in node_dict.items()]
1042
- for node, mod in cross_rings:
1043
- cuts.append((mod, node))
951
+ cross_rings = [(v, k) for k, v in mono_mod_dict.items() if (k, v) not in node_dict.items()]
952
+ cuts.extend(cross_rings)
1044
953
  dc_cuts = node_labels_to_domon_costello(cuts, chain_rank, global_mods = global_mods)
1045
954
  ion_names.append((dc_cuts))
1046
955
  return ion_names
@@ -1056,7 +965,7 @@ def priority_filter(dc_names, diffs):
1056
965
  | :-
1057
966
  | Returns a list of Domon-Costello fragment names sorted by number of cleavages and the observed mass difference
1058
967
  """
1059
- sorted_frags = sorted(list(zip(dc_names,diffs)),key=lambda x:(len(x[0]),x[1]))
968
+ sorted_frags = sorted(list(zip(dc_names, diffs)), key = lambda x:(len(x[0]), x[1]))
1060
969
  return [f[0] for f in sorted_frags]
1061
970
 
1062
971
 
@@ -1079,17 +988,28 @@ def match_fragment_properties(subg_frags, mass, mass_threshold, charge):
1079
988
  fragment_properties = []
1080
989
  modifier = np.sign(charge)
1081
990
  for z in range(1, abs(charge)+1):
1082
- charged_mass = (mass*z)-(z*modifier-modifier)
1083
- for k in subg_frags:
1084
- if abs(charged_mass-k) < mass_threshold:
1085
- for graph in subg_frags[k]:
1086
- fragment_properties.append((mass, k, abs(charged_mass-k), modifier*z, graph))
991
+ charged_mass = (mass*z) - (z - 1.0078)*modifier
992
+ for frag_mass, graphs in subg_frags.items():
993
+ if abs(charged_mass - frag_mass) < mass_threshold:
994
+ for graph in graphs:
995
+ fragment_properties.append((mass, frag_mass, abs(charged_mass - frag_mass), modifier*z, graph))
1087
996
  if fragment_properties:
1088
997
  return list(zip(*fragment_properties))
1089
998
  else:
1090
999
  return [[], [], [], [], []]
1091
1000
 
1092
1001
 
1002
+ def flatten_list(nested_list):
1003
+ """Recursively flattens a nested list."""
1004
+ flat_list = []
1005
+ for item in nested_list:
1006
+ if isinstance(item, list):
1007
+ flat_list.extend(flatten_list(item))
1008
+ else:
1009
+ flat_list.append(item)
1010
+ return flat_list
1011
+
1012
+
1093
1013
  def observed_fragments_checker(possible_fragments, observed_fragments):
1094
1014
  """Calculates for each possible fragment the largest overlap of cleavages with previous fragments\n
1095
1015
  | Arguments:
@@ -1100,16 +1020,11 @@ def observed_fragments_checker(possible_fragments, observed_fragments):
1100
1020
  | :-
1101
1021
  | Returns a list containing integers corresponding to the largest overlap each possible fragment had with all previously observed fragments
1102
1022
  """
1103
- max_overlaps_seen = []
1104
- for cleavage_combo in possible_fragments:
1105
- seen_cleavage_overlaps = []
1106
- for obs in observed_fragments:
1107
- if not obs:
1108
- seen_cleavage_overlaps.append(0)
1109
- continue
1110
- seen_cleavage_overlaps.append(len(set(cleavage_combo) & set(obs[0])))
1111
- max_overlaps_seen.append(max(seen_cleavage_overlaps, default = 0))
1112
- return max_overlaps_seen
1023
+ #if observed_fragments and observed_fragments[0] and observed_fragments[0][0] and isinstance(observed_fragments[0][0], list):
1024
+ # observed_fragments = unwrap(observed_fragments)
1025
+ observed_fragments = flatten_list(observed_fragments)
1026
+ sums = [sum(len(set(pf) & set(of)) for of in observed_fragments if of) for pf in possible_fragments]
1027
+ return [sums[i] - 1 if 'M' in ''.join(f) else sums[i] for i, f in enumerate(possible_fragments)]
1113
1028
 
1114
1029
 
1115
1030
  def simplify_fragments(dc_names):
@@ -1129,17 +1044,16 @@ def simplify_fragments(dc_names):
1129
1044
  observed_frags.append([])
1130
1045
  elif len(possible_frags[0]) == 1:
1131
1046
  observed_frags.append([possible_frags[0]])
1132
- continue
1133
1047
  else:
1134
1048
  frag_options = [x for x in possible_frags if len(x) == len(possible_frags[0])]
1135
1049
  max_overlaps_seen = (observed_fragments_checker(frag_options, observed_frags))
1136
1050
  max_overlap_idx = np.argsort(max_overlaps_seen, kind = 'stable')[-1]
1137
1051
  observed_frags.append([frag_options[max_overlap_idx]])
1138
- continue
1139
1052
  return observed_frags
1140
1053
 
1141
1054
 
1142
- def CandyCrumbs(glycan_string, fragment_masses, mass_threshold, libr = None,
1055
+ @rescue_glycans
1056
+ def CandyCrumbs(glycan_string, fragment_masses, mass_threshold,
1143
1057
  max_cleavages = 3, simplify = True, charge = -1, label_mass = 2.0156,
1144
1058
  iupac = False, intensities = None):
1145
1059
  """Basic wrapper for the annotation of observed masses with correct nomenclature given a glycan\n
@@ -1148,7 +1062,6 @@ def CandyCrumbs(glycan_string, fragment_masses, mass_threshold, libr = None,
1148
1062
  | glycan_string (string): glycan in IUPAC-condensed format
1149
1063
  | fragment_masses (list): all masses which are to be annotated with a fragment name
1150
1064
  | mass_threshold (float): the maximum tolerated mass difference around each observed mass at which to include fragments
1151
- | libr (list): library of monosaccharides; if you have one use it, otherwise a comprehensive lib will be used
1152
1065
  | max_cleavages (int): maximum number of allowed concurrent fragmentations per mass; default:3
1153
1066
  | simplify (bool): whether to try condensing fragment options to the most likely option; default:True
1154
1067
  | charge (int): the charge state of the precursor ion (singly-charged, doubly-charged); default:-1
@@ -1158,14 +1071,11 @@ def CandyCrumbs(glycan_string, fragment_masses, mass_threshold, libr = None,
1158
1071
  | :-
1159
1072
  | Returns a list of tuples containing the observed mass and all of the possible fragment names within the threshold
1160
1073
  """
1161
- if libr is None:
1162
- libr = lib
1163
1074
  hit_dict = {}
1164
- mode = 'negative' if charge < 0 else 'positive'
1165
1075
  fragment_masses = sorted(fragment_masses)
1166
1076
  mono_graph = glycan_to_graph_monos(glycan_string)
1167
- nx_mono = mono_graph_to_nx(mono_graph, directed = True, libr = libr)
1168
- subg_frags = generate_atomic_frags(nx_mono, max_cleavages = max_cleavages, fragment_masses = fragment_masses, threshold = mass_threshold, label_mass = label_mass, charge = charge, mode = mode)
1077
+ nx_mono = mono_graph_to_nx(mono_graph, directed = True)
1078
+ subg_frags = generate_atomic_frags(nx_mono, max_cleavages = max_cleavages, fragment_masses = fragment_masses, threshold = mass_threshold, label_mass = label_mass, charge = charge)
1169
1079
  downstream_values = []
1170
1080
  for observed_mass in fragment_masses:
1171
1081
  fragment_properties = match_fragment_properties(subg_frags, observed_mass, mass_threshold, charge)