use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.
the class IsotopePeakScannerTask method setUpDiffAutoCarbon.
/**
* This calculates the isotope pattern using ExtendedIsotopePattern and creates an
* ArrayList<Double> that will contain the mass shift for every expected isotope peak relative to
* the one with the lowest mass.
*
* @return
*/
private double[][] setUpDiffAutoCarbon() {
// ArrayList<Double> diff = new ArrayList<Double>(2);
double[][] diff;
if (scanType == ScanType.AUTOCARBON) {
String[] strPattern = new String[carbonRange];
ExtendedIsotopePattern[] patternBuffer = new ExtendedIsotopePattern[carbonRange];
// in the following for we calculate up the patterns
for (int p = 0; p < carbonRange; p++) {
if (p + autoCarbonMin != 0)
strPattern[p] = "C" + (p + autoCarbonMin) + element;
else
strPattern[p] = element;
try {
patternBuffer[p] = (ExtendedIsotopePattern) IsotopePatternCalculator.calculateIsotopePattern(strPattern[p], 0.001, mergeWidth, charge, polarityType, true);
patternBuffer[p] = (ExtendedIsotopePattern) IsotopePatternCalculator.removeDataPointsBelowIntensity(patternBuffer[p], minPatternIntensity);
} catch (Exception e) {
logger.warning("The entered Sum formula is invalid.");
return null;
}
}
int sizeCounter = 0;
// if they dont fit we null them
for (int p = 0; p < carbonRange; p++) {
if (patternBuffer[p].getNumberOfDataPoints() >= autoCarbonMinPatternSize) {
sizeCounter++;
} else {
patternBuffer[p] = null;
}
}
if (sizeCounter == 0)
throw new MSDKRuntimeException("Min pattern size excludes every calculated isotope pattern.\nPlease increase min pattern intensity for more data points or decrease the minimum pattern size.");
logger.info("about to add " + sizeCounter + " patterns to the scan.");
diff = new double[sizeCounter][];
int addCounter = 0;
pattern = new ExtendedIsotopePattern[sizeCounter];
for (int p = 0; p < carbonRange; p++) {
if (patternBuffer[p] == null)
continue;
pattern[addCounter] = patternBuffer[p];
DataPoint[] points = patternBuffer[p].getDataPoints();
diff[addCounter] = new double[points.length];
if (maxPatternSize < diff[addCounter].length) {
maxPatternSize = diff[addCounter].length;
maxPatternIndex = addCounter;
}
for (int i = 0; i < pattern[addCounter].getNumberOfDataPoints(); i++) {
diff[addCounter][i] = points[i].getMZ() - points[0].getMZ();
}
addCounter++;
}
} else /* if(scanType == ScanType.SPECIFIC) */
{
diff = new double[1][];
pattern = new ExtendedIsotopePattern[1];
pattern[0] = (ExtendedIsotopePattern) IsotopePatternCalculator.calculateIsotopePattern(element, 0.001, mergeWidth, charge, polarityType, true);
pattern[0] = (ExtendedIsotopePattern) IsotopePatternCalculator.removeDataPointsBelowIntensity(pattern[0], minPatternIntensity);
DataPoint[] points = pattern[0].getDataPoints();
diff[0] = new double[points.length];
if (maxPatternSize < diff[0].length) {
maxPatternSize = diff[0].length;
maxPatternIndex = 0;
}
for (int i = 0; i < pattern[0].getNumberOfDataPoints(); i++) {
diff[0][i] = points[i].getMZ() - points[0].getMZ();
}
}
logger.info("diff set up...");
return diff;
}
use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.
the class RawDataFileImpl method addScan.
@Override
public synchronized void addScan(Scan newScan) throws IOException {
// and we just need store the reference
if (newScan instanceof StorableScan) {
scans.put(newScan.getScanNumber(), (StorableScan) newScan);
return;
}
DataPoint[] dataPoints = newScan.getDataPoints();
final int storageID = storeDataPoints(dataPoints);
StorableScan storedScan = new StorableScan(newScan, this, dataPoints.length, storageID);
scans.put(newScan.getScanNumber(), storedScan);
}
use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.
the class RawDataFileImpl method getDataMaxBasePeakIntensity.
/**
* @see net.sf.mzmine.datamodel.RawDataFile#getDataMaxBasePeakIntensity()
*/
@Override
public double getDataMaxBasePeakIntensity(int msLevel) {
// check if we have this value already cached
Double maxBasePeak = dataMaxBasePeakIntensity.get(msLevel);
if (maxBasePeak != null)
return maxBasePeak;
// find the value
Enumeration<StorableScan> scansEnum = scans.elements();
while (scansEnum.hasMoreElements()) {
Scan scan = scansEnum.nextElement();
// ignore scans of other ms levels
if (scan.getMSLevel() != msLevel)
continue;
DataPoint scanBasePeak = scan.getHighestDataPoint();
if (scanBasePeak == null)
continue;
if ((maxBasePeak == null) || (scanBasePeak.getIntensity() > maxBasePeak))
maxBasePeak = scanBasePeak.getIntensity();
}
// return -1 if no scan at this MS level
if (maxBasePeak == null)
maxBasePeak = -1d;
// cache the value
dataMaxBasePeakIntensity.put(msLevel, maxBasePeak);
return maxBasePeak;
}
use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.
the class RawDataFileImpl method readDataPoints.
public synchronized DataPoint[] readDataPoints(int ID) throws IOException {
final Long currentOffset = dataPointsOffsets.get(ID);
final Integer numOfDataPoints = dataPointsLengths.get(ID);
if ((currentOffset == null) || (numOfDataPoints == null)) {
throw new IllegalArgumentException("Unknown storage ID " + ID);
}
final int numOfBytes = numOfDataPoints * 2 * 4;
if (buffer.capacity() < numOfBytes) {
buffer = ByteBuffer.allocate(numOfBytes * 2);
} else {
// JDK 9 breaks compatibility with JRE8: need to cast
// https://stackoverflow.com/questions/48693695/java-nio-buffer-not-loading-clear-method-on-runtime
((Buffer) buffer).clear();
}
dataPointsFile.seek(currentOffset);
dataPointsFile.read(buffer.array(), 0, numOfBytes);
FloatBuffer floatBuffer = buffer.asFloatBuffer();
DataPoint[] dataPoints = new DataPoint[numOfDataPoints];
for (int i = 0; i < numOfDataPoints; i++) {
float mz = floatBuffer.get();
float intensity = floatBuffer.get();
dataPoints[i] = new SimpleDataPoint(mz, intensity);
}
return dataPoints;
}
use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.
the class StorableScan method updateValues.
void updateValues() {
DataPoint[] dataPoints = getDataPoints();
// find m/z range and base peak
if (dataPoints.length > 0) {
basePeak = dataPoints[0];
mzRange = Range.singleton(dataPoints[0].getMZ());
double tic = 0;
for (DataPoint dp : dataPoints) {
if (dp.getIntensity() > basePeak.getIntensity())
basePeak = dp;
mzRange = mzRange.span(Range.singleton(dp.getMZ()));
tic += dp.getIntensity();
}
totalIonCurrent = new Double(tic);
} else {
mzRange = Range.singleton(0.0);
totalIonCurrent = new Double(0);
}
}
Aggregations