use of eu.isas.peptideshaker.preferences.DisplayParameters in project peptide-shaker by compomics.
the class SpectrumIdentificationPanel method updateSpectrum.
/**
* Update the spectrum based on the currently selected PSM.
*/
public void updateSpectrum() {
if (spectrumTable.getSelectedRow() != -1) {
spectrumChartPanel.removeAll();
String spectrumTitle = getSelectedSpectrumTitle();
Spectrum currentSpectrum = peptideShakerGUI.getSpectrumProvider().getSpectrum(fileSelected, spectrumTitle);
AnnotationParameters annotationParameters = peptideShakerGUI.getIdentificationParameters().getAnnotationParameters();
long spectrumMatchKey = SpectrumMatch.getKey(fileSelected, spectrumTitle);
SpectrumMatch spectrumMatch = identification.getSpectrumMatch(spectrumMatchKey);
// get the selected spectrum
if (currentSpectrum != null && currentSpectrum.getNPeaks() > 0) {
Precursor precursor = currentSpectrum.getPrecursor();
String chargeAsString = "";
if (spectrumMatch != null) {
if (spectrumMatch.getBestPeptideAssumption() != null) {
chargeAsString = Charge.toString(spectrumMatch.getBestPeptideAssumption().getIdentificationCharge());
} else if (spectrumMatch.getBestTagAssumption() != null) {
chargeAsString = Charge.toString(spectrumMatch.getBestTagAssumption().getIdentificationCharge());
}
} else {
chargeAsString = precursor.getPossibleChargesAsString();
}
double[] intensitiesAsArray = searchResultsTable.getSelectedRowCount() == 1 ? currentSpectrum.intensity : ArrayUtil.scaleToMax(currentSpectrum.intensity);
spectrumPanel = new SpectrumPanel(currentSpectrum.mz, intensitiesAsArray, precursor.mz, chargeAsString, "", 40, false, false, false, 2, false);
spectrumPanel.setKnownMassDeltas(peptideShakerGUI.getCurrentMassDeltas());
spectrumPanel.setDeltaMassWindow(annotationParameters.getFragmentIonAccuracy());
spectrumPanel.setBorder(null);
spectrumPanel.setDataPointAndLineColor(peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedPeakColor(), 0);
spectrumPanel.setPeakWaterMarkColor(peptideShakerGUI.getUtilitiesUserParameters().getSpectrumBackgroundPeakColor());
spectrumPanel.setPeakWidth(peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedPeakWidth());
spectrumPanel.setBackgroundPeakWidth(peptideShakerGUI.getUtilitiesUserParameters().getSpectrumBackgroundPeakWidth());
// add the mirrored spectrum
if (searchResultsTable.getSelectedRowCount() == 2) {
spectrumPanel.addMirroredSpectrum(currentSpectrum.mz, ArrayUtil.scaleToMax(currentSpectrum.intensity), precursor.mz, chargeAsString, "", false, peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedMirroredPeakColor(), peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedMirroredPeakColor());
}
}
// add spectrum annotations
if (spectrumMatch != null) {
SequenceProvider sequenceProvider = peptideShakerGUI.getSequenceProvider();
IdentificationParameters identificationParameters = peptideShakerGUI.getIdentificationParameters();
ModificationParameters modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
SequenceMatchingParameters modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
SearchParameters searchParameters = identificationParameters.getSearchParameters();
DisplayParameters displayParameters = peptideShakerGUI.getDisplayParameters();
int forwardIon = searchParameters.getForwardIons().get(0);
int rewindIon = searchParameters.getRewindIons().get(0);
if (currentSpectrum != null && spectrumPanel != null) {
if (currentSpectrum.getNPeaks() > 0) {
int maxPrecursorCharge = 1;
String modifiedSequence = "";
HashSet<String> allModifications = new HashSet<>();
ArrayList<IonMatch[]> allAnnotations = new ArrayList<>();
ArrayList<Spectrum> allSpectra = new ArrayList<>();
ArrayList<String> selectedIndexes = new ArrayList<>();
SpecificAnnotationParameters specificAnnotationParameters = null;
for (int i = 0; i < searchResultsTable.getSelectedRowCount(); i++) {
SpectrumIdentificationAssumption currentAssumption = currentAssumptionsList.get(searchResultsTable.getSelectedRows()[i]);
if (currentAssumption != null) {
selectedIndexes.add((i + 1) + " " + Charge.toString(currentAssumption.getIdentificationCharge()));
if (currentAssumption instanceof PeptideAssumption) {
PeptideAssumption currentPeptideAssumption = (PeptideAssumption) currentAssumption;
Peptide peptide = currentPeptideAssumption.getPeptide();
PeptideSpectrumAnnotator peptideSpectrumAnnotator = new PeptideSpectrumAnnotator();
specificAnnotationParameters = peptideShakerGUI.getSpecificAnnotationParameters(fileSelected, spectrumTitle, currentPeptideAssumption);
IonMatch[] annotations = peptideSpectrumAnnotator.getSpectrumAnnotation(annotationParameters, specificAnnotationParameters, fileSelected, spectrumTitle, currentSpectrum, peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
allAnnotations.add(annotations);
allSpectra.add(currentSpectrum);
// add the spectrum annotations
if (i == 0) {
// @TODO: the selection of the peak to annotate should be done outside the spectrum panel
spectrumPanel.setAnnotations(SpectrumAnnotator.getSpectrumAnnotation(annotations), annotationParameters.getTiesResolution() == SpectrumAnnotator.TiesResolution.mostIntense);
// add de novo sequencing
spectrumPanel.addAutomaticDeNovoSequencing(peptide, annotations, forwardIon, rewindIon, annotationParameters.getDeNovoCharge(), annotationParameters.showForwardIonDeNovoTags(), annotationParameters.showRewindIonDeNovoTags(), false, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
} else {
spectrumPanel.setAnnotationsMirrored(SpectrumAnnotator.getSpectrumAnnotation(annotations));
// add de novo sequencing
spectrumPanel.addAutomaticDeNovoSequencing(peptide, annotations, forwardIon, rewindIon, annotationParameters.getDeNovoCharge(), annotationParameters.showForwardIonDeNovoTags(), annotationParameters.showRewindIonDeNovoTags(), true, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
}
if (currentPeptideAssumption.getIdentificationCharge() > maxPrecursorCharge) {
maxPrecursorCharge = currentPeptideAssumption.getIdentificationCharge();
}
if (!modifiedSequence.isEmpty()) {
modifiedSequence += " vs. ";
}
modifiedSequence += peptide.getTaggedModifiedSequence(modificationParameters, sequenceProvider, modificationSequenceMatchingParameters, false, false, true, displayParameters.getDisplayedModifications());
allModifications.addAll(ModificationUtils.getAllModifications(peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters));
} else if (currentAssumption instanceof TagAssumption) {
TagAssumption tagAssumption = (TagAssumption) currentAssumption;
TagSpectrumAnnotator spectrumAnnotator = new TagSpectrumAnnotator();
specificAnnotationParameters = peptideShakerGUI.getSpecificAnnotationParameters(fileSelected, spectrumTitle, tagAssumption);
IonMatch[] annotations = spectrumAnnotator.getSpectrumAnnotation(annotationParameters, modificationParameters, modificationSequenceMatchingParameters, specificAnnotationParameters, fileSelected, spectrumTitle, currentSpectrum, tagAssumption.getTag());
// add the spectrum annotations
// @TODO: the selection of the peak to annotate should be done outside the spectrum panel
spectrumPanel.setAnnotations(SpectrumAnnotator.getSpectrumAnnotation(annotations), annotationParameters.getTiesResolution() == SpectrumAnnotator.TiesResolution.mostIntense);
// add de novo sequencing
spectrumPanel.addAutomaticDeNovoSequencing(tagAssumption.getTag(), annotations, forwardIon, rewindIon, annotationParameters.getDeNovoCharge(), annotationParameters.showForwardIonDeNovoTags(), annotationParameters.showRewindIonDeNovoTags(), false);
// get the modifications for the tag
allModifications.addAll(ModificationUtils.getAllModifications(tagAssumption.getTag(), modificationParameters, modificationSequenceMatchingParameters));
if (tagAssumption.getIdentificationCharge() > maxPrecursorCharge) {
maxPrecursorCharge = tagAssumption.getIdentificationCharge();
}
if (!modifiedSequence.isEmpty()) {
modifiedSequence += " vs. ";
}
modifiedSequence += tagAssumption.getTag().getTaggedModifiedSequence(modificationParameters, false, false, true, false, modificationSequenceMatchingParameters, displayParameters.getDisplayedModifications());
} else {
throw new UnsupportedOperationException("Spectrum annotation not implemented for identification assumption of type " + currentAssumption.getClass() + ".");
}
}
}
spectrumPanel.showAnnotatedPeaksOnly(!annotationParameters.showAllPeaks());
spectrumPanel.setYAxisZoomExcludesBackgroundPeaks(annotationParameters.yAxisZoomExcludesBackgroundPeaks());
peptideShakerGUI.updateAnnotationMenus(specificAnnotationParameters, maxPrecursorCharge, allModifications);
// update the spectrum title
if (searchResultsTable.getSelectedRowCount() == 1) {
((TitledBorder) spectrumPanelPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Spectrum & Fragment Ions (" + modifiedSequence + " " + maxPrecursorCharge + " " + Util.roundDouble(currentSpectrum.getPrecursor().mz, 2) + " m/z)" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
} else if (searchResultsTable.getSelectedRowCount() == 2) {
((TitledBorder) spectrumPanelPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Spectrum & Fragment Ions (" + modifiedSequence + ")" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
} else if (searchResultsTable.getSelectedRowCount() > 2) {
((TitledBorder) spectrumPanelPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Spectrum & Fragment Ions (" + searchResultsTable.getSelectedRowCount() + " PSMs)" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
}
spectrumPanelPanel.repaint();
if (searchResultsTable.getSelectedRowCount() > 2) {
SearchParameters.MassAccuracyType fragmentAccuracyType = peptideShakerGUI.getIdentificationParameters().getSearchParameters().getFragmentAccuracyType();
double bubbleScale = annotationParameters.getFragmentIonAccuracy() * 10 * peptideShakerGUI.getBubbleScale();
DisplayParameters displayPreferences = peptideShakerGUI.getDisplayParameters();
MassErrorBubblePlot massErrorBubblePlot = new MassErrorBubblePlot(selectedIndexes, allAnnotations, allSpectra, annotationParameters.getFragmentIonAccuracy(), bubbleScale, selectedIndexes.size() == 1, displayPreferences.showBars(), fragmentAccuracyType == SearchParameters.MassAccuracyType.PPM);
// hide the legend if selecting more than 20 spectra // @TODO: 20 should not be hardcoded here..
if (selectedIndexes.size() > 20) {
massErrorBubblePlot.getChartPanel().getChart().getLegend().setVisible(false);
}
// hide the outline
massErrorBubblePlot.getChartPanel().getChart().getPlot().setOutlineVisible(false);
spectrumChartPanel.add(massErrorBubblePlot);
}
}
}
if (searchResultsTable.getSelectedRowCount() <= 2) {
spectrumChartPanel.add(spectrumPanel);
}
} else {
// update the spectrum title
((TitledBorder) spectrumPanelPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Spectrum & Fragment Ions (" + Util.roundDouble(currentSpectrum.getPrecursor().mz, 2) + " m/z)" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
if (currentSpectrum.getNPeaks() > 0) {
spectrumChartPanel.add(spectrumPanel);
}
spectrumPanelPanel.repaint();
}
}
spectrumChartPanel.revalidate();
spectrumChartPanel.repaint();
}
use of eu.isas.peptideshaker.preferences.DisplayParameters in project peptide-shaker by compomics.
the class OverviewPanel method updateBubblePlot.
/**
* Updated the bubble plot with the current PSMs.
*/
public void updateBubblePlot() {
if (peptideTable.getSelectedRow() != -1 && displaySpectrum) {
ArrayList<String> selectedIndexes = new ArrayList<>();
// get the currenly selected rows in the psm table
int[] selectedPsmRows = psmTable.getSelectedRows();
SelfUpdatingTableModel psmTableModel = (SelfUpdatingTableModel) psmTable.getModel();
ArrayList<IonMatch[]> allAnnotations = new ArrayList<>();
ArrayList<Spectrum> allSpectra = new ArrayList<>();
SequenceProvider sequenceProvider = peptideShakerGUI.getSequenceProvider();
IdentificationParameters identificationParameters = peptideShakerGUI.getIdentificationParameters();
ModificationParameters modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
SequenceMatchingParameters modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
AnnotationParameters annotationParameters = identificationParameters.getAnnotationParameters();
DisplayParameters displayParameters = peptideShakerGUI.getDisplayParameters();
ArrayList<Peptide> peptides = new ArrayList<>();
SpectrumProvider spectrumProvider = peptideShakerGUI.getSpectrumProvider();
PeptideSpectrumAnnotator spectrumAnnotator = new PeptideSpectrumAnnotator();
SpecificAnnotationParameters specificAnnotationParameters = null;
int maxCharge = 1;
HashSet<String> allModifications = new HashSet<>();
// iterate the selected psms rows
for (int row : selectedPsmRows) {
int psmIndex = psmTableModel.getViewIndex(row);
long spectrumMatchKey = psmKeys[psmIndex];
SpectrumMatch spectrumMatch = peptideShakerGUI.getIdentification().getSpectrumMatch(spectrumMatchKey);
selectedIndexes.add((psmIndex + 1) + " " + Charge.toString(spectrumMatch.getBestPeptideAssumption().getIdentificationCharge()));
String spectrumFile = spectrumMatch.getSpectrumFile();
String spectrumTitle = spectrumMatch.getSpectrumTitle();
Spectrum currentSpectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
if (currentSpectrum != null) {
PeptideAssumption peptideAssumption = spectrumMatch.getBestPeptideAssumption();
Peptide peptide = peptideAssumption.getPeptide();
specificAnnotationParameters = peptideShakerGUI.getSpecificAnnotationParameters(spectrumFile, spectrumTitle, peptideAssumption);
peptides.add(peptide);
IonMatch[] annotations = spectrumAnnotator.getSpectrumAnnotation(annotationParameters, specificAnnotationParameters, spectrumFile, spectrumTitle, currentSpectrum, peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
allAnnotations.add(annotations);
allSpectra.add(currentSpectrum);
int currentCharge = spectrumMatch.getBestPeptideAssumption().getIdentificationCharge();
if (currentCharge > maxCharge) {
maxCharge = currentCharge;
}
allModifications.addAll(ModificationUtils.getAllModifications(peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters));
currentSpectrumMatchKey = spectrumMatch.getKey();
}
}
double bubbleScale = annotationParameters.getFragmentIonAccuracy() * 10 * peptideShakerGUI.getBubbleScale();
massErrorBubblePlot = new MassErrorBubblePlot(selectedIndexes, allAnnotations, allSpectra, annotationParameters.getFragmentIonAccuracy(), bubbleScale, selectedIndexes.size() == 1, displayParameters.showBars(), identificationParameters.getSearchParameters().getFragmentAccuracyType() == SearchParameters.MassAccuracyType.PPM);
// hide the legend if selecting more than 20 spectra // @TODO: 20 should not be hardcoded here..
if (selectedIndexes.size() > 20) {
massErrorBubblePlot.getChartPanel().getChart().getLegend().setVisible(false);
}
// hide the outline
massErrorBubblePlot.getChartPanel().getChart().getPlot().setOutlineVisible(false);
bubbleJPanel.removeAll();
bubbleJPanel.add(massErrorBubblePlot);
bubbleJPanel.revalidate();
bubbleJPanel.repaint();
if (allSpectra.size() == 2) {
for (int i = 0; i < allSpectra.size(); i++) {
if (i == 0) {
Spectrum spectrum = allSpectra.get(i);
spectrumPanel = new SpectrumPanel(spectrum.mz, ArrayUtil.scaleToMax(spectrum.intensity), 500, "2", "", 40, false, false, false, 2, false);
// @TODO: implement ties resolution in the spectrum panel
spectrumPanel.setAnnotateHighestPeak(annotationParameters.getTiesResolution() == SpectrumAnnotator.TiesResolution.mostIntense);
// @TODO: the selection of the peak to annotate should be done outside the spectrum panel
spectrumPanel.setAnnotations(SpectrumAnnotator.getSpectrumAnnotation(allAnnotations.get(i)), annotationParameters.getTiesResolution() == SpectrumAnnotator.TiesResolution.mostIntense);
SpectrumPanel.setKnownMassDeltas(peptideShakerGUI.getCurrentMassDeltas());
spectrumPanel.setDeltaMassWindow(peptideShakerGUI.getIdentificationParameters().getAnnotationParameters().getFragmentIonAccuracy());
spectrumPanel.setBorder(null);
spectrumPanel.setDataPointAndLineColor(peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedPeakColor(), 0);
spectrumPanel.setPeakWaterMarkColor(peptideShakerGUI.getUtilitiesUserParameters().getSpectrumBackgroundPeakColor());
spectrumPanel.setPeakWidth(peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedPeakWidth());
spectrumPanel.setBackgroundPeakWidth(peptideShakerGUI.getUtilitiesUserParameters().getSpectrumBackgroundPeakWidth());
spectrumPanel.showAnnotatedPeaksOnly(!annotationParameters.showAllPeaks());
spectrumPanel.setYAxisZoomExcludesBackgroundPeaks(annotationParameters.yAxisZoomExcludesBackgroundPeaks());
Integer forwardIon = peptideShakerGUI.getIdentificationParameters().getSearchParameters().getForwardIons().get(0);
Integer rewindIon = peptideShakerGUI.getIdentificationParameters().getSearchParameters().getRewindIons().get(0);
spectrumPanel.addAutomaticDeNovoSequencing(peptides.get(i), allAnnotations.get(i), forwardIon, rewindIon, annotationParameters.getDeNovoCharge(), annotationParameters.showForwardIonDeNovoTags(), annotationParameters.showRewindIonDeNovoTags(), false, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
} else {
Spectrum spectrum = allSpectra.get(i);
spectrumPanel.addMirroredSpectrum(spectrum.mz, ArrayUtil.scaleToMax(spectrum.intensity), 500, "2", "", false, peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedMirroredPeakColor(), peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedMirroredPeakColor());
// @TODO: implement ties resolution in the spectrum panel
spectrumPanel.setAnnotateHighestPeak(annotationParameters.getTiesResolution() == SpectrumAnnotator.TiesResolution.mostIntense);
spectrumPanel.setAnnotationsMirrored(SpectrumAnnotator.getSpectrumAnnotation(allAnnotations.get(i)));
Integer forwardIon = peptideShakerGUI.getIdentificationParameters().getSearchParameters().getForwardIons().get(0);
Integer rewindIon = peptideShakerGUI.getIdentificationParameters().getSearchParameters().getRewindIons().get(0);
spectrumPanel.addAutomaticDeNovoSequencing(peptides.get(i), allAnnotations.get(i), forwardIon, rewindIon, annotationParameters.getDeNovoCharge(), annotationParameters.showForwardIonDeNovoTags(), annotationParameters.showRewindIonDeNovoTags(), true, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
}
}
spectrumPanel.rescale(0.0, spectrumPanel.getMaxXAxisValue());
spectrumSplitPane.setDividerLocation(0);
spectrumContainerJPanel.revalidate();
spectrumContainerJPanel.repaint();
spectrumJPanel.removeAll();
spectrumJPanel.add(spectrumPanel);
spectrumJPanel.revalidate();
spectrumJPanel.repaint();
} else {
spectrumSplitPane.setDividerLocation(spectrumSubPlotDividerLocation);
spectrumContainerJPanel.revalidate();
spectrumContainerJPanel.repaint();
}
peptideShakerGUI.updateAnnotationMenus(specificAnnotationParameters, maxCharge, allModifications);
}
}
use of eu.isas.peptideshaker.preferences.DisplayParameters in project peptide-shaker by compomics.
the class OverviewPanel method updatePtmCoveragePlot.
/**
* Update the protein coverage PTM plot.
*
* @param proteinAccession the protein accession
*/
private void updatePtmCoveragePlot(String proteinAccession) {
if (proteinTable.getSelectedRow() != -1) {
try {
SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) proteinTable.getModel();
long proteinKey = proteinKeys[tableModel.getViewIndex(proteinTable.getSelectedRow())];
// get the ptms
ArrayList<JSparklinesDataSeries> sparkLineDataSeriesPtm = new ArrayList<>();
HashMap<Integer, ArrayList<ResidueAnnotation>> proteinTooltips = new HashMap<>();
// we need to add a first empty filler as the coverage table starts at 0
ArrayList<Double> data = new ArrayList<>();
data.add(Double.valueOf(0));
JSparklinesDataSeries sparklineDataseriesPtm = new JSparklinesDataSeries(data, new Color(0, 0, 0, 0), null);
sparkLineDataSeriesPtm.add(sparklineDataseriesPtm);
Identification identification = peptideShakerGUI.getIdentification();
ProteinMatch proteinMatch = identification.getProteinMatch(proteinKey);
PSModificationScores psPtmScores = (PSModificationScores) proteinMatch.getUrParam(PSModificationScores.dummy);
String sequence = peptideShakerGUI.getSequenceProvider().getSequence(proteinAccession);
int unmodifiedCounter = 0;
// get the fixed ptms
// @TODO: note that this only supports one fixed ptm per residue
HashMap<Integer, String> fixedPtms = new HashMap<>();
DisplayParameters displayParameters = peptideShakerGUI.getDisplayParameters();
// see if fixed ptms are displayed
if (displayParameters.getDisplayedModifications().size() != peptideShakerGUI.getIdentificationParameters().getSearchParameters().getModificationParameters().getVariableModifications().size()) {
for (long peptideKey : peptideKeys) {
PeptideMatch peptideMatch = identification.getPeptideMatch(peptideKey);
Peptide peptide = peptideMatch.getPeptide();
int[] indexesOnProtein = peptide.getProteinMapping().get(proteinAccession);
String[] fixedModifications = peptide.getFixedModifications(peptideShakerGUI.getIdentificationParameters().getSearchParameters().getModificationParameters(), peptideShakerGUI.getSequenceProvider(), peptideShakerGUI.getIdentificationParameters().getModificationLocalizationParameters().getSequenceMatchingParameters());
for (int site = 0; site < fixedModifications.length; site++) {
String modName = fixedModifications[site];
if (modName != null && displayParameters.isDisplayedPTM(modName)) {
for (int index : indexesOnProtein) {
if (site == 0) {
fixedPtms.put(site + index, modName);
} else if (site == peptide.getSequence().length() + 1) {
fixedPtms.put(site + index - 2, modName);
} else {
fixedPtms.put(site + index - 1, modName);
}
}
}
}
}
}
for (int aa = 0; aa < sequence.length(); aa++) {
String modName = fixedPtms.get(aa);
for (String variablePTM : psPtmScores.getModificationsAtRepresentativeSite(aa)) {
if (displayParameters.isDisplayedPTM(variablePTM)) {
modName = variablePTM;
break;
}
}
for (String variablePTM : psPtmScores.getConfidentModificationsAt(aa)) {
if (displayParameters.isDisplayedPTM(variablePTM)) {
modName = variablePTM;
break;
}
}
if (modName != null) {
// add the non-modified area
if (unmodifiedCounter > 0) {
data = new ArrayList<>(1);
data.add(Double.valueOf(unmodifiedCounter));
sparklineDataseriesPtm = new JSparklinesDataSeries(data, new Color(0, 0, 0, 0), null);
sparkLineDataSeriesPtm.add(sparklineDataseriesPtm);
}
// @TODO: what about multiple ptms on the same residue..?
// if (psPtmScores.getMainModificationsAt(aa).size() > 1) {
// for (int i=0; i<psPtmScores.getMainModificationsAt(aa).size(); i++) {
// psPtmScores.getMainModificationsAt(aa).get(i);
// }
// }
Color ptmColor = new Color(peptideShakerGUI.getIdentificationParameters().getSearchParameters().getModificationParameters().getColor(modName));
if (ptmColor == null) {
ptmColor = Color.lightGray;
}
ArrayList<ResidueAnnotation> annotations = new ArrayList<>(1);
// @TODO: note that terminal ptms are annotated one residue too early or too late...
annotations.add(new ResidueAnnotation(modName + " (" + (aa + 1) + ")", 0l, false));
proteinTooltips.put(sparkLineDataSeriesPtm.size(), annotations);
data = new ArrayList<>(1);
data.add(Double.valueOf(1));
sparklineDataseriesPtm = new JSparklinesDataSeries(data, ptmColor, null);
sparkLineDataSeriesPtm.add(sparklineDataseriesPtm);
// reset the non-modified area counter
unmodifiedCounter = 0;
} else {
unmodifiedCounter++;
}
}
if (unmodifiedCounter > 0) {
// add the remaining non-modified area
data = new ArrayList<>();
data.add(Double.valueOf(unmodifiedCounter));
sparklineDataseriesPtm = new JSparklinesDataSeries(data, new Color(0, 0, 0, 0), null);
sparkLineDataSeriesPtm.add(sparklineDataseriesPtm);
}
ptmSequencePanel = new ProteinSequencePanel(Color.WHITE);
ptmChart = ptmSequencePanel.getSequencePlot(this, new JSparklinesDataset(sparkLineDataSeriesPtm), proteinTooltips, false, false);
sequencePtmsPanel.removeAll();
sequencePtmsPanel.add(ptmChart);
sequencePtmsPanel.revalidate();
sequencePtmsPanel.repaint();
} catch (ClassCastException e) {
// ignore @TODO: this should not happen, but can happen if the table does not update fast enough for the filtering
}
}
}
use of eu.isas.peptideshaker.preferences.DisplayParameters in project peptide-shaker by compomics.
the class OverviewPanel method updatePeptideVariationsCoveragePlot.
/**
* Update the peptide variations coverage plot.
*
* @param proteinAccession the protein accession
*/
private void updatePeptideVariationsCoveragePlot(String proteinAccession) {
if (proteinTable.getSelectedRow() != -1) {
try {
ArrayList<JSparklinesDataSeries> sparkLineDataSeriesPtm = new ArrayList<>();
HashMap<Integer, ArrayList<ResidueAnnotation>> proteinTooltips = new HashMap<>();
// we need to add a first empty filler as the coverage table starts at 0
ArrayList<Double> data = new ArrayList<>();
data.add(Double.valueOf(1));
JSparklinesDataSeries sparklineDataseriesPtm = new JSparklinesDataSeries(data, new Color(0, 0, 0, 0), null);
sparkLineDataSeriesPtm.add(sparklineDataseriesPtm);
Identification identification = peptideShakerGUI.getIdentification();
String sequence = peptideShakerGUI.getSequenceProvider().getSequence(proteinAccession);
int unmodifiedCounter = 0;
// get the variants
HashMap<Integer, String> variantMapping = new HashMap<>();
DisplayParameters displayParameters = peptideShakerGUI.getDisplayParameters();
// see if fixed ptms are displayed
if (displayParameters.getDisplayedModifications().size() != peptideShakerGUI.getIdentificationParameters().getSearchParameters().getModificationParameters().getVariableModifications().size()) {
for (long peptideKey : peptideKeys) {
PeptideMatch peptideMatch = identification.getPeptideMatch(peptideKey);
Peptide peptide = peptideMatch.getPeptide();
HashMap<String, HashMap<Integer, PeptideVariantMatches>> allVariants = peptide.getVariantMatches();
if (allVariants != null && allVariants.containsKey(proteinAccession)) {
HashMap<Integer, PeptideVariantMatches> peptideVariants = allVariants.get(proteinAccession);
for (Integer peptideStart : peptideVariants.keySet()) {
PeptideVariantMatches peptideVariantMatches = peptideVariants.get(peptideStart);
HashMap<Integer, Variant> variants = peptideVariantMatches.getVariantMatches();
for (Integer site : variants.keySet()) {
Variant variant = variants.get(site);
variantMapping.put(site + peptideStart - 1, variant.getDescription());
}
}
}
}
}
for (int aa = 1; aa < sequence.length(); aa++) {
String variantName = variantMapping.get(aa + 1);
if (variantName != null) {
// add the unmodified area
if (unmodifiedCounter > 0) {
data = new ArrayList<>(1);
data.add(Double.valueOf(unmodifiedCounter));
sparklineDataseriesPtm = new JSparklinesDataSeries(data, new Color(0, 0, 0, 0), null);
sparkLineDataSeriesPtm.add(sparklineDataseriesPtm);
}
// @TODO: get different colors for the different variant types?
// @TODO: what about multiple variants on the same residue..?
Color ptmColor = Color.ORANGE;
ArrayList<ResidueAnnotation> annotations = new ArrayList<>(1);
annotations.add(new ResidueAnnotation(variantName + " (" + aa + ")", 0l, false));
proteinTooltips.put(sparkLineDataSeriesPtm.size(), annotations);
data = new ArrayList<>(1);
data.add(Double.valueOf(1));
sparklineDataseriesPtm = new JSparklinesDataSeries(data, ptmColor, null);
sparkLineDataSeriesPtm.add(sparklineDataseriesPtm);
// reset the unmodified area counter
unmodifiedCounter = 0;
} else {
unmodifiedCounter++;
}
}
if (unmodifiedCounter > 0) {
// add the remaining unmodified area
data = new ArrayList<>();
data.add(Double.valueOf(unmodifiedCounter));
sparklineDataseriesPtm = new JSparklinesDataSeries(data, new Color(0, 0, 0, 0), null);
sparkLineDataSeriesPtm.add(sparklineDataseriesPtm);
}
peptideVariationSequencePanel = new ProteinSequencePanel(Color.WHITE);
peptideVariationsChart = peptideVariationSequencePanel.getSequencePlot(this, new JSparklinesDataset(sparkLineDataSeriesPtm), proteinTooltips, false, false);
sequenceVariationsPanel.removeAll();
sequenceVariationsPanel.add(peptideVariationsChart);
sequenceVariationsPanel.revalidate();
sequenceVariationsPanel.repaint();
} catch (ClassCastException e) {
// ignore @TODO: this should not happen, but can happen if the
// table does not update fast enough for the filtering
}
}
}
use of eu.isas.peptideshaker.preferences.DisplayParameters in project peptide-shaker by compomics.
the class OverviewPanel method updateSpectrum.
/**
* Update the spectrum to the currently selected PSM.
*
* @param row the row index of the PSM
* @param resetMzRange if true the mz range is reset, if false the current
* zoom range is kept
*/
private void updateSpectrum(int row, boolean resetMzRange) {
if (row != -1) {
this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) psmTable.getModel();
int psmIndex = tableModel.getViewIndex(row);
long spectrumMatchKey = psmKeys[psmIndex];
if (displaySpectrum) {
SpectrumProvider spectrumProvider = peptideShakerGUI.getSpectrumProvider();
SpectrumMatch spectrumMatch = peptideShakerGUI.getIdentification().getSpectrumMatch(spectrumMatchKey);
String spectrumFile = spectrumMatch.getSpectrumFile();
String spectrumTitle = spectrumMatch.getSpectrumTitle();
Spectrum currentSpectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
if (currentSpectrum != null && currentSpectrum.getNPeaks() > 0) {
boolean newMax = false;
if (resetMzRange) {
lastMzMaximum = 0;
}
if (peptideShakerGUI.getSelectedPeptideKey() != NO_KEY) {
double newMaximum = currentSpectrum.getMaxMz();
if (lastMzMaximum < newMaximum) {
lastMzMaximum = newMaximum;
newMax = true;
}
}
double lowerMzZoomRange = 0;
double upperMzZoomRange = lastMzMaximum;
if (spectrumPanel != null && spectrumPanel.getXAxisZoomRangeLowerValue() != 0 && !newMax) {
// @TODO: sometimes the range is reset when is should not be...
lowerMzZoomRange = spectrumPanel.getXAxisZoomRangeLowerValue();
upperMzZoomRange = spectrumPanel.getXAxisZoomRangeUpperValue();
}
// add the data to the spectrum panel
Precursor precursor = currentSpectrum.getPrecursor();
spectrumPanel = new SpectrumPanel(currentSpectrum.mz, currentSpectrum.intensity, precursor.mz, Charge.toString(spectrumMatch.getBestPeptideAssumption().getIdentificationCharge()), "", 40, false, false, false, 2, false);
spectrumPanel.setKnownMassDeltas(peptideShakerGUI.getCurrentMassDeltas());
spectrumPanel.setDeltaMassWindow(peptideShakerGUI.getIdentificationParameters().getAnnotationParameters().getFragmentIonAccuracy());
spectrumPanel.setBorder(null);
spectrumPanel.setDataPointAndLineColor(peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedPeakColor(), 0);
spectrumPanel.setPeakWaterMarkColor(peptideShakerGUI.getUtilitiesUserParameters().getSpectrumBackgroundPeakColor());
spectrumPanel.setPeakWidth(peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedPeakWidth());
spectrumPanel.setBackgroundPeakWidth(peptideShakerGUI.getUtilitiesUserParameters().getSpectrumBackgroundPeakWidth());
// get the spectrum annotations
PeptideAssumption peptideAssumption = spectrumMatch.getBestPeptideAssumption();
Peptide currentPeptide = peptideAssumption.getPeptide();
PeptideSpectrumAnnotator spectrumAnnotator = new PeptideSpectrumAnnotator();
AnnotationParameters annotationParameters = peptideShakerGUI.getIdentificationParameters().getAnnotationParameters();
SequenceProvider sequenceProvider = peptideShakerGUI.getSequenceProvider();
IdentificationParameters identificationParameters = peptideShakerGUI.getIdentificationParameters();
ModificationParameters modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
SequenceMatchingParameters modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
SpecificAnnotationParameters specificAnnotationParameters = peptideShakerGUI.getSpecificAnnotationParameters(spectrumFile, spectrumTitle, peptideAssumption);
IonMatch[] annotations = spectrumAnnotator.getSpectrumAnnotation(annotationParameters, specificAnnotationParameters, spectrumFile, spectrumTitle, currentSpectrum, currentPeptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
// @TODO: the selection of the peak to annotate should be done outside the spectrum panel
spectrumPanel.setAnnotations(SpectrumAnnotator.getSpectrumAnnotation(annotations), annotationParameters.getTiesResolution() == SpectrumAnnotator.TiesResolution.mostIntense);
spectrumPanel.rescale(lowerMzZoomRange, upperMzZoomRange);
// show all or just the annotated peaks
spectrumPanel.showAnnotatedPeaksOnly(!annotationParameters.showAllPeaks());
spectrumPanel.setYAxisZoomExcludesBackgroundPeaks(annotationParameters.yAxisZoomExcludesBackgroundPeaks());
Integer forwardIon = peptideShakerGUI.getIdentificationParameters().getSearchParameters().getForwardIons().get(0);
Integer rewindIon = peptideShakerGUI.getIdentificationParameters().getSearchParameters().getRewindIons().get(0);
// add de novo sequencing
spectrumPanel.addAutomaticDeNovoSequencing(currentPeptide, annotations, forwardIon, rewindIon, annotationParameters.getDeNovoCharge(), annotationParameters.showForwardIonDeNovoTags(), annotationParameters.showRewindIonDeNovoTags(), false, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
// add the spectrum panel to the frame
spectrumJPanel.removeAll();
spectrumJPanel.add(spectrumPanel);
spectrumJPanel.revalidate();
spectrumJPanel.repaint();
// create and display the fragment ion table
ArrayList<IonMatch[]> allAnnotations = getAnnotationsForAllSelectedSpectra();
DisplayParameters displayParameters = peptideShakerGUI.getDisplayParameters();
if (!displayParameters.useIntensityIonTable()) {
fragmentIonsJScrollPane.setViewportView(new FragmentIonTable(currentPeptide, allAnnotations, specificAnnotationParameters.getFragmentIonTypes(), specificAnnotationParameters.getNeutralLossesMap(), specificAnnotationParameters.getSelectedCharges().contains(1), specificAnnotationParameters.getSelectedCharges().contains(2), modificationParameters, sequenceProvider, modificationSequenceMatchingParameters));
} else {
ArrayList<Spectrum> spectra = Arrays.stream(getSelectedPsmKeys()).mapToObj(key -> peptideShakerGUI.getIdentification().getSpectrumMatch(key)).map(selectedMatch -> spectrumProvider.getSpectrum(selectedMatch.getSpectrumFile(), selectedMatch.getSpectrumTitle())).collect(Collectors.toCollection(ArrayList::new));
fragmentIonsJScrollPane.setViewportView(new FragmentIonTable(currentPeptide, allAnnotations, spectra, specificAnnotationParameters.getFragmentIonTypes(), specificAnnotationParameters.getNeutralLossesMap(), specificAnnotationParameters.getSelectedCharges().contains(1), specificAnnotationParameters.getSelectedCharges().contains(2), modificationParameters, sequenceProvider, modificationSequenceMatchingParameters));
}
// create the sequence fragment ion view
secondarySpectrumPlotsJPanel.removeAll();
sequenceFragmentationPanel = new SequenceFragmentationPanel(peptideShakerGUI.getDisplayFeaturesGenerator().getTaggedPeptideSequence(spectrumMatch, false, false, true), annotations, true, peptideShakerGUI.getIdentificationParameters().getSearchParameters().getModificationParameters(), forwardIon, rewindIon);
sequenceFragmentationPanel.setMinimumSize(new Dimension(sequenceFragmentationPanel.getPreferredSize().width, sequenceFragmentationPanel.getHeight()));
sequenceFragmentationPanel.setOpaque(true);
sequenceFragmentationPanel.setBackground(Color.WHITE);
secondarySpectrumPlotsJPanel.add(sequenceFragmentationPanel);
// create the intensity histograms
intensityHistogram = new IntensityHistogram(annotations, currentSpectrum, annotationParameters.getAnnotationIntensityLimit());
secondarySpectrumPlotsJPanel.add(intensityHistogram);
// create the miniature mass error plot
massErrorPlot = new MassErrorPlot(annotations, currentSpectrum, specificAnnotationParameters.getFragmentIonAccuracy(), peptideShakerGUI.getIdentificationParameters().getSearchParameters().getFragmentAccuracyType() == SearchParameters.MassAccuracyType.PPM);
if (massErrorPlot.getNumberOfDataPointsInPlot() > 0) {
secondarySpectrumPlotsJPanel.add(massErrorPlot);
}
// update the UI
secondarySpectrumPlotsJPanel.revalidate();
secondarySpectrumPlotsJPanel.repaint();
// update the bubble plot
updateBubblePlot();
// disable the spectrum tab if more than two psms are selected
spectrumJTabbedPane.setEnabledAt(2, psmTable.getSelectedRowCount() <= 2);
peptideShakerGUI.enableSpectrumExport(psmTable.getSelectedRowCount() <= 2);
// move to the bubble plot tab if more than two psms are selected and the spectrum tab was selected
if (psmTable.getSelectedRowCount() > 2 && spectrumJTabbedPane.getSelectedIndex() == 2) {
spectrumJTabbedPane.setSelectedIndex(1);
}
if (psmTable.getSelectedRowCount() > 2) {
spectrumJTabbedPane.setToolTipTextAt(2, "Available for single or double spectrum selection only");
} else {
spectrumJTabbedPane.setToolTipTextAt(2, null);
}
// update the panel border title
updateSpectrumPanelBorderTitle(currentSpectrum);
spectrumMainPanel.revalidate();
spectrumMainPanel.repaint();
}
}
this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
} else {
// nothing to display, empty previous results
spectrumJPanel.removeAll();
spectrumJPanel.revalidate();
spectrumJPanel.repaint();
secondarySpectrumPlotsJPanel.removeAll();
secondarySpectrumPlotsJPanel.revalidate();
secondarySpectrumPlotsJPanel.repaint();
fragmentIonsJScrollPane.setViewportView(null);
fragmentIonsJScrollPane.revalidate();
fragmentIonsJScrollPane.repaint();
bubbleJPanel.removeAll();
bubbleJPanel.revalidate();
bubbleJPanel.repaint();
((TitledBorder) spectrumMainPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Spectrum & Fragment Ions" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
spectrumMainPanel.repaint();
}
}
Aggregations