use of com.compomics.util.experiment.identification.matches.IonMatch 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 com.compomics.util.experiment.identification.matches.IonMatch in project peptide-shaker by compomics.
the class PeptideShakerGUI method exportAnnotatedSpectrum.
/**
* Export the current spectrum annotation.
*
* @throws IOException exception thrown whenever an error occurred while
* reading or writing a file
*/
public void exportAnnotatedSpectrum() throws IOException {
int selectedTabIndex = allTabsJTabbedPane.getSelectedIndex();
HashMap<Long, ArrayList<SpectrumIdentificationAssumption>> selectedAssumptions = null;
if (selectedTabIndex == OVER_VIEW_TAB_INDEX) {
selectedAssumptions = overviewPanel.getSelectedIdentificationAssumptions();
} else if (selectedTabIndex == SPECTRUM_ID_TAB_INDEX) {
selectedAssumptions = spectrumIdentificationPanel.getSelectedIdentificationAssumptions();
} else if (selectedTabIndex == MODIFICATIONS_TAB_INDEX) {
selectedAssumptions = modificationsPanel.getSelectedIdentificationAssumptions();
}
if (selectedAssumptions != null && !selectedAssumptions.isEmpty()) {
File selectedFile = getUserSelectedFile("annotated_spectra.txt", ".txt", "Text (*.txt)", "Save As...", false);
if (selectedFile != null) {
SequenceProvider sequenceProvider = getSequenceProvider();
IdentificationParameters identificationParameters = getIdentificationParameters();
ModificationParameters modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
SequenceMatchingParameters modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
AnnotationParameters annotationParameters = getIdentificationParameters().getAnnotationParameters();
PeptideSpectrumAnnotator peptideSpectrumAnnotator = new PeptideSpectrumAnnotator();
TagSpectrumAnnotator tagSpectrumAnnotator = new TagSpectrumAnnotator();
try (SimpleFileWriter writer = new SimpleFileWriter(selectedFile, false)) {
for (long spectrumMatchKey : selectedAssumptions.keySet()) {
SpectrumMatch spectrumMatch = getIdentification().getSpectrumMatch(spectrumMatchKey);
String spectrumFile = spectrumMatch.getSpectrumFile();
String spectrumTitle = spectrumMatch.getSpectrumTitle();
Spectrum spectrum = getSpectrumProvider().getSpectrum(spectrumFile, spectrumTitle);
if (spectrum == null) {
throw new IllegalArgumentException("Spectrum " + spectrumTitle + " in " + spectrumFile + " not found.");
}
IonMatch[] annotations = null;
ArrayList<SpectrumIdentificationAssumption> assumptions = selectedAssumptions.get(spectrumMatchKey);
if (assumptions != null && !assumptions.isEmpty()) {
for (SpectrumIdentificationAssumption assumption : assumptions) {
SpecificAnnotationParameters exportAnnotationParameters = getSpecificAnnotationParameters(spectrumFile, spectrumTitle, assumption);
String identifier;
if (assumption instanceof PeptideAssumption) {
PeptideAssumption peptideAssumption = (PeptideAssumption) assumption;
Peptide peptide = peptideAssumption.getPeptide();
annotations = peptideSpectrumAnnotator.getSpectrumAnnotation(annotationParameters, exportAnnotationParameters, spectrumFile, spectrumTitle, spectrum, peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
identifier = peptide.getTaggedModifiedSequence(modificationParameters, sequenceProvider, modificationSequenceMatchingParameters, false, false, true, getDisplayParameters().getDisplayedModifications());
} else if (assumption instanceof TagAssumption) {
TagAssumption tagAssumption = (TagAssumption) assumption;
Tag tag = tagAssumption.getTag();
annotations = tagSpectrumAnnotator.getSpectrumAnnotation(annotationParameters, modificationParameters, modificationSequenceMatchingParameters, exportAnnotationParameters, spectrumFile, spectrumTitle, spectrum, tag);
identifier = tag.getTaggedModifiedSequence(modificationParameters, false, false, true, true, modificationSequenceMatchingParameters, getDisplayParameters().getDisplayedModifications());
} else {
throw new UnsupportedOperationException("Spectrum annotation not implemented for identification assumption of type " + assumption.getClass() + ".");
}
HashMap<Double, ArrayList<IonMatch>> annotationMap = new HashMap<>();
if (annotations != null) {
for (IonMatch ionMatch : annotations) {
double mz = ionMatch.peakMz;
ArrayList<IonMatch> matchesAtMz = annotationMap.get(mz);
if (matchesAtMz == null) {
matchesAtMz = new ArrayList<>(1);
annotationMap.put(mz, matchesAtMz);
}
matchesAtMz.add(ionMatch);
}
}
writer.writeLine("File: " + spectrumFile, "Spectrum: " + spectrumTitle, "Peptide: " + identifier);
writer.writeLine("m/z", "Intensity", "Ion", "Theoretic m/z", "Absolute Error");
for (int i = 0; i < spectrum.mz.length; i++) {
double mz = spectrum.mz[i];
double intensity = spectrum.intensity[i];
ArrayList<IonMatch> matches = annotationMap.get(mz);
if (matches != null) {
for (IonMatch ionMatch : matches) {
writer.writeLine(Double.toString(mz), Double.toString(intensity), ionMatch.getPeakAnnotation(), Double.toString(ionMatch.ion.getTheoreticMz(ionMatch.charge)), Double.toString(ionMatch.getAbsoluteError()));
}
} else {
writer.writeLine(Double.toString(mz), Double.toString(intensity), "", "", "");
}
}
}
} else {
writer.writeLine("File: " + spectrumFile, "Spectrum: " + spectrumTitle);
writer.writeLine("m/z", "Intensity", "Ion", "Theoretic m/z", "Absolute Error");
for (int i = 0; i < spectrum.mz.length; i++) {
double mz = spectrum.mz[i];
double intensity = spectrum.intensity[i];
writer.writeLine(Double.toString(mz), Double.toString(intensity), "", "", "");
}
}
}
JOptionPane.showMessageDialog(this, "Spectrum saved to " + selectedFile.getPath() + ".", "File Saved", JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
use of com.compomics.util.experiment.identification.matches.IonMatch in project peptide-shaker by compomics.
the class PsFragmentSection method writeSection.
/**
* Writes the desired section.
*
* @param spectrumFile The file name of the spectrum.
* @param spectrumTitle The title of the spectrum.
* @param spectrumIdentificationAssumption The spectrum identification of
* interest.
* @param sequenceProvider The sequence provider.
* @param spectrumProvider The spectrum provider.
* @param identificationParameters The identification parameters.
* @param linePrefix The line prefix.
* @param waitingHandler The waiting handler.
*
* @throws IOException exception thrown whenever an error occurred while
* writing the file
*/
public void writeSection(String spectrumFile, String spectrumTitle, SpectrumIdentificationAssumption spectrumIdentificationAssumption, SequenceProvider sequenceProvider, SpectrumProvider spectrumProvider, IdentificationParameters identificationParameters, String linePrefix, WaitingHandler waitingHandler) throws IOException {
if (waitingHandler != null) {
waitingHandler.setSecondaryProgressCounterIndeterminate(true);
}
if (header) {
writeHeader();
}
IonMatch[] annotations;
Spectrum spectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
AnnotationParameters annotationParameters = identificationParameters.getAnnotationParameters();
ModificationParameters modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
SequenceMatchingParameters modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
if (spectrumIdentificationAssumption instanceof PeptideAssumption) {
PeptideAssumption peptideAssumption = (PeptideAssumption) spectrumIdentificationAssumption;
PeptideSpectrumAnnotator spectrumAnnotator = new PeptideSpectrumAnnotator();
SpecificAnnotationParameters specificAnnotationParameters = annotationParameters.getSpecificAnnotationParameters(spectrumFile, spectrumTitle, spectrumIdentificationAssumption, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters, spectrumAnnotator);
annotations = spectrumAnnotator.getSpectrumAnnotation(annotationParameters, specificAnnotationParameters, spectrumFile, spectrumTitle, spectrum, peptideAssumption.getPeptide(), modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
} else if (spectrumIdentificationAssumption instanceof TagAssumption) {
TagAssumption tagAssumption = (TagAssumption) spectrumIdentificationAssumption;
TagSpectrumAnnotator spectrumAnnotator = new TagSpectrumAnnotator();
SpecificAnnotationParameters specificAnnotationParameters = annotationParameters.getSpecificAnnotationParameters(spectrumFile, spectrumTitle, spectrumIdentificationAssumption, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters, spectrumAnnotator);
annotations = spectrumAnnotator.getSpectrumAnnotation(annotationParameters, modificationParameters, modificationSequenceMatchingParameters, specificAnnotationParameters, spectrumFile, spectrumTitle, spectrum, tagAssumption.getTag());
} else {
throw new UnsupportedOperationException("Export not implemented for spectrum identification of type " + spectrumIdentificationAssumption.getClass() + ".");
}
TreeMap<Double, ArrayList<IonMatch>> sortedAnnotation = new TreeMap<>();
for (IonMatch ionMatch : annotations) {
double mz = ionMatch.peakMz;
if (!sortedAnnotation.containsKey(mz)) {
sortedAnnotation.put(mz, new ArrayList<>(1));
}
sortedAnnotation.get(mz).add(ionMatch);
}
int line = 1;
if (waitingHandler != null) {
waitingHandler.setWaitingText("Exporting. Please Wait...");
waitingHandler.resetSecondaryProgressCounter();
waitingHandler.setMaxSecondaryProgressCounter(annotations.length);
}
for (Entry<Double, ArrayList<IonMatch>> entry : sortedAnnotation.entrySet()) {
for (IonMatch ionMatch : entry.getValue()) {
if (waitingHandler != null) {
if (waitingHandler.isRunCanceled()) {
return;
}
waitingHandler.increaseSecondaryProgressCounter();
}
if (indexes) {
if (linePrefix != null) {
writer.write(linePrefix);
}
writer.write(Integer.toString(line));
writer.addSeparator();
}
for (PsFragmentFeature fragmentFeature : fragmentFeatures) {
switch(fragmentFeature) {
case annotation:
writer.write(ionMatch.getPeakAnnotation());
break;
case fragment_type:
writer.write(Ion.getTypeAsString(ionMatch.ion.getType()));
break;
case fragment_subType:
writer.write(ionMatch.ion.getSubTypeAsString());
break;
case fragment_number:
Ion ion = ionMatch.ion;
if (ion.getType() == Ion.IonType.PEPTIDE_FRAGMENT_ION) {
writer.write(Integer.toString(((PeptideFragmentIon) ion).getNumber()));
}
break;
case fragment_losses:
writer.write(ionMatch.ion.getNeutralLossesAsString());
break;
case fragment_name:
ion = ionMatch.ion;
String name = ion.getType() == Ion.IonType.PEPTIDE_FRAGMENT_ION ? ((PeptideFragmentIon) ion).getNameWithNumber() : ion.getName();
writer.write(name);
break;
case fragment_charge:
writer.write(Integer.toString(ionMatch.charge));
break;
case theoretic_mz:
writer.write(Double.toString(ionMatch.ion.getTheoreticMz(ionMatch.charge)));
break;
case mz:
writer.write(Double.toString(ionMatch.peakMz));
break;
case intensity:
writer.write(Double.toString(ionMatch.peakIntensity));
break;
case error_Da:
writer.write(Double.toString(ionMatch.getAbsoluteError()));
break;
case error_ppm:
writer.write(Double.toString(ionMatch.getRelativeError()));
break;
default:
writer.write("Not implemented");
}
writer.addSeparator();
}
writer.newLine();
line++;
}
}
}
use of com.compomics.util.experiment.identification.matches.IonMatch in project peptide-shaker by compomics.
the class PsIdentificationAlgorithmMatchesSection method getPeptideAssumptionFeature.
/**
* Writes the feature associated to the match of the given peptide
* assumption.
*
* @param identification The identification of the project.
* @param identificationFeaturesGenerator The identification features
* generator of the project.
* @param sequenceProvider The provider for the protein sequences.
* @param proteinDetailsProvider The provider for protein details.
* @param spectrumProvider The spectrum provider.
* @param identificationParameters The identification parameters.
* @param linePrefix The line prefix.
* @param nSurroundingAA The number of surrounding amino acids to export.
* @param peptideAssumption The assumption for the match to inspect.
* @param spectrumFile The name of the file of the spectrum.
* @param spectrumTitle The title of the spectrum.
* @param psParameter The PeptideShaker parameter of the match.
* @param exportFeature The feature to export.
* @param waitingHandler The waiting handler.
*
* @return The content corresponding to the given feature of the current
* section.
*/
public static String getPeptideAssumptionFeature(Identification identification, IdentificationFeaturesGenerator identificationFeaturesGenerator, SequenceProvider sequenceProvider, ProteinDetailsProvider proteinDetailsProvider, SpectrumProvider spectrumProvider, IdentificationParameters identificationParameters, String linePrefix, int nSurroundingAA, PeptideAssumption peptideAssumption, String spectrumFile, String spectrumTitle, PSParameter psParameter, PsIdentificationAlgorithmMatchesFeature exportFeature, WaitingHandler waitingHandler) {
switch(exportFeature) {
case rank:
return Integer.toString(peptideAssumption.getRank());
case variable_ptms:
ModificationParameters modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
SequenceMatchingParameters modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
TreeMap<String, TreeSet<Integer>> modMap = getModMap(peptideAssumption.getPeptide(), modificationParameters, sequenceProvider, modificationSequenceMatchingParameters, true);
return modMap.entrySet().stream().map(entry -> getModificationAsString(entry.getKey(), entry.getValue())).collect(Collectors.joining(";"));
case fixed_ptms:
modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
modMap = getModMap(peptideAssumption.getPeptide(), modificationParameters, sequenceProvider, modificationSequenceMatchingParameters, false);
return modMap.entrySet().stream().map(entry -> getModificationAsString(entry.getKey(), entry.getValue())).collect(Collectors.joining(";"));
case accessions:
TreeMap<String, int[]> proteinMapping = peptideAssumption.getPeptide().getProteinMapping();
return proteinMapping.navigableKeySet().stream().collect(Collectors.joining(","));
case protein_description:
proteinMapping = peptideAssumption.getPeptide().getProteinMapping();
return proteinMapping.navigableKeySet().stream().map(accession -> proteinDetailsProvider.getDescription(accession)).collect(Collectors.joining(","));
case algorithm_confidence:
return Double.toString(psParameter.getConfidence());
case algorithm_delta_confidence:
Double delta = psParameter.getAlgorithmDeltaPEP();
return delta == null ? "Not available" : Double.toString(100 * delta);
case delta_confidence:
delta = psParameter.getDeltaPEP();
return Double.toString(100 * delta);
case decoy:
return PeptideUtils.isDecoy(peptideAssumption.getPeptide(), sequenceProvider) ? "1" : "0";
case hidden:
return psParameter.getHidden() ? "1" : "0";
case identification_charge:
return Integer.toString(peptideAssumption.getIdentificationCharge());
case isotope:
double precursorMz = spectrumProvider.getPrecursorMz(spectrumFile, spectrumTitle);
return Integer.toString(peptideAssumption.getIsotopeNumber(precursorMz, identificationParameters.getSearchParameters().getMinIsotopicCorrection(), identificationParameters.getSearchParameters().getMaxIsotopicCorrection()));
case mz:
precursorMz = spectrumProvider.getPrecursorMz(spectrumFile, spectrumTitle);
return Double.toString(precursorMz);
case total_spectrum_intensity:
Spectrum spectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
return Double.toString(spectrum.getTotalIntensity());
case max_intensity:
spectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
return Double.toString(spectrum.getMaxIntensity());
case intensity_coverage:
spectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
Peptide peptide = peptideAssumption.getPeptide();
AnnotationParameters annotationParameters = identificationParameters.getAnnotationParameters();
modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
SpecificAnnotationParameters specificAnnotationParameters = annotationParameters.getSpecificAnnotationParameters(spectrumFile, spectrumTitle, peptideAssumption, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters, peptideSpectrumAnnotator);
IonMatch[] matches = peptideSpectrumAnnotator.getSpectrumAnnotation(annotationParameters, specificAnnotationParameters, spectrumFile, spectrumTitle, spectrum, peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
double coveredIntensity = Arrays.stream(matches).mapToDouble(ionMatch -> ionMatch.peakIntensity).sum();
double coverage = 100 * coveredIntensity / spectrum.getTotalIntensity();
return Double.toString(coverage);
case mz_error_ppm:
precursorMz = spectrumProvider.getPrecursorMz(spectrumFile, spectrumTitle);
return Double.toString(peptideAssumption.getDeltaMz(precursorMz, true, identificationParameters.getSearchParameters().getMinIsotopicCorrection(), identificationParameters.getSearchParameters().getMaxIsotopicCorrection()));
case mz_error_da:
precursorMz = spectrumProvider.getPrecursorMz(spectrumFile, spectrumTitle);
return Double.toString(peptideAssumption.getDeltaMz(precursorMz, false, identificationParameters.getSearchParameters().getMinIsotopicCorrection(), identificationParameters.getSearchParameters().getMaxIsotopicCorrection()));
case rt:
double precursorRt = spectrumProvider.getPrecursorRt(spectrumFile, spectrumTitle);
return Double.toString(precursorRt);
case algorithm_raw_score:
int id = peptideAssumption.getAdvocate();
double score = peptideAssumption.getRawScore();
return String.join("", Advocate.getAdvocate(id).getName(), " (", Double.toString(score), ")");
case algorithm_score:
id = peptideAssumption.getAdvocate();
score = peptideAssumption.getScore();
return String.join("", Advocate.getAdvocate(id).getName(), " (", Double.toString(score), ")");
case sequence:
return peptideAssumption.getPeptide().getSequence();
case aaBefore:
TreeMap<String, String[]> aaMap = PeptideUtils.getAaBefore(peptideAssumption.getPeptide(), nSurroundingAA, sequenceProvider);
return aaMap.values().stream().map(aas -> (Arrays.stream(aas)).collect(Collectors.joining(","))).collect(Collectors.joining(";"));
case aaAfter:
aaMap = PeptideUtils.getAaAfter(peptideAssumption.getPeptide(), nSurroundingAA, sequenceProvider);
return aaMap.values().stream().map(aas -> (Arrays.stream(aas)).collect(Collectors.joining(","))).collect(Collectors.joining(";"));
case position:
proteinMapping = peptideAssumption.getPeptide().getProteinMapping();
return proteinMapping.values().stream().map(positions -> (Arrays.stream(positions)).mapToObj(pos -> Integer.toString(pos)).collect(Collectors.joining(","))).collect(Collectors.joining(";"));
case missed_cleavages:
peptide = peptideAssumption.getPeptide();
int nMissedCleavages = peptide.getNMissedCleavages(identificationParameters.getSearchParameters().getDigestionParameters());
return Integer.toString(nMissedCleavages);
case modified_sequence:
modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
return peptideAssumption.getPeptide().getTaggedModifiedSequence(modificationParameters, sequenceProvider, modificationSequenceMatchingParameters, false, false, true, null);
case spectrum_charge:
Precursor precursor = spectrumProvider.getPrecursor(spectrumFile, spectrumTitle);
return precursor.getPossibleChargesAsString();
case precursor_intensity:
precursor = spectrumProvider.getPrecursor(spectrumFile, spectrumTitle);
return Double.toString(precursor.intensity);
case spectrum_file:
return spectrumFile;
case spectrum_array_list:
spectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
return spectrum.getPeakListAsString();
case spectrum_title:
return spectrumTitle;
case spectrum_scan_number:
// TODO: To get scan numbers from cms when source mgf files have that info
return "";
case starred:
return psParameter.getStarred() ? "1" : "0";
case theoretical_mass:
return Double.toString(peptideAssumption.getPeptide().getMass());
case validated:
if (psParameter.getMatchValidationLevel() != null) {
return psParameter.getMatchValidationLevel().toString();
} else {
return "";
}
case sequence_coverage:
peptide = peptideAssumption.getPeptide();
spectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
annotationParameters = identificationParameters.getAnnotationParameters();
modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
specificAnnotationParameters = annotationParameters.getSpecificAnnotationParameters(spectrumFile, spectrumTitle, peptideAssumption, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters, peptideSpectrumAnnotator);
matches = peptideSpectrumAnnotator.getSpectrumAnnotation(annotationParameters, specificAnnotationParameters, spectrumFile, spectrumTitle, spectrum, peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
int sequenceLength = peptide.getSequence().length();
int[] aaCoverage = new int[sequenceLength];
Arrays.stream(matches).filter(ionMatch -> ionMatch.ion instanceof PeptideFragmentIon).forEach(ionMatch -> aaCoverage[((PeptideFragmentIon) ionMatch.ion).getNumber() - 1] = 1);
double nIons = Arrays.stream(aaCoverage).sum();
coverage = 100 * nIons / sequenceLength;
return Double.toString(coverage);
case longest_amino_acid_sequence_annotated:
peptide = peptideAssumption.getPeptide();
spectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
annotationParameters = identificationParameters.getAnnotationParameters();
modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
specificAnnotationParameters = annotationParameters.getSpecificAnnotationParameters(spectrumFile, spectrumTitle, peptideAssumption, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters, peptideSpectrumAnnotator);
matches = peptideSpectrumAnnotator.getSpectrumAnnotation(annotationParameters, specificAnnotationParameters, spectrumFile, spectrumTitle, spectrum, peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
String sequence = peptide.getSequence();
sequenceLength = sequence.length();
boolean[] coverageForward = new boolean[sequenceLength];
boolean[] coverageRewind = new boolean[sequenceLength];
Arrays.stream(matches).filter(ionMatch -> ionMatch.ion instanceof PeptideFragmentIon).map(ionMatch -> ((PeptideFragmentIon) ionMatch.ion)).forEach(peptideFragmentIon -> {
if (PeptideFragmentIon.isForward(peptideFragmentIon.getSubType())) {
coverageForward[peptideFragmentIon.getNumber() - 1] = true;
} else {
coverageRewind[peptideFragmentIon.getNumber() - 1] = true;
}
});
boolean[] aaCoverageB = new boolean[sequenceLength];
boolean previous = true;
for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
boolean current = coverageForward[aaIndex];
if (current && previous) {
aaCoverageB[aaIndex] = true;
}
previous = current;
}
previous = true;
for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
boolean current = coverageRewind[aaIndex];
if (current && previous) {
aaCoverageB[sequenceLength - aaIndex - 1] = true;
}
previous = current;
}
StringBuilder currentTag = new StringBuilder();
String longestTag = new String();
for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
if (aaCoverageB[aaIndex]) {
currentTag.append(sequence.charAt(aaIndex));
} else {
if (currentTag.length() > longestTag.length()) {
longestTag = currentTag.toString();
}
currentTag = new StringBuilder();
}
}
if (currentTag.length() > longestTag.length()) {
longestTag = currentTag.toString();
}
return longestTag;
case longest_amino_acid_sequence_annotated_single_serie:
peptide = peptideAssumption.getPeptide();
spectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
annotationParameters = identificationParameters.getAnnotationParameters();
modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
specificAnnotationParameters = annotationParameters.getSpecificAnnotationParameters(spectrumFile, spectrumTitle, peptideAssumption, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters, peptideSpectrumAnnotator);
matches = peptideSpectrumAnnotator.getSpectrumAnnotation(annotationParameters, specificAnnotationParameters, spectrumFile, spectrumTitle, spectrum, peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
sequence = peptide.getSequence();
sequenceLength = sequence.length();
HashMap<Integer, boolean[]> ionCoverage = new HashMap<>(6);
ionCoverage.put(PeptideFragmentIon.A_ION, new boolean[sequenceLength]);
ionCoverage.put(PeptideFragmentIon.B_ION, new boolean[sequenceLength]);
ionCoverage.put(PeptideFragmentIon.C_ION, new boolean[sequenceLength]);
ionCoverage.put(PeptideFragmentIon.X_ION, new boolean[sequenceLength]);
ionCoverage.put(PeptideFragmentIon.Y_ION, new boolean[sequenceLength]);
ionCoverage.put(PeptideFragmentIon.Z_ION, new boolean[sequenceLength]);
Arrays.stream(matches).filter(ionMatch -> ionMatch.charge == 1 && ionMatch.ion instanceof PeptideFragmentIon && !ionMatch.ion.hasNeutralLosses()).map(ionMatch -> ((PeptideFragmentIon) ionMatch.ion)).forEach(peptideFragmentIon -> ionCoverage.get(peptideFragmentIon.getSubType())[peptideFragmentIon.getNumber() - 1] = true);
longestTag = new String();
currentTag = new StringBuilder();
previous = true;
for (int ionType : PeptideFragmentIon.getPossibleSubtypes()) {
for (int i = 0; i < sequenceLength; i++) {
int aaIndex = PeptideFragmentIon.isForward(ionType) ? i : sequence.length() - i - 1;
boolean current = ionCoverage.get(ionType)[i];
if (current && previous) {
currentTag.append(sequence.charAt(aaIndex));
} else {
if (currentTag.length() > longestTag.length()) {
if (PeptideFragmentIon.isForward(ionType)) {
currentTag.reverse();
}
longestTag = currentTag.toString();
}
currentTag = new StringBuilder();
}
previous = current;
}
if (currentTag.length() > longestTag.length()) {
if (PeptideFragmentIon.isForward(ionType)) {
currentTag.reverse();
}
longestTag = currentTag.toString();
}
}
return longestTag;
case amino_acids_annotated:
peptide = peptideAssumption.getPeptide();
spectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
annotationParameters = identificationParameters.getAnnotationParameters();
modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
specificAnnotationParameters = annotationParameters.getSpecificAnnotationParameters(spectrumFile, spectrumTitle, peptideAssumption, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters, peptideSpectrumAnnotator);
matches = peptideSpectrumAnnotator.getSpectrumAnnotation(annotationParameters, specificAnnotationParameters, spectrumFile, spectrumTitle, spectrum, peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
sequence = peptide.getSequence();
sequenceLength = sequence.length();
coverageForward = new boolean[sequenceLength];
coverageRewind = new boolean[sequenceLength];
Arrays.stream(matches).filter(ionMatch -> ionMatch.ion instanceof PeptideFragmentIon).map(ionMatch -> ((PeptideFragmentIon) ionMatch.ion)).forEach(peptideFragmentIon -> {
if (PeptideFragmentIon.isForward(peptideFragmentIon.getSubType())) {
coverageForward[peptideFragmentIon.getNumber() - 1] = true;
} else {
coverageRewind[peptideFragmentIon.getNumber() - 1] = true;
}
});
aaCoverageB = new boolean[sequenceLength];
previous = true;
for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
boolean current = coverageForward[aaIndex];
if (current && previous) {
aaCoverageB[aaIndex] = true;
}
previous = current;
}
previous = true;
for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
boolean current = coverageRewind[aaIndex];
if (current && previous) {
aaCoverageB[sequenceLength - aaIndex - 1] = true;
}
previous = current;
}
StringBuilder tag = new StringBuilder();
double gap = 0;
for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
if (aaCoverageB[aaIndex]) {
if (gap > 0) {
tag.append("<").append(gap).append(">");
}
tag.append(sequence.charAt(aaIndex));
gap = 0;
} else {
gap += AminoAcid.getAminoAcid(sequence.charAt(aaIndex)).getMonoisotopicMass();
}
}
if (gap > 0) {
tag.append("<").append(gap).append(">");
}
return tag.toString();
default:
return "Not implemented";
}
}
use of com.compomics.util.experiment.identification.matches.IonMatch in project peptide-shaker by compomics.
the class ModificationsPanel method updateSpectrum.
/**
* Update the spectra according to the currently selected PSM.
*
* @param spectrumMatchKey the main spectrum match key
* @param secondSpectrumMatchKey the secondary spectrum key
*/
public void updateSpectrum(long spectrumMatchKey, Long secondSpectrumMatchKey) {
SpectrumProvider spectrumProvider = peptideShakerGUI.getSpectrumProvider();
spectrumChartJPanel.removeAll();
spectrumChartJPanel.revalidate();
spectrumChartJPanel.repaint();
SequenceProvider sequenceProvider = peptideShakerGUI.getSequenceProvider();
IdentificationParameters identificationParameters = peptideShakerGUI.getIdentificationParameters();
AnnotationParameters annotationParameters = identificationParameters.getAnnotationParameters();
ModificationParameters modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
SequenceMatchingParameters modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
SpectrumMatch spectrumMatch = identification.getSpectrumMatch(spectrumMatchKey);
String spectrumFile = spectrumMatch.getSpectrumFile();
String spectrumTitle = spectrumMatch.getSpectrumTitle();
Spectrum currentSpectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
SpectrumMatch secondSpectrumMatch = null;
if (currentSpectrum != null && currentSpectrum.mz.length > 0) {
Precursor precursor = currentSpectrum.getPrecursor();
double[] intensityArray = secondSpectrumMatchKey == null ? currentSpectrum.intensity : ArrayUtil.scaleToMax(currentSpectrum.intensity);
spectrumPanel = new SpectrumPanel(currentSpectrum.mz, intensityArray, 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());
int identificationChargeFirstPsm = 0;
int identificationChargeSecondPsm = 0;
HashSet<String> allModifications = new HashSet<>(2);
// get the spectrum annotations
PeptideAssumption peptideAssumption = spectrumMatch.getBestPeptideAssumption();
Peptide peptide = peptideAssumption.getPeptide();
identificationChargeFirstPsm = spectrumMatch.getBestPeptideAssumption().getIdentificationCharge();
allModifications.addAll(ModificationUtils.getAllModifications(peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters));
PeptideSpectrumAnnotator spectrumAnnotator = new PeptideSpectrumAnnotator();
SpecificAnnotationParameters specificAnnotationParameters = peptideShakerGUI.getSpecificAnnotationParameters(spectrumFile, spectrumTitle, peptideAssumption);
IonMatch[] annotations = spectrumAnnotator.getSpectrumAnnotation(annotationParameters, specificAnnotationParameters, spectrumFile, spectrumTitle, currentSpectrum, peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
// 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);
spectrumPanel.showAnnotatedPeaksOnly(!annotationParameters.showAllPeaks());
spectrumPanel.setYAxisZoomExcludesBackgroundPeaks(annotationParameters.yAxisZoomExcludesBackgroundPeaks());
// add de novo sequencing
SearchParameters searchParameters = peptideShakerGUI.getIdentificationParameters().getSearchParameters();
Integer forwardIon = searchParameters.getForwardIons().get(0);
Integer rewindIon = searchParameters.getRewindIons().get(0);
spectrumPanel.addAutomaticDeNovoSequencing(peptide, annotations, forwardIon, rewindIon, annotationParameters.getDeNovoCharge(), annotationParameters.showForwardIonDeNovoTags(), annotationParameters.showRewindIonDeNovoTags(), false, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
// see if a second mirrored spectrum is to be added
if (secondSpectrumMatchKey != null) {
secondSpectrumMatch = identification.getSpectrumMatch(secondSpectrumMatchKey);
spectrumFile = spectrumMatch.getSpectrumFile();
spectrumTitle = spectrumMatch.getSpectrumTitle();
currentSpectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
if (currentSpectrum != null && currentSpectrum.mz.length > 0) {
precursor = currentSpectrum.getPrecursor();
spectrumPanel.addMirroredSpectrum(currentSpectrum.mz, ArrayUtil.scaleToMax(currentSpectrum.intensity), currentSpectrum.getPrecursor().mz, Charge.toString(secondSpectrumMatch.getBestPeptideAssumption().getIdentificationCharge()), "", false, peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedMirroredPeakColor(), peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedMirroredPeakColor());
// get the spectrum annotations
peptideAssumption = secondSpectrumMatch.getBestPeptideAssumption();
peptide = peptideAssumption.getPeptide();
identificationChargeSecondPsm = secondSpectrumMatch.getBestPeptideAssumption().getIdentificationCharge();
allModifications.addAll(ModificationUtils.getAllModifications(peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters));
specificAnnotationParameters = peptideShakerGUI.getSpecificAnnotationParameters(spectrumFile, spectrumTitle, peptideAssumption);
annotations = spectrumAnnotator.getSpectrumAnnotation(annotationParameters, specificAnnotationParameters, spectrumFile, spectrumTitle, currentSpectrum, peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
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);
spectrumPanel.rescale(0.0, spectrumPanel.getMaxXAxisValue());
}
}
spectrumChartJPanel.add(spectrumPanel);
peptideShakerGUI.updateAnnotationMenus(specificAnnotationParameters, Math.max(identificationChargeFirstPsm, identificationChargeSecondPsm), allModifications);
String modifiedSequence = peptideShakerGUI.getDisplayFeaturesGenerator().getTaggedPeptideSequence(spectrumMatch, false, false, true);
if (secondSpectrumMatchKey != null) {
modifiedSequence += " vs. " + peptideShakerGUI.getDisplayFeaturesGenerator().getTaggedPeptideSequence(secondSpectrumMatch, false, false, true);
}
((TitledBorder) spectrumAndFragmentIonPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Spectrum & Fragment Ions (" + modifiedSequence + ")" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
spectrumAndFragmentIonPanel.revalidate();
spectrumAndFragmentIonPanel.repaint();
}
spectrumChartJPanel.revalidate();
spectrumChartJPanel.repaint();
}
Aggregations