コード例 #1
0
ファイル: AlignmentTools.java プロジェクト: altunkaya/biojava
  /**
   * Fundamentally, an alignment is just a list of aligned residues in each protein. This method
   * converts two lists of ResidueNumbers into an AFPChain.
   *
   * <p>Parameters are filled with defaults (often null) or sometimes calculated.
   *
   * <p>For a way to modify the alignment of an existing AFPChain, see {@link
   * AlignmentTools#replaceOptAln(AFPChain, Atom[], Atom[], Map)}
   *
   * @param ca1 CA atoms of the first protein
   * @param ca2 CA atoms of the second protein
   * @param aligned1 A list of aligned residues from the first protein
   * @param aligned2 A list of aligned residues from the second protein. Must be the same length as
   *     aligned1.
   * @return An AFPChain representing the alignment. Many properties may be null or another default.
   * @throws StructureException if an error occured during superposition
   * @throws IllegalArgumentException if aligned1 and aligned2 have different lengths
   * @see AlignmentTools#replaceOptAln(AFPChain, Atom[], Atom[], Map)
   */
  public static AFPChain createAFPChain(
      Atom[] ca1, Atom[] ca2, ResidueNumber[] aligned1, ResidueNumber[] aligned2)
      throws StructureException {
    // input validation
    int alnLen = aligned1.length;
    if (alnLen != aligned2.length) {
      throw new IllegalArgumentException("Alignment lengths are not equal");
    }

    AFPChain a = new AFPChain(AFPChain.UNKNOWN_ALGORITHM);
    try {
      a.setName1(ca1[0].getGroup().getChain().getStructure().getName());
      if (ca2[0].getGroup().getChain().getStructure() != null) {
        // common case for cloned ca2
        a.setName2(ca2[0].getGroup().getChain().getStructure().getName());
      }
    } catch (Exception e) {
      // One of the structures wasn't fully created. Ignore
    }
    a.setBlockNum(1);
    a.setCa1Length(ca1.length);
    a.setCa2Length(ca2.length);

    a.setOptLength(alnLen);
    a.setOptLen(new int[] {alnLen});

    Matrix[] ms = new Matrix[a.getBlockNum()];
    a.setBlockRotationMatrix(ms);
    Atom[] blockShiftVector = new Atom[a.getBlockNum()];
    a.setBlockShiftVector(blockShiftVector);

    String[][][] pdbAln = new String[1][2][alnLen];
    for (int i = 0; i < alnLen; i++) {
      pdbAln[0][0][i] = aligned1[i].getChainId() + ":" + aligned1[i];
      pdbAln[0][1][i] = aligned2[i].getChainId() + ":" + aligned2[i];
    }

    a.setPdbAln(pdbAln);

    // convert pdbAln to optAln, and fill in some other basic parameters
    AFPChainXMLParser.rebuildAFPChain(a, ca1, ca2);

    return a;

    // Currently a single block. Split into several blocks by sequence if needed
    //		return AlignmentTools.splitBlocksByTopology(a,ca1,ca2);
  }
コード例 #2
0
ファイル: AlignmentTools.java プロジェクト: altunkaya/biojava
  /**
   * It replaces an optimal alignment of an AFPChain and calculates all the new alignment scores and
   * variables.
   */
  public static AFPChain replaceOptAln(int[][][] newAlgn, AFPChain afpChain, Atom[] ca1, Atom[] ca2)
      throws StructureException {

    // The order is the number of groups in the newAlgn
    int order = newAlgn.length;

    // Calculate the alignment length from all the subunits lengths
    int[] optLens = new int[order];
    for (int s = 0; s < order; s++) {
      optLens[s] = newAlgn[s][0].length;
    }
    int optLength = 0;
    for (int s = 0; s < order; s++) {
      optLength += optLens[s];
    }

    // Create a copy of the original AFPChain and set everything needed for the structure update
    AFPChain copyAFP = (AFPChain) afpChain.clone();

    // Set the new parameters of the optimal alignment
    copyAFP.setOptLength(optLength);
    copyAFP.setOptLen(optLens);
    copyAFP.setOptAln(newAlgn);

    // Set the block information of the new alignment
    copyAFP.setBlockNum(order);
    copyAFP.setBlockSize(optLens);
    copyAFP.setBlockResList(newAlgn);
    copyAFP.setBlockResSize(optLens);
    copyAFP.setBlockGap(calculateBlockGap(newAlgn));

    // Recalculate properties: superposition, tm-score, etc
    Atom[] ca2clone = StructureTools.cloneAtomArray(ca2); // don't modify ca2 positions
    AlignmentTools.updateSuperposition(copyAFP, ca1, ca2clone);

    // It re-does the sequence alignment strings from the OptAlgn information only
    copyAFP.setAlnsymb(null);
    AFPAlignmentDisplay.getAlign(copyAFP, ca1, ca2clone);

    return copyAFP;
  }
コード例 #3
0
ファイル: AlignmentTools.java プロジェクト: altunkaya/biojava
  /**
   * @param afpChain Input afpchain. UNMODIFIED
   * @param ca1
   * @param ca2
   * @param optLens
   * @param optAln
   * @return A NEW AfpChain based off the input but with the optAln modified
   * @throws StructureException if an error occured during superposition
   */
  public static AFPChain replaceOptAln(
      AFPChain afpChain, Atom[] ca1, Atom[] ca2, int blockNum, int[] optLens, int[][][] optAln)
      throws StructureException {
    int optLength = 0;
    for (int blk = 0; blk < blockNum; blk++) {
      optLength += optLens[blk];
    }

    // set everything
    AFPChain refinedAFP = (AFPChain) afpChain.clone();
    refinedAFP.setOptLength(optLength);
    refinedAFP.setBlockSize(optLens);
    refinedAFP.setOptLen(optLens);
    refinedAFP.setOptAln(optAln);
    refinedAFP.setBlockNum(blockNum);

    // TODO recalculate properties: superposition, tm-score, etc
    Atom[] ca2clone = StructureTools.cloneAtomArray(ca2); // don't modify ca2 positions
    AlignmentTools.updateSuperposition(refinedAFP, ca1, ca2clone);

    AFPAlignmentDisplay.getAlign(refinedAFP, ca1, ca2clone);
    return refinedAFP;
  }