Search in sources :

Example 1 with PolarityType

use of net.sf.mzmine.datamodel.PolarityType in project mzmine2 by mzmine.

the class IsotopePeakScannerSetupDialog method calculateIsotopePattern.

private ExtendedIsotopePattern calculateIsotopePattern() {
    if (!checkParameters())
        return null;
    String strPattern = "";
    int currentCarbonPattern = Integer.parseInt(txtCurrentPatternIndex.getText());
    if (autoCarbon)
        strPattern = "C" + String.valueOf(currentCarbonPattern) + element;
    else
        strPattern = element;
    if (strPattern.equals(""))
        return null;
    logger.info("Calculating isotope pattern: " + strPattern);
    ExtendedIsotopePattern pattern;
    PolarityType pol = (charge > 0) ? PolarityType.POSITIVE : PolarityType.NEGATIVE;
    charge = (charge > 0) ? charge : charge * -1;
    try {
        // *0.2 so the user can see the peaks below the threshold
        pattern = (ExtendedIsotopePattern) IsotopePatternCalculator.calculateIsotopePattern(strPattern, minIntensity * 0.1, mergeWidth, charge, pol, true);
    } catch (Exception e) {
        logger.warning("The entered Sum formula is invalid.");
        return null;
    }
    return pattern;
}
Also used : PolarityType(net.sf.mzmine.datamodel.PolarityType) ExtendedIsotopePattern(net.sf.mzmine.datamodel.impl.ExtendedIsotopePattern)

Example 2 with PolarityType

use of net.sf.mzmine.datamodel.PolarityType in project mzmine2 by mzmine.

the class ScanSelectionParameter method loadValueFromXML.

@Override
public void loadValueFromXML(Element xmlElement) {
    Range<Integer> scanNumberRange = null;
    Integer baseFilteringInteger = null;
    Range<Double> scanRTRange = null;
    PolarityType polarity = null;
    MassSpectrumType spectrumType = null;
    Integer msLevel = null;
    String scanDefinition = null;
    scanNumberRange = XMLUtils.parseIntegerRange(xmlElement, "scan_numbers");
    scanRTRange = XMLUtils.parseDoubleRange(xmlElement, "retention_time");
    NodeList items = xmlElement.getElementsByTagName("ms_level");
    for (int i = 0; i < items.getLength(); i++) {
        msLevel = Integer.valueOf(items.item(i).getTextContent());
    }
    items = xmlElement.getElementsByTagName("polarity");
    for (int i = 0; i < items.getLength(); i++) {
        try {
            polarity = PolarityType.valueOf(items.item(i).getTextContent());
        } catch (Exception e) {
            polarity = PolarityType.fromSingleChar(items.item(i).getTextContent());
        }
    }
    items = xmlElement.getElementsByTagName("spectrum_type");
    for (int i = 0; i < items.getLength(); i++) {
        spectrumType = MassSpectrumType.valueOf(items.item(i).getTextContent());
    }
    items = xmlElement.getElementsByTagName("scan_definition");
    for (int i = 0; i < items.getLength(); i++) {
        scanDefinition = items.item(i).getTextContent();
    }
    this.value = new ScanSelection(scanNumberRange, baseFilteringInteger, scanRTRange, polarity, spectrumType, msLevel, scanDefinition);
}
Also used : PolarityType(net.sf.mzmine.datamodel.PolarityType) NodeList(org.w3c.dom.NodeList) MassSpectrumType(net.sf.mzmine.datamodel.MassSpectrumType)

Example 3 with PolarityType

use of net.sf.mzmine.datamodel.PolarityType in project mzmine2 by mzmine.

the class ScanSelectionParameter method saveValueToXML.

