diff --git a/src/mol-io/reader/common/column.ts b/src/mol-io/reader/common/column.ts index 2e0ffcf480456a5f828f018544b2b0e25b5f9bd4..3517030320e279a5701720cec03365e021381301 100644 --- a/src/mol-io/reader/common/column.ts +++ b/src/mol-io/reader/common/column.ts @@ -4,14 +4,15 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -export type ColumnType = typeof ColumnType.str | typeof ColumnType.int | typeof ColumnType.float | typeof ColumnType.vector | typeof ColumnType.matrix +export type ColumnType = typeof ColumnType.str | typeof ColumnType.pooledStr | typeof ColumnType.int | typeof ColumnType.float | typeof ColumnType.vector | typeof ColumnType.matrix export namespace ColumnType { - export const str = { '@type': '' as string, kind: 'str' as 'str', isScalar: false }; - export const int = { '@type': 0 as number, kind: 'int' as 'int', isScalar: true }; - export const float = { '@type': 0 as number, kind: 'float' as 'float', isScalar: true }; - export const vector = { '@type': [] as number[], kind: 'vector' as 'vector', isScalar: false }; - export const matrix = { '@type': [] as number[][], kind: 'matrix' as 'matrix', isScalar: false }; + export const str = { '@type': '' as string, kind: 'str' as 'str', isScalar: false, isString: true }; + export const pooledStr = { '@type': '' as string, kind: 'pooled-str' as 'pooled-str', isScalar: false, isString: true }; + export const int = { '@type': 0 as number, kind: 'int' as 'int', isScalar: true, isString: false }; + export const float = { '@type': 0 as number, kind: 'float' as 'float', isScalar: true, isString: false }; + export const vector = { '@type': [] as number[], kind: 'vector' as 'vector', isScalar: false, isString: false }; + export const matrix = { '@type': [] as number[][], kind: 'matrix' as 'matrix', isScalar: false, isString: false }; } export interface ToArrayParams { @@ -76,12 +77,10 @@ export function ArrayColumn<T extends ColumnType>({ array, type, isValueDefined for (let i = 0, _i = end - start; i < _i; i++) ret[i] = array[start + i]; return ret; }, - stringEquals: isTyped + stringEquals: type.isScalar ? (row, value) => (array as any)[row] === +value - : type.kind === 'str' + : type.isString ? (row, value) => array[row] === value - : type.isScalar - ? (row, value) => array[row] === '' + value : (row, value) => false, areValuesEqual: (rowA, rowB) => array[rowA] === array[rowB] } diff --git a/src/mol-io/reader/common/text/column/fixed.ts b/src/mol-io/reader/common/text/column/fixed.ts index fb7534e85c8736929bbd740e8fb7a0fb76475f8e..f4b36de8d1d046a66edc4f3e3fe9ef780539b1f8 100644 --- a/src/mol-io/reader/common/text/column/fixed.ts +++ b/src/mol-io/reader/common/text/column/fixed.ts @@ -42,6 +42,7 @@ export function FixedColumn<T extends ColumnType>(lines: Tokens, offset: number, return parseFloatSkipLeadingWhitespace(data, s, s + width); }; return { + '@type': type, isDefined: true, rowCount, value, diff --git a/src/mol-io/reader/common/text/column/token.ts b/src/mol-io/reader/common/text/column/token.ts index adfc613d074c1e030fa212ed0fee0c4b61935c74..ae203b1fa02e125d7cb4c06096cd9bcde4de7495 100644 --- a/src/mol-io/reader/common/text/column/token.ts +++ b/src/mol-io/reader/common/text/column/token.ts @@ -30,6 +30,7 @@ export function TokenColumn<T extends ColumnType>(tokens: Tokens, type: T): Colu : row => fastParseFloat(data, indices[2 * row], indices[2 * row + 1]) || 0; return { + '@type': type, isDefined: true, rowCount, value,