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;
}
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);
}
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);
}
}
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);
}
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;
}
Aggregations