io.github.msdk.io.mzml.MzMLFileExportMethod Java Examples

The following examples show how to use io.github.msdk.io.mzml.MzMLFileExportMethod. 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: ExportScansTask.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Export the chromatogram - mzML format
 *
 * @throws IOException if there are i/o problems.
 */

public void exportmzML() throws MSDKException {

  // Initialize objects
  SimpleRawDataFile msdkRawFile =
      new SimpleRawDataFile("MZmine mzML export", Optional.empty(), FileType.MZML);
  for (Scan scan : scans) {
    MsScan MSDKscan = new MZmineToMSDKMsScan(scan);
    msdkRawFile.addScan(MSDKscan);
  }
  // Actually write to disk
  MzMLFileExportMethod method = new MzMLFileExportMethod(msdkRawFile, exportFile,
      MzMLCompressionType.ZLIB, MzMLCompressionType.ZLIB);
  method.execute();
}
 
Example #2
Source File: ExportScansTask.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Export the chromatogram - mzML format
 *
 * @throws IOException if there are i/o problems.
 */

public void exportmzML() throws MSDKException {

  // Initialize objects
  SimpleRawDataFile msdkRawFile =
      new SimpleRawDataFile("MZmine 2 mzML export", Optional.empty(), FileType.MZML);
  for (Scan scan : scans) {
    MsScan MSDKscan = new MZmineToMSDKMsScan(scan);
    msdkRawFile.addScan(MSDKscan);
  }
  // Actually write to disk
  MzMLFileExportMethod method = new MzMLFileExportMethod(msdkRawFile, exportFile,
      MzMLCompressionType.ZLIB, MzMLCompressionType.ZLIB);
  method.execute();
}
 
Example #3
Source File: RawDataExportTask.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see Runnable#run()
 */
public void run() {

  try {

    setStatus(TaskStatus.PROCESSING);

    logger.info("Started export of file " + dataFile + " to " + outFilename);

    MZmineToMSDKRawDataFile msdkDataFile = new MZmineToMSDKRawDataFile(dataFile);

    if (outFilename.getName().toLowerCase().endsWith("mzml")) {
      msdkMethod = new MzMLFileExportMethod(msdkDataFile, outFilename, MzMLCompressionType.ZLIB,
          MzMLCompressionType.ZLIB);
    }

    if (outFilename.getName().toLowerCase().endsWith("cdf")) {
      msdkMethod = new NetCDFFileExportMethod(msdkDataFile, outFilename);
    }

    if (isCanceled())
      return;
    msdkMethod.execute();

    setStatus(TaskStatus.FINISHED);

    logger.info("Finished export of file " + dataFile + " to " + outFilename);

  } catch (Exception e) {
    e.printStackTrace();
    setStatus(TaskStatus.ERROR);
    setErrorMessage("Error in file export: " + e.getMessage());
  }

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

  final RawDataFilesSelection rawDataFiles =
      parameters.getParameter(MzMLExportParameters.dataFiles).getValue();
  final File fileName = parameters.getParameter(MzMLExportParameters.fileName).getValue();

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

  if (rawDataFiles.getMatchingRawDataFiles().isEmpty()) {
    logger.warn("mzML export module started with no raw data files selected");
    return;
  }

  RawDataFile rawDataFile = rawDataFiles.getMatchingRawDataFiles().get(0);

  MzMLFileExportMethod method = new MzMLFileExportMethod(rawDataFile, fileName);

  MSDKTask newTask = new MSDKTask("mzML export", rawDataFile.getName(), method);

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

}
 
Example #5
Source File: RawDataExportTask.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see Runnable#run()
 */
public void run() {

  try {

    setStatus(TaskStatus.PROCESSING);

    logger.info("Started export of file " + dataFile + " to " + outFilename);

    MZmineToMSDKRawDataFile msdkDataFile = new MZmineToMSDKRawDataFile(dataFile);

    if (outFilename.getName().toLowerCase().endsWith("mzml")) {
      msdkMethod = new MzMLFileExportMethod(msdkDataFile, outFilename, MzMLCompressionType.ZLIB,
          MzMLCompressionType.ZLIB);
    }

    if (outFilename.getName().toLowerCase().endsWith("cdf")) {
      msdkMethod = new NetCDFFileExportMethod(msdkDataFile, outFilename);
    }

    if (isCanceled())
      return;
    msdkMethod.execute();

    setStatus(TaskStatus.FINISHED);

    logger.info("Finished export of file " + dataFile + " to " + outFilename);

  } catch (Exception e) {
    e.printStackTrace();
    setStatus(TaskStatus.ERROR);
    setErrorMessage("Error in file export: " + e.getMessage());
  }

}