Java Code Examples for com.google.common.collect.Range#singleton()

The following examples show how to use com.google.common.collect.Range#singleton() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MsSpectrumPlotWindowController.java    From old-mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public void handleAddScan(Event e) {
  ParameterSet parameters =
      MZmineCore.getConfiguration().getModuleParameters(MsSpectrumPlotModule.class);
  ButtonType exitCode = parameters.showSetupDialog("Add scan");
  if (exitCode != ButtonType.OK)
    return;

  final RawDataFilesSelection fileSelection =
      parameters.getParameter(MsSpectrumPlotParameters.inputFiles).getValue();
  final Integer scanNumber =
      parameters.getParameter(MsSpectrumPlotParameters.scanNumber).getValue();
  final ScanSelection scanSelection =
      new ScanSelection(Range.singleton(scanNumber), null, null, null, null, null);
  final List<RawDataFile> dataFiles = fileSelection.getMatchingRawDataFiles();
  boolean spectrumAdded = false;
  for (RawDataFile dataFile : dataFiles) {
    for (MsScan scan : scanSelection.getMatchingScans(dataFile)) {
      String title = MsScanUtils.createSingleLineMsScanDescription(scan);
      addSpectrum(scan, title);
      spectrumAdded = true;
    }
  }
  if (!spectrumAdded) {
    MZmineGUI.displayMessage("Scan not found");
  }
}
 
Example 2
Source File: RexSimplify.java    From Quicksql with MIT License 6 votes vote down vote up
private static <C extends Comparable<C>> Range<C> range(SqlKind comparison,
    C c) {
  switch (comparison) {
  case EQUALS:
    return Range.singleton(c);
  case LESS_THAN:
    return Range.lessThan(c);
  case LESS_THAN_OR_EQUAL:
    return Range.atMost(c);
  case GREATER_THAN:
    return Range.greaterThan(c);
  case GREATER_THAN_OR_EQUAL:
    return Range.atLeast(c);
  default:
    throw new AssertionError();
  }
}
 
Example 3
Source File: SimplePeakList.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void addRow(PeakListRow row) {
  for (RawDataFile testFile : row.getRawDataFiles()) {
    if (!dataFiles.contains(testFile))
      throw (new IllegalArgumentException(
          "Data file " + testFile + " is not in this feature list"));
  }

  peakListRows.add(row);
  if (row.getDataPointMaxIntensity() > maxDataPointIntensity) {
    maxDataPointIntensity = row.getDataPointMaxIntensity();
  }

  if (mzRange == null) {
    mzRange = Range.singleton(row.getAverageMZ());
    rtRange = Range.singleton(row.getAverageRT());
  } else {
    mzRange = mzRange.span(Range.singleton(row.getAverageMZ()));
    rtRange = rtRange.span(Range.singleton(row.getAverageRT()));
  }

  row.setPeakList(this);
}
 
Example 4
Source File: ManualPeak.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds a new data point to this peak
 *
 * @param scanNumber
 * @param dataPoints
 * @param rawDataPoints
 */
public void addDatapoint(int scanNumber, DataPoint dataPoint) {

  double rt = dataFile.getScan(scanNumber).getRetentionTime();

  if (dataPointMap.isEmpty()) {
    rtRange = Range.singleton(rt);
    mzRange = Range.singleton(dataPoint.getMZ());
    intensityRange = Range.singleton(dataPoint.getIntensity());
  } else {
    rtRange = rtRange.span(Range.singleton(rt));
    mzRange = mzRange.span(Range.singleton(dataPoint.getMZ()));
    intensityRange = intensityRange.span(Range.singleton(dataPoint.getIntensity()));
  }

  dataPointMap.put(scanNumber, dataPoint);

}
 
Example 5
Source File: RexSimplify.java    From Bats with Apache License 2.0 6 votes vote down vote up
private static <C extends Comparable<C>> Range<C> range(SqlKind comparison, C c) {
    switch (comparison) {
    case EQUALS:
        return Range.singleton(c);
    case LESS_THAN:
        return Range.lessThan(c);
    case LESS_THAN_OR_EQUAL:
        return Range.atMost(c);
    case GREATER_THAN:
        return Range.greaterThan(c);
    case GREATER_THAN_OR_EQUAL:
        return Range.atLeast(c);
    default:
        throw new AssertionError();
    }
}
 
Example 6
Source File: MZmineToMSDKMsScan.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Clone constructor
 */
public MZmineToMSDKMsScan(Scan mzmineScan) {
  this.mzmineScan = mzmineScan;
  if (mzmineScan.getPrecursorMZ() != 0) {
    Range<Double> isolationMzRange = Range.singleton(mzmineScan.getPrecursorMZ());
    double precursorMz = mzmineScan.getPrecursorMZ();
    int precursorCharge = mzmineScan.getPrecursorCharge();
    ActivationInfo activationInfo = null;
    isolations.add(new SimpleIsolationInfo(isolationMzRange, 0f, precursorMz, precursorCharge,
        activationInfo, null));
  }
}
 
Example 7
Source File: RawDataFileUtils.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public static @Nonnull Range<Double> findTotalRTRange(RawDataFile dataFiles[], int msLevel) {
  Range<Double> rtRange = null;
  for (RawDataFile file : dataFiles) {
    Range<Double> dfRange = file.getDataRTRange(msLevel);
    if (dfRange == null)
      continue;
    if (rtRange == null)
      rtRange = dfRange;
    else
      rtRange = rtRange.span(dfRange);
  }
  if (rtRange == null)
    rtRange = Range.singleton(0.0);
  return rtRange;
}
 
Example 8
Source File: RawDataFileImpl.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public @Nonnull Range<Double> getDataRTRange(int msLevel) {

  // check if we have this value already cached
  Range<Double> rtRange = dataRTRange.get(msLevel);
  if (rtRange != null)
    return rtRange;

  // find the value
  for (Scan scan : scans.values()) {

    // ignore scans of other ms levels
    if ((msLevel != 0) && (scan.getMSLevel() != msLevel))
      continue;

    if (rtRange == null)
      rtRange = Range.singleton(scan.getRetentionTime());
    else
      rtRange = rtRange.span(Range.singleton(scan.getRetentionTime()));

  }

  // cache the value
  if (rtRange != null)
    dataRTRange.put(msLevel, rtRange);
  else
    rtRange = Range.singleton(0.0);

  return rtRange;

}
 
Example 9
Source File: PeakSelectionParameter.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Shortcut to set value based on feature list rows
 */
public void setValue(PeakListRow rows[]) {
  List<PeakSelection> newValue = Lists.newArrayList();
  for (PeakListRow row : rows) {
    Range<Integer> idRange = Range.singleton(row.getID());
    Range<Double> mzRange = Range.singleton(row.getAverageMZ());
    Range<Double> rtRange = Range.singleton(row.getAverageRT());
    PeakSelection ps = new PeakSelection(idRange, mzRange, rtRange, null);
    newValue.add(ps);
  }
  setValue(newValue);
}
 
Example 10
Source File: ScanAlignment.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Closed mz range of all data points
 * 
 * @param dps
 * @return
 */
public static Range<Double> getMZRange(DataPoint[] dps) {
  if (dps == null || dps.length == 0)
    return Range.singleton(0d);
  double min = dps[0].getMZ();
  double max = dps[0].getMZ();
  for (int i = 1; i < dps.length; i++) {
    DataPoint dp = dps[i];
    min = Math.min(min, dp.getMZ());
    max = Math.max(max, dp.getMZ());
  }
  return Range.closed(min, max);
}
 
Example 11
Source File: PeakSelectionParameter.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Shortcut to set value based on feature list rows
 */
public void setValue(PeakListRow rows[]) {
  List<PeakSelection> newValue = Lists.newArrayList();
  for (PeakListRow row : rows) {
    Range<Integer> idRange = Range.singleton(row.getID());
    Range<Double> mzRange = Range.singleton(row.getAverageMZ());
    Range<Double> rtRange = Range.singleton(row.getAverageRT());
    PeakSelection ps = new PeakSelection(idRange, mzRange, rtRange, null);
    newValue.add(ps);
  }
  setValue(newValue);
}
 
Example 12
Source File: Chromatogram.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public void finishChromatogram() {

    int allScanNumbers[] = Ints.toArray(dataPointsMap.keySet());
    Arrays.sort(allScanNumbers);

    // Calculate median m/z
    double allMzValues[] = new double[allScanNumbers.length];
    for (int i = 0; i < allScanNumbers.length; i++) {
      allMzValues[i] = dataPointsMap.get(allScanNumbers[i]).getMZ();
    }
    mz = MathUtils.calcQuantile(allMzValues, 0.5f);

    // Update raw data point ranges, height, rt and representative scan
    height = Double.MIN_VALUE;
    for (int i = 0; i < allScanNumbers.length; i++) {

      DataPoint mzPeak = dataPointsMap.get(allScanNumbers[i]);

      // Replace the MzPeak instance with an instance of SimpleDataPoint,
      // to reduce the memory usage. After we finish this Chromatogram, we
      // don't need the additional data provided by the MzPeak

      dataPointsMap.put(allScanNumbers[i], mzPeak);

      if (i == 0) {
        rawDataPointsIntensityRange = Range.singleton(mzPeak.getIntensity());
        rawDataPointsMZRange = Range.singleton(mzPeak.getMZ());
      } else {
        rawDataPointsIntensityRange =
            rawDataPointsIntensityRange.span(Range.singleton(mzPeak.getIntensity()));
        rawDataPointsMZRange = rawDataPointsMZRange.span(Range.singleton(mzPeak.getMZ()));
      }

      if (height < mzPeak.getIntensity()) {
        height = mzPeak.getIntensity();
        rt = dataFile.getScan(allScanNumbers[i]).getRetentionTime();
        representativeScan = allScanNumbers[i];
      }
    }

    // Update area
    area = 0;
    for (int i = 1; i < allScanNumbers.length; i++) {
      // For area calculation, we use retention time in seconds
      double previousRT = dataFile.getScan(allScanNumbers[i - 1]).getRetentionTime() * 60d;
      double currentRT = dataFile.getScan(allScanNumbers[i]).getRetentionTime() * 60d;
      double previousHeight = dataPointsMap.get(allScanNumbers[i - 1]).getIntensity();
      double currentHeight = dataPointsMap.get(allScanNumbers[i]).getIntensity();
      area += (currentRT - previousRT) * (currentHeight + previousHeight) / 2;
    }

    // Update fragment scan
    fragmentScan =
        ScanUtils.findBestFragmentScan(dataFile, dataFile.getDataRTRange(1), rawDataPointsMZRange);

    if (fragmentScan > 0) {
      Scan fragmentScanObject = dataFile.getScan(fragmentScan);
      int precursorCharge = fragmentScanObject.getPrecursorCharge();
      if (precursorCharge > 0)
        this.charge = precursorCharge;
    }

    rawDataPointsRTRange = null;

    for (int scanNum : allScanNumbers) {
      double scanRt = dataFile.getScan(scanNum).getRetentionTime();
      DataPoint dp = getDataPoint(scanNum);

      if ((dp == null) || (dp.getIntensity() == 0.0))
        continue;

      if (rawDataPointsRTRange == null)
        rawDataPointsRTRange = Range.singleton(scanRt);
      else
        rawDataPointsRTRange = rawDataPointsRTRange.span(Range.singleton(scanRt));
    }

    // Discard the fields we don't need anymore
    buildingSegment = null;
    lastMzPeak = null;

  }
 
Example 13
Source File: RangeFactory.java    From jackson-datatypes-collections with Apache License 2.0 4 votes vote down vote up
public static <C extends Comparable<?>> Range<C> singleton(final C value)
{
    return Range.singleton(value);
}
 
