use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class XMLExportTask method run.
/**
* @see java.lang.Runnable#run()
*/
public void run() {
setStatus(TaskStatus.PROCESSING);
// Shall export several files?
boolean substitute = fileName.getPath().contains(plNamePattern);
// Process feature lists
for (int i = 0; i < peakLists.length; i++) {
PeakList peakList = peakLists[i];
File curFile = fileName;
try {
// Filename
if (substitute) {
// Cleanup from illegal filename characters
String cleanPlName = peakList.getName().replaceAll("[^a-zA-Z0-9.-]", "_");
// Substitute
String newFilename = fileName.getPath().replaceAll(Pattern.quote(plNamePattern), cleanPlName);
curFile = new File(newFilename);
}
// Open file
FileWriter writer;
try {
writer = new FileWriter(curFile);
} catch (Exception e) {
setStatus(TaskStatus.ERROR);
setErrorMessage("Could not open file " + curFile + " for writing.");
return;
}
logger.info("Started saving feature list " + peakList.getName());
// write the saving file
FileOutputStream fos = new FileOutputStream(curFile);
OutputStream finalStream = fos;
if (compression) {
@SuppressWarnings("resource") ZipOutputStream zos = new ZipOutputStream(fos);
zos.setLevel(9);
zos.putNextEntry(new ZipEntry(fileName.getName()));
finalStream = zos;
}
Hashtable<RawDataFile, String> dataFilesIDMap = new Hashtable<RawDataFile, String>();
for (RawDataFile file : peakList.getRawDataFiles()) {
dataFilesIDMap.put(file, file.getName());
}
PeakListSaveHandler peakListSaveHandler = new PeakListSaveHandler(finalStream, dataFilesIDMap);
peakListSaveHandlers[i] = peakListSaveHandler;
peakListSaveHandler.savePeakList(peakList);
finalStream.close();
} catch (Exception e) {
/* we may already have set the status to CANCELED */
if (getStatus() == TaskStatus.PROCESSING) {
setStatus(TaskStatus.ERROR);
}
setErrorMessage(e.toString());
e.printStackTrace();
return;
}
logger.info("Finished saving " + peakList.getName());
setStatus(TaskStatus.FINISHED);
}
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class IsotopeGrouperModule method runModule.
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
PeakList[] peakLists = parameters.getParameter(IsotopeGrouperParameters.peakLists).getValue().getMatchingPeakLists();
for (final PeakList peakList : peakLists) {
Task newTask = new IsotopeGrouperTask(project, peakList, parameters);
tasks.add(newTask);
}
return ExitCode.OK;
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class ADAP3DecompositionV2SetupDialog method shapeCluster.
/**
* Cluster list of PeakInfo based on the chromatographic shapes
*/
private void shapeCluster() {
ChromatogramPeakPair chromatogramPeakPair = cboPeakLists.getItemAt(cboPeakLists.getSelectedIndex());
if (chromatogramPeakPair == null)
return;
PeakList chromatogramList = chromatogramPeakPair.chromatograms;
PeakList peakList = chromatogramPeakPair.peaks;
if (chromatogramList == null || peakList == null)
return;
final RetTimeClusterer.Cluster cluster = cboClusters.getItemAt(cboClusters.getSelectedIndex());
if (cluster == null)
return;
Double retTimeTolerance = parameterSet.getParameter(ADAP3DecompositionV2Parameters.RET_TIME_TOLERANCE).getValue();
Boolean adjustApexRetTime = parameterSet.getParameter(ADAP3DecompositionV2Parameters.ADJUST_APEX_RET_TIME).getValue();
Integer minClusterSize = parameterSet.getParameter(ADAP3DecompositionV2Parameters.MIN_CLUSTER_SIZE).getValue();
if (retTimeTolerance == null || retTimeTolerance <= 0.0 || adjustApexRetTime == null || minClusterSize == null || minClusterSize <= 0)
return;
List<BetterPeak> chromatograms = new ADAP3DecompositionV2Utils().getPeaks(chromatogramList);
List<BetterComponent> components = null;
try {
components = new ComponentSelector().execute(chromatograms, cluster, retTimeTolerance, adjustApexRetTime, minClusterSize);
} catch (Exception e) {
e.printStackTrace();
}
if (components != null)
// chromatograms
retTimeIntensityPlot.updateData(chromatograms, components);
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class PeakListsComponent method actionPerformed.
public void actionPerformed(ActionEvent event) {
Object src = event.getSource();
if (src == detailsButton) {
PeakListsSelectionType type = (PeakListsSelectionType) typeCombo.getSelectedItem();
if (type == PeakListsSelectionType.SPECIFIC_PEAKLISTS) {
final MultiChoiceParameter<PeakList> plsParameter = new MultiChoiceParameter<PeakList>("Select feature lists", "Select feature lists", MZmineCore.getProjectManager().getCurrentProject().getPeakLists(), currentValue.getSpecificPeakLists());
final SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { plsParameter });
final Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
final ExitCode exitCode = paramSet.showSetupDialog(parent, true);
if (exitCode == ExitCode.OK) {
PeakList[] pls = paramSet.getParameter(plsParameter).getValue();
currentValue.setSpecificPeakLists(pls);
}
}
if (type == PeakListsSelectionType.NAME_PATTERN) {
final StringParameter nameParameter = new StringParameter("Name pattern", "Set name pattern that may include wildcards (*), e.g. *mouse* matches any name that contains mouse", currentValue.getNamePattern());
final SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { nameParameter });
final Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
final ExitCode exitCode = paramSet.showSetupDialog(parent, true);
if (exitCode == ExitCode.OK) {
String namePattern = paramSet.getParameter(nameParameter).getValue();
currentValue.setNamePattern(namePattern);
}
}
}
if (src == typeCombo) {
PeakListsSelectionType type = (PeakListsSelectionType) typeCombo.getSelectedItem();
currentValue.setSelectionType(type);
detailsButton.setEnabled((type == PeakListsSelectionType.NAME_PATTERN) || (type == PeakListsSelectionType.SPECIFIC_PEAKLISTS));
}
updateNumPeakLists();
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class FeaturesSelectionDialog method actionPerformed.
/*
*
*
* @see
* java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
@Override
public void actionPerformed(ActionEvent event) {
Object src = event.getSource();
if (src == btnOk) {
returnState = true;
this.dispose();
}
if (src == btnCancel) {
returnState = false;
this.dispose();
}
if (src == rawDataFileComboBox) {
panel12.removeAll();
RawDataFile dataFile = (RawDataFile) rawDataFileComboBox.getSelectedItem();
Feature[] features = allPeakLists[selectedIndex].getPeaks(dataFile);
featuresSelectionBox = new MultipleSelectionComponent<Feature>(features);
featuresSelectionBox.setToolTipText("Features Selection Box");
panel12.add(featuresSelectionBox, BorderLayout.CENTER);
panel12.revalidate();
}
if (src == peakListComboBox) {
PeakList peakList = (PeakList) peakListComboBox.getSelectedItem();
panel11.removeAll();
panel12.removeAll();
for (int j = 0; j < allPeakLists.length; j++) {
if (peakList.equals(allPeakLists[j])) {
RawDataFile[] rawDataFiles = allPeakLists[j].getRawDataFiles();
rawDataFileComboBox = new JComboBox<RawDataFile>(rawDataFiles);
rawDataFileComboBox.setToolTipText("Raw data files Selection Box");
rawDataFileComboBox.addActionListener(this);
panel11.add(rawDataFileComboBox, BorderLayout.CENTER);
this.setSize(670, 400);
LOG.finest("PeakListRowComboBox is Added");
selectedIndex = j;
RawDataFile datafile = allPeakLists[j].getRawDataFile(0);
Feature[] features = allPeakLists[j].getPeaks(datafile);
featuresSelectionBox = new MultipleSelectionComponent<Feature>(features);
featuresSelectionBox.setToolTipText("Features Selection Box");
panel12.add(featuresSelectionBox, BorderLayout.CENTER);
}
panel11.revalidate();
panel12.revalidate();
}
}
}
Aggregations