@Override
public void saveValueToXML(Element xmlElement) {
    if (value == null)
        return;
    Document parentDocument = xmlElement.getOwnerDocument();
    final Range<Integer> scanNumberRange = value.getScanNumberRange();
    final Range<Double> scanRetentionTimeRange = value.getScanRTRange();
    final Integer baseFilteringInteger = value.getBaseFilteringInteger();
    final PolarityType polarity = value.getPolarity();
    final MassSpectrumType spectrumType = value.getSpectrumType();
    final Integer msLevel = value.getMsLevel();
    final String scanDefinition = value.getScanDefinition();
    XMLUtils.appendRange(xmlElement, "scan_numbers", scanNumberRange);
    XMLUtils.appendRange(xmlElement, "retention_time", scanRetentionTimeRange);
    if (baseFilteringInteger != null) {
        Element newElement = parentDocument.createElement("baseFilteringInteger");
        newElement.setTextContent(baseFilteringInteger.toString());
        xmlElement.appendChild(newElement);
    }
    if (polarity != null) {
        Element newElement = parentDocument.createElement("polarity");
        newElement.setTextContent(polarity.toString());
        xmlElement.appendChild(newElement);
    }
    if (spectrumType != null) {
        Element newElement = parentDocument.createElement("spectrum_type");
        newElement.setTextContent(spectrumType.toString());
        xmlElement.appendChild(newElement);
    }
    if (msLevel != null) {
        Element newElement = parentDocument.createElement("ms_level");
        newElement.setTextContent(String.valueOf(msLevel));
        xmlElement.appendChild(newElement);
    }
    if (scanDefinition != null) {
        Element newElement = parentDocument.createElement("scan_definition");
        newElement.setTextContent(scanDefinition);
        xmlElement.appendChild(newElement);
    }
}
Also used : PolarityType(net.sf.mzmine.datamodel.PolarityType) Element(org.w3c.dom.Element) MassSpectrumType(net.sf.mzmine.datamodel.MassSpectrumType) Document(org.w3c.dom.Document)

Example 4 with PolarityType

use of net.sf.mzmine.datamodel.PolarityType in project mzmine2 by mzmine.

the class FormulaPredictionModule method showSingleRowIdentificationDialog.

public static void showSingleRowIdentificationDialog(PeakListRow row) {
    ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(FormulaPredictionModule.class);
    double mzValue = row.getAverageMZ();
    parameters.getParameter(FormulaPredictionParameters.neutralMass).setIonMass(mzValue);
    int bestScanNum = row.getBestPeak().getRepresentativeScanNumber();
    if (bestScanNum > 0) {
        RawDataFile dataFile = row.getBestPeak().getDataFile();
        Scan bestScan = dataFile.getScan(bestScanNum);
        PolarityType scanPolarity = bestScan.getPolarity();
        switch(scanPolarity) {
            case POSITIVE:
                parameters.getParameter(FormulaPredictionParameters.neutralMass).setIonType(IonizationType.POSITIVE_HYDROGEN);
                break;
            case NEGATIVE:
                parameters.getParameter(FormulaPredictionParameters.neutralMass).setIonType(IonizationType.NEGATIVE_HYDROGEN);
                break;
            default:
                break;
        }
    }
    int charge = row.getBestPeak().getCharge();
    if (charge > 0) {
        parameters.getParameter(FormulaPredictionParameters.neutralMass).setCharge(charge);
    }
    ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
    if (exitCode != ExitCode.OK) {
        return;
    }
    SingleRowPredictionTask newTask = new SingleRowPredictionTask(parameters.cloneParameterSet(), row);
    // execute the sequence
    MZmineCore.getTaskController().addTask(newTask);
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) PolarityType(net.sf.mzmine.datamodel.PolarityType) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) ExitCode(net.sf.mzmine.util.ExitCode) Scan(net.sf.mzmine.datamodel.Scan)

Example 5 with PolarityType

use of net.sf.mzmine.datamodel.PolarityType in project mzmine2 by mzmine.

the class NetCDFReadTask method readNextScan.

/**
 * Reads one scan from the file. Requires that general information has already been read.
 */
