JonStargaryen 3 роки тому
батько
коміт
e0fe7e6f64
3 змінених файлів з 67 додано та 4 видалено
  1. 11 1
      src/viewer/helpers/selection.ts
  2. 45 0
      src/viewer/index.html
  3. 11 3
      src/viewer/ui/strucmotif.tsx

+ 11 - 1
src/viewer/helpers/selection.ts

@@ -64,11 +64,21 @@ export function normalizeTargets(targets: Target[], structure: Structure, operat
 }
 
 function toOperatorName(structure: Structure, expression: string): string {
+    function join(opers: any[]) {
+        // this makes the assumptions that '1' is the identity operator
+        if (!opers || !opers.length) return '1';
+        if (opers.length > 1) {
+            // Mol* operators are right-to-left
+            return opers[1] + 'x' + opers[0];
+        }
+        return opers[0];
+    }
+
     for (const unit of structure.units) {
         const assembly = unit.conformation.operator.assembly;
         if (!assembly) continue;
 
-        if (expression === assembly.operList.join('x')) return `ASM_${assembly.operId}`;
+        if (expression === join(assembly.operList)) return `ASM_${assembly.operId}`;
     }
     // TODO better error handling?
     throw Error(`Unable to find expression '${expression}'`);

+ 45 - 0
src/viewer/index.html

@@ -90,6 +90,9 @@
             <button style="padding: 3px;" onclick="motifs1()">Motifs 1</button>
             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
+            <button style="padding: 3px;" onclick="motifs2()">Motifs 2</button>
+            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+
             <button style="padding: 3px" onclick="propset()">Propset</button>
         </div>
         <script>
@@ -446,6 +449,48 @@
                     });
             }
 
+            function motifs2() {
+                viewer.clear()
+                    .then(function() {
+                        return viewer.loadPdbIds([{
+                            pdbId: '1M4X',
+                            props: {
+                                label: '1M4X',
+                                kind: 'motif',
+                                // assemblyId: '7', // library should be able to infer assemblyId of the query
+                                targets: [
+                                    { label_asym_id: 'C', label_seq_id: 161, struct_oper_id: 'Px81' },
+                                    { label_asym_id: 'C', label_seq_id: 165, struct_oper_id: 'Px81' },
+                                    { label_asym_id: 'C', label_seq_id: 170, struct_oper_id: 'Px81' }
+                                ],
+                                // color: 13203230
+                            }
+                        }, {
+                            pdbId: '6Z1U',
+                            props: {
+                                label: '6Z1U',
+                                kind: 'motif',
+                                assemblyId: '1',
+                                targets: [
+                                    { label_asym_id: 'B', label_seq_id: 318 },
+                                    { label_asym_id: 'B', label_seq_id: 313 },
+                                    { label_asym_id: 'B', label_seq_id: 140 }
+                                ],
+                                // color: 13203230
+                            },
+                            matrix: [
+                                0.06100543003250275, 0.970442655069822, 0.23349387728072024, 0,
+                                -0.12571833183698783, -0.22459600865041415, 0.9663081982154702, 0,
+                                0.990188486373516, -0.08830450792195021, 0.10830085564753325, 0,
+                                -446.93412657022236, 100.02208856523754, 351.2076146944444, 1
+                            ]
+                        }]);
+                    })
+                    .then(function() {
+                        viewer.resetCamera(0)
+                    });
+            }
+
             function propset() {
                 viewer.clear()
                     .then(function () {

+ 11 - 3
src/viewer/ui/strucmotif.tsx

@@ -117,6 +117,16 @@ class SubmitControls extends PurePluginUIComponent<{}, { isBusy: boolean, residu
             return false;
         };
 
+        function join(opers: any[]) {
+            // this makes the assumptions that '1' is the identity operator
+            if (!opers || !opers.length) return '1';
+            if (opers.length > 1) {
+                // Mol* operators are right-to-left
+                return opers[1] + 'x' + opers[0];
+            }
+            return opers[0];
+        }
+
         const loci = this.plugin.managers.structure.selection.additionsHistory;
         for (let i = 0; i < Math.min(MAX_MOTIF_SIZE, loci.length); i++) {
             const l = loci[i];
@@ -124,9 +134,7 @@ class SubmitControls extends PurePluginUIComponent<{}, { isBusy: boolean, residu
             pdbId.add(structure.model.entry);
 
             const struct_oper_list_ids = StructureProperties.unit.pdbx_struct_oper_list_ids(location);
-            // this makes the assumptions that '1' is the identity operator
-            // TODO is the order always correct or does Mol* sometimes gives right-to-left order?
-            const struct_oper_id = struct_oper_list_ids?.length ? struct_oper_list_ids.join('x') : '1';
+            const struct_oper_id = join(struct_oper_list_ids);
 
             // only first element and only first index will be considered (ignoring multiple residues)
             if (!determineBackboneAtom(structure, elements[0])) {