|
@@ -8,7 +8,8 @@
|
|
|
import { Segmentation } from '../../../../mol-data/int';
|
|
|
import { MinimizeRmsd } from '../../../../mol-math/linear-algebra/3d/minimize-rmsd';
|
|
|
import { SIFTSMapping } from '../../../../mol-model-props/sequence/sifts-mapping';
|
|
|
-import { ElementIndex } from '../../model/indexing';
|
|
|
+import { ElementIndex, ResidueIndex } from '../../model/indexing';
|
|
|
+import { StructureElement } from '../element';
|
|
|
import { Structure } from '../structure';
|
|
|
import { Unit } from '../unit';
|
|
|
|
|
@@ -24,11 +25,16 @@ export interface AlignmentResult {
|
|
|
failedPairs: [number, number][]
|
|
|
}
|
|
|
|
|
|
-export function alignAndSuperposeWithSIFTSMapping(structures: Structure[], options?: { traceOnly?: boolean }): AlignmentResult {
|
|
|
+type IncludeResidueTest = (traceElementOrFirstAtom: StructureElement.Location<Unit.Atomic>, residueIndex: ResidueIndex, startIndex: ElementIndex, endIndex: ElementIndex) => boolean
|
|
|
+
|
|
|
+export function alignAndSuperposeWithSIFTSMapping(
|
|
|
+ structures: Structure[],
|
|
|
+ options?: { traceOnly?: boolean, includeResidueTest?: IncludeResidueTest }
|
|
|
+): AlignmentResult {
|
|
|
const indexMap = new Map<string, IndexEntry>();
|
|
|
|
|
|
for (let i = 0; i < structures.length; i++) {
|
|
|
- buildIndex(structures[i], indexMap, i, options?.traceOnly ?? true);
|
|
|
+ buildIndex(structures[i], indexMap, i, options?.traceOnly ?? true, options?.includeResidueTest ?? _includeAllResidues);
|
|
|
}
|
|
|
|
|
|
const index = Array.from(indexMap.values());
|
|
@@ -137,11 +143,16 @@ interface IndexEntry {
|
|
|
pivots: { [i: number]: [unit: Unit.Atomic, start: ElementIndex, end: ElementIndex] | undefined }
|
|
|
}
|
|
|
|
|
|
-function buildIndex(structure: Structure, index: Map<string, IndexEntry>, sI: number, traceOnly: boolean) {
|
|
|
+function _includeAllResidues() { return true; }
|
|
|
+
|
|
|
+function buildIndex(structure: Structure, index: Map<string, IndexEntry>, sI: number, traceOnly: boolean, includeTest: IncludeResidueTest) {
|
|
|
+ const loc = StructureElement.Location.create<Unit.Atomic>(structure);
|
|
|
+
|
|
|
for (const unit of structure.units) {
|
|
|
if (unit.kind !== Unit.Kind.Atomic) continue;
|
|
|
|
|
|
const { elements, model } = unit;
|
|
|
+ loc.unit = unit;
|
|
|
|
|
|
const map = SIFTSMapping.Provider.get(model).value;
|
|
|
if (!map) return;
|
|
@@ -161,9 +172,11 @@ function buildIndex(structure: Structure, index: Map<string, IndexEntry>, sI: nu
|
|
|
|
|
|
if (!dbName[rI]) continue;
|
|
|
|
|
|
+ const traceElement = traceElementIndex[rI];
|
|
|
+
|
|
|
let start, end;
|
|
|
if (traceOnly) {
|
|
|
- start = traceElementIndex[rI];
|
|
|
+ start = traceElement;
|
|
|
if (start === -1) continue;
|
|
|
end = start + 1 as ElementIndex;
|
|
|
} else {
|
|
@@ -171,6 +184,9 @@ function buildIndex(structure: Structure, index: Map<string, IndexEntry>, sI: nu
|
|
|
end = elements[residueSegment.end - 1] + 1 as ElementIndex;
|
|
|
}
|
|
|
|
|
|
+ loc.element = (traceElement >= 0 ? traceElement : start) as ElementIndex;
|
|
|
+ if (!includeTest(loc, rI, start, end)) continue;
|
|
|
+
|
|
|
const key = `${dbName[rI]}-${accession[rI]}-${num[rI]}`;
|
|
|
|
|
|
if (!index.has(key)) {
|