Example 14
Source File: ExtendedPeak.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public void finishExtendedPeak() {

    int allScanNumbers[] = Ints.toArray(dataPointsMap.keySet());
    Arrays.sort(allScanNumbers);

    scanNumbers = allScanNumbers;

    // Calculate median m/z
    double allMzValues[] = new double[allScanNumbers.length];
    for (int i = 0; i < allScanNumbers.length; i++) {
      allMzValues[i] = dataPointsMap.get(allScanNumbers[i]).getMZ();
    }
    mz = MathUtils.calcQuantile(allMzValues, 0.5f);

    // Update raw data point ranges, height, rt and representative scan
    height = Double.MIN_VALUE;
    for (int i = 0; i < allScanNumbers.length; i++) {

      DataPoint mzPeak = dataPointsMap.get(allScanNumbers[i]);
      Scan aScan = dataFile.getScan(allScanNumbers[i]);

      // Replace the MzPeak instance with an instance of SimpleDataPoint,
      // to reduce the memory usage. After we finish this extended peak,
      // we don't need the additional data provided by the MzPeak
      SimpleDataPoint newDataPoint = new SimpleDataPoint(mzPeak);
      dataPointsMap.put(allScanNumbers[i], newDataPoint);

      if (i == 0) {
        rawDataPointsIntensityRange = Range.singleton(mzPeak.getIntensity());
        rawDataPointsMZRange = Range.singleton(mzPeak.getMZ());
        rawDataPointsRTRange = Range.singleton(aScan.getRetentionTime());
      } else {
        rawDataPointsIntensityRange =
            rawDataPointsIntensityRange.span(Range.singleton(mzPeak.getIntensity()));
        rawDataPointsMZRange = rawDataPointsMZRange.span(Range.singleton(mzPeak.getMZ()));
        rawDataPointsRTRange = rawDataPointsRTRange.span(Range.singleton(aScan.getRetentionTime()));
      }

      if (height < mzPeak.getIntensity()) {
        height = mzPeak.getIntensity();
        rt = aScan.getRetentionTime();
        representativeScan = allScanNumbers[i];
      }
    }

    // Update area
    area = 0;

    for (int i = 1; i < allScanNumbers.length; i++) {
      // For area calculation, we use retention time in seconds
      double previousRT = dataFile.getScan(allScanNumbers[i - 1]).getRetentionTime() * 60d;
      double currentRT = dataFile.getScan(allScanNumbers[i]).getRetentionTime() * 60d;

      double previousHeight = dataPointsMap.get(allScanNumbers[i - 1]).getIntensity();
      double currentHeight = dataPointsMap.get(allScanNumbers[i]).getIntensity();
      area += (currentRT - previousRT) * (currentHeight + previousHeight) / 2;
    }

    // Update fragment scan
    fragmentScan =
        ScanUtils.findBestFragmentScan(dataFile, dataFile.getDataRTRange(1), rawDataPointsMZRange);

    allMS2FragmentScanNumbers = ScanUtils.findAllMS2FragmentScans(dataFile,
        dataFile.getDataRTRange(1), rawDataPointsMZRange);

    if (fragmentScan > 0) {
      Scan fragmentScanObject = dataFile.getScan(fragmentScan);
      int precursorCharge = fragmentScanObject.getPrecursorCharge();
      if ((precursorCharge > 0) && (this.charge == 0))
        this.charge = precursorCharge;
    }

  }
 
