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) {
export function printSecStructure(model: Model) {
console.log('\nSecondary Structure\n=============');
const { residues } = model.atomicHierarchy;
const { index, elements } = model.properties.secondaryStructure;
const { key, elements } = model.properties.secondaryStructure;
const count = residues._rowCount;
let rI = 0;
while (rI < count) {
let start = rI;
while (rI < count && index[start] === index[rI]) rI++;
while (rI < count && key[start] === key[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)}`);
rI++;
}
......
......@@ -75,7 +75,7 @@ interface SSElement<T extends SecondaryStructure.Element> {
}
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>[] = [];
......@@ -91,7 +91,7 @@ function findElements<T extends SecondaryStructure.Element>(ctx: CifExportContex
if (move) current = residues.move();
const start = current!.index;
const startIdx = index[start];
const startIdx = key[start];
const element = elements[startIdx];
if (element.kind !== kind) {
move = true;
......@@ -102,7 +102,7 @@ function findElements<T extends SecondaryStructure.Element>(ctx: CifExportContex
while (residues.hasNext) {
prev = current!.index;
current = residues.move();
if (startIdx !== index[current.index]) {
if (startIdx !== key[current.index]) {
move = false;
ssElements[ssElements.length] = {
start: Element.Location(unit, segs.segments[start]),
......
......@@ -20,7 +20,7 @@ export function getSecondaryStructureMmCif(data: mmCIF_Database, hierarchy: Atom
const secStruct: SecondaryStructureData = {
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
};
......@@ -34,10 +34,10 @@ type SecondaryStructureEntry = {
endSeqNumber: number,
endInsCode: string | null,
type: SecondaryStructureType,
index: number
key: number
}
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[]) {
if (!cat._rowCount) return;
......@@ -66,7 +66,7 @@ function addHelices(cat: mmCIF['struct_conf'], map: SecondaryStructureMap, eleme
endSeqNumber: end_label_seq_id.value(i),
endInsCode: pdbx_end_PDB_ins_code.value(i),
type,
index: elements.length
key: elements.length
};
elements[elements.length] = element;
......@@ -112,7 +112,7 @@ function addSheets(cat: mmCIF['struct_sheet_range'], map: SecondaryStructureMap,
endSeqNumber: end_label_seq_id.value(i),
endInsCode: pdbx_end_PDB_ins_code.value(i),
type,
index: elements.length
key: elements.length
};
elements[elements.length] = element;
......@@ -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) {
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;
while (rI < resEnd) {
const seqNumber = label_seq_id.value(rI);
data.type[rI] = type;
data.index[rI] = index;
data.key[rI] = key;
if ((seqNumber > endSeqNumber) ||
(seqNumber === endSeqNumber && pdbx_PDB_ins_code.value(rI) === endInsCode)) {
......
......@@ -11,7 +11,7 @@ interface SecondaryStructure {
readonly type: ArrayLike<SecondaryStructureType>,
/** index into the elements array */
readonly index: ArrayLike<number>,
readonly key: ArrayLike<number>,
/** indexed by key */
readonly elements: ReadonlyArray<SecondaryStructure.Element>
}
......
......@@ -59,7 +59,7 @@ const residue = {
// 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_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 = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment