Skip to content

Commit

Permalink
fix: float(i) returns 0 if value is missing
Browse files Browse the repository at this point in the history
valueKind has 3 values: 0 if present, 1 if not present ('.' in Cif), 2 if unknown ('?' in Cif)
  • Loading branch information
papillot committed Apr 28, 2024
1 parent 0f37a74 commit d93a5e3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/parser/cif-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { Structure } from '../ngl';
import StructureBuilder from '../structure/structure-builder';
import { NumberArray } from '../types'
import ChemCompMap from '../store/chemcomp-map'
import { Column } from 'molstar/lib/mol-data/db/column'

Check failure on line 26 in src/parser/cif-parser.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

'Column' is declared but its value is never read.

Check failure on line 26 in src/parser/cif-parser.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'Column' is declared but its value is never read.

const reAtomSymbol = /^\D{1,2}/ // atom symbol in atom_site_label

Expand Down Expand Up @@ -1081,20 +1082,20 @@ class CifParser extends StructureParser {
}

if (field = cif.categories.reflns?.getField('d_resolution_high') ?? cif.categories.refine?.getField('ls_d_res_high')) {
if (Number.isFinite(valData = field.float(0))) {
s.header.resolution = valData
if (field.valueKind(0) === 0) { // is value present?
s.header.resolution = field.float(0)
}
}

if ( field = cif.categories.refine?.getField('ls_R_factor_R_free')) {
if (Number.isFinite(valData = field.float(0))) {
s.header.rFree = valData
if (field.valueKind(0) === 0) { // is value present?
s.header.rFree = field.float(0)
}
}

if ( field = cif.categories.refine?.getField('ls_R_factor_R_work')) {
if (Number.isFinite(valData = field.float(0))) {
s.header.rFree = valData
if (field.valueKind(0) === 0) { // is value present?
s.header.rFree = field.float(0)
}
}

Expand Down

0 comments on commit d93a5e3

Please sign in to comment.