コード例 #1
0
  public SimpleIsotopePattern(
      DataPoint dataPoints[], IsotopePatternStatus status, String description) {

    assert dataPoints.length > 0;

    highestIsotope = ScanUtils.findTopDataPoint(dataPoints);
    this.dataPoints = dataPoints;
    this.status = status;
    this.description = description;
    this.mzRange = ScanUtils.findMzRange(dataPoints);
  }
コード例 #2
0
  /** @see java.lang.Runnable#run() */
  public void run() {

    setStatus(TaskStatus.PROCESSING);
    logger.info("Started parsing file " + file);

    MzMLUnmarshaller unmarshaller = new MzMLUnmarshaller(file);

    totalScans = unmarshaller.getObjectCountForXpath("/run/spectrumList/spectrum");

    MzMLObjectIterator<Spectrum> spectrumIterator =
        unmarshaller.unmarshalCollectionFromXpath("/run/spectrumList/spectrum", Spectrum.class);
    try {

      while (spectrumIterator.hasNext()) {

        Spectrum spectrum = spectrumIterator.next();

        String scanId = spectrum.getId();
        int scanNumber = convertScanIdToScanNumber(scanId);

        int msLevel = extractMSLevel(spectrum);
        double retentionTime = extractRetentionTime(spectrum);

        // Get parent scan number
        int parentScan = extractParentScanNumber(spectrum);
        double precursorMz = extractPrecursorMz(spectrum);
        int precursorCharge = extractPrecursorCharge(spectrum);

        DataPoint dataPoints[] = extractDataPoints(spectrum);

        // Auto-detect whether this scan is centroided
        boolean centroided = ScanUtils.isCentroided(dataPoints);

        // Remove zero data points
        DataPoint optimizedDataPoints[] = ScanUtils.removeZeroDataPoints(dataPoints, centroided);

        SimpleScan scan =
            new SimpleScan(
                null,
                scanNumber,
                msLevel,
                retentionTime,
                parentScan,
                precursorMz,
                precursorCharge,
                null,
                optimizedDataPoints,
                centroided);

        for (SimpleScan s : parentStack) {
          if (s.getScanNumber() == parentScan) {
            s.addFragmentScan(scanNumber);
          }
        }

        /*
         * Verify the size of parentStack. The actual size of the window
         * to cover possible candidates is defined by limitSize.
         */
        if (parentStack.size() > PARENT_STACK_SIZE) {
          SimpleScan firstScan = parentStack.removeLast();
          newMZmineFile.addScan(firstScan);
        }

        parentStack.addFirst(scan);

        parsedScans++;
      }

      while (!parentStack.isEmpty()) {
        SimpleScan scan = parentStack.removeLast();
        newMZmineFile.addScan(scan);
      }

      finalRawDataFile = newMZmineFile.finishWriting();

    } catch (Throwable e) {
      setStatus(TaskStatus.ERROR);
      errorMessage = "Error parsing mzML: " + ExceptionUtils.exceptionToString(e);
      e.printStackTrace();
      return;
    }

    if (parsedScans == 0) {
      setStatus(TaskStatus.ERROR);
      errorMessage = "No scans found";
      return;
    }

    logger.info("Finished parsing " + file + ", parsed " + parsedScans + " scans");
    setStatus(TaskStatus.FINISHED);
  }