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 2c96719
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/parser/cif-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1081,20 +1081,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 2c96719

Please sign in to comment.