Skip to content
Snippets Groups Projects
Commit 72190cf9 authored by David Sehnal's avatar David Sehnal
Browse files

Renamed SecondaryStructure 'index' back to 'key'

parent 1e9bd971
No related branches found
No related tags found
No related merge requests found
...@@ -49,16 +49,16 @@ export function residueLabel(model: Model, rI: number) { ...@@ -49,16 +49,16 @@ export function residueLabel(model: Model, rI: number) {
export function printSecStructure(model: Model) { export function printSecStructure(model: Model) {
console.log('\nSecondary Structure\n============='); console.log('\nSecondary Structure\n=============');
const { residues } = model.atomicHierarchy; const { residues } = model.atomicHierarchy;
const { index, elements } = model.properties.secondaryStructure; const { key, elements } = model.properties.secondaryStructure;
const count = residues._rowCount; const count = residues._rowCount;
let rI = 0; let rI = 0;
while (rI < count) { while (rI < count) {
let start = rI; let start = rI;
while (rI < count && index[start] === index[rI]) rI++; while (rI < count && key[start] === key[rI]) rI++;
rI--; rI--;
const e = elements[index[start]]; const e = elements[key[start]];
if (e.kind !== 'none') console.log(`${e.kind}: ${residueLabel(model, start)} - ${residueLabel(model, rI)}`); if (e.kind !== 'none') console.log(`${e.kind}: ${residueLabel(model, start)} - ${residueLabel(model, rI)}`);
rI++; rI++;
} }
......
...@@ -75,7 +75,7 @@ interface SSElement<T extends SecondaryStructure.Element> { ...@@ -75,7 +75,7 @@ interface SSElement<T extends SecondaryStructure.Element> {
} }
function findElements<T extends SecondaryStructure.Element>(ctx: CifExportContext, kind: SecondaryStructure.Element['kind']) { function findElements<T extends SecondaryStructure.Element>(ctx: CifExportContext, kind: SecondaryStructure.Element['kind']) {
const { index, elements } = ctx.model.properties.secondaryStructure; const { key, elements } = ctx.model.properties.secondaryStructure;
const ssElements: SSElement<any>[] = []; const ssElements: SSElement<any>[] = [];
...@@ -91,7 +91,7 @@ function findElements<T extends SecondaryStructure.Element>(ctx: CifExportContex ...@@ -91,7 +91,7 @@ function findElements<T extends SecondaryStructure.Element>(ctx: CifExportContex
if (move) current = residues.move(); if (move) current = residues.move();
const start = current!.index; const start = current!.index;
const startIdx = index[start]; const startIdx = key[start];
const element = elements[startIdx]; const element = elements[startIdx];
if (element.kind !== kind) { if (element.kind !== kind) {
move = true; move = true;
...@@ -102,7 +102,7 @@ function findElements<T extends SecondaryStructure.Element>(ctx: CifExportContex ...@@ -102,7 +102,7 @@ function findElements<T extends SecondaryStructure.Element>(ctx: CifExportContex
while (residues.hasNext) { while (residues.hasNext) {
prev = current!.index; prev = current!.index;
current = residues.move(); current = residues.move();
if (startIdx !== index[current.index]) { if (startIdx !== key[current.index]) {
move = false; move = false;
ssElements[ssElements.length] = { ssElements[ssElements.length] = {
start: Element.Location(unit, segs.segments[start]), start: Element.Location(unit, segs.segments[start]),
......
...@@ -20,7 +20,7 @@ export function getSecondaryStructureMmCif(data: mmCIF_Database, hierarchy: Atom ...@@ -20,7 +20,7 @@ export function getSecondaryStructureMmCif(data: mmCIF_Database, hierarchy: Atom
const secStruct: SecondaryStructureData = { const secStruct: SecondaryStructureData = {
type: new Int32Array(hierarchy.residues._rowCount) as any, type: new Int32Array(hierarchy.residues._rowCount) as any,
index: new Int32Array(hierarchy.residues._rowCount) as any, key: new Int32Array(hierarchy.residues._rowCount) as any,
elements elements
}; };
...@@ -34,10 +34,10 @@ type SecondaryStructureEntry = { ...@@ -34,10 +34,10 @@ type SecondaryStructureEntry = {
endSeqNumber: number, endSeqNumber: number,
endInsCode: string | null, endInsCode: string | null,
type: SecondaryStructureType, type: SecondaryStructureType,
index: number key: number
} }
type SecondaryStructureMap = Map<string, Map<number, SecondaryStructureEntry>> type SecondaryStructureMap = Map<string, Map<number, SecondaryStructureEntry>>
type SecondaryStructureData = { type: SecondaryStructureType[], index: number[], elements: SecondaryStructure.Element[] } type SecondaryStructureData = { type: SecondaryStructureType[], key: number[], elements: SecondaryStructure.Element[] }
function addHelices(cat: mmCIF['struct_conf'], map: SecondaryStructureMap, elements: SecondaryStructure.Element[]) { function addHelices(cat: mmCIF['struct_conf'], map: SecondaryStructureMap, elements: SecondaryStructure.Element[]) {
if (!cat._rowCount) return; if (!cat._rowCount) return;
...@@ -66,7 +66,7 @@ function addHelices(cat: mmCIF['struct_conf'], map: SecondaryStructureMap, eleme ...@@ -66,7 +66,7 @@ function addHelices(cat: mmCIF['struct_conf'], map: SecondaryStructureMap, eleme
endSeqNumber: end_label_seq_id.value(i), endSeqNumber: end_label_seq_id.value(i),
endInsCode: pdbx_end_PDB_ins_code.value(i), endInsCode: pdbx_end_PDB_ins_code.value(i),
type, type,
index: elements.length key: elements.length
}; };
elements[elements.length] = element; elements[elements.length] = element;
...@@ -112,7 +112,7 @@ function addSheets(cat: mmCIF['struct_sheet_range'], map: SecondaryStructureMap, ...@@ -112,7 +112,7 @@ function addSheets(cat: mmCIF['struct_sheet_range'], map: SecondaryStructureMap,
endSeqNumber: end_label_seq_id.value(i), endSeqNumber: end_label_seq_id.value(i),
endInsCode: pdbx_end_PDB_ins_code.value(i), endInsCode: pdbx_end_PDB_ins_code.value(i),
type, type,
index: elements.length key: elements.length
}; };
elements[elements.length] = element; elements[elements.length] = element;
...@@ -131,13 +131,13 @@ function addSheets(cat: mmCIF['struct_sheet_range'], map: SecondaryStructureMap, ...@@ -131,13 +131,13 @@ function addSheets(cat: mmCIF['struct_sheet_range'], map: SecondaryStructureMap,
function assignSecondaryStructureEntry(hierarchy: AtomicHierarchy, entry: SecondaryStructureEntry, resStart: number, resEnd: number, data: SecondaryStructureData) { function assignSecondaryStructureEntry(hierarchy: AtomicHierarchy, entry: SecondaryStructureEntry, resStart: number, resEnd: number, data: SecondaryStructureData) {
const { label_seq_id, pdbx_PDB_ins_code } = hierarchy.residues; const { label_seq_id, pdbx_PDB_ins_code } = hierarchy.residues;
const { endSeqNumber, endInsCode, index, type } = entry; const { endSeqNumber, endInsCode, key, type } = entry;
let rI = resStart; let rI = resStart;
while (rI < resEnd) { while (rI < resEnd) {
const seqNumber = label_seq_id.value(rI); const seqNumber = label_seq_id.value(rI);
data.type[rI] = type; data.type[rI] = type;
data.index[rI] = index; data.key[rI] = key;
if ((seqNumber > endSeqNumber) || if ((seqNumber > endSeqNumber) ||
(seqNumber === endSeqNumber && pdbx_PDB_ins_code.value(rI) === endInsCode)) { (seqNumber === endSeqNumber && pdbx_PDB_ins_code.value(rI) === endInsCode)) {
......
...@@ -11,7 +11,7 @@ interface SecondaryStructure { ...@@ -11,7 +11,7 @@ interface SecondaryStructure {
readonly type: ArrayLike<SecondaryStructureType>, readonly type: ArrayLike<SecondaryStructureType>,
/** index into the elements array */ /** index into the elements array */
readonly index: ArrayLike<number>, readonly key: ArrayLike<number>,
/** indexed by key */ /** indexed by key */
readonly elements: ReadonlyArray<SecondaryStructure.Element> readonly elements: ReadonlyArray<SecondaryStructure.Element>
} }
......
...@@ -59,7 +59,7 @@ const residue = { ...@@ -59,7 +59,7 @@ const residue = {
// Properties // Properties
secondary_structure_type: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.properties.secondaryStructure.type[l.unit.residueIndex[l.element]]), secondary_structure_type: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.properties.secondaryStructure.type[l.unit.residueIndex[l.element]]),
secondary_structure_key: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.properties.secondaryStructure.index[l.unit.residueIndex[l.element]]), secondary_structure_key: Element.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.properties.secondaryStructure.key[l.unit.residueIndex[l.element]]),
} }
const chain = { const chain = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment