use of net.sf.mzmine.datamodel.RawDataFile in project mzmine2 by mzmine.
the class ManualPickerTask method run.
public void run() {
setStatus(TaskStatus.PROCESSING);
logger.finest("Starting manual peak picker, RT: " + rtRange + ", m/z: " + mzRange);
// Calculate total number of scans to process
for (RawDataFile dataFile : dataFiles) {
int[] scanNumbers = dataFile.getScanNumbers(1, rtRange);
totalScans += scanNumbers.length;
}
// Find peak in each data file
for (RawDataFile dataFile : dataFiles) {
ManualPeak newPeak = new ManualPeak(dataFile);
boolean dataPointFound = false;
int[] scanNumbers = dataFile.getScanNumbers(1, rtRange);
for (int scanNumber : scanNumbers) {
if (isCanceled())
return;
// Get next scan
Scan scan = dataFile.getScan(scanNumber);
// Find most intense m/z peak
DataPoint basePeak = ScanUtils.findBasePeak(scan, mzRange);
if (basePeak != null) {
if (basePeak.getIntensity() > 0)
dataPointFound = true;
newPeak.addDatapoint(scan.getScanNumber(), basePeak);
} else {
final double mzCenter = (mzRange.lowerEndpoint() + mzRange.upperEndpoint()) / 2.0;
DataPoint fakeDataPoint = new SimpleDataPoint(mzCenter, 0);
newPeak.addDatapoint(scan.getScanNumber(), fakeDataPoint);
}
processedScans++;
}
if (dataPointFound) {
newPeak.finalizePeak();
if (newPeak.getArea() > 0)
peakListRow.addPeak(dataFile, newPeak);
} else {
peakListRow.removePeak(dataFile);
}
}
// Notify the GUI that peaklist contents have changed
if (peakList != null) {
// Check if the feature list row has been added to the feature list, and
// if it has not, add it
List<PeakListRow> rows = Arrays.asList(peakList.getRows());
if (!rows.contains(peakListRow)) {
peakList.addRow(peakListRow);
}
// Add quality parameters to peaks
QualityParameters.calculateQualityParameters(peakList);
project.notifyObjectChanged(peakList, true);
}
if (table != null) {
((AbstractTableModel) table.getModel()).fireTableDataChanged();
}
logger.finest("Finished manual peak picker, " + processedScans + " scans processed");
setStatus(TaskStatus.FINISHED);
}
use of net.sf.mzmine.datamodel.RawDataFile in project mzmine2 by mzmine.
the class BaselineCorrectionModule method runModule.
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
RawDataFile[] dataFiles = parameters.getParameter(BaselineCorrectionParameters.dataFiles).getValue().getMatchingRawDataFiles();
for (final RawDataFile dataFile : dataFiles) {
Task newTask = new BaselineCorrectionTask(project, dataFile, parameters);
tasks.add(newTask);
}
return ExitCode.OK;
}
use of net.sf.mzmine.datamodel.RawDataFile in project mzmine2 by mzmine.
the class UserParameterSaveHandler method fillParameterElement.
/**
* Create the part of the XML document related to the scans
*
* @param scan
* @param element
*/
private void fillParameterElement(UserParameter<?, ?> parameter, TransformerHandler hd) throws SAXException, IOException {
AttributesImpl atts = new AttributesImpl();
RawDataFile[] dataFiles = project.getDataFiles();
if (parameter instanceof ComboParameter) {
Object[] choices = ((ComboParameter<?>) parameter).getChoices();
for (Object choice : choices) {
hd.startElement("", "", UserParameterElementName.OPTION.getElementName(), atts);
hd.characters(choice.toString().toCharArray(), 0, choice.toString().length());
hd.endElement("", "", UserParameterElementName.OPTION.getElementName());
}
}
for (RawDataFile dataFile : dataFiles) {
Object value = project.getParameterValue(parameter, dataFile);
if (value == null)
continue;
String valueString = String.valueOf(value);
String dataFileID = dataFilesIDMap.get(dataFile);
atts.addAttribute("", "", UserParameterElementName.DATA_FILE.getElementName(), "CDATA", dataFileID);
hd.startElement("", "", UserParameterElementName.VALUE.getElementName(), atts);
atts.clear();
hd.characters(valueString.toCharArray(), 0, valueString.length());
hd.endElement("", "", UserParameterElementName.VALUE.getElementName());
}
}
use of net.sf.mzmine.datamodel.RawDataFile in project mzmine2 by mzmine.
the class ADAP3DModule method runModule.
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
RawDataFile[] dataFiles = parameters.getParameter(new RawDataFilesParameter()).getValue().getMatchingRawDataFiles();
for (int i = 0; i < dataFiles.length; i++) {
Task newTask = new ADAP3DTask(project, dataFiles[i], parameters.cloneParameterSet());
tasks.add(newTask);
}
return ExitCode.OK;
}
use of net.sf.mzmine.datamodel.RawDataFile in project mzmine2 by mzmine.
the class RawFileMergeModule method runModule.
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
// merge all selected
if (parameters.getParameter(RawFileMergeParameters.mode).getValue().equals(MODE.MERGE_SELECTED)) {
RawDataFile[] raw = parameters.getParameter(RawFileMergeParameters.dataFiles).getValue().getMatchingRawDataFiles();
RawFileMergeTask task = new RawFileMergeTask(project, parameters, raw);
tasks.add(task);
} else {
// sort files into merge groups
RawDataFile[] raw = parameters.getParameter(RawFileMergeParameters.dataFiles).getValue().getMatchingRawDataFiles();
POSITION pos = parameters.getParameter(RawFileMergeParameters.position).getValue();
String posMarker = parameters.getParameter(RawFileMergeParameters.posMarker).getValue();
String groupingElement = "";
List<RawDataFile> current = new ArrayList<>();
do {
current.clear();
for (int i = 0; i < raw.length; i++) {
if (raw[i] != null) {
String group = extractGroup(pos, posMarker, raw[i]);
if (current.isEmpty()) {
groupingElement = group;
current.add(raw[i]);
raw[i] = null;
} else if (group.equals(groupingElement)) {
current.add(raw[i]);
raw[i] = null;
}
}
}
// run task
if (current.size() > 1) {
RawFileMergeTask task = new RawFileMergeTask(project, parameters, current.toArray(new RawDataFile[current.size()]));
tasks.add(task);
}
} while (!current.isEmpty());
}
return ExitCode.OK;
}
Aggregations