Package net.sf.mzmine.data.impl

Examples of net.sf.mzmine.data.impl.SimplePeakListRow


  public int length() {
    return peaks.length;
  }

  public PeakListRow convertToAlignmentRow(int ID) {
    PeakListRow newRow = new SimplePeakListRow(ID);
    try {
      for (PeakListRow row : this.peaks) {
        if (row != null) {
          for (ChromatographicPeak peak : row.getPeaks()) {
            newRow.addPeak(peak.getDataFile(), peak);
          }
        }
      }
    } catch (NullPointerException e) {
      e.printStackTrace();
View Full Code Here


      final PeakListRow row = peakListRows[i];

      if (row != null) {

        // Copy the peak list row.
        final PeakListRow newRow = new SimplePeakListRow(row.getID());
        PeakUtils.copyPeakListRowProperties(row, newRow);

        // Copy the peaks.
        for (final ChromatographicPeak peak : row.getPeaks()) {

          final ChromatographicPeak newPeak = new SimpleChromatographicPeak(
              peak);
          PeakUtils.copyPeakProperties(peak, newPeak);
          newRow.addPeak(peak.getDataFile(), newPeak);
        }

        newPeakList.addRow(newRow);
      }
    }
View Full Code Here

      newPeak.setIsotopePattern(newPattern);
      newPeak.setCharge(bestFitCharge);

      // Keep old ID
      int oldID = oldRow.getID();
      SimplePeakListRow newRow = new SimplePeakListRow(oldID);
      PeakUtils.copyPeakListRowProperties(oldRow, newRow);
      newRow.addPeak(dataFile, newPeak);
      deisotopedPeakList.addRow(newRow);

      // Remove all peaks already assigned to isotope pattern
      for (int i = 0; i < sortedPeaks.length; i++) {
        if (bestFitPeaks.contains(sortedPeaks[i]))
View Full Code Here

    // Create PeakListRows
    int id = 0;

    for (String name : FameData.FAME_NAMES) {
      PeakListRow row = new SimplePeakListRow(++id);
      row.setComment(name);

      for (FameAlignmentProcessingTask task : processingTasks) {
        if (task.getResults().containsKey(name))
          row.addPeak(task.getResults().get(name).getDataFile(), task
              .getResults().get(name));
      }

      peakList.addRow(row);
    }
View Full Code Here

    // Create PeakList
    int id = 0;

    for (Double averageRT : matchedCandidates.keySet()) {
      List<MassCandidate> masses = matchedCandidates.get(averageRT);
      PeakListRow row = new SimplePeakListRow(id++);

      for (MassCandidate m : masses)
        row.addPeak(m.getDataFile(), m);

      peakList.addRow(row);
    }

    MZmineCore.getCurrentProject().addPeakList(peakList);
View Full Code Here

      if (buildingPeakList == null) {
        initializePeakList();
      }
      int rowID = Integer.parseInt(attrs
          .getValue(PeakListElementName_2_3.ID.getElementName()));
      buildingRow = new SimplePeakListRow(rowID);
      String comment = attrs.getValue(PeakListElementName_2_3.COMMENT
          .getElementName());
      buildingRow.setComment(comment);
    }
View Full Code Here

          continue rowIteration;
        }
      }

      // Copy comment and identification
      SimplePeakListRow normalizedRow = new SimplePeakListRow(row.getID());
      PeakUtils.copyPeakListRowProperties(row, normalizedRow);

      // Get m/z and RT of the current row
      double mz = row.getAverageMZ();
      double rt = row.getAverageRT();

      // Loop through all raw data files
      for (RawDataFile file : originalPeakList.getRawDataFiles()) {

        double normalizationFactors[] = null;
        double normalizationFactorWeights[] = null;

        if (normalizationType == StandardUsageType.Nearest) {

          // Search for nearest standard
          PeakListRow nearestStandardRow = null;
          double nearestStandardRowDistance = Double.MAX_VALUE;

          for (int standardRowIndex = 0; standardRowIndex < standardRows.length; standardRowIndex++) {
            PeakListRow standardRow = standardRows[standardRowIndex];

            double stdMZ = standardRow.getAverageMZ();
            double stdRT = standardRow.getAverageRT();
            double distance = MZvsRTBalance * Math.abs(mz - stdMZ)
                + Math.abs(rt - stdRT);
            if (distance <= nearestStandardRowDistance) {
              nearestStandardRow = standardRow;
              nearestStandardRowDistance = distance;
            }

          }

          assert nearestStandardRow != null;

          // Calc and store a single normalization factor
          normalizationFactors = new double[1];
          normalizationFactorWeights = new double[1];
          ChromatographicPeak standardPeak = nearestStandardRow
              .getPeak(file);
          if (peakMeasurementType == PeakMeasurementType.HEIGHT) {
            normalizationFactors[0] = standardPeak.getHeight();
          } else {
            normalizationFactors[0] = standardPeak.getArea();
          }
          logger.finest("Normalizing row #" + row.getID()
              + " using standard peak " + standardPeak
              + ", factor " + normalizationFactors[0]);
          normalizationFactorWeights[0] = 1.0f;

        }

        if (normalizationType == StandardUsageType.Weighted) {

          // Add all standards as factors, and use distance as weight
          normalizationFactors = new double[standardRows.length];
          normalizationFactorWeights = new double[standardRows.length];

          for (int standardRowIndex = 0; standardRowIndex < standardRows.length; standardRowIndex++) {
            PeakListRow standardRow = standardRows[standardRowIndex];

            double stdMZ = standardRow.getAverageMZ();
            double stdRT = standardRow.getAverageRT();
            double distance = MZvsRTBalance * Math.abs(mz - stdMZ)
                + Math.abs(rt - stdRT);

            ChromatographicPeak standardPeak = standardRow
                .getPeak(file);
            if (standardPeak == null) {
              // What to do if standard peak is not
              // available? (Currently this is ruled out by the
              // setup dialog, which shows only peaks that are
              // present in all samples)
              normalizationFactors[standardRowIndex] = 1.0;
              normalizationFactorWeights[standardRowIndex] = 0.0;
            } else {
              if (peakMeasurementType == PeakMeasurementType.HEIGHT) {
                normalizationFactors[standardRowIndex] = standardPeak
                    .getHeight();
              } else {
                normalizationFactors[standardRowIndex] = standardPeak
                    .getArea();
              }
              normalizationFactorWeights[standardRowIndex] = 1 / distance;
            }
          }

        }

        assert normalizationFactors != null;
        assert normalizationFactorWeights != null;

        // Calculate a single normalization factor as weighted average
        // of all factors
        double weightedSum = 0.0f;
        double sumOfWeights = 0.0f;
        for (int factorIndex = 0; factorIndex < normalizationFactors.length; factorIndex++) {
          weightedSum += normalizationFactors[factorIndex]
              * normalizationFactorWeights[factorIndex];
          sumOfWeights += normalizationFactorWeights[factorIndex];
        }
        double normalizationFactor = weightedSum / sumOfWeights;

        // For simple scaling of the normalized values
        normalizationFactor = normalizationFactor / 100.0f;

        logger.finest("Normalizing row #" + row.getID() + "[" + file
            + "] using factor " + normalizationFactor);

        // How to handle zero normalization factor?
        if (normalizationFactor == 0.0)
          normalizationFactor = Double.MIN_VALUE;

        // Normalize peak
        ChromatographicPeak originalPeak = row.getPeak(file);
        if (originalPeak != null) {

          SimpleChromatographicPeak normalizedPeak = new SimpleChromatographicPeak(
              originalPeak);

          PeakUtils.copyPeakProperties(originalPeak, normalizedPeak);

          double normalizedHeight = originalPeak.getHeight()
              / normalizationFactor;
          double normalizedArea = originalPeak.getArea()
              / normalizationFactor;
          normalizedPeak.setHeight(normalizedHeight);
          normalizedPeak.setArea(normalizedArea);

          normalizedRow.addPeak(file, normalizedPeak);
        }

      }

      normalizedPeakList.addRow(normalizedRow);
