|
@@ -0,0 +1,262 @@
|
|
|
|
+
|
|
|
|
+ * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
|
|
+ *
|
|
|
|
+ * @author Alexander Rose <alexander.rose@weirdbyte.de>
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+import { CifCategory, CifField } from 'mol-io/reader/cif';
|
|
|
|
+import { mmCIF_Schema } from 'mol-io/reader/cif/schema/mmcif';
|
|
|
|
+import { Tokens } from 'mol-io/reader/common/text/tokenizer';
|
|
|
|
+
|
|
|
|
+const HelixTypes: {[k: string]: mmCIF_Schema['struct_conf']['conf_type_id']['T']} = {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ 1: 'HELX_RH_AL_P',
|
|
|
|
+ 2: 'HELX_RH_OM_P',
|
|
|
|
+ 3: 'HELX_RH_PI_P',
|
|
|
|
+ 4: 'HELX_RH_GA_P',
|
|
|
|
+ 5: 'HELX_RH_3T_P',
|
|
|
|
+ 6: 'HELX_LH_AL_P',
|
|
|
|
+ 7: 'HELX_LH_OM_P',
|
|
|
|
+ 8: 'HELX_LH_GA_P',
|
|
|
|
+ 9: 'HELX_RH_27_P',
|
|
|
|
+ 10: 'HELX_RH_PP_P',
|
|
|
|
+}
|
|
|
|
+function getStructConfTypeId(type: string): mmCIF_Schema['struct_conf']['conf_type_id']['T'] {
|
|
|
|
+ return HelixTypes[type] || 'HELX_P'
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+interface PdbHelix {
|
|
|
|
+ serNum: string,
|
|
|
|
+ helixID: string,
|
|
|
|
+ initResName: string,
|
|
|
|
+ initChainID: string,
|
|
|
|
+ initSeqNum: string,
|
|
|
|
+ initICode: string,
|
|
|
|
+ endResName: string,
|
|
|
|
+ endChainID: string,
|
|
|
|
+ endSeqNum: string,
|
|
|
|
+ endICode: string,
|
|
|
|
+ helixClass: string,
|
|
|
|
+ comment: string,
|
|
|
|
+ length: string
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export function parseHelix(lines: Tokens, lineStart: number, lineEnd: number): CifCategory {
|
|
|
|
+ const helices: PdbHelix[] = []
|
|
|
|
+ const getLine = (n: number) => lines.data.substring(lines.indices[2 * n], lines.indices[2 * n + 1]);
|
|
|
|
+
|
|
|
|
+ for (let i = lineStart; i < lineEnd; i++) {
|
|
|
|
+ let line = getLine(i);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ helices.push({
|
|
|
|
+ serNum: line.substr(7, 3).trim(),
|
|
|
|
+ helixID: line.substr(11, 3).trim(),
|
|
|
|
+ initResName: line.substr(15, 3).trim(),
|
|
|
|
+ initChainID: line.substr(19, 1).trim(),
|
|
|
|
+ initSeqNum: line.substr(21, 4).trim(),
|
|
|
|
+ initICode: line.substr(25, 1).trim(),
|
|
|
|
+ endResName: line.substr(27, 3).trim(),
|
|
|
|
+ endChainID: line.substr(31, 3).trim(),
|
|
|
|
+ endSeqNum: line.substr(33, 4).trim(),
|
|
|
|
+ endICode: line.substr(37, 1).trim(),
|
|
|
|
+ helixClass: line.substr(38, 2).trim(),
|
|
|
|
+ comment: line.substr(40, 30).trim(),
|
|
|
|
+ length: line.substr(71, 5).trim()
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const beg_auth_asym_id = CifField.ofStrings(helices.map(h => h.initChainID))
|
|
|
|
+ const beg_auth_comp_id = CifField.ofStrings(helices.map(h => h.initResName))
|
|
|
|
+ const beg_auth_seq_id = CifField.ofStrings(helices.map(h => h.initSeqNum))
|
|
|
|
+
|
|
|
|
+ const end_auth_asym_id = CifField.ofStrings(helices.map(h => h.endChainID))
|
|
|
|
+ const end_auth_comp_id = CifField.ofStrings(helices.map(h => h.endResName))
|
|
|
|
+ const end_auth_seq_id = CifField.ofStrings(helices.map(h => h.endSeqNum))
|
|
|
|
+
|
|
|
|
+ const struct_conf: CifCategory.Fields<mmCIF_Schema['struct_conf']> = {
|
|
|
|
+ beg_label_asym_id: beg_auth_asym_id,
|
|
|
|
+ beg_label_comp_id: beg_auth_comp_id,
|
|
|
|
+ beg_label_seq_id: beg_auth_seq_id,
|
|
|
|
+ beg_auth_asym_id,
|
|
|
|
+ beg_auth_comp_id,
|
|
|
|
+ beg_auth_seq_id,
|
|
|
|
+
|
|
|
|
+ conf_type_id: CifField.ofStrings(helices.map(h => getStructConfTypeId(h.helixClass))),
|
|
|
|
+ details: CifField.ofStrings(helices.map(h => h.comment)),
|
|
|
|
+
|
|
|
|
+ end_label_asym_id: end_auth_asym_id,
|
|
|
|
+ end_label_comp_id: end_auth_asym_id,
|
|
|
|
+ end_label_seq_id: end_auth_seq_id,
|
|
|
|
+ end_auth_asym_id,
|
|
|
|
+ end_auth_comp_id,
|
|
|
|
+ end_auth_seq_id,
|
|
|
|
+
|
|
|
|
+ id: CifField.ofStrings(helices.map(h => h.serNum)),
|
|
|
|
+ pdbx_beg_PDB_ins_code: CifField.ofStrings(helices.map(h => h.initICode)),
|
|
|
|
+ pdbx_end_PDB_ins_code: CifField.ofStrings(helices.map(h => h.endICode)),
|
|
|
|
+ pdbx_PDB_helix_class: CifField.ofStrings(helices.map(h => h.helixClass)),
|
|
|
|
+ pdbx_PDB_helix_length: CifField.ofStrings(helices.map(h => h.length)),
|
|
|
|
+ pdbx_PDB_helix_id: CifField.ofStrings(helices.map(h => h.helixID)),
|
|
|
|
+ };
|
|
|
|
+ return CifCategory.ofFields('struct_conf', struct_conf);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+interface PdbSheet {
|
|
|
|
+ strand: string,
|
|
|
|
+ sheetID: string,
|
|
|
|
+ numStrands: string,
|
|
|
|
+ initResName: string,
|
|
|
|
+ initChainID: string,
|
|
|
|
+ initSeqNum: string,
|
|
|
|
+ initICode: string,
|
|
|
|
+ endResName: string,
|
|
|
|
+ endChainID: string,
|
|
|
|
+ endSeqNum: string,
|
|
|
|
+ endICode: string,
|
|
|
|
+ sense: string,
|
|
|
|
+ curAtom: string,
|
|
|
|
+ curResName: string,
|
|
|
|
+ curChainId: string,
|
|
|
|
+ curResSeq: string,
|
|
|
|
+ curICode: string,
|
|
|
|
+ prevAtom: string,
|
|
|
|
+ prevResName: string,
|
|
|
|
+ prevChainId: string,
|
|
|
|
+ prevResSeq: string,
|
|
|
|
+ prevICode: string,
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export function parseSheet(lines: Tokens, lineStart: number, lineEnd: number): CifCategory {
|
|
|
|
+ const sheets: PdbSheet[] = []
|
|
|
|
+ const getLine = (n: number) => lines.data.substring(lines.indices[2 * n], lines.indices[2 * n + 1]);
|
|
|
|
+
|
|
|
|
+ for (let i = lineStart; i < lineEnd; i++) {
|
|
|
|
+ let line = getLine(i);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ sheets.push({
|
|
|
|
+ strand: line.substr(7, 3).trim(),
|
|
|
|
+ sheetID: line.substr(11, 3).trim(),
|
|
|
|
+ numStrands: line.substr(14, 2).trim(),
|
|
|
|
+ initResName: line.substr(17, 3).trim(),
|
|
|
|
+ initChainID: line.substr(21, 1).trim(),
|
|
|
|
+ initSeqNum: line.substr(22, 4).trim(),
|
|
|
|
+ initICode: line.substr(26, 1).trim(),
|
|
|
|
+ endResName: line.substr(28, 3).trim(),
|
|
|
|
+ endChainID: line.substr(32, 1).trim(),
|
|
|
|
+ endSeqNum: line.substr(33, 4).trim(),
|
|
|
|
+ endICode: line.substr(37, 1).trim(),
|
|
|
|
+ sense: line.substr(38, 2).trim(),
|
|
|
|
+ curAtom: line.substr(41, 4).trim(),
|
|
|
|
+ curResName: line.substr(45, 3).trim(),
|
|
|
|
+ curChainId: line.substr(49, 1).trim(),
|
|
|
|
+ curResSeq: line.substr(50, 4).trim(),
|
|
|
|
+ curICode: line.substr(54, 1).trim(),
|
|
|
|
+ prevAtom: line.substr(56, 4).trim(),
|
|
|
|
+ prevResName: line.substr(60, 3).trim(),
|
|
|
|
+ prevChainId: line.substr(64, 1).trim(),
|
|
|
|
+ prevResSeq: line.substr(65, 4).trim(),
|
|
|
|
+ prevICode: line.substr(69, 1).trim(),
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const beg_auth_asym_id = CifField.ofStrings(sheets.map(s => s.initChainID))
|
|
|
|
+ const beg_auth_comp_id = CifField.ofStrings(sheets.map(s => s.initResName))
|
|
|
|
+ const beg_auth_seq_id = CifField.ofStrings(sheets.map(s => s.initSeqNum))
|
|
|
|
+
|
|
|
|
+ const end_auth_asym_id = CifField.ofStrings(sheets.map(s => s.endChainID))
|
|
|
|
+ const end_auth_comp_id = CifField.ofStrings(sheets.map(s => s.endResName))
|
|
|
|
+ const end_auth_seq_id = CifField.ofStrings(sheets.map(s => s.endSeqNum))
|
|
|
|
+
|
|
|
|
+ const struct_sheet_range: CifCategory.Fields<mmCIF_Schema['struct_sheet_range']> = {
|
|
|
|
+ beg_label_asym_id: beg_auth_asym_id,
|
|
|
|
+ beg_label_comp_id: beg_auth_comp_id,
|
|
|
|
+ beg_label_seq_id: beg_auth_seq_id,
|
|
|
|
+ beg_auth_asym_id,
|
|
|
|
+ beg_auth_comp_id,
|
|
|
|
+ beg_auth_seq_id,
|
|
|
|
+
|
|
|
|
+ end_label_asym_id: end_auth_asym_id,
|
|
|
|
+ end_label_comp_id: end_auth_asym_id,
|
|
|
|
+ end_label_seq_id: end_auth_seq_id,
|
|
|
|
+ end_auth_asym_id,
|
|
|
|
+ end_auth_comp_id,
|
|
|
|
+ end_auth_seq_id,
|
|
|
|
+
|
|
|
|
+ id: CifField.ofStrings(sheets.map(s => s.strand)),
|
|
|
|
+ sheet_id: CifField.ofStrings(sheets.map(s => s.sheetID)),
|
|
|
|
+ pdbx_beg_PDB_ins_code: CifField.ofStrings(sheets.map(s => s.initICode)),
|
|
|
|
+ pdbx_end_PDB_ins_code: CifField.ofStrings(sheets.map(s => s.endICode)),
|
|
|
|
+ };
|
|
|
|
+ return CifCategory.ofFields('struct_sheet_range', struct_sheet_range);
|
|
|
|
+}
|