Browse Source

Merge "single residue units" together in Structure.ofModel

David Sehnal 6 years ago
parent
commit
52a8a0e55b

+ 5 - 6
src/apps/structure-info/model.ts

@@ -99,10 +99,9 @@ export function printLinks(structure: Structure, showIntra: boolean, showInter:
             if (!Unit.isAtomic(unit)) continue;
 
             for (const pairLinks of links.getLinkedUnits(unit)) {
-                if (!pairLinks.areUnitsOrdered) continue;
+                if (!pairLinks.areUnitsOrdered || pairLinks.bondCount === 0) continue;
 
                 const { unitA, unitB } = pairLinks;
-
                 console.log(`${pairLinks.unitA.id} - ${pairLinks.unitB.id}: ${pairLinks.bondCount} bond(s)`);
 
                 for (const aI of pairLinks.linkedElementIndices) {
@@ -193,12 +192,12 @@ export function printIHMModels(model: Model) {
 async function run(mmcif: mmCIF_Database) {
     const models = await Model.create({ kind: 'mmCIF', data: mmcif }).run();
     const structure = Structure.ofModel(models[0]);
-    printSequence(models[0]);
+    //printSequence(models[0]);
     //printIHMModels(models[0]);
     printUnits(structure);
-    printRings(structure);
-    printLinks(structure, false, true);
-    printModRes(models[0]);
+    //printRings(structure);
+    printLinks(structure, true, true);
+    //printModRes(models[0]);
     //printSecStructure(models[0]);
 }
 

+ 1 - 0
src/mol-app/skin/components/sequence-view.scss

@@ -5,4 +5,5 @@
     left: 0;
     bottom: 0;
     overflow: hidden;
+    overflow-x: scroll;
 }

+ 3 - 2
src/mol-model/structure/model/formats/mmcif.ts

@@ -39,11 +39,12 @@ function findHierarchyOffsets({ data }: mmCIF_Format, bounds: Interval) {
     const start = Interval.start(bounds), end = Interval.end(bounds);
     const residues = [start], chains = [start];
 
-    const { label_entity_id, auth_asym_id, auth_seq_id, pdbx_PDB_ins_code, label_comp_id } = data.atom_site;
+    const { label_entity_id, label_asym_id, label_seq_id, auth_seq_id, pdbx_PDB_ins_code, label_comp_id } = data.atom_site;
 
     for (let i = start + 1; i < end; i++) {
-        const newChain = !label_entity_id.areValuesEqual(i - 1, i) || !auth_asym_id.areValuesEqual(i - 1, i);
+        const newChain = !label_entity_id.areValuesEqual(i - 1, i) || !label_asym_id.areValuesEqual(i - 1, i);
         const newResidue = newChain
+            || !label_seq_id.areValuesEqual(i - 1, i)
             || !auth_seq_id.areValuesEqual(i - 1, i)
             || !pdbx_PDB_ins_code.areValuesEqual(i - 1, i)
             || !label_comp_id.areValuesEqual(i - 1, i);

+ 14 - 1
src/mol-model/structure/structure/structure.ts

@@ -98,8 +98,21 @@ namespace Structure {
         const chains = model.atomicHierarchy.chainSegments;
         const builder = new StructureBuilder();
 
+        const { residueSegments: { segmentMap: residueIndex } } = model.atomicHierarchy;
+
         for (let c = 0; c < chains.count; c++) {
-            const elements = SortedArray.ofBounds(chains.segments[c], chains.segments[c + 1]);
+            const start = chains.segments[c];
+            let end = chains.segments[c + 1];
+
+            let rStart = residueIndex[start], rEnd = residueIndex[end - 1];
+            while (rEnd - rStart <= 1 && c + 1 < chains.count) {
+                c++;
+                end = chains.segments[c + 1];
+                rStart = rEnd;
+                rEnd = residueIndex[end - 1];
+            }
+
+            const elements = SortedArray.ofBounds(start, end);
             builder.addUnit(Unit.Kind.Atomic, model, SymmetryOperator.Default, elements);
         }
 

+ 1 - 1
src/mol-view/stage.ts

@@ -39,7 +39,7 @@ export class Stage {
         this.viewer = Viewer.create(canvas, container)
         this.viewer.animate()
         this.ctx.viewer = this.viewer
-        // this.loadPdbid('1crn')
+        //this.loadPdbid('1jj2')
         this.loadMmcifUrl(`../../examples/1cbs_full.bcif`)
     }