Example 15
Source File: ADAPChromatogram.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public void finishChromatogram() {

    int allScanNumbers[] = Ints.toArray(dataPointsMap.keySet());
    Arrays.sort(allScanNumbers);

    mz = highPointMZ;

    // Update raw data point ranges, height, rt and representative scan
    height = Double.MIN_VALUE;
    for (int i = 0; i < allScanNumbers.length; i++) {

      DataPoint mzPeak = dataPointsMap.get(allScanNumbers[i]);

      // Replace the MzPeak instance with an instance of SimpleDataPoint,
      // to reduce the memory usage. After we finish this Chromatogram, we
      // don't need the additional data provided by the MzPeak

      dataPointsMap.put(allScanNumbers[i], mzPeak);

      if (i == 0) {
        rawDataPointsIntensityRange = Range.singleton(mzPeak.getIntensity());
        rawDataPointsMZRange = Range.singleton(mzPeak.getMZ());
      } else {
        rawDataPointsIntensityRange =
            rawDataPointsIntensityRange.span(Range.singleton(mzPeak.getIntensity()));
        rawDataPointsMZRange = rawDataPointsMZRange.span(Range.singleton(mzPeak.getMZ()));
      }

      if (height < mzPeak.getIntensity()) {
        height = mzPeak.getIntensity();
        rt = dataFile.getScan(allScanNumbers[i]).getRetentionTime();
        representativeScan = allScanNumbers[i];
      }
    }

    // Update area
    area = 0;
    for (int i = 1; i < allScanNumbers.length; i++) {
      // For area calculation, we use retention time in seconds
      double previousRT = dataFile.getScan(allScanNumbers[i - 1]).getRetentionTime() * 60d;
      double currentRT = dataFile.getScan(allScanNumbers[i]).getRetentionTime() * 60d;
      double previousHeight = dataPointsMap.get(allScanNumbers[i - 1]).getIntensity();
      double currentHeight = dataPointsMap.get(allScanNumbers[i]).getIntensity();
      area += (currentRT - previousRT) * (currentHeight + previousHeight) / 2;
    }

    // Update fragment scan
    fragmentScan =
        ScanUtils.findBestFragmentScan(dataFile, dataFile.getDataRTRange(1), rawDataPointsMZRange);

    allMS2FragmentScanNumbers = ScanUtils.findAllMS2FragmentScans(dataFile,
        dataFile.getDataRTRange(1), rawDataPointsMZRange);

    if (fragmentScan > 0) {
      Scan fragmentScanObject = dataFile.getScan(fragmentScan);
      int precursorCharge = fragmentScanObject.getPrecursorCharge();
      if (precursorCharge > 0)
        this.charge = precursorCharge;
    }

    rawDataPointsRTRange = null;

    for (int scanNum : allScanNumbers) {
      double scanRt = dataFile.getScan(scanNum).getRetentionTime();
      DataPoint dp = getDataPoint(scanNum);

      if ((dp == null) || (dp.getIntensity() == 0.0))
        continue;

      if (rawDataPointsRTRange == null)
        rawDataPointsRTRange = Range.singleton(scanRt);
      else
        rawDataPointsRTRange = rawDataPointsRTRange.span(Range.singleton(scanRt));
    }

    // Discard the fields we don't need anymore
    buildingSegment = null;
    lastMzPeak = null;

  }
 
Example 16
Source File: ExtendedPeak.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
public void finishExtendedPeak() {

    int allScanNumbers[] = Ints.toArray(dataPointsMap.keySet());
    Arrays.sort(allScanNumbers);

    scanNumbers = allScanNumbers;

    // Calculate median m/z
    double allMzValues[] = new double[allScanNumbers.length];
    for (int i = 0; i < allScanNumbers.length; i++) {
      allMzValues[i] = dataPointsMap.get(allScanNumbers[i]).getMZ();
    }
    mz = MathUtils.calcQuantile(allMzValues, 0.5f);

    // Update raw data point ranges, height, rt and representative scan
    height = Double.MIN_VALUE;
    for (int i = 0; i < allScanNumbers.length; i++) {

      DataPoint mzPeak = dataPointsMap.get(allScanNumbers[i]);
      Scan aScan = dataFile.getScan(allScanNumbers[i]);

      // Replace the MzPeak instance with an instance of SimpleDataPoint,
      // to reduce the memory usage. After we finish this extended peak,
      // we don't need the additional data provided by the MzPeak
      SimpleDataPoint newDataPoint = new SimpleDataPoint(mzPeak);
      dataPointsMap.put(allScanNumbers[i], newDataPoint);

      if (i == 0) {
        rawDataPointsIntensityRange = Range.singleton(mzPeak.getIntensity());
        rawDataPointsMZRange = Range.singleton(mzPeak.getMZ());
        rawDataPointsRTRange = Range.singleton(aScan.getRetentionTime());
      } else {
        rawDataPointsIntensityRange =
            rawDataPointsIntensityRange.span(Range.singleton(mzPeak.getIntensity()));
        rawDataPointsMZRange = rawDataPointsMZRange.span(Range.singleton(mzPeak.getMZ()));
        rawDataPointsRTRange = rawDataPointsRTRange.span(Range.singleton(aScan.getRetentionTime()));
      }

      if (height < mzPeak.getIntensity()) {
        height = mzPeak.getIntensity();
        rt = aScan.getRetentionTime();
        representativeScan = allScanNumbers[i];
      }
    }

    // Update area
    area = 0;

    for (int i = 1; i < allScanNumbers.length; i++) {
      // For area calculation, we use retention time in seconds
      double previousRT = dataFile.getScan(allScanNumbers[i - 1]).getRetentionTime() * 60d;
      double currentRT = dataFile.getScan(allScanNumbers[i]).getRetentionTime() * 60d;

      double previousHeight = dataPointsMap.get(allScanNumbers[i - 1]).getIntensity();
      double currentHeight = dataPointsMap.get(allScanNumbers[i]).getIntensity();
      area += (currentRT - previousRT) * (currentHeight + previousHeight) / 2;
    }

    // Update fragment scan
    fragmentScan =
        ScanUtils.findBestFragmentScan(dataFile, dataFile.getDataRTRange(1), rawDataPointsMZRange);

    allMS2FragmentScanNumbers = ScanUtils.findAllMS2FragmentScans(dataFile,
        dataFile.getDataRTRange(1), rawDataPointsMZRange);

    if (fragmentScan > 0) {
      Scan fragmentScanObject = dataFile.getScan(fragmentScan);
      int precursorCharge = fragmentScanObject.getPrecursorCharge();
      if ((precursorCharge > 0) && (this.charge == 0))
        this.charge = precursorCharge;
    }

  }
 
Example 17
Source File: ADAPChromatogram.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
public void finishChromatogram() {

    int allScanNumbers[] = Ints.toArray(dataPointsMap.keySet());
    Arrays.sort(allScanNumbers);

    mz = highPointMZ;

    // Update raw data point ranges, height, rt and representative scan
    height = Double.MIN_VALUE;
    for (int i = 0; i < allScanNumbers.length; i++) {

      DataPoint mzPeak = dataPointsMap.get(allScanNumbers[i]);

      // Replace the MzPeak instance with an instance of SimpleDataPoint,
      // to reduce the memory usage. After we finish this Chromatogram, we
      // don't need the additional data provided by the MzPeak

      dataPointsMap.put(allScanNumbers[i], mzPeak);

      if (i == 0) {
        rawDataPointsIntensityRange = Range.singleton(mzPeak.getIntensity());
        rawDataPointsMZRange = Range.singleton(mzPeak.getMZ());
      } else {
        rawDataPointsIntensityRange =
            rawDataPointsIntensityRange.span(Range.singleton(mzPeak.getIntensity()));
        rawDataPointsMZRange = rawDataPointsMZRange.span(Range.singleton(mzPeak.getMZ()));
      }

      if (height < mzPeak.getIntensity()) {
        height = mzPeak.getIntensity();
        rt = dataFile.getScan(allScanNumbers[i]).getRetentionTime();
        representativeScan = allScanNumbers[i];
      }
    }

    // Update area
    area = 0;
    for (int i = 1; i < allScanNumbers.length; i++) {
      // For area calculation, we use retention time in seconds
      double previousRT = dataFile.getScan(allScanNumbers[i - 1]).getRetentionTime() * 60d;
      double currentRT = dataFile.getScan(allScanNumbers[i]).getRetentionTime() * 60d;
      double previousHeight = dataPointsMap.get(allScanNumbers[i - 1]).getIntensity();
      double currentHeight = dataPointsMap.get(allScanNumbers[i]).getIntensity();
      area += (currentRT - previousRT) * (currentHeight + previousHeight) / 2;
    }

    // Update fragment scan
    fragmentScan =
        ScanUtils.findBestFragmentScan(dataFile, dataFile.getDataRTRange(1), rawDataPointsMZRange);

    allMS2FragmentScanNumbers = ScanUtils.findAllMS2FragmentScans(dataFile,
        dataFile.getDataRTRange(1), rawDataPointsMZRange);

    if (fragmentScan > 0) {
      Scan fragmentScanObject = dataFile.getScan(fragmentScan);
      int precursorCharge = fragmentScanObject.getPrecursorCharge();
      if (precursorCharge > 0)
        this.charge = precursorCharge;
    }

    rawDataPointsRTRange = null;

    for (int scanNum : allScanNumbers) {
      double scanRt = dataFile.getScan(scanNum).getRetentionTime();
      DataPoint dp = getDataPoint(scanNum);

      if ((dp == null) || (dp.getIntensity() == 0.0))
        continue;

      if (rawDataPointsRTRange == null)
        rawDataPointsRTRange = Range.singleton(scanRt);
      else
        rawDataPointsRTRange = rawDataPointsRTRange.span(Range.singleton(scanRt));
    }

    // Discard the fields we don't need anymore
    buildingSegment = null;
    lastMzPeak = null;

  }
 
