Skip to content

Commit

Permalink
fix: alt-loc is always empty
Browse files Browse the repository at this point in the history
The CIF library returns `0` when a string column is converted to an int array.
The fix here is to map the string array from the column using the String.charCodeAt() function.
  • Loading branch information
papillot committed May 21, 2024
1 parent bc0fda4 commit c63fbd6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/parser/cif-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -979,8 +979,12 @@ class CifParser extends StructureParser {
atomStore.serial = atomSite.getField('id')!.toIntArray({start: 0, end: numAtoms}) as unknown as Int32Array
atomStore.bfactor = getFieldAsFloat32(atomSite, 'B_iso_or_equiv', numAtoms)
atomStore.occupancy = getFieldAsFloat32(atomSite, 'occupancy', numAtoms)
atomStore.altloc = atomSite.getField('label_alt_id')!.toIntArray({array: Uint8Array, start: 0, end: numAtoms}) as unknown as Uint8Array


const altlocField = atomSite.getField('label_alt_id')
if (altlocField?.isDefined) {
atomStore.altloc = Uint8Array.from(altlocField.toStringArray(), c => c.charCodeAt(0))
}

const atomnameField = atomSite.getField('label_atom_id')
const elementField = atomSite.getField('type_symbol')
resnameField = atomSite.getField('label_comp_id')!
Expand Down

0 comments on commit c63fbd6

Please sign in to comment.