123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- /**
- * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info.
- *
- * @author David Sehnal <david.sehnal@gmail.com>
- */
- import { Segmentation } from '../../../../mol-data/int';
- import StructureElement from '../../../../mol-model/structure/structure/element';
- import { StructureProperties as P, Unit } from '../../structure';
- import Structure from '../../structure/structure';
- import { StructureQuery } from '../query';
- import { StructureSelection } from '../selection';
- import { QueryContext } from '../context';
- import { LinkType } from '../../model/types';
- export function defaultLinkTest(ctx: QueryContext) {
- return LinkType.isCovalent(ctx.atomicLink.type);
- }
- export function atomicSequence(): StructureQuery {
- return ctx => {
- const { inputStructure } = ctx;
- const l = StructureElement.create();
- const units: Unit[] = [];
- for (const unit of inputStructure.units) {
- if (unit.kind !== Unit.Kind.Atomic) continue;
- l.unit = unit;
- const elements = unit.elements;
- l.element = elements[0];
- if (P.entity.type(l) !== 'polymer') continue;
- const residuesIt = Segmentation.transientSegments(unit.model.atomicHierarchy.residueAtomSegments, elements);
- let residueCount = 0;
- while (residuesIt.hasNext) {
- residueCount++;
- residuesIt.move();
- }
- if (residueCount < 8) continue;
- units.push(unit);
- }
- return StructureSelection.Singletons(inputStructure, new Structure(units, inputStructure, ));
- };
- }
- export function water(): StructureQuery {
- return ctx => {
- const { inputStructure } = ctx;
- const l = StructureElement.create();
- const units: Unit[] = [];
- for (const unit of inputStructure.units) {
- if (unit.kind !== Unit.Kind.Atomic) continue;
- l.unit = unit;
- const elements = unit.elements;
- l.element = elements[0];
- if (P.entity.type(l) !== 'water') continue;
- units.push(unit);
- }
- return StructureSelection.Singletons(inputStructure, new Structure(units, inputStructure));
- };
- }
- export function atomicHet(): StructureQuery {
- return ctx => {
- const { inputStructure } = ctx;
- const l = StructureElement.create();
- const units: Unit[] = [];
- for (const unit of inputStructure.units) {
- if (unit.kind !== Unit.Kind.Atomic) continue;
- l.unit = unit;
- const elements = unit.elements;
- l.element = elements[0];
- if (P.entity.type(l) === 'water') continue;
- if (P.entity.type(l) === 'polymer') {
- const residuesIt = Segmentation.transientSegments(unit.model.atomicHierarchy.residueAtomSegments, elements);
- let residueCount = 0;
- while (residuesIt.hasNext) {
- residueCount++;
- residuesIt.move();
- }
- if (residueCount >= 8) continue;
- }
- units.push(unit);
- }
- return StructureSelection.Singletons(inputStructure, new Structure(units, inputStructure));
- };
- }
- export function spheres(): StructureQuery {
- return ctx => {
- const { inputStructure } = ctx;
- const units: Unit[] = [];
- for (const unit of inputStructure.units) {
- if (unit.kind !== Unit.Kind.Spheres) continue;
- units.push(unit);
- }
- return StructureSelection.Singletons(inputStructure, new Structure(units, inputStructure));
- };
- }
|