|
@@ -8,7 +8,6 @@ import { AtomicSegments } from '../atomic';
|
|
|
import { AtomicData, AtomicRanges } from '../atomic/hierarchy';
|
|
|
import { Segmentation, Interval } from 'mol-data/int';
|
|
|
import SortedRanges from 'mol-data/int/sorted-ranges';
|
|
|
-import { ChemicalComponentMap } from '../chemical-component';
|
|
|
import { MoleculeType, isPolymer } from '../../types';
|
|
|
import { ElementIndex, ResidueIndex } from '../../indexing';
|
|
|
import { getAtomIdForAtomRole } from '../../../util';
|
|
@@ -17,11 +16,6 @@ import { Vec3 } from 'mol-math/linear-algebra';
|
|
|
|
|
|
// TODO add gaps at the ends of the chains by comparing to the polymer sequence data
|
|
|
|
|
|
-function getMoleculeType(compId: string, chemicalComponentMap: ChemicalComponentMap) {
|
|
|
- const cc = chemicalComponentMap.get(compId)
|
|
|
- return cc ? cc.moleculeType : MoleculeType.unknown
|
|
|
-}
|
|
|
-
|
|
|
function getElementIndexForAtomId(rI: ResidueIndex, atomId: string, data: AtomicData, segments: AtomicSegments): ElementIndex {
|
|
|
const { offsets } = segments.residueAtomSegments
|
|
|
const { label_atom_id } = data.atoms
|
|
@@ -31,10 +25,9 @@ function getElementIndexForAtomId(rI: ResidueIndex, atomId: string, data: Atomic
|
|
|
return offsets[rI]
|
|
|
}
|
|
|
|
|
|
-function areBackboneConnected(riStart: ResidueIndex, riEnd: ResidueIndex, data: AtomicData, segments: AtomicSegments, conformation: AtomicConformation, chemicalComponentMap: ChemicalComponentMap) {
|
|
|
- const { label_comp_id } = data.residues
|
|
|
- const mtStart = getMoleculeType(label_comp_id.value(riStart), chemicalComponentMap)
|
|
|
- const mtEnd = getMoleculeType(label_comp_id.value(riEnd), chemicalComponentMap)
|
|
|
+function areBackboneConnected(riStart: ResidueIndex, riEnd: ResidueIndex, data: AtomicData, segments: AtomicSegments, conformation: AtomicConformation, moleculeType: ArrayLike<MoleculeType>) {
|
|
|
+ const mtStart = moleculeType[riStart]
|
|
|
+ const mtEnd = moleculeType[riEnd]
|
|
|
if (!isPolymer(mtStart) || !isPolymer(mtEnd)) return false
|
|
|
|
|
|
const startId = getAtomIdForAtomRole(mtStart, 'backboneStart')
|
|
@@ -49,13 +42,13 @@ function areBackboneConnected(riStart: ResidueIndex, riEnd: ResidueIndex, data:
|
|
|
return Vec3.distance(pStart, pEnd) < 10
|
|
|
}
|
|
|
|
|
|
-export function getAtomicRanges(data: AtomicData, segments: AtomicSegments, conformation: AtomicConformation, chemicalComponentMap: ChemicalComponentMap): AtomicRanges {
|
|
|
+export function getAtomicRanges(data: AtomicData, segments: AtomicSegments, conformation: AtomicConformation, moleculeType: ArrayLike<MoleculeType>): AtomicRanges {
|
|
|
const polymerRanges: number[] = []
|
|
|
const gapRanges: number[] = []
|
|
|
const cyclicPolymerMap = new Map<ResidueIndex, ResidueIndex>()
|
|
|
const chainIt = Segmentation.transientSegments(segments.chainAtomSegments, Interval.ofBounds(0, data.atoms._rowCount))
|
|
|
const residueIt = Segmentation.transientSegments(segments.residueAtomSegments, Interval.ofBounds(0, data.atoms._rowCount))
|
|
|
- const { label_seq_id, label_comp_id } = data.residues
|
|
|
+ const { label_seq_id } = data.residues
|
|
|
|
|
|
let prevSeqId: number
|
|
|
let prevStart: number
|
|
@@ -72,7 +65,7 @@ export function getAtomicRanges(data: AtomicData, segments: AtomicSegments, conf
|
|
|
|
|
|
const riStart = segments.residueAtomSegments.index[chainSegment.start]
|
|
|
const riEnd = segments.residueAtomSegments.index[chainSegment.end - 1]
|
|
|
- if (areBackboneConnected(riStart, riEnd, data, segments, conformation, chemicalComponentMap)) {
|
|
|
+ if (areBackboneConnected(riStart, riEnd, data, segments, conformation, moleculeType)) {
|
|
|
cyclicPolymerMap.set(riStart, riEnd)
|
|
|
cyclicPolymerMap.set(riEnd, riStart)
|
|
|
}
|
|
@@ -80,9 +73,8 @@ export function getAtomicRanges(data: AtomicData, segments: AtomicSegments, conf
|
|
|
while (residueIt.hasNext) {
|
|
|
const residueSegment = residueIt.move();
|
|
|
const residueIndex = residueSegment.index
|
|
|
- const moleculeType = getMoleculeType(label_comp_id.value(residueIndex), chemicalComponentMap)
|
|
|
const seqId = label_seq_id.value(residueIndex)
|
|
|
- if (isPolymer(moleculeType)) {
|
|
|
+ if (isPolymer(moleculeType[residueIndex])) {
|
|
|
if (startIndex !== -1) {
|
|
|
if (seqId !== prevSeqId + 1) {
|
|
|
polymerRanges.push(startIndex, prevEnd - 1)
|
|
@@ -93,7 +85,7 @@ export function getAtomicRanges(data: AtomicData, segments: AtomicSegments, conf
|
|
|
} else {
|
|
|
const riStart = segments.residueAtomSegments.index[residueSegment.start]
|
|
|
const riEnd = segments.residueAtomSegments.index[prevEnd - 1]
|
|
|
- if (!areBackboneConnected(riStart, riEnd, data, segments, conformation, chemicalComponentMap)) {
|
|
|
+ if (!areBackboneConnected(riStart, riEnd, data, segments, conformation, moleculeType)) {
|
|
|
polymerRanges.push(startIndex, prevEnd - 1)
|
|
|
startIndex = residueSegment.start
|
|
|
}
|