Beispiel #1
0
 @Transient
 @Field(index = Index.UN_TOKENIZED, store = Store.NO)
 public String getMass() {
   try {
     PeptideProperties pp = calculateStats();
     if (pp.isHasMass()) {
       long mass = Math.round(pp.getMassInDaltons());
       return String.format("%09d", mass);
     }
     return "";
   } catch (RuntimeException exp) {
     return "";
   }
 }
Beispiel #2
0
  /**
   * Calculate the predicted properties of this polypeptide.
   *
   * @return a <code>PeptideProperties</code> object containing the predicted properties of this
   *     polypeptide.
   */
  public PeptideProperties calculateStats() {
    if (this.getResidues() == null) {
      logger.warn("No residues for '" + this.getUniqueName() + "'");
      return null;
    }
    String residuesString = new String(this.getResidues());

    SymbolList residuesSymbolList = null;
    PeptideProperties pp = new PeptideProperties();
    try {
      SymbolTokenization proteinTokenization = ProteinTools.getTAlphabet().getTokenization("token");
      residuesSymbolList = new SimpleSymbolList(proteinTokenization, residuesString);

      if (residuesSymbolList.length() == 0) {
        logger.error(
            String.format(
                "Polypeptide feature '%s' has zero-length residues", this.getUniqueName()));
        return pp;
      }

      try {
        // if the sequence ends with a termination symbol (*), we need to remove it
        if (residuesSymbolList.symbolAt(residuesSymbolList.length()) == ProteinTools.ter()) {
          if (residuesSymbolList.length() == 1) {
            logger.error(
                String.format(
                    "Polypeptide feature '%s' only has termination symbol", this.getUniqueName()));
            return pp;
          }
          residuesSymbolList = residuesSymbolList.subList(1, residuesSymbolList.length() - 1);
        }

      } catch (IndexOutOfBoundsException exception) {
        throw new RuntimeException(exception);
      }
    } catch (BioException e) {
      logger.error("Can't translate into a protein sequence", e);
      return pp;
    }

    pp.setAminoAcids(residuesSymbolList.length());

    try {
      double isoElectricPoint = new IsoelectricPointCalc().getPI(residuesSymbolList, false, false);
      pp.setIsoelectricPoint(isoElectricPoint);
    } catch (Exception e) {
      logger.error(
          String.format("Error computing protein isoelectric point for '%s'", residuesSymbolList),
          e);
    }

    double mass2 = calculateMass(residuesSymbolList);
    if (mass2 != -1) {
      // mass = mass2;
      pp.setMass(mass2);
    }

    double charge = calculateCharge(residuesString);
    pp.setCharge(charge);

    return pp;
  }