Skip to content
Snippets Groups Projects
Select Git revision
8 results Searching

help.c

Blame
    • yorhel's avatar
      87a7925b
      * Rewrote the file browser, help window, and delete windows · 87a7925b
      yorhel authored
      * Split browser.c into delete.c and help.c
      * Added "reference to parent directory"-hack
      * File browser doesn't use the ncurses menu lib anymore
      * Fixed bug #1758403: large directories work fine now
      * Fixed bug with wide characters in the browser
      * Performance improvements when browsing large directories
      * Required (instead of recommended) gettimeofday()
      
      
      git-svn-id: svn://blicky.net/ncdu/trunk@6 ce56bc8d-f834-0410-b703-f827bd498a76
      87a7925b
      History
      * Rewrote the file browser, help window, and delete windows
      yorhel authored
      * Split browser.c into delete.c and help.c
      * Added "reference to parent directory"-hack
      * File browser doesn't use the ncurses menu lib anymore
      * Fixed bug #1758403: large directories work fine now
      * Fixed bug with wide characters in the browser
      * Performance improvements when browsing large directories
      * Required (instead of recommended) gettimeofday()
      
      
      git-svn-id: svn://blicky.net/ncdu/trunk@6 ce56bc8d-f834-0410-b703-f827bd498a76
    internal.ts 3.59 KiB
    /**
     * 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));
        };
    }