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

Handle "long" _struct_conn entries

parent f636ff44
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
*/
import Model from '../../model'
import { Element } from '../../../structure'
import { LinkType } from '../../types'
import { findEntityIdByAsymId, findAtomIndexByLabelName } from './util'
import { Column } from 'mol-data/db'
......@@ -85,7 +86,7 @@ export namespace StructConn {
distance: number,
order: number,
flags: number,
partners: { residueIndex: number, atomIndex: number, symmetry: string }[]
partners: { residueIndex: number, atomIndex: Element, symmetry: string }[]
}
type StructConnType =
......
......@@ -5,6 +5,7 @@
*/
import Model from '../../model'
import { Element } from '../../../structure'
export function findEntityIdByAsymId(model: Model, asymId: string) {
if (model.sourceData.kind !== 'mmCIF') return ''
......@@ -15,12 +16,12 @@ export function findEntityIdByAsymId(model: Model, asymId: string) {
return ''
}
export function findAtomIndexByLabelName(model: Model, residueIndex: number, atomName: string, altLoc: string | null) {
export function findAtomIndexByLabelName(model: Model, residueIndex: number, atomName: string, altLoc: string | null): Element {
const { segmentMap, segments } = model.atomicHierarchy.residueSegments
const idx = segmentMap[residueIndex]
const { label_atom_id, label_alt_id } = model.atomicHierarchy.atoms;
for (let i = segments[idx], n = segments[idx + 1]; i <= n; ++i) {
if (label_atom_id.value(i) === atomName && (!altLoc || label_alt_id.value(i) === altLoc)) return i;
if (label_atom_id.value(i) === atomName && (!altLoc || label_alt_id.value(i) === altLoc)) return i as Element;
}
return -1;
return -1 as Element;
}
\ No newline at end of file
......@@ -11,6 +11,7 @@ import Unit from '../../unit';
import { getElementIdx, getElementPairThreshold, getElementThreshold, isHydrogen, LinkComputationParameters, MetalsSet } from './common';
import { InterUnitBonds } from './data';
import { UniqueArray } from 'mol-data/generic';
import { SortedArray } from 'mol-data/int';
const MAX_RADIUS = 4;
......@@ -57,6 +58,19 @@ function findPairLinks(unitA: Unit.Atomic, unitB: Unit.Atomic, params: LinkCompu
const metalA = MetalsSet.has(aeI);
const structConnEntries = params.forceCompute ? void 0 : structConn && structConn.getAtomEntries(aI);
if (structConnEntries) {
for (const se of structConnEntries) {
if (se.distance < MAX_RADIUS) continue;
for (const p of se.partners) {
const _bI = SortedArray.indexOf(unitB.elements, p.atomIndex);
if (_bI < 0) continue;
addLink(_aI, _bI, se.order, se.flags, state);
bondCount++;
}
}
}
for (let ni = 0; ni < count; ni++) {
const _bI = indices[ni];
const bI = atomsB[_bI];
......
......@@ -10,6 +10,7 @@ import { StructConn, ComponentBond } from '../../../model/formats/mmcif/bonds'
import Unit from '../../unit'
import { IntAdjacencyGraph } from 'mol-math/graph';
import { LinkComputationParameters, getElementIdx, MetalsSet, getElementThreshold, isHydrogen, getElementPairThreshold } from './common';
import { SortedArray } from 'mol-data/int';
function getGraph(atomA: number[], atomB: number[], _order: number[], _flags: number[], atomCount: number): IntraUnitLinks {
const builder = new IntAdjacencyGraph.EdgeBuilder(atomCount, atomA, atomB);
......@@ -70,6 +71,21 @@ function _computeBonds(unit: Unit.Atomic, params: LinkComputationParameters): In
const metalA = MetalsSet.has(aeI);
const structConnEntries = params.forceCompute ? void 0 : structConn && structConn.getAtomEntries(aI);
if (structConnEntries) {
for (const se of structConnEntries) {
if (se.distance < MAX_RADIUS) continue;
for (const p of se.partners) {
const _bI = SortedArray.indexOf(unit.elements, p.atomIndex);
if (_bI < 0) continue;
atomA[atomA.length] = _aI;
atomB[atomB.length] = _bI;
flags[flags.length] = se.flags;
order[order.length] = se.order;
}
}
}
for (let ni = 0; ni < count; ni++) {
const _bI = indices[ni];
const bI = atoms[_bI];
......
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