/** Calculate the frequency of every one of the keys of the X axis */
  @Override
  protected void processData(ExperimentSummaryData summaryData) {
    Map<Integer, Integer> valuesIdentified = new HashMap<Integer, Integer>();
    Map<Integer, Integer> valuesUnidentified = new HashMap<Integer, Integer>();

    List<Double> chargeIdentified = summaryData.getPrecChargeVecExp(true);
    int maxChargeFound = 0;
    for (double key : chargeIdentified) {
      int auxKey = (int) key;
      int value = valuesIdentified.containsKey(auxKey) ? valuesIdentified.get(auxKey) + 1 : 1;
      valuesIdentified.put(auxKey, value);
      if (auxKey > maxChargeFound) maxChargeFound = auxKey;
    }

    List<Double> chargeUnidentified = summaryData.getPrecChargeVecExp(false);
    for (double key : chargeUnidentified) {
      int auxKey = (int) key;
      int value = valuesUnidentified.containsKey(auxKey) ? valuesUnidentified.get(auxKey) + 1 : 1;
      valuesUnidentified.put(auxKey, value);
      if (auxKey > maxChargeFound) maxChargeFound = auxKey;
    }

    if (maxChargeFound == 0) {
      recordError("No correct charges has been found");
      return;
    }

    List<SeriesPair<Integer, Integer>> identified = new ArrayList<SeriesPair<Integer, Integer>>();
    // List<SeriesPair<Integer,Integer>> unidentified = new
    // ArrayList<SeriesPair<Integer,Integer>>();
    // With the 'for' loop we ensure that the SeriesPair are added in an ordered way
    for (int key = 1; key <= maxChargeFound; key++) {
      // Only the charges found are stored int the intermediate identified
      if (valuesIdentified.containsKey(key))
        identified.add(new SeriesPair<Integer, Integer>(key, valuesIdentified.get(key)));

      // if(valuesUnidentified.containsKey(key))
      //    unidentified.add(new SeriesPair<Integer, Integer>(key,valuesUnidentified.get(key)));
    }

    if (identified.isEmpty()) {
      recordError("The experiment does not contain identified spectra");
      return;
    }

    intermediateData = new IntermediateData();
    // In this case the type and the name of the series are the same
    intermediateData.addPrideChartSerie(
        new DataSeries<Integer, Integer>(
            DataSeriesType.IDENTIFIED_SPECTRA, "Identified Spectra", identified));
    // intermediateData.addPrideChartSerie(new
    // DataSeries<Integer,Integer>(DataSeriesType.UNIDENTIFIED_SPECTRA, "Unidentified Spectra",
    // unidentified));

    try {
      intermediateData.setVariable("experimentSize", summaryData.size());
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
  @Override
  protected boolean isDataConsistent(ExperimentSummaryData summaryData) {
    if (!summaryData.getState().isPrecursorChargesLoaded())
      recordError("The experiment does not contain precursor charges");

    if (!summaryData.getState().isPrecursorMassesLoaded())
      recordError("The experiment does not contain precursor masses");

    if (summaryData.getProteinsPeptides().size() == 0)
      recordError("The experiment does not contain identifications data");

    return isValid();
  }
  @Override
  protected boolean isDataConsistent(ExperimentSummaryData summaryData) {
    if (!summaryData.getState().isPrecursorChargesLoaded())
      recordError("The experiment does not contain precursor charge values");

    return isValid();
  }
Ejemplo n.º 4
0
  @Override
  protected void processData(ExperimentSummaryData summaryData) {
    List<Double> data = new ArrayList<Double>();

    for (ProteinPeptide pp : summaryData.getProteinsPeptides()) {
      SpectrumData sData;
      try {
        Comparable spectrumID = pp.getSpectrumID();
        sData = summaryData.getSpectrum(String.valueOf(spectrumID));
      } catch (ProteinPeptideException e) {
        // If there is not spectrumID, the precursor mass and charge could not be found
        continue;
      }

      double mz;
      int charge;
      try {
        mz = sData.getPrecursorMass();
        charge = (int) sData.getPrecursorCharge();
      } catch (Exception e) {
        System.err.println(e.getMessage());
        continue;
      }
      // the sum of the PTM masses is stored in the ProteinPeptide object, but for calling
      // the calculateDeltaMz method, we need a list of PTM (the Water loss mono mass value
      // will be added by the method)
      List<Double> ptmMasses = new ArrayList<Double>();
      ptmMasses.add(pp.getPtmMass());
      Double deltaMass =
          MoleculeUtilities.calculateDeltaMz(pp.getSequence(), mz, charge, ptmMasses);

      if (deltaMass != null) data.add(deltaMass);
    }

    if (data.size() == 0) {
      recordError("Peptide sequences could not be associated to a MS 1 precursor");
      return;
    }

    Map<Double, Integer> histogram = new HashMap<Double, Integer>();

    double min = Collections.min(data);
    double max = Collections.max(data);

    double binWidth = Math.abs((max - min) / (double) BINS);
    binWidth = binWidth < MIN_BIN_WIDTH ? MIN_BIN_WIDTH : binWidth;
    for (double value : data) {
      int bin = (int) Math.round(value / binWidth);
      double pos = bin * binWidth;
      if (histogram.keySet().contains(pos)) {
        histogram.put(pos, histogram.get(pos) + 1);
      } else {
        histogram.put(pos, 1);
      }
    }

    List<SeriesPair<Double, Double>> deltaMasses = new ArrayList<SeriesPair<Double, Double>>();

    if (histogram.keySet().size() == 1) {
      for (Double key : histogram.keySet()) {
        if (key > 0.0) { // To center the chart on 0
          deltaMasses.add(new SeriesPair<Double, Double>(-key - MIN_BIN_WIDTH, 0.0));
        }

        deltaMasses.add(new SeriesPair<Double, Double>(key - MIN_BIN_WIDTH, 0.0));
        deltaMasses.add(new SeriesPair<Double, Double>(key, 1.0));
        deltaMasses.add(new SeriesPair<Double, Double>(key + MIN_BIN_WIDTH, 0.0));

        if (key < 0.0) { // To center the chart on 0
          deltaMasses.add(new SeriesPair<Double, Double>(-key + MIN_BIN_WIDTH, 0.0));
        }
      }
    } else {
      int maxFreq = Collections.max(histogram.values());
      for (int pos = -BINS; pos < BINS; pos++) {
        double key = pos * binWidth;
        double value = histogram.containsKey(key) ? histogram.get(key) / (double) maxFreq : 0.0;
        deltaMasses.add(new SeriesPair<Double, Double>(key, value));
      }
    }

    DataSeries series = new DataSeries<Double, Double>(null, "deltaMasses", deltaMasses);
    intermediateData = new IntermediateData(series);
    try {
      intermediateData.setVariable("sequenceNumber", data.size());
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }