Explorar el Código

replace encoding string with union type

Sebastian Bittrich hace 5 años
padre
commit
df6b163505
Se han modificado 2 ficheros con 31 adiciones y 3 borrados
  1. 27 0
      src/mol-io/writer/_spec/cif.spec.ts
  2. 4 3
      src/mol-io/writer/cif.ts

+ 27 - 0
src/mol-io/writer/_spec/cif.spec.ts

@@ -0,0 +1,27 @@
+import { CifWriter } from '../cif';
+
+const cif = await downloadFromPdb('1brr')
+const encoder = CifWriter.createEncoder({
+    binary: true,
+    encoderName: 'mol*',
+    binaryAutoClassifyEncoding: true,
+    binaryEncodingPovider: CifWriter.createEncodingProviderFromJsonConfig([
+        {
+            'categoryName': 'atom_site',
+            'columnName': 'Cartn_y',
+            'encoding': 'rle',
+            'precision': 0
+        },
+        {
+            'categoryName': 'atom_site',
+            'columnName': 'Cartn_z',
+            'encoding': 'delta',
+            'precision': 1
+        },
+        {
+            'categoryName': 'atom_site',
+            'columnName': 'label_seq_id',
+            'encoding': 'delta-rle'
+        }
+    ])
+});

+ 4 - 3
src/mol-io/writer/cif.ts

@@ -103,8 +103,9 @@ export namespace CifWriter {
 export interface EncodingStrategyHint {
     categoryName: string,
     columnName: string,
-    // 'pack', 'rle', 'delta', or 'delta-rle'
-    encoding: string,
+    encoding: EncodingType,
     // number of decimal places to keep - must be specified to float columns
     precision?: number
-}
+}
+
+type EncodingType = 'pack' | 'rle' | 'delta' | 'delta-rle'