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

mol-model & formats: added fallback when chem_comp category is missing

parent da1deee7
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ import { getSecondaryStructure } from './secondary-structure';
import { getSequence } from './sequence';
import { sortAtomSite } from './sort';
import { StructConn } from './bonds/struct_conn';
import { getMoleculeType, MoleculeType, getEntityType, getEntitySubtype } from '../../../mol-model/structure/model/types';
import { getMoleculeType, MoleculeType, getEntityType, getEntitySubtype, getDefaultChemicalComponent } from '../../../mol-model/structure/model/types';
import { ModelFormat } from '../format';
import { SaccharideComponentMap, SaccharideComponent, SaccharidesSnfgMap, SaccharideCompIdMap, UnknownSaccharideComponent } from '../../../mol-model/structure/structure/carbohydrates/constants';
import mmCIF_Format = ModelFormat.mmCIF
......@@ -127,10 +127,18 @@ function getMissingResidues(format: mmCIF_Format): Model['properties']['missingR
function getChemicalComponentMap(format: mmCIF_Format): Model['properties']['chemicalComponentMap'] {
const map = new Map<string, ChemicalComponent>();
const { chem_comp } = format.data
if (chem_comp._rowCount > 0) {
const { id } = chem_comp
for (let i = 0, il = id.rowCount; i < il; ++i) {
map.set(id.value(i), Table.getRow(chem_comp, i))
}
} else {
const uniqueNames = getUniqueComponentNames(format);
uniqueNames.forEach(n => {
map.set(n, getDefaultChemicalComponent(n));
});
}
return map
}
......
......@@ -9,7 +9,7 @@ import BitFlags from '../../../mol-util/bit-flags'
import { SaccharideCompIdMap } from '../structure/carbohydrates/constants';
import { mmCIF_Schema } from '../../../mol-io/reader/cif/schema/mmcif';
import { SetUtils } from '../../../mol-util/set';
import { EntitySubtype } from './properties/common';
import { EntitySubtype, ChemicalComponent } from './properties/common';
const _esCache = (function () {
const cache = Object.create(null);
......@@ -245,6 +245,20 @@ export function getComponentType(compId: string): mmCIF_Schema['chem_comp']['typ
}
}
export function getDefaultChemicalComponent(compId: string): ChemicalComponent {
// TODO: this is to make the chem_comp_type property work if chem_comp category is not present.
// should we try to set the formula etc better?
return {
formula: '',
formula_weight: 0,
id: compId,
name: compId,
mon_nstd_flag: 'n',
pdbx_synonyms: [],
type: getComponentType(compId)
};
}
export function getEntityType(compId: string): mmCIF_Schema['entity']['type']['T'] {
compId = compId.toUpperCase()
if (WaterNames.has(compId)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment