spectrumChartPanel.removeAll();
String key = getSelectedSpectrumKey();
MSnSpectrum currentSpectrum = peptideShakerGUI.getSpectrum(key);
SpectrumPanel tempSpectrumPanel = null;
AnnotationPreferences annotationPreferences = peptideShakerGUI.getAnnotationPreferences();
if (currentSpectrum != null) {
Precursor precursor = currentSpectrum.getPrecursor();
String charge;
if (identification.matchExists(currentSpectrumKey)) {
SpectrumMatch spectrumMatch = identification.getSpectrumMatch(currentSpectrumKey);
if (spectrumMatch.getBestPeptideAssumption() != null) {
charge = spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().toString();
} else if (spectrumMatch.getBestTagAssumption() != null) {
charge = spectrumMatch.getBestTagAssumption().getIdentificationCharge().toString();
} else {
throw new IllegalArgumentException("Best hit not found for spectrum " + key + ".");
}
} else {
charge = precursor.getPossibleChargesAsString();
}
if (currentSpectrum.getMzValuesAsArray().length > 0 && currentSpectrum.getIntensityValuesAsArray().length > 0) {
tempSpectrumPanel = new SpectrumPanel(
currentSpectrum.getMzValuesAsArray(), currentSpectrum.getIntensityValuesAsArray(),
precursor.getMz(), charge,
"", 40, false, false, false, 2, false);
tempSpectrumPanel.setKnownMassDeltas(peptideShakerGUI.getCurrentMassDeltas());
tempSpectrumPanel.setDeltaMassWindow(annotationPreferences.getFragmentIonAccuracy());
tempSpectrumPanel.setBorder(null);
tempSpectrumPanel.setDataPointAndLineColor(peptideShakerGUI.getUtilitiesUserPreferences().getSpectrumAnnotatedPeakColor(), 0);
tempSpectrumPanel.setPeakWaterMarkColor(peptideShakerGUI.getUtilitiesUserPreferences().getSpectrumBackgroundPeakColor());
tempSpectrumPanel.setPeakWidth(peptideShakerGUI.getUtilitiesUserPreferences().getSpectrumAnnotatedPeakWidth());
tempSpectrumPanel.setBackgroundPeakWidth(peptideShakerGUI.getUtilitiesUserPreferences().getSpectrumBackgroundPeakWidth());
}
}
if (identification.matchExists(key)) {
SpectrumMatch spectrumMatch = identification.getSpectrumMatch(key);
SearchParameters searchParameters = peptideShakerGUI.getSearchParameters();
int forwardIon = searchParameters.getIonSearched1();
int rewindIon = searchParameters.getIonSearched2();
ModificationProfile modificationProfile = searchParameters.getModificationProfile();
if (currentSpectrum != null && tempSpectrumPanel != null) {
if (currentSpectrum.getMzValuesAsArray().length > 0 && currentSpectrum.getIntensityValuesAsArray().length > 0) {
if (searchResultsTable.getSelectedRow() != -1) {
SpectrumIdentificationAssumption currentAssumption = currentAssumptionsList.get(searchResultsTable.getSelectedRow());
if (currentAssumption != null) {
currentSpectrumKey = spectrumMatch.getKey();
if (currentAssumption instanceof PeptideAssumption) {
PeptideAssumption currentPeptideAssumption = (PeptideAssumption) currentAssumption;
Peptide peptide = currentPeptideAssumption.getPeptide();
annotationPreferences.setCurrentSettings(currentPeptideAssumption, !currentSpectrumKey.equalsIgnoreCase(spectrumMatch.getKey()),
peptideShakerGUI.getSequenceMatchingPreferences());
ArrayList<IonMatch> annotations = specificAnnotator.getSpectrumAnnotation(annotationPreferences.getIonTypes(),
annotationPreferences.getNeutralLosses(),
annotationPreferences.getValidatedCharges(),
currentPeptideAssumption.getIdentificationCharge().value,
currentSpectrum, peptide,
currentSpectrum.getIntensityLimit(annotationPreferences.getAnnotationIntensityLimit()),
annotationPreferences.getFragmentIonAccuracy(), false, annotationPreferences.isHighResolutionAnnotation());
// add the spectrum annotations
tempSpectrumPanel.setAnnotations(SpectrumAnnotator.getSpectrumAnnotation(annotations));
tempSpectrumPanel.showAnnotatedPeaksOnly(!annotationPreferences.showAllPeaks());
tempSpectrumPanel.setYAxisZoomExcludesBackgroundPeaks(annotationPreferences.yAxisZoomExcludesBackgroundPeaks());
// add de novo sequencing
tempSpectrumPanel.addAutomaticDeNovoSequencing(peptide, annotations,
forwardIon, rewindIon, annotationPreferences.getDeNovoCharge(),
annotationPreferences.showForwardIonDeNovoTags(),
annotationPreferences.showRewindIonDeNovoTags());
peptideShakerGUI.updateAnnotationMenus(currentPeptideAssumption.getIdentificationCharge().value, peptide.getModificationMatches());
// update the spectrum title
String modifiedSequence = peptide.getTaggedModifiedSequence(modificationProfile, false, false, true);
((TitledBorder) spectrumPanel.getBorder()).setTitle(
PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING
+ "Spectrum & Fragment Ions (" + modifiedSequence
+ " " + currentPeptideAssumption.getIdentificationCharge().toString() + " "
+ Util.roundDouble(currentSpectrum.getPrecursor().getMz(), 2) + " m/z)"
+ PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
} else if (currentAssumption instanceof TagAssumption) {
TagAssumption tagAssumption = (TagAssumption) currentAssumption;
// add the annotations
annotationPreferences.setCurrentSettings(tagAssumption, !currentSpectrumKey.equalsIgnoreCase(spectrumMatch.getKey()),
peptideShakerGUI.getSequenceMatchingPreferences());
TagSpectrumAnnotator spectrumAnnotator = new TagSpectrumAnnotator();
ArrayList<IonMatch> annotations = spectrumAnnotator.getSpectrumAnnotation(annotationPreferences.getIonTypes(),
annotationPreferences.getNeutralLosses(),
annotationPreferences.getValidatedCharges(),
tagAssumption.getIdentificationCharge().value,
currentSpectrum, tagAssumption.getTag(),
currentSpectrum.getIntensityLimit(annotationPreferences.getAnnotationIntensityLimit()),
annotationPreferences.getFragmentIonAccuracy(),
false, annotationPreferences.isHighResolutionAnnotation());
// add the spectrum annotations
tempSpectrumPanel.setAnnotations(SpectrumAnnotator.getSpectrumAnnotation(annotations));
tempSpectrumPanel.showAnnotatedPeaksOnly(!annotationPreferences.showAllPeaks());
tempSpectrumPanel.setYAxisZoomExcludesBackgroundPeaks(annotationPreferences.yAxisZoomExcludesBackgroundPeaks());
// add de novo sequencing
tempSpectrumPanel.addAutomaticDeNovoSequencing(tagAssumption.getTag(), annotations,
forwardIon, rewindIon, annotationPreferences.getDeNovoCharge(),
annotationPreferences.showForwardIonDeNovoTags(),
annotationPreferences.showRewindIonDeNovoTags());
// get the modifications for the tag
ArrayList<ModificationMatch> modificationMatches = new ArrayList<ModificationMatch>();
for (TagComponent tagComponent : tagAssumption.getTag().getContent()) {