View Full Code Here

   * @return the newly created copy.
   */
  private static PeakListRow copyPeakRow(final PeakListRow row) {

    // Copy the peak list row.
    final PeakListRow newRow = new SimplePeakListRow(row.getID());
    PeakUtils.copyPeakListRowProperties(row, newRow);

    // Copy the peaks.
    for (final ChromatographicPeak peak : row.getPeaks()) {

      final ChromatographicPeak newPeak = new SimpleChromatographicPeak(
          peak);
      PeakUtils.copyPeakProperties(peak, newPeak);
      newRow.addPeak(peak.getDataFile(), newPeak);
    }

    return newRow;
  }
View Full Code Here

      for (PeakListRow row : allRows) {
        PeakListRow targetRow = alignmentMapping.get(row);

        // If we have no mapping for this row, add a new one
        if (targetRow == null) {
          targetRow = new SimplePeakListRow(newRowID);
          newRowID++;
          alignedPeakList.addRow(targetRow);
        }

        // Add all peaks from the original row to the aligned row
View Full Code Here

        // Get previous pekaListRow
        PeakListRow oldRow = peakList.getPeakRow(oldPeak);

        // keep old ID
        int oldID = oldRow.getID();
        SimplePeakListRow newRow = new SimplePeakListRow(oldID);
        PeakUtils.copyPeakListRowProperties(oldRow, newRow);
        newRow.addPeak(dataFile, newPeak);
        extendedPeakList.addRow(newRow);
      }

      // Update completion rate
      processedPeaks++;
View Full Code Here

TOP

Related Classes of net.sf.mzmine.data.impl.SimplePeakListRow

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.