Browse Source

tweaks to sdf output

JonStargaryen 4 years ago
parent
commit
3b2b87d264
1 changed files with 8 additions and 7 deletions
  1. 8 7
      src/mol-io/writer/sdf/encoder.ts

+ 8 - 7
src/mol-io/writer/sdf/encoder.ts

@@ -68,7 +68,7 @@ export class SdfEncoder implements Encoder<string> {
         // use separate builder because we still need to write Counts and Bonds line
         const ctab = StringBuilder.create();
         const bonds = StringBuilder.create();
-        const charges = StringBuilder.create();
+        // const charges = StringBuilder.create();
 
         // write Atom block and gather data for Bonds and Charges
         const { instance, source } = getCategoryInstanceData(category, context);
@@ -82,7 +82,7 @@ export class SdfEncoder implements Encoder<string> {
 
         // write header
         const name = label_comp_id.value(source[0].keys().move(), source[0].data, 0) as string;
-        StringBuilder.write(this.builder, `${name}\nCreated by ${this.encoder}\n\n`);
+        StringBuilder.write(this.builder, `${name}\n  Created by ${this.encoder}\n\n`);
 
         const bondMap = this.componentData.entries.get(name)!;
         let bondCount = 0;
@@ -99,7 +99,8 @@ export class SdfEncoder implements Encoder<string> {
                     StringBuilder.writeIntegerPadLeft(bonds, i2 + 1, 3);
                     StringBuilder.writeIntegerPadLeft(bonds, order, 3);
                     StringBuilder.writeSafe(bonds, '  0  0  0  0\n');
-                    // TODO 2nd value: Single bonds: 0 = not stereo, 1 = Up, 4 = Either, 6 = Down, Double bonds: 0 = Use x-, y-, z-coords from atom block to determine cis or trans, 3 = Cis or trans (either) double bond
+                    // TODO 3rd value: charge - 0 = uncharged or value other than these, 1 = +3, 2 = +2, 3 = +1, 4 = doublet radical, 5 = -1, 6 = -2, 7 = -3
+                    // TODO optional 2nd value: Single bonds: 0 = not stereo, 1 = Up, 4 = Either, 6 = Down, Double bonds: 0 = Use x-, y-, z-coords from atom block to determine cis or trans, 3 = Cis or trans (either) double bond
                     bondCount++;
                 }
             });
@@ -108,13 +109,13 @@ export class SdfEncoder implements Encoder<string> {
         // write counts line
         StringBuilder.writeIntegerPadLeft(this.builder, atoms.length, 3);
         StringBuilder.writeIntegerPadLeft(this.builder, bondCount, 3);
-        StringBuilder.write(this.builder, '  0     0  0  0  0  0  0999 V2000\n');
-        // TODO 2nd value: chiral flag: 0=not chiral, 1=chiral
+        StringBuilder.write(this.builder, '  0  0  0  0  0  0  0  0  0\n');
+        // TODO optional 2nd value: chiral flag: 0=not chiral, 1=chiral
 
         StringBuilder.writeSafe(this.builder, StringBuilder.getString(ctab));
         StringBuilder.writeSafe(this.builder, StringBuilder.getString(bonds));
-        StringBuilder.writeSafe(this.builder, StringBuilder.getString(charges));
-        // TODO charges?
+        // StringBuilder.writeSafe(this.builder, StringBuilder.getString(charges));
+        // TODO optional charges
 
         StringBuilder.writeSafe(this.builder, 'M  END\n');
     }