dssp()

in packages/miew/src/chem/Complex.js [863:927]


  dssp() {
    const ssMap = new SecondaryStructureMap(this);

    const structures = this.structures = [];
    const helices = this._helices = [];
    const sheets = this._sheets = [];

    const getSheet = (index) => {
      let item = sheets[index];
      if (!item) {
        item = sheets[index] = new Sheet(String(index), 0);
      }
      return item;
    };

    let lastCode;
    let lastSheetIndex;
    let lastHelixIndex = 0;
    let curStructure = null;
    for (let i = 0, n = this._residues.length; i < n; ++i) {
      const curCode = ssMap._ss[i];
      const curResidue = this._residues[i];
      const curSheetIndex = ssMap._sheet[i];

      // expand the last structure
      if (curCode === lastCode && curSheetIndex === lastSheetIndex) {
        curResidue._secondary = curStructure;
        if (curStructure) {
          curStructure.term = curResidue;
        }
        if (curStructure instanceof Helix) {
          curStructure.length++;
        }
        continue;
      }

      // create a new structure
      const helixClass = helixClassMap[curCode];
      const loopType = loopMap[curCode];
      if (curCode === StructureType.STRAND) {
        const curSheet = getSheet(curSheetIndex);
        curStructure = new Strand(curSheet, curResidue, curResidue, 0, null, null);
        curSheet.addStrand(curStructure);
      } else if (helixClass !== undefined) {
        lastHelixIndex++;
        curStructure = new Helix(helixClass, curResidue, curResidue, lastHelixIndex, String(lastHelixIndex), '', 1);
        helices.push(curStructure);
      } else if (loopType !== undefined) {
        curStructure = new StructuralElement(loopType, curResidue, curResidue);
      } else {
        curStructure = null;
      }

      if (curStructure) {
        structures.push(curStructure);
      }

      curResidue._secondary = curStructure;

      lastCode = curCode;
      lastSheetIndex = curSheetIndex;
    }

    this._sheets = sheets.filter((_sheet) => true); // squeeze sheets array
  }