Explorar o código

Treat empty string as non-present value in BinaryCIF

dsehnal %!s(int64=3) %!d(string=hai) anos
pai
achega
fbb60c9493
Modificáronse 2 ficheiros con 9 adicións e 2 borrados
  1. 1 0
      CHANGELOG.md
  2. 8 2
      src/mol-io/writer/cif/encoder/binary.ts

+ 1 - 0
CHANGELOG.md

@@ -21,6 +21,7 @@ Note that since we don't clearly distinguish between a public and private interf
 - [Breaking] Add style parameter to "illustrative" color theme
     - Defaults to "entity-id" style instead of "chain-id"
 - Add "illustrative" representation preset
+- Bugfix: Automatically treat empty string as "non-present" value in BinaryCIF writer.
 
 ## [v3.0.0-dev.9] - 2022-01-09
 

+ 8 - 2
src/mol-io/writer/cif/encoder/binary.ts

@@ -191,8 +191,14 @@ function getFieldData(field: Field<any, any>, arrayCtor: ArrayCtor<string | numb
                     array[offset] = '';
                 allPresent = false;
             } else {
-                mask[offset] = Column.ValueKind.Present;
-                array[offset] = getter(key, d, offset);
+                const value = getter(key, d, offset);
+                if (typeof value === 'string' && !value) {
+                    mask[offset] = Column.ValueKind.NotPresent;
+                    allPresent = false;
+                } else {
+                    mask[offset] = Column.ValueKind.Present;
+                }
+                array[offset] = value;
             }
             offset++;
         }