private Scan readNextScan() throws IOException {
    // Get scan starting position and length
    int[] scanStartPosition = new int[1];
    int[] scanLength = new int[1];
    Integer[] startAndLength = scansIndex.get(scanNum);
    // End of file
    if (startAndLength == null) {
        return null;
    }
    scanStartPosition[0] = startAndLength[0];
    scanLength[0] = startAndLength[1];
    // Get retention time of the scan
    Double retentionTime = scansRetentionTimes.get(scanNum);
    if (retentionTime == null) {
        logger.severe("Could not find retention time for scan " + scanNum);
        throw (new IOException("Could not find retention time for scan " + scanNum));
    }
    // An empty scan needs special attention..
    if (scanLength[0] == 0) {
        scanNum++;
        return new SimpleScan(null, scanNum, 1, retentionTime.doubleValue(), 0, 0, null, new DataPoint[0], MassSpectrumType.CENTROIDED, PolarityType.UNKNOWN, "", null);
    }
    // Is there any way how to extract polarity from netcdf?
    PolarityType polarity = PolarityType.UNKNOWN;
    // Is there any way how to extract scan definition from netcdf?
    String scanDefinition = "";
    // Read mass and intensity values
    Array massValueArray;
    Array intensityValueArray;
    try {
        massValueArray = massValueVariable.read(scanStartPosition, scanLength);
        intensityValueArray = intensityValueVariable.read(scanStartPosition, scanLength);
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Could not read from variables mass_values and/or intensity_values.", e);
        throw (new IOException("Could not read from variables mass_values and/or intensity_values."));
    }
    Index massValuesIndex = massValueArray.getIndex();
    Index intensityValuesIndex = intensityValueArray.getIndex();
    int arrayLength = massValueArray.getShape()[0];
    DataPoint[] dataPoints = new DataPoint[arrayLength];
    for (int j = 0; j < arrayLength; j++) {
        Index massIndex0 = massValuesIndex.set0(j);
        Index intensityIndex0 = intensityValuesIndex.set0(j);
        double mz = massValueArray.getDouble(massIndex0) * massValueScaleFactor;
        double intensity = intensityValueArray.getDouble(intensityIndex0) * intensityValueScaleFactor;
        dataPoints[j] = new SimpleDataPoint(mz, intensity);
    }
    scanNum++;
    // Auto-detect whether this scan is centroided
    MassSpectrumType spectrumType = ScanUtils.detectSpectrumType(dataPoints);
    SimpleScan buildingScan = new SimpleScan(null, scanNum, 1, retentionTime.doubleValue(), 0, 0, null, dataPoints, spectrumType, polarity, scanDefinition, null);
    return buildingScan;
}
Also used : PolarityType(net.sf.mzmine.datamodel.PolarityType) Index(ucar.ma2.Index) MassSpectrumType(net.sf.mzmine.datamodel.MassSpectrumType) IOException(java.io.IOException) IOException(java.io.IOException) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) Array(ucar.ma2.Array) SimpleScan(net.sf.mzmine.datamodel.impl.SimpleScan) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint)

Aggregations

PolarityType (net.sf.mzmine.datamodel.PolarityType)7 MassSpectrumType (net.sf.mzmine.datamodel.MassSpectrumType)4 DataPoint (net.sf.mzmine.datamodel.DataPoint)3 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)3 ExtendedIsotopePattern (net.sf.mzmine.datamodel.impl.ExtendedIsotopePattern)2 SimpleScan (net.sf.mzmine.datamodel.impl.SimpleScan)2 ParameterSet (net.sf.mzmine.parameters.ParameterSet)2 ExitCode (net.sf.mzmine.util.ExitCode)2 IOException (java.io.IOException)1 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)1 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)1 Scan (net.sf.mzmine.datamodel.Scan)1 SimpleIsotopePattern (net.sf.mzmine.datamodel.impl.SimpleIsotopePattern)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1 NodeList (org.w3c.dom.NodeList)1 Array (ucar.ma2.Array)1 Index (ucar.ma2.Index)1 Spectrum (uk.ac.ebi.jmzml.model.mzml.Spectrum)1 MzMLUnmarshaller (uk.ac.ebi.jmzml.xml.io.MzMLUnmarshaller)1