PeakListTableColumnModel( GroupableTableHeader header, PeakListTableModel tableModel, ParameterSet parameters, PeakList peakList) { this.parameters = parameters; this.peakList = peakList; this.header = header; header.addMouseListener(this); // prepare formatters NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat(); NumberFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat(); // prepare cell renderers mzRenderer = new FormattedCellRenderer(mzFormat); rtRenderer = new FormattedCellRenderer(rtFormat); intensityRenderer = new FormattedCellRenderer(intensityFormat); peakShapeRenderer = new PeakShapeCellRenderer(peakList, parameters); identityRenderer = new CompoundIdentityCellRenderer(); peakStatusRenderer = new PeakStatusCellRenderer(); defaultRenderer = new DefaultTableCellRenderer(); defaultRenderer.setHorizontalAlignment(SwingConstants.CENTER); defaultRendererLeft = new DefaultTableCellRenderer(); defaultRendererLeft.setHorizontalAlignment(SwingConstants.LEFT); }
/** * Search for a peak-list row's mass spectrum. * * @param peakList the peak-list. * @param row the peak-list row. */ public static void singleRowSearch(final PeakList peakList, final PeakListRow row) { final ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(NistMsSearchModule.class); if (parameters.showSetupDialog() == ExitCode.OK) { MZmineCore.getTaskController().addTask(new NistMsSearchTask(row, peakList, parameters)); } }
/** @see java.lang.Runnable#run() */ public void run() { Task actualTask = wrappedTask.getActualTask(); logger.finest("Starting processing of task: " + actualTask.getTaskDescription()); try { // Process the actual task actualTask.run(); // Check if task finished with an error if (actualTask.getStatus() == TaskStatus.ERROR) { logger.severe("Task error: " + actualTask.getErrorMessage()); String errorMsg = actualTask.getErrorMessage(); if (errorMsg == null) errorMsg = "Unspecified error"; MZmineCore.getDesktop() .displayErrorMessage("Error of task " + actualTask.getTaskDescription(), errorMsg); } /* * This is important to allow the garbage collector to remove the * task, while keeping the task description in the * "Tasks in progress" window */ wrappedTask.removeTaskReference(); } catch (Throwable e) { /* * This should never happen, it means the task did not handle its * exception properly, or there was some severe error, like * OutOfMemoryError */ logger.log( Level.SEVERE, "Unhandled exception " + e + " while processing task " + actualTask.getTaskDescription(), e); e.printStackTrace(); MZmineCore.getDesktop() .displayErrorMessage( "Unhandled exception in task " + actualTask.getTaskDescription() + ": " + ExceptionUtils.exceptionToString(e)); } /* * Mark this thread as finished */ finished = true; }
public MsMsVisualizerWindow( RawDataFile dataFile, Range<Double> rtRange, Range<Double> mzRange, IntensityType intensityType, NormalizationType normalizationType, Double minPeakInt, ParameterSet parameters) { super("MS/MS visualizer: [" + dataFile.getName() + "]"); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setBackground(Color.white); this.dataFile = dataFile; this.tooltipMode = true; dataset = new MsMsDataSet( dataFile, rtRange, mzRange, intensityType, normalizationType, minPeakInt, this); toolBar = new MsMsToolBar(this); add(toolBar, BorderLayout.EAST); IDAPlot = new MsMsPlot(this, dataFile, this, dataset, rtRange, mzRange); add(IDAPlot, BorderLayout.CENTER); bottomPanel = new MsMsBottomPanel(this, dataFile, parameters); add(bottomPanel, BorderLayout.SOUTH); updateTitle(); // After we have constructed everything, load the peak lists into the // bottom panel bottomPanel.rebuildPeakListSelector(); MZmineCore.getDesktop().addPeakListTreeListener(bottomPanel); // Add the Windows menu JMenuBar menuBar = new JMenuBar(); menuBar.add(new WindowsMenu()); setJMenuBar(menuBar); pack(); // get the window settings parameter ParameterSet paramSet = MZmineCore.getConfiguration().getModuleParameters(MsMsVisualizerModule.class); WindowSettingsParameter settings = paramSet.getParameter(MsMsParameters.windowSettings); // update the window and listen for changes settings.applySettingsToWindow(this); this.addComponentListener(settings); }
@Override @Nonnull public ExitCode runModule(@Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) { final RawDataFile[] dataFiles = parameters.getParameter(TICVisualizerParameters.DATA_FILES).getValue(); final int msLevel = parameters.getParameter(TICVisualizerParameters.MS_LEVEL).getValue(); final Range rtRange = parameters.getParameter(TICVisualizerParameters.RT_RANGE).getValue(); final Range mzRange = parameters.getParameter(TICVisualizerParameters.MZ_RANGE).getValue(); final PlotType plotType = parameters.getParameter(TICVisualizerParameters.PLOT_TYPE).getValue(); final ChromatographicPeak[] selectionPeaks = parameters.getParameter(TICVisualizerParameters.PEAKS).getValue(); if (dataFiles == null || dataFiles.length == 0) { MZmineCore.getDesktop().displayErrorMessage("Please select raw data file(s)"); } else { // Add the window to the desktop only if we actually have any raw // data to show. boolean weHaveData = false; for (int i = 0, dataFilesLength = dataFiles.length; !weHaveData && i < dataFilesLength; i++) { weHaveData = dataFiles[i].getScanNumbers(msLevel, rtRange).length > 0; } if (weHaveData) { MZmineCore.getDesktop() .addInternalFrame( new TICVisualizerWindow( dataFiles, plotType, msLevel, rtRange, mzRange, selectionPeaks, ((TICVisualizerParameters) parameters).getPeakLabelMap())); } else { MZmineCore.getDesktop() .displayErrorMessage( "No scans found at MS level " + msLevel + " within given retention time range."); } } return ExitCode.OK; }
@Override public void loadValueFromXML(Element xmlElement) { PeakList[] currentDataPeakLists = MZmineCore.getProjectManager().getCurrentProject().getPeakLists(); PeakListsSelectionType selectionType; final String attrValue = xmlElement.getAttribute("type"); if (Strings.isNullOrEmpty(attrValue)) selectionType = PeakListsSelectionType.GUI_SELECTED_PEAKLISTS; else selectionType = PeakListsSelectionType.valueOf(xmlElement.getAttribute("type")); ArrayList<Object> newValues = new ArrayList<Object>(); NodeList items = xmlElement.getElementsByTagName("specific_peak_list"); for (int i = 0; i < items.getLength(); i++) { String itemString = items.item(i).getTextContent(); for (PeakList df : currentDataPeakLists) { if (df.getName().equals(itemString)) newValues.add(df); } } PeakList specificPeakLists[] = newValues.toArray(new PeakList[0]); String namePattern = null; items = xmlElement.getElementsByTagName("name_pattern"); for (int i = 0; i < items.getLength(); i++) { namePattern = items.item(i).getTextContent(); } this.value = new PeakListsSelection(); this.value.setSelectionType(selectionType); this.value.setSpecificPeakLists(specificPeakLists); this.value.setNamePattern(namePattern); }
public ExitCode showSetupDialog() { JFileChooser chooser = new JFileChooser(); for (FileFilter filter : filters) chooser.setFileFilter(filter); chooser.setFileFilter(filters[0]); File lastFiles[] = getParameter(fileNames).getValue(); if ((lastFiles != null) && (lastFiles.length > 0)) { File currentDir = lastFiles[0].getParentFile(); if ((currentDir != null) && (currentDir.exists())) chooser.setCurrentDirectory(currentDir); } chooser.setMultiSelectionEnabled(true); int returnVal = chooser.showOpenDialog(MZmineCore.getDesktop().getMainWindow()); if (returnVal != JFileChooser.APPROVE_OPTION) return ExitCode.CANCEL; File selectedFiles[] = chooser.getSelectedFiles(); getParameter(fileNames).setValue(selectedFiles); return ExitCode.OK; }
public FragmentIdentity(final PeakListRow mainPeakListRow) { super( "Fragment of " + MZmineCore.getConfiguration().getMZFormat().format(mainPeakListRow.getAverageMZ()) + " m/z"); setPropertyValue(PROPERTY_METHOD, "Fragment search"); }
/** Remove a remote job descriptor from the data file */ public synchronized void removeJob(String name) { for (RemoteJob job : jobs_info) { if (job.getName().equals(name)) { jobs_info.remove(job); MZmineCore.getCurrentProject().removeJob(job); break; } } }
public static void setupNewTICVisualizer(final RawDataFile[] dataFiles) { setupNewTICVisualizer( MZmineCore.getCurrentProject().getDataFiles(), dataFiles, new ChromatographicPeak[0], new ChromatographicPeak[0], null, null, null); }
public static void setupNewTICVisualizer( final RawDataFile[] allFiles, final RawDataFile[] selectedFiles, final ChromatographicPeak[] allPeaks, final ChromatographicPeak[] selectedPeaks, final Map<ChromatographicPeak, String> peakLabels, final Range rtRange, final Range mzRange) { assert allFiles != null; final TICVisualizerModule myInstance = MZmineCore.getModuleInstance(TICVisualizerModule.class); final TICVisualizerParameters myParameters = (TICVisualizerParameters) MZmineCore.getConfiguration().getModuleParameters(TICVisualizerModule.class); myParameters.getParameter(TICVisualizerParameters.MS_LEVEL).setValue(1); myParameters.getParameter(TICVisualizerParameters.PLOT_TYPE).setValue(PlotType.BASEPEAK); if (rtRange != null) { myParameters.getParameter(TICVisualizerParameters.RT_RANGE).setValue(rtRange); } if (mzRange != null) { myParameters.getParameter(TICVisualizerParameters.MZ_RANGE).setValue(mzRange); } if (myParameters.showSetupDialog(allFiles, selectedFiles, allPeaks, selectedPeaks) == ExitCode.OK) { final TICVisualizerParameters p = (TICVisualizerParameters) myParameters.cloneParameter(); if (peakLabels != null) { p.setPeakLabelMap(peakLabels); } myInstance.runModule(p, new ArrayList<Task>()); } }
/** Reloads peak lists from the project to the selector combo box */ void rebuildPeakListSelector() { logger.finest("Rebuilding the peak list selector"); PeakList selectedPeakList = (PeakList) peakListSelector.getSelectedItem(); PeakList currentPeakLists[] = MZmineCore.getProjectManager().getCurrentProject().getPeakLists(dataFile); peakListSelector.removeAllItems(); for (int i = currentPeakLists.length - 1; i >= 0; i--) { peakListSelector.addItem(currentPeakLists[i]); } if (selectedPeakList != null) peakListSelector.setSelectedItem(selectedPeakList); }
public static void showNewTICVisualizerWindow( final RawDataFile[] dataFiles, final ChromatographicPeak[] selectionPeaks, final Map<ChromatographicPeak, String> peakLabels, final int msLevel, final PlotType plotType, final Range rtRange, final Range mzRange) { MZmineCore.getDesktop() .addInternalFrame( new TICVisualizerWindow( dataFiles, plotType, msLevel, rtRange, mzRange, selectionPeaks, peakLabels)); }
public void dispose() { super.dispose(); MZmineCore.getDesktop().removePeakListTreeListener(bottomPanel); }
/** * Parameters used by CentWaveDetector. * * @author $Author: cpudney $ * @version $Revision: 3153 $ */ public class CentWaveDetectorParameters extends SimpleParameterSet { /** Peak integration methods. */ public enum PeakIntegrationMethod { UseSmoothedData("Use smoothed data", 1), UseRawData("Use raw data", 2); private final String name; private final int index; /** * Create the method. * * @param aName name * @param anIndex index (as used by findPeaks.centWave) */ PeakIntegrationMethod(final String aName, final int anIndex) { name = aName; index = anIndex; } @Override public String toString() { return name; } public int getIndex() { return index; } } public static final RangeParameter PEAK_DURATION = new RangeParameter( "Peak duration range", "Range of acceptable peak lengths", MZmineCore.getConfiguration().getRTFormat(), new Range(0.0, 10.0)); public static final RangeParameter PEAK_SCALES = new RangeParameter( "Wavelet scales", "Range wavelet widths (smallest, largest) in minutes", MZmineCore.getConfiguration().getRTFormat(), new Range(0.25, 5.0)); public static final DoubleParameter SN_THRESHOLD = new DoubleParameter( "S/N threshold", "Signal to noise ratio threshold", NumberFormat.getNumberInstance(), 10.0, 0.0, null); public static final ComboParameter<PeakIntegrationMethod> INTEGRATION_METHOD = new ComboParameter<PeakIntegrationMethod>( "Peak integration method", "Method used to determine RT extents of detected peaks", PeakIntegrationMethod.values(), PeakIntegrationMethod.UseSmoothedData); public CentWaveDetectorParameters() { super(new Parameter[] {SN_THRESHOLD, PEAK_SCALES, PEAK_DURATION, INTEGRATION_METHOD}); } @Override public ExitCode showSetupDialog() { final PeakResolverSetupDialog dialog = new PeakResolverSetupDialog(this, CentWaveDetector.class); dialog.setVisible(true); return dialog.getExitCode(); } }
public class PeakSummaryTableModel extends AbstractTableModel { private static NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); private static NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat(); private static NumberFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat(); private Vector<ChromatographicPeak> peaks = new Vector<ChromatographicPeak>(); private Vector<Color> peakColors = new Vector<Color>(); private static String[] columnNames = {"File Name", "Mass", "RT", "Height", "Area"}; public String getColumnName(int col) { return columnNames[col].toString(); } public int getRowCount() { return peaks.size(); } public int getColumnCount() { return columnNames.length; } public Object getValueAt(int row, int col) { Object value = null; ChromatographicPeak peak = peaks.get(row); switch (col) { case (0): value = peak.getDataFile().getName(); break; case (1): value = mzFormat.format(peak.getMZ()); break; case (2): value = rtFormat.format(peak.getRT()); break; case (3): value = intensityFormat.format(peak.getHeight()); break; case (4): value = intensityFormat.format(peak.getArea()); break; } return value; } public ChromatographicPeak getElementAt(int row) { return peaks.get(row); } public boolean isCellEditable(int row, int col) { return false; } public Color getPeakColor(int row) { return peakColors.get(row); } public void addElement(ChromatographicPeak peak, Color peakColor) { peaks.add(peak); peakColors.add(peakColor); fireTableRowsInserted(0, peaks.size() - 1); } public void setValueAt(Object value, int row, int col) {} public int getIndexRow(String fileName) { String localFileName; int index = -1; for (int i = 0; i < peaks.size(); i++) { localFileName = peaks.get(i).getDataFile().getName(); if (localFileName.equals(fileName)) { index = i; } } return index; } }
/** @see Runnable#run() */ public void run() { if ((mzWeight == 0) && (rtWeight == 0)) { setStatus(TaskStatus.ERROR); errorMessage = "Cannot run alignment, all the weight parameters are zero"; return; } setStatus(TaskStatus.PROCESSING); logger.info("Running join aligner"); // Remember how many rows we need to process. Each row will be processed // twice, first for score calculation, second for actual alignment. for (int i = 0; i < peakLists.length; i++) { totalRows += peakLists[i].getNumberOfRows() * 2; } // Collect all data files Vector<RawDataFile> allDataFiles = new Vector<RawDataFile>(); for (PeakList peakList : peakLists) { for (RawDataFile dataFile : peakList.getRawDataFiles()) { // Each data file can only have one column in aligned peak list if (allDataFiles.contains(dataFile)) { setStatus(TaskStatus.ERROR); errorMessage = "Cannot run alignment, because file " + dataFile + " is present in multiple peak lists"; return; } allDataFiles.add(dataFile); } } // Create a new aligned peak list alignedPeakList = new SimplePeakList(peakListName, allDataFiles.toArray(new RawDataFile[0])); // Iterate source peak lists for (PeakList peakList : peakLists) { // Create a sorted set of scores matching TreeSet<RowVsRowScore> scoreSet = new TreeSet<RowVsRowScore>(); PeakListRow allRows[] = peakList.getRows(); // Calculate scores for all possible alignments of this row for (PeakListRow row : allRows) { if (isCanceled()) return; // Calculate limits for a row with which the row can be aligned Range mzRange = mzTolerance.getToleranceRange(row.getAverageMZ()); Range rtRange = rtTolerance.getToleranceRange(row.getAverageRT()); // Get all rows of the aligned peaklist within parameter limits PeakListRow candidateRows[] = alignedPeakList.getRowsInsideScanAndMZRange(rtRange, mzRange); // Calculate scores and store them for (PeakListRow candidate : candidateRows) { if (sameChargeRequired) { if (!PeakUtils.compareChargeState(row, candidate)) continue; } if (sameIDRequired) { if (!PeakUtils.compareIdentities(row, candidate)) continue; } if (compareIsotopePattern) { IsotopePattern ip1 = row.getBestIsotopePattern(); IsotopePattern ip2 = candidate.getBestIsotopePattern(); if ((ip1 != null) && (ip2 != null)) { ParameterSet isotopeParams = parameters .getParameter(JoinAlignerParameters.compareIsotopePattern) .getEmbeddedParameters(); if (!IsotopePatternScoreCalculator.checkMatch(ip1, ip2, isotopeParams)) { continue; } } } RowVsRowScore score = new RowVsRowScore( row, candidate, mzRange.getSize() / 2, mzWeight, rtRange.getSize() / 2, rtWeight); scoreSet.add(score); } processedRows++; } // Create a table of mappings for best scores Hashtable<PeakListRow, PeakListRow> alignmentMapping = new Hashtable<PeakListRow, PeakListRow>(); // Iterate scores by descending order Iterator<RowVsRowScore> scoreIterator = scoreSet.iterator(); while (scoreIterator.hasNext()) { RowVsRowScore score = scoreIterator.next(); // Check if the row is already mapped if (alignmentMapping.containsKey(score.getPeakListRow())) continue; // Check if the aligned row is already filled if (alignmentMapping.containsValue(score.getAlignedRow())) continue; alignmentMapping.put(score.getPeakListRow(), score.getAlignedRow()); } // Align all rows using mapping for (PeakListRow row : allRows) { PeakListRow targetRow = alignmentMapping.get(row); // If we have no mapping for this row, add a new one if (targetRow == null) { targetRow = new SimplePeakListRow(newRowID); newRowID++; alignedPeakList.addRow(targetRow); } // Add all peaks from the original row to the aligned row for (RawDataFile file : row.getRawDataFiles()) { targetRow.addPeak(file, row.getPeak(file)); } // Add all non-existing identities from the original row to the // aligned row PeakUtils.copyPeakListRowProperties(row, targetRow); processedRows++; } } // Next peak list // Add new aligned peak list to the project MZmineProject currentProject = MZmineCore.getCurrentProject(); currentProject.addPeakList(alignedPeakList); // Add task description to peakList alignedPeakList.addDescriptionOfAppliedTask( new SimplePeakListAppliedMethod("Join aligner", parameters)); logger.info("Finished join aligner"); setStatus(TaskStatus.FINISHED); }
/** Add a remote job descriptor to the data file */ public synchronized void addJob( String name, RawDataFile raw, String targetName, VeritomyxSaaS vtmx) { RemoteJob job = new RemoteJob(name, raw, targetName, vtmx); this.jobs_info.add(job); MZmineCore.getCurrentProject().addJob(job); }