Java Code Examples for it.unimi.dsi.fastutil.doubles.DoubleArrayList#isEmpty()

The following examples show how to use it.unimi.dsi.fastutil.doubles.DoubleArrayList#isEmpty() . 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: MZDistributionHistoTask.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see Runnable#run()
 */
@Override
public void run() {
  setStatus(TaskStatus.PROCESSING);
  logger.info("Starting to build mz distribution histogram for " + dataFile);

  // all selected scans
  scans = scanSelection.getMatchingScans(dataFile);
  totalScans = scans.length;

  // histo data
  DoubleArrayList data = new DoubleArrayList();

  for (Scan scan : scans) {
    if (isCanceled())
      return;

    // retention time in range
    if (!useRTRange || rtRange.contains(scan.getRetentionTime())) {
      // go through all mass lists
      MassList massList = scan.getMassList(massListName);
      if (massList == null) {
        setStatus(TaskStatus.ERROR);
        setErrorMessage("Scan " + dataFile + " #" + scan.getScanNumber()
            + " does not have a mass list " + massListName);
        return;
      }
      DataPoint mzValues[] = massList.getDataPoints();

      // insert all mz in order and count them
      Arrays.stream(mzValues).mapToDouble(dp -> dp.getMZ()).filter(mz -> mzRange.contains(mz))
          .forEach(mz -> data.add(mz));
      processedScans++;
    }
  }

  if (!data.isEmpty()) {
    // to array
    double[] histo = new double[data.size()];
    for (int i = 0; i < data.size(); i++)
      histo[i] = data.get(i);

    // create histogram dialog
    Platform.runLater(() -> {
      HistogramDialog dialog =
          new HistogramDialog("m/z distribution", "m/z", new HistogramData(histo), binWidth);
      dialog.showAndWait();
    });

  } else {
    throw new MSDKRuntimeException("Data was empty. Review your selected filters.");
  }
  setStatus(TaskStatus.FINISHED);
  logger.info("Finished mz distribution histogram on " + dataFile);
}
 
Example 2
Source File: MZDistributionHistoTask.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see Runnable#run()
 */
public void run() {
  setStatus(TaskStatus.PROCESSING);
  logger.info("Starting to build mz distribution histogram for " + dataFile);

  // all selected scans
  scans = scanSelection.getMatchingScans(dataFile);
  totalScans = scans.length;

  // histo data
  DoubleArrayList data = new DoubleArrayList();

  for (Scan scan : scans) {
    if (isCanceled())
      return;

    // retention time in range
    if (!useRTRange || rtRange.contains(scan.getRetentionTime())) {
      // go through all mass lists
      MassList massList = scan.getMassList(massListName);
      if (massList == null) {
        setStatus(TaskStatus.ERROR);
        setErrorMessage("Scan " + dataFile + " #" + scan.getScanNumber()
            + " does not have a mass list " + massListName);
        return;
      }
      DataPoint mzValues[] = massList.getDataPoints();

      // insert all mz in order and count them
      Arrays.stream(mzValues).mapToDouble(dp -> dp.getMZ()).filter(mz -> mzRange.contains(mz))
          .forEach(mz -> data.add(mz));
      processedScans++;
    }
  }

  if (!data.isEmpty()) {
    // to array
    double[] histo = new double[data.size()];
    for (int i = 0; i < data.size(); i++)
      histo[i] = data.get(i);

    // create histogram dialog
    EHistogramDialog dialog =
        new EHistogramDialog("m/z distribution", "m/z", new HistogramData(histo), binWidth);
    dialog.setVisible(true);
  } else {
    throw new MSDKRuntimeException("Data was empty. Review your selected filters.");
  }
  setStatus(TaskStatus.FINISHED);
  logger.info("Finished mz distribution histogram on " + dataFile);
}