Example 18
Source File: PeptideScan.java    From mzmine3 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * @param mzValues m/z values to set
 * @param intensityValues Intensity values to set
 */
public void setDataPoints(DataPoint[] dataPoints) {

  this.dataPoints = dataPoints;
  mzRange = Range.singleton(0.0);
  basePeak = null;
  totalIonCurrent = 0;

  // find m/z range and base peak
  if (dataPoints.length > 0) {

    basePeak = dataPoints[0];
    mzRange = Range.singleton(dataPoints[0].getMZ());

    for (DataPoint dp : dataPoints) {

      if (dp.getIntensity() > basePeak.getIntensity())
        basePeak = dp;

      mzRange = mzRange.span(Range.singleton(dp.getMZ()));
      totalIonCurrent += dp.getIntensity();

    }

  }

}
 
Example 19
Source File: SimpleScan.java    From mzmine2 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * @param mzValues m/z values to set
 * @param intensityValues Intensity values to set
 */
public void setDataPoints(DataPoint[] dataPoints) {

  this.dataPoints = dataPoints;
  mzRange = Range.singleton(0.0);
  basePeak = null;
  totalIonCurrent = 0;

  // find m/z range and base peak
  if (dataPoints.length > 0) {

    basePeak = dataPoints[0];
    mzRange = Range.singleton(dataPoints[0].getMZ());

    for (DataPoint dp : dataPoints) {

      if (dp.getIntensity() > basePeak.getIntensity())
        basePeak = dp;

      mzRange = mzRange.span(Range.singleton(dp.getMZ()));
      totalIonCurrent += dp.getIntensity();

    }

  }

}
 
Example 20
Source File: SimpleScan.java    From mzmine3 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * @param mzValues m/z values to set
 * @param intensityValues Intensity values to set
 */

public void setDataPoints(DataPoint[] dataPoints) {

  this.dataPoints = dataPoints;
  mzRange = Range.singleton(0.0);
  basePeak = null;
  totalIonCurrent = 0;

  // find m/z range and base peak
  if (dataPoints.length > 0) {

    basePeak = dataPoints[0];
    mzRange = Range.singleton(dataPoints[0].getMZ());

    for (DataPoint dp : dataPoints) {

      if (dp.getIntensity() > basePeak.getIntensity())
        basePeak = dp;

      mzRange = mzRange.span(Range.singleton(dp.getMZ()));
      totalIonCurrent += dp.getIntensity();

    }

  }

}