Skip to content
Snippets Groups Projects
Select Git revision
  • e1a04c8b0b658ba6fdbc2570cd9bfaeadbdc983c
  • master default protected
  • rednatco-v2
  • rednatco
  • test
  • ntc-tube-uniform-color
  • ntc-tube-missing-atoms
  • restore-vertex-array-per-program
  • watlas2
  • dnatco_new
  • cleanup-old-nodejs
  • webmmb
  • fix_auth_seq_id
  • update_deps
  • ext_dev
  • ntc_balls
  • nci-2
  • plugin
  • bugfix-0.4.5
  • nci
  • servers
  • v0.5.0-dev.1
  • v0.4.5
  • v0.4.4
  • v0.4.3
  • v0.4.2
  • v0.4.1
  • v0.4.0
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • v0.3.3
  • v0.3.2
  • v0.3.1
  • v0.3.0
41 results

model.ts

Blame
  • model.ts 10.52 KiB
    /**
     * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
     *
     * @author Alexander Rose <alexander.rose@weirdbyte.de>
     * @author David Sehnal <david.sehnal@gmail.com>
     */
    
    import * as argparse from 'argparse'
    require('util.promisify').shim();
    
    import { CifFrame } from '../../mol-io/reader/cif'
    import { Model, Structure, StructureElement, Unit, StructureProperties, UnitRing } from '../../mol-model/structure'
    // import { Run, Progress } from '../../mol-task'
    import { OrderedSet } from '../../mol-data/int';
    import { openCif, downloadCif } from './helpers';
    import { Vec3 } from '../../mol-math/linear-algebra';
    import { trajectoryFromMmCIF } from '../../mol-model-formats/structure/mmcif';
    
    
    async function downloadFromPdb(pdb: string) {
        // `https://files.rcsb.org/download/${pdb}.cif`
        const parsed = await downloadCif(`http://www.ebi.ac.uk/pdbe/static/entry/${pdb}_updated.cif`, false);
        return parsed.blocks[0];
    }
    
    export async function readCifFile(path: string) {
        const parsed = await openCif(path);
        return parsed.blocks[0];
    }
    
    export function atomLabel(model: Model, aI: number) {
        const { atoms, residues, chains, residueAtomSegments, chainAtomSegments } = model.atomicHierarchy
        const { label_atom_id } = atoms
        const { label_comp_id, label_seq_id } = residues
        const { label_asym_id } = chains
        const rI = residueAtomSegments.index[aI]
        const cI = chainAtomSegments.index[aI]
        return `${label_asym_id.value(cI)} ${label_comp_id.value(rI)} ${label_seq_id.value(rI)} ${label_atom_id.value(aI)}`
    }
    
    export function residueLabel(model: Model, rI: number) {
        const { residues, chains, residueAtomSegments, chainAtomSegments } = model.atomicHierarchy
        const { label_comp_id, label_seq_id } = residues
        const { label_asym_id } = chains
        const cI = chainAtomSegments.index[residueAtomSegments.offsets[rI]]
        return `${label_asym_id.value(cI)} ${label_comp_id.value(rI)} ${label_seq_id.value(rI)}`
    }
    
    export function printSecStructure(model: Model) {
        console.log('\nSecondary Structure\n=============');
        const { residues } = model.atomicHierarchy;
        const { key, elements } = model.properties.secondaryStructure;
    
        const count = residues._rowCount;
        let rI = 0;
        while (rI < count) {
            let start = rI;
            while (rI < count && key[start] === key[rI]) rI++;
            rI--;
    
            const e = elements[key[start]];
            if (e.kind !== 'none') console.log(`${e.kind}: ${residueLabel(model, start)} - ${residueLabel(model, rI)}`);
            rI++;
        }
    }
    
    export function printLinks(structure: Structure, showIntra: boolean, showInter: boolean) {
        if (showIntra) {
            console.log('\nIntra Unit Links\n=============');
            for (const unit of structure.units) {