소스 검색

Merge pull request #906 from JonStargaryen/atomcount

ModelServer ligand queries: fix atom count reported by SDF/MOL/MOL2 export
Alexander Rose 1 년 전
부모
커밋
61a351b3d4
5개의 변경된 파일13개의 추가작업 그리고 5개의 파일을 삭제
  1. 1 0
      CHANGELOG.md
  2. 4 2
      src/mol-io/writer/mol/encoder.ts
  3. 4 2
      src/mol-io/writer/mol2/encoder.ts
  4. 3 0
      src/servers/model/CHANGELOG.md
  5. 1 1
      src/servers/model/version.ts

+ 1 - 0
CHANGELOG.md

@@ -8,6 +8,7 @@ Note that since we don't clearly distinguish between a public and private interf
 
 - Do not call `updateFocusRepr` if default `StructureFocusRepresentation` isn't present.
 - Treat "tap" as a click in `InputObserver`
+- ModelServer ligand queries: fix atom count reported by SDF/MOL/MOL2 export
 - CCD extension: Make visuals for aromatic bonds configurable
 - Add optional `file?: CifFile` to `MmcifFormat.data`
 

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

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2020-2023 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Sebastian Bittrich <sebastian.bittrich@rcsb.org>
  */
@@ -29,6 +29,7 @@ export class MolEncoder extends LigandEncoder {
         // happens for the unknown ligands (UNL)
         if (!atomMap) throw Error(`The Chemical Component Dictionary doesn't hold any atom data for ${name}`);
 
+        let atomCount = 0;
         let bondCount = 0;
         let chiral = false;
 
@@ -55,6 +56,7 @@ export class MolEncoder extends LigandEncoder {
             StringBuilder.writeSafe(ctab, '  0');
             StringBuilder.writeIntegerPadLeft(ctab, this.mapCharge(charge), 3);
             StringBuilder.writeSafe(ctab, '  0  0  0  0  0  0  0  0  0  0\n');
+            atomCount++;
             if (stereo_config !== 'n') chiral = true;
 
             // no data for metal ions
@@ -76,7 +78,7 @@ export class MolEncoder extends LigandEncoder {
         });
 
         // write counts line
-        StringBuilder.writeIntegerPadLeft(this.builder, atoms.size, 3);
+        StringBuilder.writeIntegerPadLeft(this.builder, atomCount, 3);
         StringBuilder.writeIntegerPadLeft(this.builder, bondCount, 3);
         StringBuilder.writeSafe(this.builder, `  0  0  ${chiral ? 1 : 0}  0  0  0  0  0  0\n`);
 

+ 4 - 2
src/mol-io/writer/mol2/encoder.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2020-2023 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Sebastian Bittrich <sebastian.bittrich@rcsb.org>
  */
@@ -33,6 +33,7 @@ export class Mol2Encoder extends LigandEncoder {
         const bondMap = this.componentBondData.entries.get(name)!;
         // happens for the unknown ligands (UNL)
         if (!atomMap) throw Error(`The Chemical Component Dictionary doesn't hold any atom data for ${name}`);
+        let atomCount = 0;
         let bondCount = 0;
 
         const atoms = this.getAtoms(instance, source);
@@ -67,10 +68,11 @@ export class Mol2Encoder extends LigandEncoder {
 
             const sybyl = bondMap?.map ? this.mapToSybyl(label_atom_id1, type_symbol1, bondMap) : type_symbol1;
             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`);
+            atomCount++;
         });
 
         // could write something like 'SMALL\nNO_CHARGES', for now let's write **** indicating non-optional, yet missing, string values
-        StringBuilder.writeSafe(this.out, `@<TRIPOS>MOLECULE\n${name}\n${atoms.size} ${bondCount} 1\n****\n****\n\n`);
+        StringBuilder.writeSafe(this.out, `@<TRIPOS>MOLECULE\n${name}\n${atomCount} ${bondCount} 1\n****\n****\n\n`);
         StringBuilder.writeSafe(this.out, StringBuilder.getString(a));
         StringBuilder.writeSafe(this.out, StringBuilder.getString(b));
         StringBuilder.writeSafe(this.out, `@<TRIPOS>SUBSTRUCTURE\n1 ${name} 1\n`);

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

@@ -1,3 +1,6 @@
+# 0.9.10
+* /ligand queries: fix atom count reported by SDF/MOL/MOL2 export
+
 # 0.9.9
 * /ligand queries: fix behavior for alternate locations
 * /ligand queries: handle additional atoms more gracefully

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

@@ -4,4 +4,4 @@
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
-export const VERSION = '0.9.9';
+export const VERSION = '0.9.10';