Browse Source

Merge branch 'master' of https://github.com/molstar/molstar into mp4-export

David Sehnal 4 years ago
parent
commit
d2a3c9c61f

+ 4 - 0
src/mol-canvas3d/camera.ts

@@ -67,6 +67,10 @@ class Camera implements ICamera {
 
     update() {
         const snapshot = this.state as Camera.Snapshot;
+        if (snapshot.radiusMax === 0) {
+            return false;
+        }
+
         const height = 2 * Math.tan(snapshot.fov / 2) * Vec3.distance(snapshot.position, snapshot.target);
         this.zoom = this.viewport.height / height;
 

+ 2 - 0
src/mol-io/writer/mol/encoder.ts

@@ -44,6 +44,8 @@ export class MolEncoder extends LigandEncoder {
             StringBuilder.writeSafe(ctab, '  0  0  0  0  0  0  0  0  0  0\n');
             if (stereo_config !== 'N') chiral = true;
 
+            // no data for metal ions
+            if (!bondMap?.map) return;
             bondMap.map.get(label_atom_id1)!.forEach((bond, label_atom_id2) => {
                 const atom2 = atoms.get(label_atom_id2);
                 if (!atom2) return;

+ 15 - 13
src/mol-io/writer/mol2/encoder.ts

@@ -37,20 +37,22 @@ export class Mol2Encoder extends LigandEncoder {
         StringBuilder.writeSafe(b, '@<TRIPOS>BOND\n');
         atoms.forEach((atom1, label_atom_id1) => {
             const { index: i1 } = atom1;
-            bondMap.map.get(label_atom_id1)!.forEach((bond, label_atom_id2) => {
-                const atom2 = atoms.get(label_atom_id2);
-                if (!atom2) return;
-
-                const { index: i2, type_symbol: type_symbol2 } = atom2;
-                if (i1 < i2 && !this.skipHydrogen(type_symbol2)) {
-                    const { order, flags } = bond;
-                    const ar = BondType.is(BondType.Flag.Aromatic, flags);
-                    StringBuilder.writeSafe(b, `${++bondCount} ${i1 + 1} ${i2 + 1} ${ar ? 'ar' : order}`);
-                    StringBuilder.newline(b);
-                }
-            });
+            if (bondMap?.map) {
+                bondMap.map.get(label_atom_id1)!.forEach((bond, label_atom_id2) => {
+                    const atom2 = atoms.get(label_atom_id2);
+                    if (!atom2) return;
+
+                    const { index: i2, type_symbol: type_symbol2 } = atom2;
+                    if (i1 < i2 && !this.skipHydrogen(type_symbol2)) {
+                        const { order, flags } = bond;
+                        const ar = BondType.is(BondType.Flag.Aromatic, flags);
+                        StringBuilder.writeSafe(b, `${++bondCount} ${i1 + 1} ${i2 + 1} ${ar ? 'ar' : order}`);
+                        StringBuilder.newline(b);
+                    }
+                });
+            }
 
-            const sybyl = this.mapToSybyl(label_atom_id1, atom1.type_symbol, bondMap);
+            const sybyl = bondMap?.map ? this.mapToSybyl(label_atom_id1, atom1.type_symbol, bondMap) : atom1.type_symbol;
             StringBuilder.writeSafe(a, `${i1 + 1} ${label_atom_id1} ${atom1.Cartn_x.toFixed(3)} ${atom1.Cartn_y.toFixed(3)} ${atom1.Cartn_z.toFixed(3)} ${sybyl} 1 ${name} 0.000\n`);
         });
 

+ 2 - 1
src/mol-theme/label.ts

@@ -203,7 +203,8 @@ export function _bundleLabel(bundle: Loci.Bundle<any>, options: LabelOptions) {
 export function elementLabel(location: StructureElement.Location, options: Partial<LabelOptions> = {}): string {
     const o = { ...DefaultLabelOptions, ...options };
     const _label = _elementLabel(location, o.granularity, o.hidePrefix, o.reverse || o.condensed);
-    const label = o.condensed ? _label[0].replace(/\[.*\]/g, '').trim() : _label.filter(l => !!l).join(' | ');
+    // TODO: condensed label for single atom structure returns empty label.. handle this case here?
+    const label = o.condensed ? _label[0]?.replace(/\[.*\]/g, '').trim() ?? '' : _label.filter(l => !!l).join(' | ');
     return o.htmlStyling ? label : stripTags(label);
 }
 

+ 3 - 0
src/servers/model/CHANGELOG.md

@@ -1,3 +1,6 @@
+# 0.9.4
+* bug fix for /ligand queries on metal ions
+
 # 0.9.3
 * optional transform parameter
 

+ 1 - 1
src/servers/model/version.ts

@@ -4,4 +4,4 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-export default '0.9.3';
+export default '0.9.4';