@datagrok/proteomics 1.0.0
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.
- package/.eslintignore +1 -0
- package/.eslintrc.json +56 -0
- package/CHANGELOG.md +3 -0
- package/LICENSE +674 -0
- package/README.md +3 -0
- package/detectors.js +9 -0
- package/dist/package-test.js +1745 -0
- package/dist/package-test.js.map +1 -0
- package/dist/package.js +147 -0
- package/dist/package.js.map +1 -0
- package/package.json +62 -0
- package/package.png +0 -0
- package/scripts/number_antibody.py +190 -0
- package/scripts/number_antibody_abnumber.py +177 -0
- package/scripts/number_antibody_anarci.py +200 -0
- package/src/package-api.ts +37 -0
- package/src/package-test.ts +20 -0
- package/src/package.g.ts +1 -0
- package/src/package.ts +17 -0
- package/tsconfig.json +71 -0
- package/webpack.config.js +45 -0
package/dist/package.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
var proteomics;
|
|
2
|
+
/******/ (() => { // webpackBootstrap
|
|
3
|
+
/******/ "use strict";
|
|
4
|
+
/******/ var __webpack_modules__ = ({
|
|
5
|
+
|
|
6
|
+
/***/ "./src/package.g.ts"
|
|
7
|
+
/*!**************************!*\
|
|
8
|
+
!*** ./src/package.g.ts ***!
|
|
9
|
+
\**************************/
|
|
10
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
11
|
+
|
|
12
|
+
__webpack_require__.r(__webpack_exports__);
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/***/ },
|
|
17
|
+
|
|
18
|
+
/***/ "datagrok-api/dg"
|
|
19
|
+
/*!*********************!*\
|
|
20
|
+
!*** external "DG" ***!
|
|
21
|
+
\*********************/
|
|
22
|
+
(module) {
|
|
23
|
+
|
|
24
|
+
module.exports = DG;
|
|
25
|
+
|
|
26
|
+
/***/ },
|
|
27
|
+
|
|
28
|
+
/***/ "datagrok-api/grok"
|
|
29
|
+
/*!***********************!*\
|
|
30
|
+
!*** external "grok" ***!
|
|
31
|
+
\***********************/
|
|
32
|
+
(module) {
|
|
33
|
+
|
|
34
|
+
module.exports = grok;
|
|
35
|
+
|
|
36
|
+
/***/ }
|
|
37
|
+
|
|
38
|
+
/******/ });
|
|
39
|
+
/************************************************************************/
|
|
40
|
+
/******/ // The module cache
|
|
41
|
+
/******/ var __webpack_module_cache__ = {};
|
|
42
|
+
/******/
|
|
43
|
+
/******/ // The require function
|
|
44
|
+
/******/ function __webpack_require__(moduleId) {
|
|
45
|
+
/******/ // Check if module is in cache
|
|
46
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
47
|
+
/******/ if (cachedModule !== undefined) {
|
|
48
|
+
/******/ return cachedModule.exports;
|
|
49
|
+
/******/ }
|
|
50
|
+
/******/ // Create a new module (and put it into the cache)
|
|
51
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
52
|
+
/******/ // no module.id needed
|
|
53
|
+
/******/ // no module.loaded needed
|
|
54
|
+
/******/ exports: {}
|
|
55
|
+
/******/ };
|
|
56
|
+
/******/
|
|
57
|
+
/******/ // Execute the module function
|
|
58
|
+
/******/ if (!(moduleId in __webpack_modules__)) {
|
|
59
|
+
/******/ delete __webpack_module_cache__[moduleId];
|
|
60
|
+
/******/ var e = new Error("Cannot find module '" + moduleId + "'");
|
|
61
|
+
/******/ e.code = 'MODULE_NOT_FOUND';
|
|
62
|
+
/******/ throw e;
|
|
63
|
+
/******/ }
|
|
64
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
65
|
+
/******/
|
|
66
|
+
/******/ // Return the exports of the module
|
|
67
|
+
/******/ return module.exports;
|
|
68
|
+
/******/ }
|
|
69
|
+
/******/
|
|
70
|
+
/************************************************************************/
|
|
71
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
72
|
+
/******/ (() => {
|
|
73
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
74
|
+
/******/ __webpack_require__.n = (module) => {
|
|
75
|
+
/******/ var getter = module && module.__esModule ?
|
|
76
|
+
/******/ () => (module['default']) :
|
|
77
|
+
/******/ () => (module);
|
|
78
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
79
|
+
/******/ return getter;
|
|
80
|
+
/******/ };
|
|
81
|
+
/******/ })();
|
|
82
|
+
/******/
|
|
83
|
+
/******/ /* webpack/runtime/define property getters */
|
|
84
|
+
/******/ (() => {
|
|
85
|
+
/******/ // define getter functions for harmony exports
|
|
86
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
87
|
+
/******/ for(var key in definition) {
|
|
88
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
89
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
90
|
+
/******/ }
|
|
91
|
+
/******/ }
|
|
92
|
+
/******/ };
|
|
93
|
+
/******/ })();
|
|
94
|
+
/******/
|
|
95
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
96
|
+
/******/ (() => {
|
|
97
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
98
|
+
/******/ })();
|
|
99
|
+
/******/
|
|
100
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
101
|
+
/******/ (() => {
|
|
102
|
+
/******/ // define __esModule on exports
|
|
103
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
104
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
105
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
106
|
+
/******/ }
|
|
107
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
108
|
+
/******/ };
|
|
109
|
+
/******/ })();
|
|
110
|
+
/******/
|
|
111
|
+
/************************************************************************/
|
|
112
|
+
var __webpack_exports__ = {};
|
|
113
|
+
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
114
|
+
(() => {
|
|
115
|
+
/*!************************!*\
|
|
116
|
+
!*** ./src/package.ts ***!
|
|
117
|
+
\************************/
|
|
118
|
+
__webpack_require__.r(__webpack_exports__);
|
|
119
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
120
|
+
/* harmony export */ PackageFunctions: () => (/* binding */ PackageFunctions),
|
|
121
|
+
/* harmony export */ _package: () => (/* binding */ _package),
|
|
122
|
+
/* harmony export */ info: () => (/* binding */ info)
|
|
123
|
+
/* harmony export */ });
|
|
124
|
+
/* harmony import */ var datagrok_api_grok__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! datagrok-api/grok */ "datagrok-api/grok");
|
|
125
|
+
/* harmony import */ var datagrok_api_grok__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(datagrok_api_grok__WEBPACK_IMPORTED_MODULE_0__);
|
|
126
|
+
/* harmony import */ var datagrok_api_dg__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! datagrok-api/dg */ "datagrok-api/dg");
|
|
127
|
+
/* harmony import */ var datagrok_api_dg__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(datagrok_api_dg__WEBPACK_IMPORTED_MODULE_1__);
|
|
128
|
+
/* harmony import */ var _package_g__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./package.g */ "./src/package.g.ts");
|
|
129
|
+
/* eslint-disable max-len */
|
|
130
|
+
/* Do not change these import lines to match external modules in webpack configuration */
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
const _package = new datagrok_api_dg__WEBPACK_IMPORTED_MODULE_1__.Package();
|
|
135
|
+
//name: info
|
|
136
|
+
function info() {
|
|
137
|
+
datagrok_api_grok__WEBPACK_IMPORTED_MODULE_0__.shell.info(_package.webRoot);
|
|
138
|
+
}
|
|
139
|
+
class PackageFunctions {
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
})();
|
|
143
|
+
|
|
144
|
+
proteomics = __webpack_exports__;
|
|
145
|
+
/******/ })()
|
|
146
|
+
;
|
|
147
|
+
//# sourceMappingURL=package.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;ACAA,oB;;;;;;;;;;ACAA,sB;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;UACA;;;;;WC5BA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA,E;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA,E;;;;;WCPA,wF;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D,E;;;;;;;;;;;;;;;;;;;;;ACNA,4BAA4B;AAC5B,yFAAyF;AAC/C;AAEJ;AACV;AAErB,MAAM,QAAQ,GAAG,IAAI,oDAAU,EAAE,CAAC;AAEzC,YAAY;AACL,SAAS,IAAI;IAClB,oDAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC;AAEM,MAAM,gBAAgB;CAE5B","sources":["webpack://proteomics/./src/package.g.ts","webpack://proteomics/external var \"DG\"","webpack://proteomics/external var \"grok\"","webpack://proteomics/webpack/bootstrap","webpack://proteomics/webpack/runtime/compat get default export","webpack://proteomics/webpack/runtime/define property getters","webpack://proteomics/webpack/runtime/hasOwnProperty shorthand","webpack://proteomics/webpack/runtime/make namespace object","webpack://proteomics/./src/package.ts"],"sourcesContent":["import * as DG from 'datagrok-api/dg';\n","module.exports = DG;","module.exports = grok;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\tif (!(moduleId in __webpack_modules__)) {\n\t\tdelete __webpack_module_cache__[moduleId];\n\t\tvar e = new Error(\"Cannot find module '\" + moduleId + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t}\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/* eslint-disable max-len */\r\n/* Do not change these import lines to match external modules in webpack configuration */\r\nimport * as grok from 'datagrok-api/grok';\r\nimport * as ui from 'datagrok-api/ui';\r\nimport * as DG from 'datagrok-api/dg';\r\nexport * from './package.g';\r\n\r\nexport const _package = new DG.Package();\r\n\r\n//name: info\r\nexport function info() {\r\n grok.shell.info(_package.webRoot);\r\n}\r\n\r\nexport class PackageFunctions {\r\n \r\n}\r\n"],"names":[],"sourceRoot":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@datagrok/proteomics",
|
|
3
|
+
"friendlyName": "Proteomics",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Proteomics package for Datagrok",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Davit Rizhinashvili",
|
|
8
|
+
"email": "drizhinashvili@datagrok.ai"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@datagrok-libraries/bio": "^5.60.1",
|
|
12
|
+
"@datagrok-libraries/utils": "^4.6.5",
|
|
13
|
+
"@typescript-eslint/eslint-plugin": "^8.39.0",
|
|
14
|
+
"@typescript-eslint/parser": "^8.39.0",
|
|
15
|
+
"cash-dom": "^8.1.5",
|
|
16
|
+
"css-loader": "^7.1.2",
|
|
17
|
+
"datagrok-api": "^1.26.0",
|
|
18
|
+
"dayjs": "^1.11.13",
|
|
19
|
+
"eslint": "^8.57.1",
|
|
20
|
+
"eslint-config-google": "^0.14.0",
|
|
21
|
+
"@datagrok-libraries/test": "^1.1.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/wu": "^2.1.44",
|
|
25
|
+
"datagrok-tools": "^5.0.0",
|
|
26
|
+
"ts-loader": "^9.5.4",
|
|
27
|
+
"typescript": "^5.9.3",
|
|
28
|
+
"webpack": "^5.95.0",
|
|
29
|
+
"webpack-cli": "^5.1.4"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"link-all": "grok link",
|
|
33
|
+
"debug-proteomics": "webpack && grok publish",
|
|
34
|
+
"release-proteomics": "webpack && grok publish --release",
|
|
35
|
+
"build-proteomics": "webpack",
|
|
36
|
+
"build": "grok api && grok check && webpack",
|
|
37
|
+
"debug-proteomics-dev": "webpack && grok publish dev",
|
|
38
|
+
"release-proteomics-dev": "webpack && grok publish dev --release",
|
|
39
|
+
"debug-proteomics-local": "webpack && grok publish local",
|
|
40
|
+
"release-proteomics-local": "webpack && grok publish local --release",
|
|
41
|
+
"debug-proteomics-localhost": "webpack && grok publish localhost",
|
|
42
|
+
"release-proteomics-localhost": "webpack && grok publish localhost --release",
|
|
43
|
+
"debug-proteomics-release": "webpack && grok publish release",
|
|
44
|
+
"release-proteomics-release": "webpack && grok publish release --release",
|
|
45
|
+
"debug-proteomics-test": "webpack && grok publish test",
|
|
46
|
+
"release-proteomics-test": "webpack && grok publish test --release"
|
|
47
|
+
},
|
|
48
|
+
"canEdit": [
|
|
49
|
+
"Developers"
|
|
50
|
+
],
|
|
51
|
+
"canView": [
|
|
52
|
+
"All users"
|
|
53
|
+
],
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "https://github.com/datagrok-ai/Proteomics.git",
|
|
57
|
+
"directory": "."
|
|
58
|
+
},
|
|
59
|
+
"overrides": {
|
|
60
|
+
"datagrok-api": "$datagrok-api"
|
|
61
|
+
}
|
|
62
|
+
}
|
package/package.png
ADDED
|
Binary file
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
#name: Antpack Antibody Numbering
|
|
2
|
+
#description: Assigns antibody numbering (IMGT/Kabat/Chothia/AHo) using AntPack
|
|
3
|
+
#language: python
|
|
4
|
+
#environment: channels: [conda-forge, defaults], dependencies: [python=3.9, pip, pip: [antpack==0.3.8.6,pyside6,qt_material]]
|
|
5
|
+
#meta.role: antibodyNumbering
|
|
6
|
+
#input: dataframe df
|
|
7
|
+
#input: column seqCol {semType: Macromolecule}
|
|
8
|
+
#input: string scheme {choices: ["imgt", "kabat", "chothia", "aho"]} [Numbering scheme]
|
|
9
|
+
#output: dataframe result
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
import pandas as pd
|
|
13
|
+
|
|
14
|
+
try:
|
|
15
|
+
from antpack import SingleChainAnnotator
|
|
16
|
+
except ImportError:
|
|
17
|
+
raise ImportError(
|
|
18
|
+
'AntPack is not installed. Please install it with:\n'
|
|
19
|
+
' pip install antpack==0.3.8.5\n'
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
# Antpack github: https://gidthub.com/jlparkI/AntPack
|
|
23
|
+
# While antpack is currently under non-commercial licence, the version used here (0.3.8.6 as specified in environment) is released unde GPL, allowing us to distribute this plugin with same GPL.
|
|
24
|
+
|
|
25
|
+
# AntPack uses "martin" for modern Chothia numbering
|
|
26
|
+
SCHEME_MAP = {
|
|
27
|
+
'imgt': 'imgt',
|
|
28
|
+
'kabat': 'kabat',
|
|
29
|
+
'chothia': 'martin',
|
|
30
|
+
'aho': 'aho',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
# Region definitions per scheme, keyed by (scheme, chain_group).
|
|
34
|
+
# chain_group is 'Heavy' or 'Light'.
|
|
35
|
+
# Each region: (name, start_position, end_position).
|
|
36
|
+
IMGT_REGIONS = {
|
|
37
|
+
'Heavy': [
|
|
38
|
+
('FR1', 1, 26), ('CDR1', 27, 38), ('FR2', 39, 55),
|
|
39
|
+
('CDR2', 56, 65), ('FR3', 66, 104), ('CDR3', 105, 117), ('FR4', 118, 128),
|
|
40
|
+
],
|
|
41
|
+
'Light': [
|
|
42
|
+
('FR1', 1, 26), ('CDR1', 27, 38), ('FR2', 39, 55),
|
|
43
|
+
('CDR2', 56, 65), ('FR3', 66, 104), ('CDR3', 105, 117), ('FR4', 118, 127),
|
|
44
|
+
],
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
KABAT_REGIONS = {
|
|
48
|
+
'Heavy': [
|
|
49
|
+
('FR1', 1, 30), ('CDR1', 31, 35), ('FR2', 36, 49),
|
|
50
|
+
('CDR2', 50, 65), ('FR3', 66, 94), ('CDR3', 95, 102), ('FR4', 103, 113),
|
|
51
|
+
],
|
|
52
|
+
'Light': [
|
|
53
|
+
('FR1', 1, 23), ('CDR1', 24, 34), ('FR2', 35, 49),
|
|
54
|
+
('CDR2', 50, 56), ('FR3', 57, 88), ('CDR3', 89, 97), ('FR4', 98, 107),
|
|
55
|
+
],
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
CHOTHIA_REGIONS = {
|
|
59
|
+
'Heavy': [
|
|
60
|
+
('FR1', 1, 25), ('CDR1', 26, 32), ('FR2', 33, 51),
|
|
61
|
+
('CDR2', 52, 56), ('FR3', 57, 94), ('CDR3', 95, 102), ('FR4', 103, 113),
|
|
62
|
+
],
|
|
63
|
+
'Light': [
|
|
64
|
+
('FR1', 1, 25), ('CDR1', 26, 32), ('FR2', 33, 49),
|
|
65
|
+
('CDR2', 50, 52), ('FR3', 53, 90), ('CDR3', 91, 96), ('FR4', 97, 107),
|
|
66
|
+
],
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
AHO_REGIONS = {
|
|
70
|
+
'Heavy': [
|
|
71
|
+
('FR1', 1, 24), ('CDR1', 25, 40), ('FR2', 41, 55),
|
|
72
|
+
('CDR2', 56, 78), ('FR3', 79, 108), ('CDR3', 109, 138), ('FR4', 139, 149),
|
|
73
|
+
],
|
|
74
|
+
'Light': [
|
|
75
|
+
('FR1', 1, 24), ('CDR1', 25, 40), ('FR2', 41, 55),
|
|
76
|
+
('CDR2', 56, 78), ('FR3', 79, 108), ('CDR3', 109, 138), ('FR4', 139, 149),
|
|
77
|
+
],
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
SCHEME_REGIONS = {
|
|
81
|
+
'imgt': IMGT_REGIONS,
|
|
82
|
+
'kabat': KABAT_REGIONS,
|
|
83
|
+
'chothia': CHOTHIA_REGIONS,
|
|
84
|
+
'aho': AHO_REGIONS,
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def extract_sequence(raw_seq):
|
|
89
|
+
"""Extract single-letter amino acid sequence from various formats."""
|
|
90
|
+
if not raw_seq or not isinstance(raw_seq, str):
|
|
91
|
+
return ''
|
|
92
|
+
s = raw_seq.strip()
|
|
93
|
+
s = s.replace('-', '').replace('.', '')
|
|
94
|
+
valid = set('ACDEFGHIKLMNPQRSTVWY')
|
|
95
|
+
return ''.join(c for c in s.upper() if c in valid)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
# Map user-facing scheme to AntPack scheme name
|
|
99
|
+
antpack_scheme = SCHEME_MAP.get(scheme, 'imgt')
|
|
100
|
+
|
|
101
|
+
# Create the annotator once for all sequences
|
|
102
|
+
annotator = SingleChainAnnotator(chains=['H', 'K', 'L'], scheme=antpack_scheme)
|
|
103
|
+
|
|
104
|
+
# Extract sequences from the input column
|
|
105
|
+
col_name = seqCol
|
|
106
|
+
sequences = []
|
|
107
|
+
for i in range(df.shape[0]):
|
|
108
|
+
raw = df[col_name].iloc[i]
|
|
109
|
+
sequences.append(extract_sequence(str(raw) if raw is not None else ''))
|
|
110
|
+
|
|
111
|
+
# Process each sequence
|
|
112
|
+
position_names_list = []
|
|
113
|
+
chain_types = []
|
|
114
|
+
region_annotations_list = []
|
|
115
|
+
numbering_results = []
|
|
116
|
+
numbering_maps = []
|
|
117
|
+
|
|
118
|
+
regions_def = SCHEME_REGIONS.get(scheme, IMGT_REGIONS)
|
|
119
|
+
|
|
120
|
+
for seq in sequences:
|
|
121
|
+
if not seq:
|
|
122
|
+
position_names_list.append('')
|
|
123
|
+
chain_types.append('')
|
|
124
|
+
region_annotations_list.append('[]')
|
|
125
|
+
numbering_results.append('')
|
|
126
|
+
numbering_maps.append('')
|
|
127
|
+
continue
|
|
128
|
+
|
|
129
|
+
numbering, pct_identity, chain_type_code, err = annotator.analyze_seq(seq)
|
|
130
|
+
|
|
131
|
+
if err or pct_identity < 0.5:
|
|
132
|
+
position_names_list.append('')
|
|
133
|
+
chain_types.append('')
|
|
134
|
+
region_annotations_list.append('[]')
|
|
135
|
+
numbering_results.append('')
|
|
136
|
+
numbering_maps.append('')
|
|
137
|
+
continue
|
|
138
|
+
|
|
139
|
+
# Determine chain type
|
|
140
|
+
if chain_type_code == 'H':
|
|
141
|
+
chain_type = 'Heavy'
|
|
142
|
+
elif chain_type_code in ('K', 'L'):
|
|
143
|
+
chain_type = 'Light'
|
|
144
|
+
else:
|
|
145
|
+
chain_type = 'Unknown'
|
|
146
|
+
|
|
147
|
+
# Build position names, numbering detail, and position-to-character-index map.
|
|
148
|
+
# numbering is a list with the same length as the input sequence;
|
|
149
|
+
# each element is a position code string or '-' for residues outside the variable region.
|
|
150
|
+
pos_names = []
|
|
151
|
+
numbering_detail = []
|
|
152
|
+
pos_to_char_idx = {}
|
|
153
|
+
for i, pos_code in enumerate(numbering):
|
|
154
|
+
if pos_code != '-':
|
|
155
|
+
pos_names.append(pos_code)
|
|
156
|
+
numbering_detail.append({'position': pos_code, 'aa': seq[i]})
|
|
157
|
+
pos_to_char_idx[pos_code] = i
|
|
158
|
+
|
|
159
|
+
position_names_list.append(', '.join(pos_names))
|
|
160
|
+
chain_types.append(chain_type)
|
|
161
|
+
|
|
162
|
+
# Build region annotations
|
|
163
|
+
chain_key = chain_type if chain_type in regions_def else 'Heavy'
|
|
164
|
+
region_defs = regions_def.get(chain_key, [])
|
|
165
|
+
annotations = []
|
|
166
|
+
for region_name, start, end in region_defs:
|
|
167
|
+
annotations.append({
|
|
168
|
+
'id': f'{scheme}-{chain_type}-{region_name}'.lower(),
|
|
169
|
+
'name': region_name,
|
|
170
|
+
'description': f'{region_name} ({scheme.upper()} {start}-{end})',
|
|
171
|
+
'start': str(start),
|
|
172
|
+
'end': str(end),
|
|
173
|
+
'visualType': 'region',
|
|
174
|
+
'category': 'structure',
|
|
175
|
+
'sourceScheme': scheme.upper(),
|
|
176
|
+
'autoGenerated': True,
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
region_annotations_list.append(json.dumps(annotations))
|
|
180
|
+
numbering_results.append(json.dumps(numbering_detail))
|
|
181
|
+
numbering_maps.append(json.dumps(pos_to_char_idx))
|
|
182
|
+
|
|
183
|
+
# Build result DataFrame
|
|
184
|
+
result = pd.DataFrame({
|
|
185
|
+
'position_names': position_names_list,
|
|
186
|
+
'chain_type': chain_types,
|
|
187
|
+
'annotations_json': region_annotations_list,
|
|
188
|
+
'numbering_detail': numbering_results,
|
|
189
|
+
'numbering_map': numbering_maps,
|
|
190
|
+
})
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
#name: Number Antibody Sequences (AbNumber)
|
|
2
|
+
#description: [Legacy] Assigns antibody numbering (IMGT/Kabat/Chothia/AHo) using AbNumber
|
|
3
|
+
#language: python
|
|
4
|
+
#environment: channels: [conda-forge, bioconda, defaults], dependencies: [python=3.9, pip, hmmer=3.3.2, pip: [abnumber]]
|
|
5
|
+
#input: dataframe df
|
|
6
|
+
#input: column seqCol {semType: Macromolecule}
|
|
7
|
+
#input: string scheme {choices: ["imgt", "kabat", "chothia", "aho"]} [Numbering scheme]
|
|
8
|
+
#output: dataframe result
|
|
9
|
+
|
|
10
|
+
import json
|
|
11
|
+
import pandas as pd
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
from abnumber import Chain
|
|
15
|
+
except ImportError:
|
|
16
|
+
raise ImportError(
|
|
17
|
+
'AbNumber is not installed. Please install it with:\n'
|
|
18
|
+
' conda install -c bioconda abnumber\n'
|
|
19
|
+
'or:\n'
|
|
20
|
+
' pip install abnumber\n'
|
|
21
|
+
'HMMER must also be available on PATH.'
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
# Region definitions per scheme, keyed by (scheme, chain_group).
|
|
25
|
+
# chain_group is 'Heavy' or 'Light'.
|
|
26
|
+
# Each region: (name, start_position, end_position).
|
|
27
|
+
IMGT_REGIONS = {
|
|
28
|
+
'Heavy': [
|
|
29
|
+
('FR1', 1, 26), ('CDR1', 27, 38), ('FR2', 39, 55),
|
|
30
|
+
('CDR2', 56, 65), ('FR3', 66, 104), ('CDR3', 105, 117), ('FR4', 118, 128),
|
|
31
|
+
],
|
|
32
|
+
'Light': [
|
|
33
|
+
('FR1', 1, 26), ('CDR1', 27, 38), ('FR2', 39, 55),
|
|
34
|
+
('CDR2', 56, 65), ('FR3', 66, 104), ('CDR3', 105, 117), ('FR4', 118, 127),
|
|
35
|
+
],
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
KABAT_REGIONS = {
|
|
39
|
+
'Heavy': [
|
|
40
|
+
('FR1', 1, 30), ('CDR1', 31, 35), ('FR2', 36, 49),
|
|
41
|
+
('CDR2', 50, 65), ('FR3', 66, 94), ('CDR3', 95, 102), ('FR4', 103, 113),
|
|
42
|
+
],
|
|
43
|
+
'Light': [
|
|
44
|
+
('FR1', 1, 23), ('CDR1', 24, 34), ('FR2', 35, 49),
|
|
45
|
+
('CDR2', 50, 56), ('FR3', 57, 88), ('CDR3', 89, 97), ('FR4', 98, 107),
|
|
46
|
+
],
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
CHOTHIA_REGIONS = {
|
|
50
|
+
'Heavy': [
|
|
51
|
+
('FR1', 1, 25), ('CDR1', 26, 32), ('FR2', 33, 51),
|
|
52
|
+
('CDR2', 52, 56), ('FR3', 57, 94), ('CDR3', 95, 102), ('FR4', 103, 113),
|
|
53
|
+
],
|
|
54
|
+
'Light': [
|
|
55
|
+
('FR1', 1, 25), ('CDR1', 26, 32), ('FR2', 33, 49),
|
|
56
|
+
('CDR2', 50, 52), ('FR3', 53, 90), ('CDR3', 91, 96), ('FR4', 97, 107),
|
|
57
|
+
],
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
AHO_REGIONS = {
|
|
61
|
+
'Heavy': [
|
|
62
|
+
('FR1', 1, 24), ('CDR1', 25, 40), ('FR2', 41, 55),
|
|
63
|
+
('CDR2', 56, 78), ('FR3', 79, 108), ('CDR3', 109, 138), ('FR4', 139, 149),
|
|
64
|
+
],
|
|
65
|
+
'Light': [
|
|
66
|
+
('FR1', 1, 24), ('CDR1', 25, 40), ('FR2', 41, 55),
|
|
67
|
+
('CDR2', 56, 78), ('FR3', 79, 108), ('CDR3', 109, 138), ('FR4', 139, 149),
|
|
68
|
+
],
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
SCHEME_REGIONS = {
|
|
72
|
+
'imgt': IMGT_REGIONS,
|
|
73
|
+
'kabat': KABAT_REGIONS,
|
|
74
|
+
'chothia': CHOTHIA_REGIONS,
|
|
75
|
+
'aho': AHO_REGIONS,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def extract_sequence(raw_seq):
|
|
80
|
+
"""Extract single-letter amino acid sequence from various formats."""
|
|
81
|
+
if not raw_seq or not isinstance(raw_seq, str):
|
|
82
|
+
return ''
|
|
83
|
+
s = raw_seq.strip()
|
|
84
|
+
s = s.replace('-', '').replace('.', '')
|
|
85
|
+
valid = set('ACDEFGHIKLMNPQRSTVWY')
|
|
86
|
+
return ''.join(c for c in s.upper() if c in valid)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def number_single_sequence(seq, scheme_name):
|
|
90
|
+
"""Number a single sequence using AbNumber's Chain object.
|
|
91
|
+
|
|
92
|
+
Returns (chain, error_msg) where chain is an abnumber.Chain or None.
|
|
93
|
+
"""
|
|
94
|
+
if not seq:
|
|
95
|
+
return None, 'empty sequence'
|
|
96
|
+
try:
|
|
97
|
+
chain = Chain(seq, scheme=scheme_name)
|
|
98
|
+
return chain, None
|
|
99
|
+
except Exception as e:
|
|
100
|
+
return None, str(e)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
# Extract sequences from the input column
|
|
104
|
+
col_name = seqCol
|
|
105
|
+
sequences = []
|
|
106
|
+
for i in range(df.shape[0]):
|
|
107
|
+
raw = df[col_name].iloc[i]
|
|
108
|
+
sequences.append(extract_sequence(str(raw) if raw is not None else ''))
|
|
109
|
+
|
|
110
|
+
# Process each sequence
|
|
111
|
+
position_names_list = []
|
|
112
|
+
chain_types = []
|
|
113
|
+
region_annotations_list = []
|
|
114
|
+
numbering_results = []
|
|
115
|
+
|
|
116
|
+
regions_def = SCHEME_REGIONS.get(scheme, IMGT_REGIONS)
|
|
117
|
+
|
|
118
|
+
for seq in sequences:
|
|
119
|
+
chain, err = number_single_sequence(seq, scheme)
|
|
120
|
+
|
|
121
|
+
if chain is None:
|
|
122
|
+
position_names_list.append('')
|
|
123
|
+
chain_types.append('')
|
|
124
|
+
region_annotations_list.append('[]')
|
|
125
|
+
numbering_results.append('')
|
|
126
|
+
continue
|
|
127
|
+
|
|
128
|
+
# Determine chain type
|
|
129
|
+
ct = chain.chain_type # 'H', 'K', or 'L'
|
|
130
|
+
if ct == 'H':
|
|
131
|
+
chain_type = 'Heavy'
|
|
132
|
+
elif ct in ('K', 'L'):
|
|
133
|
+
chain_type = 'Light'
|
|
134
|
+
else:
|
|
135
|
+
chain_type = 'Unknown'
|
|
136
|
+
|
|
137
|
+
# Build position names from numbering
|
|
138
|
+
pos_names = []
|
|
139
|
+
numbering_detail = []
|
|
140
|
+
for position, aa in chain:
|
|
141
|
+
pos_name = str(position.number)
|
|
142
|
+
if position.letter and position.letter.strip():
|
|
143
|
+
pos_name += position.letter.strip()
|
|
144
|
+
pos_names.append(pos_name)
|
|
145
|
+
numbering_detail.append({'position': pos_name, 'aa': aa})
|
|
146
|
+
|
|
147
|
+
position_names_list.append(', '.join(pos_names))
|
|
148
|
+
|
|
149
|
+
chain_types.append(chain_type)
|
|
150
|
+
|
|
151
|
+
# Build region annotations
|
|
152
|
+
chain_key = chain_type if chain_type in regions_def else 'Heavy'
|
|
153
|
+
region_defs = regions_def.get(chain_key, [])
|
|
154
|
+
annotations = []
|
|
155
|
+
for region_name, start, end in region_defs:
|
|
156
|
+
annotations.append({
|
|
157
|
+
'id': f'{scheme}-{chain_type}-{region_name}'.lower(),
|
|
158
|
+
'name': region_name,
|
|
159
|
+
'description': f'{region_name} ({scheme.upper()} {start}-{end})',
|
|
160
|
+
'start': str(start),
|
|
161
|
+
'end': str(end),
|
|
162
|
+
'visualType': 'region',
|
|
163
|
+
'category': 'structure',
|
|
164
|
+
'sourceScheme': scheme.upper(),
|
|
165
|
+
'autoGenerated': True,
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
region_annotations_list.append(json.dumps(annotations))
|
|
169
|
+
numbering_results.append(json.dumps(numbering_detail))
|
|
170
|
+
|
|
171
|
+
# Build result DataFrame
|
|
172
|
+
result = pd.DataFrame({
|
|
173
|
+
'position_names': position_names_list,
|
|
174
|
+
'chain_type': chain_types,
|
|
175
|
+
'annotations_json': region_annotations_list,
|
|
176
|
+
'numbering_detail': numbering_results,
|
|
177
|
+
})
|