|
@@ -13,13 +13,15 @@ import { Column } from 'mol-data/db';
|
|
|
|
|
|
export function getSecondaryStructureMmCif(data: mmCIF_Database, hierarchy: AtomicHierarchy): SecondaryStructure {
|
|
|
const map: SecondaryStructureMap = new Map();
|
|
|
- addHelices(data.struct_conf, map);
|
|
|
+ const elements: SecondaryStructure.Element[] = [{ kind: 'none' }];
|
|
|
+ addHelices(data.struct_conf, map, elements);
|
|
|
// must add Helices 1st because of 'key' value assignment.
|
|
|
- addSheets(data.struct_sheet_range, map, data.struct_conf._rowCount);
|
|
|
+ addSheets(data.struct_sheet_range, map, data.struct_conf._rowCount, elements);
|
|
|
|
|
|
const secStruct: SecondaryStructureData = {
|
|
|
type: new Int32Array(hierarchy.residues._rowCount) as any,
|
|
|
- key: new Int32Array(hierarchy.residues._rowCount) as any
|
|
|
+ index: new Int32Array(hierarchy.residues._rowCount) as any,
|
|
|
+ elements
|
|
|
};
|
|
|
|
|
|
if (map.size > 0) assignSecondaryStructureRanges(hierarchy, map, secStruct);
|
|
@@ -32,34 +34,45 @@ type SecondaryStructureEntry = {
|
|
|
endSeqNumber: number,
|
|
|
endInsCode: string | null,
|
|
|
type: SecondaryStructureType,
|
|
|
- key: number
|
|
|
+ index: number
|
|
|
}
|
|
|
type SecondaryStructureMap = Map<string, Map<number, SecondaryStructureEntry>>
|
|
|
-type SecondaryStructureData = { type: SecondaryStructureType[], key: number[] }
|
|
|
+type SecondaryStructureData = { type: SecondaryStructureType[], index: number[], elements: SecondaryStructure.Element[] }
|
|
|
|
|
|
-function addHelices(cat: mmCIF['struct_conf'], map: SecondaryStructureMap) {
|
|
|
+function addHelices(cat: mmCIF['struct_conf'], map: SecondaryStructureMap, elements: SecondaryStructure.Element[]) {
|
|
|
if (!cat._rowCount) return;
|
|
|
|
|
|
const { beg_label_asym_id, beg_label_seq_id, pdbx_beg_PDB_ins_code } = cat;
|
|
|
const { end_label_seq_id, pdbx_end_PDB_ins_code } = cat;
|
|
|
- const { pdbx_PDB_helix_class, conf_type_id } = cat;
|
|
|
+ const { pdbx_PDB_helix_class, conf_type_id, details } = cat;
|
|
|
|
|
|
for (let i = 0, _i = cat._rowCount; i < _i; i++) {
|
|
|
- const type = pdbx_PDB_helix_class.valueKind(i) === Column.ValueKind.Present
|
|
|
+ const type = SecondaryStructureType.create(pdbx_PDB_helix_class.valueKind(i) === Column.ValueKind.Present
|
|
|
? SecondaryStructureType.SecondaryStructurePdb[pdbx_PDB_helix_class.value(i)]
|
|
|
: conf_type_id.valueKind(i) === Column.ValueKind.Present
|
|
|
? SecondaryStructureType.SecondaryStructureMmcif[conf_type_id.value(i)]
|
|
|
- : SecondaryStructureType.Flag.NA
|
|
|
-
|
|
|
+ : SecondaryStructureType.Flag.NA);
|
|
|
+
|
|
|
+ const element: SecondaryStructure.Helix = {
|
|
|
+ kind: 'helix',
|
|
|
+ flags: type,
|
|
|
+ type_id: pdbx_PDB_helix_class.valueKind(i) === Column.ValueKind.Present
|
|
|
+ ? pdbx_PDB_helix_class.value(i) : conf_type_id.valueKind(i) === Column.ValueKind.Present
|
|
|
+ ? conf_type_id.value(i) : 'HELIX_P',
|
|
|
+ helix_class: pdbx_PDB_helix_class.value(i),
|
|
|
+ details: details.valueKind(i) === Column.ValueKind.Present ? details.value(i) : void 0
|
|
|
+ };
|
|
|
const entry: SecondaryStructureEntry = {
|
|
|
startSeqNumber: beg_label_seq_id.value(i),
|
|
|
startInsCode: pdbx_beg_PDB_ins_code.value(i),
|
|
|
endSeqNumber: end_label_seq_id.value(i),
|
|
|
endInsCode: pdbx_end_PDB_ins_code.value(i),
|
|
|
- type: SecondaryStructureType.create(type),
|
|
|
- key: i + 1
|
|
|
+ type,
|
|
|
+ index: elements.length
|
|
|
};
|
|
|
|
|
|
+ elements[elements.length] = element;
|
|
|
+
|
|
|
const asymId = beg_label_asym_id.value(i)!;
|
|
|
if (map.has(asymId)) {
|
|
|
map.get(asymId)!.set(entry.startSeqNumber, entry);
|
|
@@ -69,7 +82,7 @@ function addHelices(cat: mmCIF['struct_conf'], map: SecondaryStructureMap) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function addSheets(cat: mmCIF['struct_sheet_range'], map: SecondaryStructureMap, sheetCount: number) {
|
|
|
+function addSheets(cat: mmCIF['struct_sheet_range'], map: SecondaryStructureMap, sheetCount: number, elements: SecondaryStructure.Element[]) {
|
|
|
if (!cat._rowCount) return;
|
|
|
|
|
|
const { beg_label_asym_id, beg_label_seq_id, pdbx_beg_PDB_ins_code } = cat;
|
|
@@ -88,15 +101,25 @@ function addSheets(cat: mmCIF['struct_sheet_range'], map: SecondaryStructureMap,
|
|
|
sheet_id_key.set(id, key);
|
|
|
}
|
|
|
|
|
|
+ const type = SecondaryStructureType.create(SecondaryStructureType.Flag.Beta | SecondaryStructureType.Flag.BetaSheet);
|
|
|
+ const element: SecondaryStructure.Sheet = {
|
|
|
+ kind: 'sheet',
|
|
|
+ flags: type,
|
|
|
+ sheet_id: id,
|
|
|
+ symmetry: void 0
|
|
|
+ }
|
|
|
const entry: SecondaryStructureEntry = {
|
|
|
startSeqNumber: beg_label_seq_id.value(i),
|
|
|
startInsCode: pdbx_beg_PDB_ins_code.value(i),
|
|
|
endSeqNumber: end_label_seq_id.value(i),
|
|
|
endInsCode: pdbx_end_PDB_ins_code.value(i),
|
|
|
- type: SecondaryStructureType.create(SecondaryStructureType.Flag.Beta | SecondaryStructureType.Flag.BetaSheet),
|
|
|
- key
|
|
|
+ type,
|
|
|
+ index: elements.length
|
|
|
};
|
|
|
|
|
|
+ elements[elements.length] = element;
|
|
|
+
|
|
|
+
|
|
|
const asymId = beg_label_asym_id.value(i)!;
|
|
|
if (map.has(asymId)) {
|
|
|
map.get(asymId)!.set(entry.startSeqNumber, entry);
|
|
@@ -110,14 +133,13 @@ function addSheets(cat: mmCIF['struct_sheet_range'], map: SecondaryStructureMap,
|
|
|
|
|
|
function assignSecondaryStructureEntry(hierarchy: AtomicHierarchy, entry: SecondaryStructureEntry, resStart: number, resEnd: number, data: SecondaryStructureData) {
|
|
|
const { label_seq_id, pdbx_PDB_ins_code } = hierarchy.residues;
|
|
|
- const { endSeqNumber, endInsCode, type, key } = entry;
|
|
|
+ const { endSeqNumber, endInsCode, index, type } = entry;
|
|
|
|
|
|
let rI = resStart;
|
|
|
while (rI < resEnd) {
|
|
|
const seqNumber = label_seq_id.value(rI);
|
|
|
-
|
|
|
data.type[rI] = type;
|
|
|
- data.key[rI] = key;
|
|
|
+ data.index[rI] = index;
|
|
|
|
|
|
if ((seqNumber > endSeqNumber) ||
|
|
|
(seqNumber === endSeqNumber && pdbx_PDB_ins_code.value(rI) === endInsCode)) {
|