Example #1
0
  /**
   * Checks whether a second cross-link has the same atom identifier, i.e. residue name, residue
   * number, chain Id and atom name.
   *
   * @param crossLink - CrossLink object to be compared to this CrossLink object.
   * @return {@code TRUE} if both CrossLink object are equal in all atom identifier, {@code FALSE}
   *     otherwise.
   */
  public final boolean equals(final CrossLink crossLink) {
    Atom preAtom1 = this.getPreAtom();
    Atom postAtom1 = this.getPostAtom();
    Atom preAtom2 = crossLink.getPreAtom();
    Atom postAtom2 = crossLink.getPostAtom();

    if (this.equalsInHomolog(crossLink)) {
      String residueId1 = preAtom1.getChainId() + "#" + preAtom1.getName().trim();
      String residueId2 = postAtom1.getChainId() + "#" + postAtom1.getName().trim();
      String residueId3 = preAtom2.getChainId() + "#" + preAtom2.getName().trim();
      String residueId4 = postAtom2.getChainId() + "#" + postAtom2.getName().trim();

      if ((residueId1.equals(residueId3) && residueId2.equals(residueId4))
          || (residueId2.equals(residueId3) && residueId1.equals(residueId4))) {
        return true;
      }
    }
    return false;
  }
Example #2
0
  /**
   * Returns a string representation of the PyMol commands to name and place dashes between
   * cross-linked amino acids.
   *
   * @param crossLinkList - CrossLinkList object holding all cross-links found for a protein
   *     complex.
   * @return String object with PyMol commands.
   */
  private String getEuclideanDistancePyMolCommands(final CrossLinkList crossLinkList) {
    StringBuffer output = new StringBuffer();
    String infile = CrossLinkParameter.getParameter(Parameter.INFILE_PATH);
    String nl = Constants.LINE_SEPERATOR;

    String infileWithoutExtension =
        new File(infile).getName().substring(0, new File(infile).getName().lastIndexOf('.'));

    for (CrossLink crossLink : crossLinkList) {
      Atom atom1 = crossLink.getPreAtom();
      Atom atom2 = crossLink.getPostAtom();

      if (atom1.getChainId() != '_') {
        output.append(
            "create chain"
                + atom1.getChainId()
                + ", chain "
                + atom1.getChainId()
                + " and "
                + infileWithoutExtension
                + nl);
      }
      if (atom2.getChainId() != '_') {
        output.append(
            "create chain"
                + atom2.getChainId()
                + ", chain "
                + atom2.getChainId()
                + " and "
                + infileWithoutExtension
                + nl);
      }
      String selection1 =
          "resn "
              + atom1.getResidueName().trim()
              + " and resi "
              + atom1.getResidueNumber()
              + " and chain "
              + atom1.getChainId()
              + " and name "
              + atom1.getName().trim()
              + " and "
              + infileWithoutExtension;
      if (atom1.getAlternativeLocation() != ' ') {
        selection1 += " and alt " + atom1.getAlternativeLocation();
      }
      String selection2 =
          "resn "
              + atom2.getResidueName().trim()
              + " and resi "
              + atom2.getResidueNumber()
              + " and chain "
              + atom2.getChainId()
              + " and name "
              + atom1.getName().trim()
              + " and "
              + infileWithoutExtension;
      if (atom2.getAlternativeLocation() != ' ') {
        selection2 += " and alt " + atom2.getAlternativeLocation();
      }

      String distName = crossLink.getIndex() + "_";
      if (Boolean.parseBoolean(
          CrossLinkParameter.getParameter(Parameter.DO_SOLVENT_PATH_DISTANCE))) {
        distName += this.decFormat.format(crossLink.getSolventPathDistance()) + "_";
      } else {
        distName += this.decFormat.format(crossLink.getEuclideanDistance()) + "_";
      }

      distName +=
          atom1.getResidueName().trim()
              + ""
              + atom1.getResidueNumber()
              + ""
              + atom1.getChainId()
              + atom1.getName().trim();
      if (atom1.getAlternativeLocation() != ' ') {
        distName += atom1.getAlternativeLocation();
      }
      distName +=
          "-"
              + atom2.getResidueName().trim()
              + ""
              + atom2.getResidueNumber()
              + ""
              + atom2.getChainId()
              + atom2.getName().trim();
      if (atom2.getAlternativeLocation() != ' ') {
        distName += atom2.getAlternativeLocation();
      }

      output.append("select pk1, " + selection1 + nl);
      output.append("select pk2, " + selection2 + nl);
      output.append("show spheres, pk1" + nl);
      output.append("show spheres, pk2" + nl);
      output.append("distance \"" + distName + "\"" + nl);
      //            output.append("cmd.color(\"red\", \"" + distName + "\")" + nl);
    }
    output.append("delete pk1" + nl);
    output.append("delete pk2" + nl);

    return output.toString();
  }
Example #3
0
  /**
   * Returns a String representation of this cross-link in distance file format.
   *
   * @return String object holding the representation of this cross-link in distance file format.
   */
  public final String toString() {
    String atomId1 = AminoAcid.getAminoAcidId(preAtom) + "-" + preAtom.getName().trim();
    String atomId2 = AminoAcid.getAminoAcidId(postAtom) + "-" + postAtom.getName().trim();

    if (preAtom.getAlternativeLocation() != ' ') {
      atomId1 += "-" + preAtom.getAlternativeLocation();
    }

    if (postAtom.getAlternativeLocation() != ' ') {
      atomId2 += "-" + postAtom.getAlternativeLocation();
    }

    StringBuffer output = new StringBuffer();
    int maxPeptideLength = xwalk.constants.Constants.MAX_PEPTIDE_LENGTH;
    int minPeptideLength = xwalk.constants.Constants.MIN_PEPTIDE_LENGTH;
    boolean outputPeptide = false;
    if (preAtomPeptide != null && postAtomPeptide != null) {
      outputPeptide =
          preAtomPeptide.size() <= maxPeptideLength
              && preAtomPeptide.size() >= minPeptideLength
              && postAtomPeptide.size() <= maxPeptideLength
              && postAtomPeptide.size() >= minPeptideLength;
    }

    output.append(
        this.filePath
            + "\t"
            + atomId1
            + "\t"
            + atomId2
            + "\t"
            + this.seqDist
            + "\t"
            + this.getEuclideanDistance()
            + "\t");
    if (this.getSolventPathDistance() > -0.1 || this.getSolventPathDistance() < -0.9) {
      output.append(this.getSolventPathDistance() + "\t");
    } else {
      output.append("-\t");
    }
    if (this.doProbability) {
      output.append(this.getEuclideanDistanceProbability() + "\t");
      if (this.getSolventPathDistance() > -0.1 || this.getSolventPathDistance() < -0.9) {
        output.append(this.getSolventPathDistanceProbability() + "\t");
      } else {
        output.append("-\t");
      }
    } else {
      output.append("-\t-\t");
    }

    if (outputPeptide) {
      output.append(
          this.preAtomPeptide.toStringOneLetterCode()
              + "-"
              + this.postAtomPeptide.toStringOneLetterCode());
    } else {
      output.append("-");
    }
    output.append(Constants.LINE_SEPERATOR);
    return output.toString();
  }