use of com.compomics.util.experiment.io.biology.protein.SequenceProvider 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.io.biology.protein.SequenceProvider in project peptide-shaker by compomics.
the class ModificationLocalizationScorer method attachProbabilisticScore.
/**
* Attaches the selected probabilistic modification score.
*
* @param spectrumMatch The spectrum match studied, the score will be
* calculated for the best assumption only.
* @param sequenceProvider The protein sequence provider to use.
* @param spectrumProvider The spectrum provider to use.
* @param modificationProvider The modification provider to use.
* @param identificationParameters The identification parameters.
* @param peptideSpectrumAnnotator The peptide spectrum annotator to use.
* @param identification The identification object containing the matches.
*/
private void attachProbabilisticScore(SpectrumMatch spectrumMatch, SequenceProvider sequenceProvider, SpectrumProvider spectrumProvider, ModificationProvider modificationProvider, IdentificationParameters identificationParameters, PeptideSpectrumAnnotator peptideSpectrumAnnotator, Identification identification) {
SearchParameters searchParameters = identificationParameters.getSearchParameters();
AnnotationParameters annotationParameters = identificationParameters.getAnnotationParameters();
ModificationLocalizationParameters scoringParameters = identificationParameters.getModificationLocalizationParameters();
SequenceMatchingParameters sequenceMatchingParameters = identificationParameters.getSequenceMatchingParameters();
SequenceMatchingParameters modificationSequenceMatchingParameters = scoringParameters.getSequenceMatchingParameters();
ModificationParameters modificationParameters = searchParameters.getModificationParameters();
PSModificationScores modificationScores = (PSModificationScores) spectrumMatch.getUrParam(PSModificationScores.dummy);
if (modificationScores != null) {
modificationScores = new PSModificationScores();
spectrumMatch.addUrParam(modificationScores);
}
HashMap<Double, ArrayList<Modification>> modificationsMap = new HashMap<>(1);
HashMap<Double, Integer> nMod = new HashMap<>(1);
PeptideAssumption bestPeptideAssumption = spectrumMatch.getBestPeptideAssumption();
Peptide peptide = bestPeptideAssumption.getPeptide();
for (ModificationMatch modificationMatch : peptide.getVariableModifications()) {
Modification refMod = modificationProvider.getModification(modificationMatch.getModification());
double modMass = refMod.getMass();
if (!modificationsMap.containsKey(modMass)) {
ArrayList<Modification> modifications = modificationFactory.getSameMassNotFixedModifications(modMass, searchParameters).stream().map(modification -> modificationProvider.getModification(modification)).collect(Collectors.toCollection(ArrayList::new));
modificationsMap.put(modMass, modifications);
nMod.put(modMass, 1);
} else {
nMod.put(modMass, nMod.get(modMass) + 1);
}
}
if (!modificationsMap.isEmpty()) {
String spectrumFile = spectrumMatch.getSpectrumFile();
String spectrumTitle = spectrumMatch.getSpectrumTitle();
Spectrum spectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
SpecificAnnotationParameters specificAnnotationParameters = annotationParameters.getSpecificAnnotationParameters(spectrumFile, spectrumTitle, bestPeptideAssumption, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters, peptideSpectrumAnnotator);
for (double modMass : modificationsMap.keySet()) {
HashMap<Integer, Double> scores = null;
if (scoringParameters.getSelectedProbabilisticScore() == ModificationLocalizationScore.PhosphoRS) {
scores = PhosphoRS.getSequenceProbabilities(peptide, modificationsMap.get(modMass), modificationParameters, spectrum, sequenceProvider, annotationParameters, specificAnnotationParameters, scoringParameters.isProbabilisticScoreNeutralLosses(), sequenceMatchingParameters, modificationSequenceMatchingParameters, peptideSpectrumAnnotator);
if (scores == null) {
throw new IllegalArgumentException("An error occurred while scoring spectrum " + spectrumTitle + " of file " + spectrumFile + " with PhosphoRS.");
// Most likely a compatibility issue with utilities
}
}
if (scores != null) {
// remap to searched modifications
Modification mappedModification = null;
String peptideSequence = peptide.getSequence();
for (int site : scores.keySet()) {
if (site == 0) {
// N-term mod
for (Modification modification : modificationsMap.get(modMass)) {
if (modification.getModificationType().isNTerm()) {
mappedModification = modification;
break;
}
}
if (mappedModification == null) {
throw new IllegalArgumentException("Could not map the PTM of mass " + modMass + " on the N-terminus of the peptide " + peptideSequence + ".");
}
} else if (site == peptideSequence.length() + 1) {
// C-term mod
for (Modification modification : modificationsMap.get(modMass)) {
if (modification.getModificationType().isCTerm()) {
mappedModification = modification;
break;
}
}
if (mappedModification == null) {
throw new IllegalArgumentException("Could not map the PTM of mass " + modMass + " on the C-terminus of the peptide " + peptideSequence + ".");
}
} else {
for (Modification modification : modificationsMap.get(modMass)) {
mappedModification = modification;
break;
}
if (mappedModification == null) {
throw new IllegalArgumentException("Could not map the PTM of mass " + modMass + " at site " + site + " in peptide " + peptide.getSequence() + ".");
}
}
String modName = mappedModification.getName();
ModificationScoring modificationScoring = modificationScores.getModificationScoring(modName);
if (modificationScoring == null) {
modificationScoring = new ModificationScoring(modName);
modificationScores.addModificationScoring(modName, modificationScoring);
}
modificationScoring.setProbabilisticScore(site, scores.get(site));
}
}
}
identification.updateObject(spectrumMatch.getKey(), spectrumMatch);
}
}
use of com.compomics.util.experiment.io.biology.protein.SequenceProvider in project peptide-shaker by compomics.
the class QCPanel method getPeptideDataset.
/**
* Returns the dataset to use for the peptide QC plot.
*/
private void getPeptideDataset() {
maxValue = Double.MIN_VALUE;
SequenceProvider sequenceProvider = peptideShakerGUI.getSequenceProvider();
if (peptideValidatedPsmsJRadioButton.isSelected()) {
progressDialog.setPrimaryProgressCounterIndeterminate(false);
progressDialog.setMaxPrimaryProgressCounter(peptideShakerGUI.getIdentification().getPeptideIdentification().size());
progressDialog.setValue(0);
// values for the number of validated PSMs
validatedValues = new ArrayList<>();
validatedDoubtfulValues = new ArrayList<>();
nonValidatedValues = new ArrayList<>();
validatedDecoyValues = new ArrayList<>();
nonValidatedDecoyValues = new ArrayList<>();
PeptideMatchesIterator peptideMatchesIterator = peptideShakerGUI.getIdentification().getPeptideMatchesIterator(progressDialog);
PeptideMatch peptideMatch;
while ((peptideMatch = peptideMatchesIterator.next()) != null) {
if (progressDialog.isRunCanceled()) {
break;
}
double value = 0;
for (long spectrumMatchKey : peptideMatch.getSpectrumMatchesKeys()) {
if (progressDialog.isRunCanceled()) {
break;
}
SpectrumMatch spectrumMatch = peptideShakerGUI.getIdentification().getSpectrumMatch(spectrumMatchKey);
PSParameter spectrumParameter = (PSParameter) spectrumMatch.getUrParam(PSParameter.dummy);
if (spectrumParameter.getMatchValidationLevel().isValidated() && !spectrumParameter.getHidden()) {
value = value + 1;
}
}
if (value > maxValue) {
maxValue = value;
}
PSParameter peptideParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
if (!peptideParameter.getHidden()) {
if (!PeptideUtils.isDecoy(peptideMatch.getPeptide(), sequenceProvider)) {
if (peptideParameter.getMatchValidationLevel().isValidated()) {
if (peptideParameter.getMatchValidationLevel() == MatchValidationLevel.confident) {
validatedValues.add(value);
} else {
validatedDoubtfulValues.add(value);
}
} else {
nonValidatedValues.add(value);
}
} else if (peptideParameter.getMatchValidationLevel().isValidated()) {
validatedDecoyValues.add(value);
} else {
nonValidatedDecoyValues.add(value);
}
}
progressDialog.increasePrimaryProgressCounter();
}
} else if (peptideMissedCleavagesJRadioButton.isSelected()) {
progressDialog.setPrimaryProgressCounterIndeterminate(false);
progressDialog.setMaxPrimaryProgressCounter(peptideShakerGUI.getIdentification().getPeptideIdentification().size());
progressDialog.setValue(0);
// Values for the missed cleavages
validatedValues = new ArrayList<>();
validatedDoubtfulValues = new ArrayList<>();
nonValidatedValues = new ArrayList<>();
validatedDecoyValues = new ArrayList<>();
nonValidatedDecoyValues = new ArrayList<>();
PeptideMatchesIterator peptideMatchesIterator = peptideShakerGUI.getIdentification().getPeptideMatchesIterator(progressDialog);
PeptideMatch peptideMatch;
while ((peptideMatch = peptideMatchesIterator.next()) != null) {
if (progressDialog.isRunCanceled()) {
break;
}
PSParameter peptideParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
if (!peptideParameter.getHidden()) {
Double value = null;
DigestionParameters digestionParameters = peptideShakerGUI.getIdentificationParameters().getSearchParameters().getDigestionParameters();
if (digestionParameters.getCleavageParameter() == DigestionParameters.CleavageParameter.enzyme) {
for (Enzyme enzyme : digestionParameters.getEnzymes()) {
int enzymeMissedCelavages = enzyme.getNmissedCleavages(peptideMatch.getPeptide().getSequence());
if (value == null || enzymeMissedCelavages < value) {
value = Double.valueOf(enzymeMissedCelavages);
}
}
}
if (value == null) {
value = 0.0;
}
if (value > 0) {
if (value > maxValue) {
maxValue = value;
}
}
if (!PeptideUtils.isDecoy(peptideMatch.getPeptide(), sequenceProvider)) {
if (peptideParameter.getMatchValidationLevel().isValidated()) {
if (peptideParameter.getMatchValidationLevel() == MatchValidationLevel.confident) {
validatedValues.add(value);
} else {
validatedDoubtfulValues.add(value);
}
} else {
nonValidatedValues.add(value);
}
} else if (peptideParameter.getMatchValidationLevel().isValidated()) {
validatedDecoyValues.add(value);
} else {
nonValidatedDecoyValues.add(value);
}
}
progressDialog.increasePrimaryProgressCounter();
}
} else if (peptideLengthJRadioButton.isSelected()) {
progressDialog.setPrimaryProgressCounterIndeterminate(false);
progressDialog.setMaxPrimaryProgressCounter(peptideShakerGUI.getIdentification().getPeptideIdentification().size());
progressDialog.setValue(0);
// values for the peptide length
validatedValues = new ArrayList<>();
validatedDoubtfulValues = new ArrayList<>();
nonValidatedValues = new ArrayList<>();
validatedDecoyValues = new ArrayList<>();
nonValidatedDecoyValues = new ArrayList<>();
PeptideMatchesIterator peptideMatchesIterator = peptideShakerGUI.getIdentification().getPeptideMatchesIterator(progressDialog);
PeptideMatch peptideMatch;
while ((peptideMatch = peptideMatchesIterator.next()) != null) {
if (progressDialog.isRunCanceled()) {
break;
}
PSParameter peptideParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
if (!peptideParameter.getHidden()) {
double length = peptideMatch.getPeptide().getSequence().length();
if (length > 0) {
if (length > maxValue) {
maxValue = length;
}
}
if (!PeptideUtils.isDecoy(peptideMatch.getPeptide(), sequenceProvider)) {
if (peptideParameter.getMatchValidationLevel().isValidated()) {
if (peptideParameter.getMatchValidationLevel() == MatchValidationLevel.confident) {
validatedValues.add(length);
} else {
validatedDoubtfulValues.add(length);
}
} else {
nonValidatedValues.add(length);
}
} else if (peptideParameter.getMatchValidationLevel().isValidated()) {
validatedDecoyValues.add(length);
} else {
nonValidatedDecoyValues.add(length);
}
}
progressDialog.increasePrimaryProgressCounter();
}
}
}
use of com.compomics.util.experiment.io.biology.protein.SequenceProvider in project peptide-shaker by compomics.
the class QCPanel method getPeptideModificationEnrichmentSpecificityDataset.
/**
* Returns the dataset for the peptide modification rate QC plot.
*
* @return the dataset for the peptide modification rate QC plot
*/
private DefaultCategoryDataset getPeptideModificationEnrichmentSpecificityDataset() {
ModificationFactory modificationFactory = ModificationFactory.getInstance();
Identification identification = peptideShakerGUI.getIdentification();
SequenceProvider sequenceProvider = peptideShakerGUI.getSequenceProvider();
IdentificationParameters identificationParameters = peptideShakerGUI.getIdentificationParameters();
ModificationParameters modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
SequenceMatchingParameters modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
ArrayList<String> modNames = modificationParameters.getAllNotFixedModifications();
HashMap<String, Integer> modifiedPeptidesMap = new HashMap<>(modNames.size());
HashMap<String, Integer> possiblyModifiedPeptidesMap = new HashMap<>(modNames.size());
progressDialog.setPrimaryProgressCounterIndeterminate(false);
progressDialog.setMaxPrimaryProgressCounter(identification.getPeptideIdentification().size());
progressDialog.setValue(0);
PeptideMatchesIterator peptideMatchesIterator = identification.getPeptideMatchesIterator(progressDialog);
PeptideMatch peptideMatch;
while ((peptideMatch = peptideMatchesIterator.next()) != null) {
PSParameter psParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
if (psParameter.getMatchValidationLevel().isValidated()) {
Peptide peptide = peptideMatch.getPeptide();
for (String modName : modificationParameters.getAllNotFixedModifications()) {
Modification modification = modificationFactory.getModification(modName);
int[] possibleSites = ModificationUtils.getPossibleModificationSites(peptide, modification, sequenceProvider, modificationSequenceMatchingParameters);
if (possibleSites.length != 0) {
Integer nPossiblePeptides = possiblyModifiedPeptidesMap.get(modName);
if (nPossiblePeptides == null) {
possiblyModifiedPeptidesMap.put(modName, 1);
} else {
possiblyModifiedPeptidesMap.put(modName, nPossiblePeptides + 1);
}
boolean modified = false;
for (ModificationMatch modificationMatch : peptide.getVariableModifications()) {
if (modificationMatch.getModification().equals(modName)) {
modified = true;
break;
}
}
if (modified) {
Integer nModifiedPeptides = modifiedPeptidesMap.get(modName);
if (nModifiedPeptides == null) {
modifiedPeptidesMap.put(modName, 1);
} else {
modifiedPeptidesMap.put(modName, nModifiedPeptides + 1);
}
}
}
}
}
if (progressDialog.isRunCanceled()) {
break;
}
progressDialog.increaseSecondaryProgressCounter();
}
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (String modName : modificationParameters.getAllNotFixedModifications()) {
Integer nFound = modifiedPeptidesMap.get(modName);
if (nFound == null) {
nFound = 0;
}
Integer nPossible = possiblyModifiedPeptidesMap.get(modName);
Double rate = 0.0;
if (nPossible != null) {
rate = (100.0 * nFound) / nPossible;
}
dataset.addValue(rate, "Modified", modName);
double rest = 0.0;
if (nPossible != null) {
rest = 100 - rate;
}
dataset.addValue(rest, "Not Modified", modName);
}
return dataset;
}
use of com.compomics.util.experiment.io.biology.protein.SequenceProvider in project peptide-shaker by compomics.
the class QCPanel method getPeptideModificationEfficiencyDataset.
/**
* Returns the dataset for the peptide modification efficiency QC plot.
*
* @return the dataset for the peptide modification efficiency QC plot
*/
private DefaultCategoryDataset getPeptideModificationEfficiencyDataset() {
ModificationFactory modificationFactory = ModificationFactory.getInstance();
Identification identification = peptideShakerGUI.getIdentification();
SequenceProvider sequenceProvider = peptideShakerGUI.getSequenceProvider();
IdentificationParameters identificationParameters = peptideShakerGUI.getIdentificationParameters();
ModificationParameters modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
SequenceMatchingParameters modificationSequenceMatchingPreferences = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
ArrayList<String> modNames = modificationParameters.getAllNotFixedModifications();
HashMap<String, Integer> modifiedSitesMap = new HashMap<>(modNames.size());
HashMap<String, Integer> possibleSitesMap = new HashMap<>(modNames.size());
PSParameter psParameter = new PSParameter();
progressDialog.setPrimaryProgressCounterIndeterminate(false);
progressDialog.setMaxPrimaryProgressCounter(identification.getPeptideIdentification().size());
progressDialog.setValue(0);
PeptideMatchesIterator peptideMatchesIterator = identification.getPeptideMatchesIterator(progressDialog);
PeptideMatch peptideMatch;
while ((peptideMatch = peptideMatchesIterator.next()) != null) {
psParameter = (PSParameter) peptideMatch.getUrParam(psParameter);
if (psParameter.getMatchValidationLevel().isValidated()) {
Peptide peptide = peptideMatch.getPeptide();
HashMap<String, Integer> peptideModificationsMap = new HashMap<>(peptide.getVariableModifications().length);
for (ModificationMatch modificationMatch : peptide.getVariableModifications()) {
String modName = modificationMatch.getModification();
Integer occurrence = peptideModificationsMap.get(modName);
if (occurrence == null) {
peptideModificationsMap.put(modName, 1);
} else {
peptideModificationsMap.put(modName, occurrence + 1);
}
}
for (String modName : modificationParameters.getAllNotFixedModifications()) {
Modification modification = modificationFactory.getModification(modName);
int[] possibleSites = ModificationUtils.getPossibleModificationSites(peptide, modification, sequenceProvider, modificationSequenceMatchingPreferences);
if (possibleSites.length != 0) {
Integer occurrencePeptide = peptideModificationsMap.get(modName);
if (occurrencePeptide != null) {
Integer occurrenceDataset = modifiedSitesMap.get(modName);
if (occurrenceDataset == null) {
modifiedSitesMap.put(modName, occurrencePeptide);
} else {
modifiedSitesMap.put(modName, occurrenceDataset + occurrencePeptide);
}
}
Integer possibleSitesDataset = possibleSitesMap.get(modName);
if (possibleSitesDataset == null) {
possibleSitesMap.put(modName, possibleSites.length);
} else {
possibleSitesMap.put(modName, possibleSitesDataset + possibleSites.length);
}
}
}
}
if (progressDialog.isRunCanceled()) {
break;
}
progressDialog.increaseSecondaryProgressCounter();
}
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (String modName : modificationParameters.getAllNotFixedModifications()) {
Integer nFound = modifiedSitesMap.get(modName);
if (nFound == null) {
nFound = 0;
}
Integer nPossible = possibleSitesMap.get(modName);
Double rate = 0.0;
if (nPossible != null) {
rate = (100.0 * nFound) / nPossible;
}
dataset.addValue(rate, "Modified", modName);
double rest = 100 - rate;
dataset.addValue(rest, "Not Modified", modName);
}
return dataset;
}
Aggregations