Skip to content
Snippets Groups Projects
Commit d8adf7c5 authored by Alexander Rose's avatar Alexander Rose
Browse files

get saccharide component from 'SNFG CARB SYMBOL' pdbx_chem_comp_identifier.type when available

parent 4e6a08c9
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,7 @@ import { ChemicalComponent, ChemicalComponentMap } from '../properties/chemical- ...@@ -27,6 +27,7 @@ import { ChemicalComponent, ChemicalComponentMap } from '../properties/chemical-
import { ComponentType, getMoleculeType } from '../types'; import { ComponentType, getMoleculeType } from '../types';
import mmCIF_Format = Format.mmCIF import mmCIF_Format = Format.mmCIF
import { SaccharideComponentMap, SaccharideComponent, SaccharidesSnfgMap, UnknownSaccharideComponent, SaccharideCompIdMap } from 'mol-model/structure/structure/carbohydrates/constants';
type AtomSite = mmCIF_Database['atom_site'] type AtomSite = mmCIF_Database['atom_site']
...@@ -125,17 +126,41 @@ function getChemicalComponentMap(format: mmCIF_Format): ChemicalComponentMap { ...@@ -125,17 +126,41 @@ function getChemicalComponentMap(format: mmCIF_Format): ChemicalComponentMap {
return map return map
} }
function getSaccharideComponentMap(format: mmCIF_Format): SaccharideComponentMap {
const map = new Map<string, SaccharideComponent>();
const { pdbx_chem_comp_identifier } = format.data
if (pdbx_chem_comp_identifier._rowCount > 0) {
const { type, comp_id, identifier } = pdbx_chem_comp_identifier
for (let i = 0, il = pdbx_chem_comp_identifier._rowCount; i < il; ++i) {
if (type.value(i) === 'SNFG CARB SYMBOL') {
const snfgName = identifier.value(i)
const saccharideComp = SaccharidesSnfgMap.get(snfgName)
if (saccharideComp) {
map.set(comp_id.value(i), saccharideComp)
} else {
console.warn(`Unknown SNFG name '${snfgName}'`)
}
}
}
return map
} else {
return SaccharideCompIdMap
}
}
export interface FormatData { export interface FormatData {
modifiedResidues: Model['properties']['modifiedResidues'] modifiedResidues: Model['properties']['modifiedResidues']
asymIdSerialMap: Model['properties']['asymIdSerialMap'] asymIdSerialMap: Model['properties']['asymIdSerialMap']
chemicalComponentMap: Model['properties']['chemicalComponentMap'] chemicalComponentMap: Model['properties']['chemicalComponentMap']
saccharideComponentMap: Model['properties']['saccharideComponentMap']
} }
function getFormatData(format: mmCIF_Format): FormatData { function getFormatData(format: mmCIF_Format): FormatData {
return { return {
modifiedResidues: getModifiedResidueNameMap(format), modifiedResidues: getModifiedResidueNameMap(format),
asymIdSerialMap: getAsymIdSerialMap(format), asymIdSerialMap: getAsymIdSerialMap(format),
chemicalComponentMap: getChemicalComponentMap(format) chemicalComponentMap: getChemicalComponentMap(format),
saccharideComponentMap: getSaccharideComponentMap(format)
} }
} }
......
...@@ -16,6 +16,7 @@ import { SecondaryStructure } from './properties/seconday-structure'; ...@@ -16,6 +16,7 @@ import { SecondaryStructure } from './properties/seconday-structure';
import from_mmCIF from './formats/mmcif' import from_mmCIF from './formats/mmcif'
import { ChemicalComponentMap } from './properties/chemical-component'; import { ChemicalComponentMap } from './properties/chemical-component';
import { SaccharideComponentMap } from '../structure/carbohydrates/constants';
/** /**
* Interface to the "source data" of the molecule. * Interface to the "source data" of the molecule.
...@@ -50,6 +51,8 @@ export interface Model extends Readonly<{ ...@@ -50,6 +51,8 @@ export interface Model extends Readonly<{
readonly asymIdSerialMap: ReadonlyMap<string, number> readonly asymIdSerialMap: ReadonlyMap<string, number>
/** maps residue name to `ChemicalComponent` data */ /** maps residue name to `ChemicalComponent` data */
readonly chemicalComponentMap: ChemicalComponentMap readonly chemicalComponentMap: ChemicalComponentMap
/** maps residue name to `SaccharideComponent` data */
readonly saccharideComponentMap: SaccharideComponentMap
}, },
customProperties: CustomProperties, customProperties: CustomProperties,
......
...@@ -11,13 +11,13 @@ import { IntAdjacencyGraph } from 'mol-math/graph'; ...@@ -11,13 +11,13 @@ import { IntAdjacencyGraph } from 'mol-math/graph';
import { Vec3 } from 'mol-math/linear-algebra'; import { Vec3 } from 'mol-math/linear-algebra';
import PrincipalAxes from 'mol-math/linear-algebra/matrix/principal-axes'; import PrincipalAxes from 'mol-math/linear-algebra/matrix/principal-axes';
import { fillSerial } from 'mol-util/array'; import { fillSerial } from 'mol-util/array';
import { ResidueIndex } from '../../model'; import { ResidueIndex, Model } from '../../model';
import { ElementSymbol, MoleculeType } from '../../model/types'; import { ElementSymbol, MoleculeType } from '../../model/types';
import { getAtomicMoleculeType, getPositionMatrix } from '../../util'; import { getAtomicMoleculeType, getPositionMatrix } from '../../util';
import StructureElement from '../element'; import StructureElement from '../element';
import Structure from '../structure'; import Structure from '../structure';
import Unit from '../unit'; import Unit from '../unit';
import { SaccharideNameMap, UnknownSaccharideComponent } from './constants'; import { SaccharideCompIdMap, UnknownSaccharideComponent, SaccharideComponent, SaccharidesSnfgMap } from './constants';
import { CarbohydrateElement, CarbohydrateLink, Carbohydrates, CarbohydrateTerminalLink, PartialCarbohydrateElement } from './data'; import { CarbohydrateElement, CarbohydrateLink, Carbohydrates, CarbohydrateTerminalLink, PartialCarbohydrateElement } from './data';
import { UnitRings, UnitRing } from '../unit/rings'; import { UnitRings, UnitRing } from '../unit/rings';
import { ElementIndex } from '../../model/indexing'; import { ElementIndex } from '../../model/indexing';
...@@ -118,6 +118,10 @@ function filterFusedRings(unitRings: UnitRings, rings: UnitRings.Index[] | undef ...@@ -118,6 +118,10 @@ function filterFusedRings(unitRings: UnitRings, rings: UnitRings.Index[] | undef
} }
} }
function getSaccharideComp(compId: string, model: Model): SaccharideComponent {
return model.properties.saccharideComponentMap.get(compId) || UnknownSaccharideComponent
}
export function computeCarbohydrates(structure: Structure): Carbohydrates { export function computeCarbohydrates(structure: Structure): Carbohydrates {
const links: CarbohydrateLink[] = [] const links: CarbohydrateLink[] = []
const terminalLinks: CarbohydrateTerminalLink[] = [] const terminalLinks: CarbohydrateTerminalLink[] = []
...@@ -162,7 +166,7 @@ export function computeCarbohydrates(structure: Structure): Carbohydrates { ...@@ -162,7 +166,7 @@ export function computeCarbohydrates(structure: Structure): Carbohydrates {
while (residueIt.hasNext) { while (residueIt.hasNext) {
const { index: residueIndex } = residueIt.move(); const { index: residueIndex } = residueIt.move();
const saccharideComp = SaccharideNameMap.get(label_comp_id.value(residueIndex)) || UnknownSaccharideComponent const saccharideComp = getSaccharideComp(label_comp_id.value(residueIndex), model)
if (saccharideComp === UnknownSaccharideComponent) { if (saccharideComp === UnknownSaccharideComponent) {
if (getAtomicMoleculeType(unit.model, residueIndex) !== MoleculeType.saccharide) continue if (getAtomicMoleculeType(unit.model, residueIndex) !== MoleculeType.saccharide) continue
} }
......
...@@ -174,6 +174,15 @@ const Monosaccharides: SaccharideComponent[] = [ ...@@ -174,6 +174,15 @@ const Monosaccharides: SaccharideComponent[] = [
{ abbr: 'Psi', name: 'Psicose', color: SaccharideColors.Pink, type: SaccharideType.Assigned }, { abbr: 'Psi', name: 'Psicose', color: SaccharideColors.Pink, type: SaccharideType.Assigned },
] ]
export const SaccharidesSnfgMap = (function () {
const map = new Map<string, SaccharideComponent>()
for (let i = 0, il = Monosaccharides.length; i < il; ++i) {
const saccharide = Monosaccharides[i]
map.set(saccharide.abbr, saccharide)
}
return map
})()
export const MonosaccharidesColorTable: [string, Color][] = [ export const MonosaccharidesColorTable: [string, Color][] = [
['Glc-family', SaccharideColors.Blue], ['Glc-family', SaccharideColors.Blue],
['Man-family', SaccharideColors.Green], ['Man-family', SaccharideColors.Green],
...@@ -287,7 +296,7 @@ const CommonSaccharideNames: { [k: string]: string[] } = { ...@@ -287,7 +296,7 @@ const CommonSaccharideNames: { [k: string]: string[] } = {
Psi: [], Psi: [],
} }
export const SaccharideNameMap = (function () { export const SaccharideCompIdMap = (function () {
const map = new Map<string, SaccharideComponent>() const map = new Map<string, SaccharideComponent>()
for (let i = 0, il = Monosaccharides.length; i < il; ++i) { for (let i = 0, il = Monosaccharides.length; i < il; ++i) {
const saccharide = Monosaccharides[i] const saccharide = Monosaccharides[i]
...@@ -299,4 +308,6 @@ export const SaccharideNameMap = (function () { ...@@ -299,4 +308,6 @@ export const SaccharideNameMap = (function () {
} }
} }
return map return map
})() })()
\ No newline at end of file
export type SaccharideComponentMap = ReadonlyMap<string, SaccharideComponent>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment