io.github.msdk.datamodel.RawDataFile Java Examples

The following examples show how to use io.github.msdk.datamodel.RawDataFile. 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: MZmineGUIProject.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public void removeFile(final RawDataFile rawDataFile) {
  super.removeFile(rawDataFile);
  for (TreeItem<?> df1 : rawDataRootItem.getChildren()) {
    if (df1.getValue() == rawDataFile) {
      rawDataRootItem.getChildren().remove(df1);
      break;
    }
  }
}
 
Example #2
Source File: MZmineGUI.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public static @Nonnull List<RawDataFile> getSelectedRawDataFiles() {

    final ArrayList<RawDataFile> list = new ArrayList<>();
    final TreeView<Object> rawDataTree = mainWindowController.getRawDataTree();
    for (TreeItem<Object> item : rawDataTree.getSelectionModel().getSelectedItems()) {
      if (!(item.getValue() instanceof RawDataFile))
        continue;
      RawDataFile file = (RawDataFile) item.getValue();
      list.add(file);
    }

    return list;

  }
 
Example #3
Source File: MainWindowController.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public void removeRawData(ActionEvent event) {
  // Get selected tree items
  ObservableList<TreeItem<Object>> rows = null;
  if (rawDataTree.getSelectionModel() != null) {
    rows = rawDataTree.getSelectionModel().getSelectedItems();
  }

  // Loop through all selected tree items
  if (rows != null) {
    for (int i = rows.size() - 1; i >= 0; i--) {
      TreeItem<Object> row = rows.get(i);

      if (!(row.getValue() instanceof RawDataFile))
        continue;

      // Remove feature table from current project
      RawDataFile rawDataFile = (RawDataFile) row.getValue();
      MZmineCore.getCurrentProject().removeFile(rawDataFile);

      // Remove raw data file from tree table view
      TreeItem<?> parent = row.getParent();
      if (parent == null)
        continue;
      parent.getChildren().remove(row);
    }
    rawDataTree.getSelectionModel().clearSelection();
  }
}
 
Example #4
Source File: MsScanUtils.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates a single-line textual description of a given MS/MS scan, taking the precursor m/z
 * from a given isolation (a single scan can have multiple isolations)
 */
public static String createSingleLineMsScanDescription(MsScan scan, IsolationInfo isolation) {

  RawDataFile rdf = scan.getRawDataFile();

  StringBuilder sb = new StringBuilder();

  if (rdf != null) {
    sb.append(rdf.getName());
    sb.append(" ");
  }

  sb.append("#");
  sb.append(scan.getScanNumber());
  ChromatographyInfo scanRt = scan.getChromatographyInfo();
  if (scanRt != null) {
    NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat();
    sb.append(" @");
    sb.append(rtFormat.format(scanRt.getRetentionTime() / 60f));
    sb.append(" min");
  }
  if (isolation != null) {
    Double precursorMz = isolation.getPrecursorMz();
    if (precursorMz != null) {
      NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat();
      sb.append(", precursor ");
      sb.append(mzFormat.format(precursorMz));
      sb.append(" m/z");
    }
  }
  return sb.toString();
}
 
Example #5
Source File: LocalMaxCentroidingModule.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters,
    @Nonnull Collection<Task<?>> tasks) {

  final RawDataFilesSelection rawDataFiles =
      parameters.getParameter(LocalMaxCentroidingParameters.dataFiles).getValue();
  final String suffix = parameters.getParameter(LocalMaxCentroidingParameters.suffix).getValue();

  if (rawDataFiles == null || rawDataFiles.getMatchingRawDataFiles().isEmpty()) {
    logger.warn("Centroiding module started with no raw data files selected");
    return;
  }

  for (RawDataFile rawDataFile : rawDataFiles.getMatchingRawDataFiles()) {

    // Create the data structures
    DataPointStore dataStore = DataPointStoreFactory.getTmpFileDataStore();

    final String newName = rawDataFile.getName() + " " + suffix;
    LocalMaximaCentroidingAlgorithm algorithm = new LocalMaximaCentroidingAlgorithm(dataStore);

    MSDKCentroidingMethod method = new MSDKCentroidingMethod(rawDataFile, algorithm, dataStore);

    MSDKTask newTask =
        new MSDKTask("Local maxima centroiding method", rawDataFile.getName(), method);

    // Add the feature table to the project
    newTask.setOnSucceeded(e -> {
      RawDataFile newRawFile = method.getResult();
      newRawFile.setName(newName);
      project.addFile(newRawFile);
    });

    // Add the task to the queue
    tasks.add(newTask);

  }

}
 
