Browse Source

more comp_id fixes

Alexander Rose 4 years ago
parent
commit
a59f6546c5

+ 4 - 3
src/cli/structure-info/model.ts

@@ -39,7 +39,7 @@ export function atomLabel(model: Model, aI: number) {
     const { label_asym_id } = chains;
     const rI = residueAtomSegments.index[aI];
     const cI = chainAtomSegments.index[aI];
-    return `${label_asym_id.value(cI)} ${label_comp_id.value(rI)} ${label_seq_id.value(rI)} ${label_atom_id.value(aI)}`;
+    return `${label_asym_id.value(cI)} ${label_comp_id.value(aI)} ${label_seq_id.value(rI)} ${label_atom_id.value(aI)}`;
 }
 
 export function residueLabel(model: Model, rI: number) {
@@ -47,8 +47,9 @@ export function residueLabel(model: Model, rI: number) {
     const { label_comp_id } = atoms;
     const { label_seq_id } = residues;
     const { label_asym_id } = chains;
-    const cI = chainAtomSegments.index[residueAtomSegments.offsets[rI]];
-    return `${label_asym_id.value(cI)} ${label_comp_id.value(rI)} ${label_seq_id.value(rI)}`;
+    const aI = residueAtomSegments.offsets[rI];
+    const cI = chainAtomSegments.index[aI];
+    return `${label_asym_id.value(cI)} ${label_comp_id.value(aI)} ${label_seq_id.value(rI)}`;
 }
 
 export function printSecStructure(model: Model) {

+ 1 - 1
src/examples/proteopedia-wrapper/helpers.ts

@@ -58,7 +58,7 @@ export namespace ModelInfo {
             const entityType = model.entities.data.type.value(eI);
             if (entityType !== 'non-polymer' && entityType !== 'branched') continue;
 
-            const comp_id = model.atomicHierarchy.atoms.label_comp_id.value(rI);
+            const comp_id = model.atomicHierarchy.atoms.label_comp_id.value(residueOffsets[rI]);
 
             let lig = hetMap.get(comp_id);
             if (!lig) {

+ 1 - 1
src/mol-model-props/computed/chemistry/util.ts

@@ -27,7 +27,7 @@ export function altLoc(unit: Unit.Atomic, index: StructureElement.UnitIndex) {
 }
 
 export function compId(unit: Unit.Atomic, index: StructureElement.UnitIndex) {
-    return unit.model.atomicHierarchy.atoms.label_comp_id.value(unit.getResidueIndex(index));
+    return unit.model.atomicHierarchy.atoms.label_comp_id.value(unit.elements[index]);
 }
 
 //

+ 2 - 2
src/mol-model-props/computed/interactions/charged.ts

@@ -67,7 +67,7 @@ function addUnitPositiveCharges(structure: Structure, unit: Unit.Atomic, builder
 
     while (residueIt.hasNext) {
         const { index: residueIndex, start, end } = residueIt.move();
-        const compId = label_comp_id.value(residueIndex);
+        const compId = label_comp_id.value(unit.model.atomicHierarchy.residueAtomSegments.offsets[residueIndex]);
 
         if (PositvelyCharged.includes(compId)) {
             builder.startState();
@@ -120,7 +120,7 @@ function addUnitNegativeCharges(structure: Structure, unit: Unit.Atomic, builder
 
     while (residueIt.hasNext) {
         const { index: residueIndex, start, end } = residueIt.move();
-        const compId = label_comp_id.value(residueIndex);
+        const compId = label_comp_id.value(unit.model.atomicHierarchy.residueAtomSegments.offsets[residueIndex]);
 
         if (NegativelyCharged.includes(compId)) {
             builder.startState();

+ 1 - 1
src/mol-model/structure/structure/carbohydrates/compute.ts

@@ -168,7 +168,7 @@ export function computeCarbohydrates(structure: Structure): Carbohydrates {
             while (residueIt.hasNext) {
                 const { index: residueIndex } = residueIt.move();
 
-                const saccharideComp = getSaccharideComp(label_comp_id.value(residueIndex), model);
+                const saccharideComp = getSaccharideComp(label_comp_id.value(residueAtomSegments.offsets[residueIndex]), model);
                 if (!saccharideComp) continue;
 
                 if (!sugarResidueMap) {

+ 1 - 1
src/mol-model/structure/structure/unit/bonds/intra-compute.ts

@@ -99,7 +99,7 @@ function _computeBonds(unit: Unit.Atomic, props: BondComputationProps): IntraUni
         }
 
         const raI = residueIndex[aI];
-        const compId = label_comp_id.value(raI);
+        const compId = label_comp_id.value(aI);
 
         if (!props.forceCompute && raI !== lastResidue) {
             if (!!component && component.entries.has(compId)) {

+ 1 - 1
src/mol-model/structure/structure/unit/rings.ts

@@ -102,7 +102,7 @@ namespace UnitRing {
         const { type_symbol, label_comp_id } = unit.model.atomicHierarchy.atoms;
 
         // ignore Proline (can be flat because of bad geometry)
-        if (label_comp_id.value(unit.getResidueIndex(ring[0])) === 'PRO') return false;
+        if (label_comp_id.value(unit.elements[ring[0]]) === 'PRO') return false;
 
         let aromaticBondCount = 0;
         let hasAromaticRingElement = false;

+ 0 - 21
src/mol-model/structure/util.ts

@@ -45,27 +45,6 @@ export function getAtomIdForAtomRole(polymerType: PolymerType, atomRole: AtomRol
     return EmptyAtomIds;
 }
 
-export function residueLabel(model: Model, rI: number) {
-    const { atoms, residues, chains, residueAtomSegments, chainAtomSegments } = model.atomicHierarchy;
-    const { label_comp_id } = atoms;
-    const { label_seq_id } = residues;
-    const { label_asym_id } = chains;
-    const cI = chainAtomSegments.index[residueAtomSegments.offsets[rI]];
-    return `${label_asym_id.value(cI)} ${label_comp_id.value(rI)} ${label_seq_id.value(rI)}`;
-}
-
-export function elementLabel(model: Model, index: ElementIndex) {
-    const { atoms, residues, chains, residueAtomSegments, chainAtomSegments } = model.atomicHierarchy;
-    const { label_atom_id, label_comp_id } = atoms;
-    const { auth_seq_id } = residues;
-    const { auth_asym_id } = chains;
-
-    const residueIndex = residueAtomSegments.index[index];
-    const chainIndex = chainAtomSegments.index[residueIndex];
-
-    return `[${label_comp_id.value(residueIndex)}]${auth_seq_id.value(residueIndex)}:${auth_asym_id.value(chainIndex)}.${label_atom_id.value(index)}`;
-}
-
 const tmpPositionsVec = Vec3.zero();
 export function getPositions(unit: Unit, indices: ArrayLike<number>): NumberArray {
     const pos = unit.conformation.position;

+ 1 - 1
src/mol-plugin-ui/sequence/hetero.ts

@@ -81,7 +81,7 @@ export class HeteroSequenceWrapper extends SequenceWrapper<StructureUnit> {
                 sequenceIndices.set(index, sequence.length);
                 residueIndices.set(sequence.length, index);
                 seqToUnit.set(sequence.length, unit);
-                sequence.push(atoms.label_comp_id.value(index));
+                sequence.push(atoms.label_comp_id.value(residueAtomSegments.offsets[index]));
             }
         }
 

+ 1 - 1
src/mol-repr/structure/visual/nucleotide-block-mesh.ts

@@ -75,7 +75,7 @@ function createNucleotideBlockMesh(ctx: VisualContext, unit: Unit, structure: St
             const { index: residueIndex } = residueIt.move();
 
             if (isNucleic(moleculeType[residueIndex])) {
-                const compId = label_comp_id.value(residueIndex);
+                const compId = label_comp_id.value(residueAtomSegments.offsets[residueIndex]);
                 let idx1: ElementIndex | -1 = -1, idx2: ElementIndex | -1 = -1, idx3: ElementIndex | -1 = -1, idx4: ElementIndex | -1 = -1, idx5: ElementIndex | -1 = -1, idx6: ElementIndex | -1 = -1;
                 let width = 4.5, height = 4.5, depth = 2.5 * sizeFactor;
 

+ 1 - 1
src/mol-repr/structure/visual/nucleotide-ring-mesh.ts

@@ -96,7 +96,7 @@ function createNucleotideRingMesh(ctx: VisualContext, unit: Unit, structure: Str
             const { index: residueIndex } = residueIt.move();
 
             if (isNucleic(moleculeType[residueIndex])) {
-                const compId = label_comp_id.value(residueIndex);
+                const compId = label_comp_id.value(residueAtomSegments.offsets[residueIndex]);
 
                 let idxTrace: ElementIndex | -1 = -1, idxN1: ElementIndex | -1 = -1, idxC2: ElementIndex | -1 = -1, idxN3: ElementIndex | -1 = -1, idxC4: ElementIndex | -1 = -1, idxC5: ElementIndex | -1 = -1, idxC6: ElementIndex | -1 = -1, idxN7: ElementIndex | -1 = -1, idxC8: ElementIndex | -1 = -1, idxN9: ElementIndex | -1 = -1;