Skip to content
Snippets Groups Projects
Commit c5e64b39 authored by David Sehnal's avatar David Sehnal
Browse files

mol-model-formats: mmCIF substitute undefined atom_site.label_* with auth_*...

mol-model-formats: mmCIF substitute undefined atom_site.label_* with auth_* columns (and vice versa)
parent 4911585a
Branches
Tags
No related merge requests found
...@@ -42,6 +42,15 @@ function findHierarchyOffsets(atom_site: AtomSite) { ...@@ -42,6 +42,15 @@ function findHierarchyOffsets(atom_site: AtomSite) {
return { residues, chains }; return { residues, chains };
} }
function substUndefinedColumn<T extends Table<any>>(table: T, a: keyof T, b: keyof T) {
if (!(table as any)[a].isDefined) {
(table as any)[a] = (table as any)[b];
}
if (!(table as any)[b].isDefined) {
(table as any)[b] = (table as any)[a];
}
}
function createHierarchyData(atom_site: AtomSite, sourceIndex: Column<number>, offsets: { residues: ArrayLike<number>, chains: ArrayLike<number> }): AtomicData { function createHierarchyData(atom_site: AtomSite, sourceIndex: Column<number>, offsets: { residues: ArrayLike<number>, chains: ArrayLike<number> }): AtomicData {
const atoms = Table.ofColumns(AtomsSchema, { const atoms = Table.ofColumns(AtomsSchema, {
type_symbol: Column.ofArray({ array: Column.mapToArray(atom_site.type_symbol, ElementSymbol), schema: Column.Schema.Aliased<ElementSymbol>(Column.Schema.str) }), type_symbol: Column.ofArray({ array: Column.mapToArray(atom_site.type_symbol, ElementSymbol), schema: Column.Schema.Aliased<ElementSymbol>(Column.Schema.str) }),
...@@ -51,11 +60,20 @@ function createHierarchyData(atom_site: AtomSite, sourceIndex: Column<number>, o ...@@ -51,11 +60,20 @@ function createHierarchyData(atom_site: AtomSite, sourceIndex: Column<number>, o
pdbx_formal_charge: atom_site.pdbx_formal_charge, pdbx_formal_charge: atom_site.pdbx_formal_charge,
sourceIndex sourceIndex
}); });
const residues = Table.view(atom_site, ResiduesSchema, offsets.residues); const residues = Table.view(atom_site, ResiduesSchema, offsets.residues);
// Optimize the numeric columns // Optimize the numeric columns
Table.columnToArray(residues, 'label_seq_id', Int32Array); Table.columnToArray(residues, 'label_seq_id', Int32Array);
Table.columnToArray(residues, 'auth_seq_id', Int32Array); Table.columnToArray(residues, 'auth_seq_id', Int32Array);
const chains = Table.view(atom_site, ChainsSchema, offsets.chains); const chains = Table.view(atom_site, ChainsSchema, offsets.chains);
// Fix possibly missing auth_/label_ columns
substUndefinedColumn(residues, 'label_seq_id', 'auth_seq_id');
substUndefinedColumn(atoms, 'label_atom_id', 'auth_atom_id');
substUndefinedColumn(residues, 'label_comp_id', 'auth_comp_id');
substUndefinedColumn(chains, 'label_asym_id', 'auth_asym_id');
return { atoms, residues, chains }; return { atoms, residues, chains };
} }
......
...@@ -132,10 +132,7 @@ export class Sequence<P extends SequenceProps> extends PluginUIComponent<P> { ...@@ -132,10 +132,7 @@ export class Sequence<P extends SequenceProps> extends PluginUIComponent<P> {
const l = StructureElement.Loci.getFirstLocation(loci, this.location); const l = StructureElement.Loci.getFirstLocation(loci, this.location);
if (l) { if (l) {
if (Unit.isAtomic(l.unit)) { if (Unit.isAtomic(l.unit)) {
const { residues } = l.unit.model.atomicHierarchy const seqId = StructureProperties.residue.auth_seq_id(l)
const seqId = residues.auth_seq_id.isDefined
? StructureProperties.residue.auth_seq_id(l)
: StructureProperties.residue.label_seq_id(l)
const insCode = StructureProperties.residue.pdbx_PDB_ins_code(l) const insCode = StructureProperties.residue.pdbx_PDB_ins_code(l)
sequenceNumber = `${seqId}${insCode ? insCode : ''}` sequenceNumber = `${seqId}${insCode ? insCode : ''}`
} else if (Unit.isCoarse(l.unit)) { } else if (Unit.isCoarse(l.unit)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment