_parseAssemblyInfo()

in packages/miew/src/io/parsers/MMTFParser.js [316:392]


  _parseAssemblyInfo(mmtfData) {
    let i;
    let j;
    let k;
    const assemblies = [];
    const { logger } = this;

    for (i = 0; i < mmtfData.bioAssemblyList.length; ++i) {
      const baInfo = mmtfData.bioAssemblyList[i];
      if (baInfo.transformList.length === 0) {
        continue;
      }

      const chains = baInfo.transformList[0].chainIndexList;
      const chainListCheck = new ArrayComparator(chains);

      // build list of chain names
      const chainNames = {};
      for (j = 0; j < chains.length; ++j) {
        chainNames[this._complex._chains[chains[j]].getName()] = 1;
      }

      // all chains with the same name should belong to assembly if one of them belongs
      const allChains = [];
      let name;
      for (name in chainNames) {
        if (chainNames.hasOwnProperty(name)) {
          // just concat arrays -- there should be no duplicates
          Array.prototype.push.apply(allChains, this._chainsByName[name]);
        }
      }
      if (!chainListCheck.compare(allChains)) {
        // assembly is missing some of the chains
        logger.debug('MMTF: Assembly is missing some of the synonymous chains. Skipping...');
      }

      const a = new Assembly(this._complex);

      // add chains to assembly
      for (name in chainNames) {
        if (chainNames.hasOwnProperty(name)) {
          a.addChain(name);
        }
      }

      // add unique matrices to assembly
      a.addMatrix(new THREE.Matrix4().fromArray(baInfo.transformList[0].matrix).transpose());
      for (j = 1; j < baInfo.transformList.length; ++j) {
        const transform = baInfo.transformList[j];

        if (!chainListCheck.compare(transform.chainIndexList)) {
          // list of chains for this transform doesn't match that for other transforms
          // this is illegal in our structure
          logger.debug('MMTF: Chain lists differ for different transforms in one assembly. Skipping...');
          continue;
        }

        const m = new THREE.Matrix4().fromArray(transform.matrix).transpose();

        // check if matrix is already in the list
        for (k = 0; k < a.matrices.length; ++k) {
          if (a.matrices[k].equals(m)) {
            break;
          }
        }

        if (k === a.matrices.length) {
          a.addMatrix(m);
        }
      }

      a.finalize();
      assemblies.push(a);
    }

    return assemblies;
  }