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); }
public Number getX(int series, int index) { return dataFile.getScan(scanNumbers[index]).getRetentionTime(); }
public void createColumns() { // clear column groups ColumnGroup groups[] = header.getColumnGroups(); if (groups != null) { for (ColumnGroup group : groups) { header.removeColumnGroup(group); } } // clear the column model while (getColumnCount() > 0) { TableColumn col = getColumn(0); removeColumn(col); } // create the "average" group ColumnGroup averageGroup = new ColumnGroup("Average"); header.addColumnGroup(averageGroup); JTextField editorField = new JTextField(); editorField.setFont(editFont); DefaultCellEditor defaultEditor = new DefaultCellEditor(editorField); ColumnSettingParameter<CommonColumnType> csPar = parameters.getParameter(PeakListTableParameters.commonColumns); CommonColumnType visibleCommonColumns[] = csPar.getValue(); // This is a workaround for a bug - we need to always show the ID, m/z // and RT columns, otherwise manual editing of peak identities does not // work. ArrayList<CommonColumnType> commonColumnsList = new ArrayList<>(Arrays.asList(visibleCommonColumns)); commonColumnsList.remove(CommonColumnType.ROWID); commonColumnsList.remove(CommonColumnType.AVERAGEMZ); commonColumnsList.remove(CommonColumnType.AVERAGERT); commonColumnsList.add(0, CommonColumnType.ROWID); commonColumnsList.add(1, CommonColumnType.AVERAGEMZ); commonColumnsList.add(2, CommonColumnType.AVERAGERT); visibleCommonColumns = commonColumnsList.toArray(visibleCommonColumns); ColumnSettingParameter<DataFileColumnType> dfPar = parameters.getParameter(PeakListTableParameters.dataFileColumns); DataFileColumnType visibleDataFileColumns[] = dfPar.getValue(); for (int i = 0; i < visibleCommonColumns.length; i++) { CommonColumnType commonColumn = visibleCommonColumns[i]; int modelIndex = Arrays.asList(CommonColumnType.values()).indexOf(commonColumn); TableColumn newColumn = new TableColumn(modelIndex); newColumn.setHeaderValue(commonColumn.getColumnName()); newColumn.setIdentifier(commonColumn); switch (commonColumn) { case AVERAGEMZ: newColumn.setCellRenderer(mzRenderer); break; case AVERAGERT: newColumn.setCellRenderer(rtRenderer); break; case IDENTITY: newColumn.setCellRenderer(identityRenderer); break; case COMMENT: newColumn.setCellRenderer(defaultRendererLeft); newColumn.setCellEditor(defaultEditor); break; case PEAKSHAPE: newColumn.setCellRenderer(peakShapeRenderer); break; default: newColumn.setCellRenderer(defaultRenderer); } this.addColumn(newColumn); newColumn.setPreferredWidth(csPar.getColumnWidth(modelIndex)); if ((commonColumn == CommonColumnType.AVERAGEMZ) || (commonColumn == CommonColumnType.AVERAGERT)) { averageGroup.add(newColumn); } } for (int i = 0; i < peakList.getNumberOfRawDataFiles(); i++) { RawDataFile dataFile = peakList.getRawDataFile(i); ColumnGroup fileGroup = new ColumnGroup(dataFile.getName()); header.addColumnGroup(fileGroup); for (int j = 0; j < visibleDataFileColumns.length; j++) { DataFileColumnType dataFileColumn = visibleDataFileColumns[j]; int dataFileColumnIndex = Arrays.asList(DataFileColumnType.values()).indexOf(dataFileColumn); int modelIndex = CommonColumnType.values().length + (i * DataFileColumnType.values().length) + dataFileColumnIndex; TableColumn newColumn = new TableColumn(modelIndex); newColumn.setHeaderValue(dataFileColumn.getColumnName()); newColumn.setIdentifier(dataFileColumn); switch (dataFileColumn) { case MZ: newColumn.setCellRenderer(mzRenderer); break; case PEAKSHAPE: newColumn.setCellRenderer(peakShapeRenderer); break; case STATUS: newColumn.setCellRenderer(peakStatusRenderer); break; case RT: newColumn.setCellRenderer(rtRenderer); break; case RT_START: newColumn.setCellRenderer(rtRenderer); break; case RT_END: newColumn.setCellRenderer(rtRenderer); break; case DURATION: newColumn.setCellRenderer(rtRenderer); break; case HEIGHT: newColumn.setCellRenderer(intensityRenderer); break; case AREA: newColumn.setCellRenderer(intensityRenderer); break; default: newColumn.setCellRenderer(defaultRenderer); break; } this.addColumn(newColumn); newColumn.setPreferredWidth(dfPar.getColumnWidth(dataFileColumnIndex)); fileGroup.add(newColumn); } } }
/** * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, * java.lang.String) */ public void endElement(String namespaceURI, String sName, String qName) throws SAXException { if (canceled) throw new SAXException("Parsing canceled"); // <NAME> if (qName.equals(PeakListElementName_2_3.PEAKLIST_NAME.getElementName())) { name = getTextOfElement(); logger.info("Loading peak list: " + name); peakListName = name; } // <PEAKLIST_DATE> if (qName.equals(PeakListElementName_2_3.PEAKLIST_DATE.getElementName())) { dateCreated = getTextOfElement(); } // <QUANTITY> if (qName.equals(PeakListElementName_2_3.QUANTITY.getElementName())) { String text = getTextOfElement(); totalRows = Integer.parseInt(text); } // <RAW_FILE> if (qName.equals(PeakListElementName_2_3.RAWFILE.getElementName())) { rawDataFileID = getTextOfElement(); RawDataFile dataFile = dataFilesIDMap.get(rawDataFileID); if (dataFile == null) { throw new SAXException( "Cannot open peak list, because raw data file " + rawDataFileID + " is missing."); } currentPeakListDataFiles.add(dataFile); } // <SCAN_ID> if (qName.equals(PeakListElementName_2_3.SCAN_ID.getElementName())) { byte[] bytes = Base64.decodeToBytes(getTextOfElement()); // make a data input stream DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(bytes)); scanNumbers = new int[numOfMZpeaks]; for (int i = 0; i < numOfMZpeaks; i++) { try { scanNumbers[i] = dataInputStream.readInt(); } catch (IOException ex) { throw new SAXException(ex); } } } // <REPRESENTATIVE_SCAN> if (qName.equals(PeakListElementName_2_3.REPRESENTATIVE_SCAN.getElementName())) { representativeScan = Integer.valueOf(getTextOfElement()); } // <FRAGMENT_SCAN> if (qName.equals(PeakListElementName_2_3.FRAGMENT_SCAN.getElementName())) { fragmentScan = Integer.valueOf(getTextOfElement()); } // <MASS> if (qName.equals(PeakListElementName_2_3.MZ.getElementName())) { byte[] bytes = Base64.decodeToBytes(getTextOfElement()); // make a data input stream DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(bytes)); masses = new double[numOfMZpeaks]; for (int i = 0; i < numOfMZpeaks; i++) { try { masses[i] = (double) dataInputStream.readFloat(); } catch (IOException ex) { throw new SAXException(ex); } } } // <HEIGHT> if (qName.equals(PeakListElementName_2_3.HEIGHT.getElementName())) { byte[] bytes = Base64.decodeToBytes(getTextOfElement()); // make a data input stream DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(bytes)); intensities = new double[numOfMZpeaks]; for (int i = 0; i < numOfMZpeaks; i++) { try { intensities[i] = (double) dataInputStream.readFloat(); } catch (IOException ex) { throw new SAXException(ex); } } } // <PEAK> if (qName.equals(PeakListElementName_2_3.PEAK.getElementName())) { DataPoint[] mzPeaks = new DataPoint[numOfMZpeaks]; Range peakRTRange = null, peakMZRange = null, peakIntensityRange = null; RawDataFile dataFile = dataFilesIDMap.get(peakColumnID); if (dataFile == null) throw new SAXException("Error in project: data file " + peakColumnID + " not found"); for (int i = 0; i < numOfMZpeaks; i++) { Scan sc = dataFile.getScan(scanNumbers[i]); double retentionTime = sc.getRetentionTime(); double mz = masses[i]; double intensity = intensities[i]; if ((peakRTRange == null) || (peakIntensityRange == null)) { peakRTRange = new Range(retentionTime); peakIntensityRange = new Range(intensity); } else { peakRTRange.extendRange(retentionTime); peakIntensityRange.extendRange(intensity); } if (mz > 0.0) { mzPeaks[i] = new SimpleDataPoint(mz, intensity); if (peakMZRange == null) peakMZRange = new Range(mz); else peakMZRange.extendRange(mz); } } FeatureStatus status = FeatureStatus.valueOf(peakStatus); SimpleFeature peak = new SimpleFeature( dataFile, mass, rt, height, area, scanNumbers, mzPeaks, status, representativeScan, fragmentScan, peakRTRange, peakMZRange, peakIntensityRange); peak.setCharge(currentPeakCharge); if (currentIsotopes.size() > 0) { SimpleIsotopePattern newPattern = new SimpleIsotopePattern( currentIsotopes.toArray(new DataPoint[0]), currentIsotopePatternStatus, currentIsotopePatternDescription); peak.setIsotopePattern(newPattern); currentIsotopes.clear(); } buildingRow.addPeak(dataFile, peak); } // <IDENTITY_PROPERTY> if (qName.equals(PeakListElementName_2_3.IDPROPERTY.getElementName())) { identityProperties.put(identityPropertyName, getTextOfElement()); } // <PEAK_IDENTITY> if (qName.equals(PeakListElementName_2_3.PEAK_IDENTITY.getElementName())) { SimplePeakIdentity identity = new SimplePeakIdentity(identityProperties); buildingRow.addPeakIdentity(identity, preferred); } // <ROW> if (qName.equals(PeakListElementName_2_3.ROW.getElementName())) { buildingPeakList.addRow(buildingRow); buildingRow = null; parsedRows++; } // <ISOTOPE> if (qName.equals(PeakListElementName_2_3.ISOTOPE.getElementName())) { String text = getTextOfElement(); String items[] = text.split(":"); double mz = Double.valueOf(items[0]); double intensity = Double.valueOf(items[1]); DataPoint isotope = new SimpleDataPoint(mz, intensity); currentIsotopes.add(isotope); } if (qName.equals(PeakListElementName_2_3.METHOD_NAME.getElementName())) { String appliedMethod = getTextOfElement(); appliedMethods.add(appliedMethod); } if (qName.equals(PeakListElementName_2_3.METHOD_PARAMETERS.getElementName())) { String appliedMethodParam = getTextOfElement(); appliedMethodParameters.add(appliedMethodParam); } }
void updateTitle() { StringBuffer title = new StringBuffer(); title.append("Time vs. m/z for precursor ions\n"); title.append(dataFile.getName()); IDAPlot.setTitle(title.toString()); }