|
@@ -1,5 +1,5 @@
|
|
|
/**
|
|
|
- * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
|
+ * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
|
*
|
|
|
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
|
|
*/
|
|
@@ -7,6 +7,7 @@
|
|
|
import { Unit, ElementIndex } from 'mol-model/structure';
|
|
|
import { Segmentation, OrderedSet, Interval, SortedArray } from 'mol-data/int';
|
|
|
import SortedRanges from 'mol-data/int/sorted-ranges';
|
|
|
+import { isNucleic, isProtein } from 'mol-model/structure/model/types';
|
|
|
|
|
|
export function getAtomicPolymerElements(unit: Unit.Atomic) {
|
|
|
const indices: ElementIndex[] = []
|
|
@@ -43,6 +44,8 @@ export function getCoarsePolymerElements(unit: Unit.Spheres | Unit.Gaussians) {
|
|
|
return SortedArray.ofSortedArray<ElementIndex>(indices)
|
|
|
}
|
|
|
|
|
|
+//
|
|
|
+
|
|
|
export function getAtomicGapElements(unit: Unit.Atomic) {
|
|
|
const indices: ElementIndex[] = []
|
|
|
const { elements, model, residueIndex } = unit
|
|
@@ -73,4 +76,50 @@ export function getCoarseGapElements(unit: Unit.Spheres | Unit.Gaussians) {
|
|
|
indices.push(elements[start], elements[end - 1])
|
|
|
}
|
|
|
return SortedArray.ofSortedArray<ElementIndex>(indices)
|
|
|
+}
|
|
|
+
|
|
|
+//
|
|
|
+
|
|
|
+export function getNucleotideElements(unit: Unit.Atomic) {
|
|
|
+ const indices: ElementIndex[] = []
|
|
|
+ const { elements, model } = unit
|
|
|
+ const { chainAtomSegments, residueAtomSegments } = model.atomicHierarchy
|
|
|
+ const { moleculeType, traceElementIndex } = model.atomicHierarchy.derived.residue
|
|
|
+ const chainIt = Segmentation.transientSegments(chainAtomSegments, elements)
|
|
|
+ const residueIt = Segmentation.transientSegments(residueAtomSegments, elements)
|
|
|
+ while (chainIt.hasNext) {
|
|
|
+ residueIt.setSegment(chainIt.move());
|
|
|
+
|
|
|
+ while (residueIt.hasNext) {
|
|
|
+ const { index } = residueIt.move();
|
|
|
+
|
|
|
+ if (isNucleic(moleculeType[index])) {
|
|
|
+ const elementIndex = traceElementIndex[index]
|
|
|
+ indices.push(elementIndex === -1 ? residueAtomSegments.offsets[index] : elementIndex)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return SortedArray.ofSortedArray<ElementIndex>(indices)
|
|
|
+}
|
|
|
+
|
|
|
+export function getProteinElements(unit: Unit.Atomic) {
|
|
|
+ const indices: ElementIndex[] = []
|
|
|
+ const { elements, model } = unit
|
|
|
+ const { chainAtomSegments, residueAtomSegments } = model.atomicHierarchy
|
|
|
+ const { moleculeType, traceElementIndex } = model.atomicHierarchy.derived.residue
|
|
|
+ const chainIt = Segmentation.transientSegments(chainAtomSegments, elements)
|
|
|
+ const residueIt = Segmentation.transientSegments(residueAtomSegments, elements)
|
|
|
+ while (chainIt.hasNext) {
|
|
|
+ residueIt.setSegment(chainIt.move());
|
|
|
+
|
|
|
+ while (residueIt.hasNext) {
|
|
|
+ const { index } = residueIt.move();
|
|
|
+
|
|
|
+ if (isProtein(moleculeType[index])) {
|
|
|
+ const elementIndex = traceElementIndex[index]
|
|
|
+ indices.push(elementIndex === -1 ? residueAtomSegments.offsets[index] : elementIndex)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return SortedArray.ofSortedArray<ElementIndex>(indices)
|
|
|
}
|