Example #6
Source File: ShutDownHook.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {

  logger.info("Running post-shutdown code");

  // Cancel all running tasks - this is important because tasks can spawn
  // additional processes (such as ThermoRawDump.exe on Windows) and these
  // will block the shutdown of the JVM. If we cancel the tasks, the
  // processes will be killed immediately.
  /*
   * for (WrappedTask wt : MZmineCore.getTaskController().getTaskQueue() .getQueueSnapshot()) {
   * Task t = wt.getActualTask(); if ((t.getStatus() == TaskStatus.WAITING) || (t.getStatus() ==
   * TaskStatus.PROCESSING)) { t.cancel(); } }
   */

  // Save configuration
  try {
    MZmineConfiguration configuration = MZmineCore.getConfiguration();
    if (configuration != null) {
      configuration.saveConfiguration(MZmineConfiguration.CONFIG_FILE);
    }
  } catch (Exception e) {
    e.printStackTrace();
  }

  // Remove all temporary files
  MZmineProject currentProject = MZmineCore.getCurrentProject();
  if (currentProject != null) {
    for (RawDataFile dataFile : currentProject.getRawDataFiles()) {
      dataFile.dispose();
    }
    for (FeatureTable featureTable : currentProject.getFeatureTables()) {
      featureTable.dispose();
    }
  }

}
 
Example #7
Source File: ExactMassCentroidingModule.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters,
    @Nonnull Collection<Task<?>> tasks) {

  final RawDataFilesSelection rawDataFiles =
      parameters.getParameter(ExactMassCentroidingParameters.dataFiles).getValue();
  final String suffix = parameters.getParameter(ExactMassCentroidingParameters.suffix).getValue();

  if (rawDataFiles == null || rawDataFiles.getMatchingRawDataFiles().isEmpty()) {
    logger.warn("Centroiding module started with no raw data files selected");
    return;
  }

  for (RawDataFile rawDataFile : rawDataFiles.getMatchingRawDataFiles()) {

    // Create the data structures
    DataPointStore dataStore = DataPointStoreFactory.getTmpFileDataStore();

    final String newName = rawDataFile.getName() + " " + suffix;
    ExactMassCentroidingAlgorithm algorithm = new ExactMassCentroidingAlgorithm(dataStore);

    MSDKCentroidingMethod method = new MSDKCentroidingMethod(rawDataFile, algorithm, dataStore);

    MSDKTask newTask =
        new MSDKTask("Exact mass centroiding method", rawDataFile.getName(), method);

    // Add the feature table to the project
    newTask.setOnSucceeded(e -> {
      RawDataFile newRawFile = method.getResult();
      newRawFile.setName(newName);
      project.addFile(newRawFile);
    });

    // Add the task to the queue
    tasks.add(newTask);

  }

}
 
Example #8
Source File: BinningCentroidingModule.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters,
    @Nonnull Collection<Task<?>> tasks) {

  final RawDataFilesSelection rawDataFiles =
      parameters.getParameter(BinningCentroidingParameters.dataFiles).getValue();
  final Double binSize = parameters.getParameter(BinningCentroidingParameters.binSize).getValue();
  final String suffix = parameters.getParameter(BinningCentroidingParameters.suffix).getValue();

  if (rawDataFiles == null || rawDataFiles.getMatchingRawDataFiles().isEmpty()) {
    logger.warn("Centroiding module started with no raw data files selected");
    return;
  }

  for (RawDataFile rawDataFile : rawDataFiles.getMatchingRawDataFiles()) {

    // Create the data structures
    DataPointStore dataStore = DataPointStoreFactory.getTmpFileDataStore();

    final String newName = rawDataFile.getName() + " " + suffix;
    BinningCentroidingAlgorithm algorithm = new BinningCentroidingAlgorithm(dataStore, binSize);

    MSDKCentroidingMethod method = new MSDKCentroidingMethod(rawDataFile, algorithm, dataStore);

    MSDKTask newTask = new MSDKTask("Binning centroiding method", rawDataFile.getName(), method);

    // Add the feature table to the project
    newTask.setOnSucceeded(e -> {
      RawDataFile newRawFile = method.getResult();
      newRawFile.setName(newName);
      project.addFile(newRawFile);
    });

    // Add the task to the queue
    tasks.add(newTask);

  }

}
 
Example #9
Source File: WaveletCentroidingModule.java    From old-mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters,
    @Nonnull Collection<Task<?>> tasks) {

  final RawDataFilesSelection rawDataFiles =
      parameters.getParameter(WaveletCentroidingParameters.dataFiles).getValue();
  final Integer scaleLevel =
      parameters.getParameter(WaveletCentroidingParameters.scaleLevel).getValue();
  final Double waveletWindow =
      parameters.getParameter(WaveletCentroidingParameters.waveletWindow).getValue();
  final String suffix = parameters.getParameter(WaveletCentroidingParameters.suffix).getValue();

  if (rawDataFiles == null || rawDataFiles.getMatchingRawDataFiles().isEmpty()) {
    logger.warn("Centroiding module started with no raw data files selected");
    return;
  }

  for (RawDataFile rawDataFile : rawDataFiles.getMatchingRawDataFiles()) {

    // Create the data structures
    DataPointStore dataStore = DataPointStoreFactory.getTmpFileDataStore();

    final String newName = rawDataFile.getName() + " " + suffix;
    WaveletCentroidingAlgorithm algorithm =
        new WaveletCentroidingAlgorithm(dataStore, scaleLevel, waveletWindow);

    MSDKCentroidingMethod method = new MSDKCentroidingMethod(rawDataFile, algorithm, dataStore);

    MSDKTask newTask = new MSDKTask("Wavelet centroiding method", rawDataFile.getName(), method);

    // Add the feature table to the project
    newTask.setOnSucceeded(e -> {
      RawDataFile newRawFile = method.getResult();
      newRawFile.setName(newName);
      project.addFile(newRawFile);
    });

    // Add the task to the queue
    tasks.add(newTask);

  }

}
 
Example #10
Source File: MZmineToMSDKMsScan.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public RawDataFile getRawDataFile() {
  return null;
}
 
Example #11
Source File: MsScanUtils.java    From old-mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates a multi-line textual description of a given MsScan
 */
public static String createFullMsScanDescription(MsScan scan) {

  RawDataFile rdf = scan.getRawDataFile();
  Integer scanNum = scan.getScanNumber();
  MsFunction msFunc = scan.getMsFunction();
  Integer msLevel = msFunc.getMsLevel();
  ChromatographyInfo chromInfo = scan.getChromatographyInfo();

  StringBuilder sb = new StringBuilder();

  if (rdf != null)
    sb.append("Raw data file: " + rdf.getName() + "\n");

  sb.append("Scan number: " + scanNum + "\n");

  if (chromInfo != null) {
    NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat();
    Float rt = chromInfo.getRetentionTime();
    sb.append("Retention time: ");
    sb.append(rtFormat.format(rt / 60f));
    sb.append(" min\n");
    Float secondRT = chromInfo.getSecondaryRetentionTime();
    if (secondRT != null) {
      sb.append("Secondary retention time: ");
      sb.append(rtFormat.format(secondRT / 60f));
      sb.append(" min\n");
    }
  }

  sb.append("MS function: ");
  sb.append(msFunc.getName());
  sb.append("\n");
  if (msLevel != null) {
    sb.append("MS level: ");
    sb.append(msLevel);
    sb.append("\n");
  }
  sb.append("Scan definition: ");
  sb.append(scan.getScanDefinition());
  sb.append("\n");
  sb.append("Polarity: ");
  sb.append(scan.getPolarity());
  sb.append("\n");

  return sb.toString();
}
 
Example #12
Source File: MZmineToMSDKMsScan.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public RawDataFile getRawDataFile() {
  return null;
}
 
Example #13
Source File: RecursiveCentroidingModule.java    From old-mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters,
    @Nonnull Collection<Task<?>> tasks) {

  final RawDataFilesSelection rawDataFiles =
      parameters.getParameter(RecursiveCentroidingParameters.dataFiles).getValue();
  final Range<Double> mzPeakWidth = RecursiveCentroidingParameters.mzPeakWidth.getValue();
  final String suffix = parameters.getParameter(RecursiveCentroidingParameters.suffix).getValue();

  if (rawDataFiles == null || rawDataFiles.getMatchingRawDataFiles().isEmpty()) {
    logger.warn("Centroiding module started with no raw data files selected");
    return;
  }

  for (RawDataFile rawDataFile : rawDataFiles.getMatchingRawDataFiles()) {

    // Create the data structures
    DataPointStore dataStore = DataPointStoreFactory.getTmpFileDataStore();

    final String newName = rawDataFile.getName() + " " + suffix;
    RecursiveCentroidingAlgorithm algorithm =
        new RecursiveCentroidingAlgorithm(dataStore, mzPeakWidth);

    MSDKCentroidingMethod method = new MSDKCentroidingMethod(rawDataFile, algorithm, dataStore);

    MSDKTask newTask =
        new MSDKTask("Recursive centroiding method", rawDataFile.getName(), method);

    // Add the feature table to the project
    newTask.setOnSucceeded(e -> {
      RawDataFile newRawFile = method.getResult();
      newRawFile.setName(newName);
      project.addFile(newRawFile);
    });

    // Add the task to the queue
    tasks.add(newTask);

  }

}
 
Example #14
Source File: MZmineProject.java    From old-mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public @Nonnull List<RawDataFile> getRawDataFiles() {
  synchronized (rawDataFiles) {
    return ImmutableList.copyOf(rawDataFiles);
  }
}
 
Example #15
Source File: MZmineProject.java    From old-mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public void removeFile(final RawDataFile rawDataFile) {
  synchronized (rawDataFiles) {
    rawDataFiles.remove(rawDataFile);
  }
}
 
Example #16
Source File: MZmineProject.java    From old-mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public void addFile(final RawDataFile rawDataFile) {
  synchronized (rawDataFiles) {
    rawDataFiles.add(rawDataFile);
  }
}
 
Example #17
Source File: MZmineGUIProject.java    From old-mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public void addFile(final RawDataFile rawDataFile) {
  super.addFile(rawDataFile);
  TreeItem<Object> df1 = new TreeItem<>(rawDataFile);
  df1.setGraphic(new ImageView(fileIcon));
  rawDataRootItem.getChildren().add(df1);
}