use of eu.isas.peptideshaker.gui.protein_sequence.ResidueAnnotation 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.gui.protein_sequence.ResidueAnnotation in project peptide-shaker by compomics.
the class OverviewPanel method updateSequenceCoverage.
/**
* Updates the sequence coverage panel.
*
* @param proteinAccession the protein accession
* @param updateProtein if true, force a complete recreation of the plot
*/
private void updateSequenceCoverage(long proteinKey, String proteinAccession, boolean updateProtein) {
// @TODO: should be in a separate thread that is possible to cancel if the selection changes
try {
// only need to redo this if the protein changes
if (updateProtein || !proteinAccession.equalsIgnoreCase(currentProteinAccession) || coverage == null) {
updateProteinSequenceCoveragePanelTitle(proteinAccession);
updatePtmCoveragePlot(proteinAccession);
updatePeptideVariationsCoveragePlot(proteinAccession);
}
currentProteinAccession = proteinAccession;
SearchParameters searchParameters = peptideShakerGUI.getIdentificationParameters().getSearchParameters();
ArrayList<Integer> selectedPeptideStart = new ArrayList<>();
int selectionLength = 0;
if (peptideTable.getSelectedRow() != -1) {
SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) peptideTable.getModel();
int peptideIndex = tableModel.getViewIndex(peptideTable.getSelectedRow());
long peptideKey = peptideKeys[peptideIndex];
PeptideMatch peptideMatch = peptideShakerGUI.getIdentification().getPeptideMatch(peptideKey);
String peptideSequence = peptideMatch.getPeptide().getSequence();
selectionLength = peptideSequence.length();
try {
for (int startIndex : peptideMatch.getPeptide().getProteinMapping().get(currentProteinAccession)) {
selectedPeptideStart.add(startIndex);
}
} catch (Exception e) {
// ignore errors due to the user switching too quickly between rows. seems to solve themselves anyway
}
}
IdentificationFeaturesGenerator identificationFeaturesGenerator = peptideShakerGUI.getIdentificationFeaturesGenerator();
int[] validationCoverage;
if (coverageShowAllPeptidesJRadioButtonMenuItem.isSelected()) {
validationCoverage = identificationFeaturesGenerator.getAACoverage(proteinKey);
} else {
validationCoverage = identificationFeaturesGenerator.estimateAACoverage(proteinKey, coverageShowEnzymaticPeptidesOnlyJRadioButtonMenuItem.isSelected());
}
double minHeight = 0.2, maxHeight = 1;
NonSymmetricalNormalDistribution peptideLengthDistribution = peptideShakerGUI.getMetrics().getPeptideLengthDistribution();
if (peptideLengthDistribution != null) {
double medianLength = peptideLengthDistribution.getMean();
maxHeight = (1 - minHeight) * peptideLengthDistribution.getProbabilityAt(medianLength);
}
double[] coverageLikelihood = identificationFeaturesGenerator.getCoverableAA(proteinKey);
double[] coverageHeight = new double[coverageLikelihood.length];
for (int i = 0; i < coverageLikelihood.length; i++) {
double p = coverageLikelihood[i];
coverageHeight[i] = minHeight + p / maxHeight;
}
HashMap<Integer, Color> colors = new HashMap<>();
colors.put(MatchValidationLevel.confident.getIndex(), peptideShakerGUI.getSparklineColor());
colors.put(MatchValidationLevel.doubtful.getIndex(), peptideShakerGUI.getUtilitiesUserParameters().getSparklineColorDoubtful());
colors.put(MatchValidationLevel.not_validated.getIndex(), peptideShakerGUI.getSparklineColorNonValidated());
colors.put(MatchValidationLevel.none.getIndex(), peptideShakerGUI.getSparklineColorNotFound());
int userSelectionIndex = 0;
while (colors.containsKey(userSelectionIndex)) {
userSelectionIndex++;
}
// @TODO: use non hard coded value
colors.put(userSelectionIndex, Color.blue);
int[] coverageColor = validationCoverage.clone();
for (int aaStart : selectedPeptideStart) {
for (int aa = aaStart; aa < aaStart + selectionLength; aa++) {
coverageColor[aa] = userSelectionIndex;
}
}
// Dirty fix until the width of the sparkline can change
int transparentIndex = userSelectionIndex + 1;
colors.put(userSelectionIndex + 1, new Color(0, 0, 0, 0));
for (int aa = 0; aa < coverageHeight.length; aa++) {
if (coverageColor[aa] == MatchValidationLevel.none.getIndex()) {
if (coverageLikelihood[aa] < 0.01 || !coverageShowPossiblePeptidesJCheckBoxMenuItem.isSelected()) {
// NOTE: if the fix is removed, make sure that this line is kept!!!
coverageColor[aa] = transparentIndex;
}
}
}
// create the coverage plot
ArrayList<JSparklinesDataSeries> sparkLineDataSeriesCoverage = ProteinSequencePanel.getSparkLineDataSeriesCoverage(coverageHeight, coverageColor, colors);
HashMap<Integer, ArrayList<ResidueAnnotation>> proteinTooltips = peptideShakerGUI.getDisplayFeaturesGenerator().getResidueAnnotation(proteinKey, peptideShakerGUI.getIdentificationParameters().getSequenceMatchingParameters(), identificationFeaturesGenerator, peptideShakerGUI.getMetrics(), peptideShakerGUI.getIdentification(), coverageShowAllPeptidesJRadioButtonMenuItem.isSelected(), searchParameters, coverageShowEnzymaticPeptidesOnlyJRadioButtonMenuItem.isSelected());
// Dirty fix for a bloc-level annotation
HashMap<Integer, ArrayList<ResidueAnnotation>> blocTooltips = new HashMap<>();
int aaCpt = 0, blocCpt = 0;
for (JSparklinesDataSeries jSparklinesDataSeries : sparkLineDataSeriesCoverage) {
double sparkLineLength = jSparklinesDataSeries.getData().get(0);
ArrayList<ResidueAnnotation> blocAnnotation = new ArrayList<>();
for (int j = 0; j < sparkLineLength; j++, aaCpt++) {
ArrayList<ResidueAnnotation> aaAnnotation = proteinTooltips.get(aaCpt);
if (aaAnnotation != null) {
for (ResidueAnnotation residueAnnotation : aaAnnotation) {
if (!blocAnnotation.contains(residueAnnotation)) {
blocAnnotation.add(residueAnnotation);
}
}
}
}
blocTooltips.put(blocCpt, blocAnnotation);
blocCpt++;
}
proteinSequencePanel = new ProteinSequencePanel(Color.WHITE);
coverageChart = proteinSequencePanel.getSequencePlot(this, new JSparklinesDataset(sparkLineDataSeriesCoverage), blocTooltips, true, true);
// make sure that the range is the same for all the sequence annotation charts
coverageChart.getChart().addChangeListener(new ChartChangeListener() {
@Override
public void chartChanged(ChartChangeEvent cce) {
if (ptmChart != null) {
Range range = ((CategoryPlot) coverageChart.getChart().getPlot()).getRangeAxis().getRange();
((CategoryPlot) ptmChart.getChart().getPlot()).getRangeAxis().setRange(range);
ptmChart.revalidate();
ptmChart.repaint();
}
if (peptideVariationsChart != null) {
Range range = ((CategoryPlot) coverageChart.getChart().getPlot()).getRangeAxis().getRange();
((CategoryPlot) peptideVariationsChart.getChart().getPlot()).getRangeAxis().setRange(range);
peptideVariationsChart.revalidate();
peptideVariationsChart.repaint();
}
}
});
sequenceCoverageInnerPanel.removeAll();
sequenceCoverageInnerPanel.add(coverageChart);
sequenceCoverageInnerPanel.revalidate();
sequenceCoverageInnerPanel.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.gui.protein_sequence.ResidueAnnotation 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.gui.protein_sequence.ResidueAnnotation in project peptide-shaker by compomics.
the class OverviewPanel method annotationClicked.
@Override
public void annotationClicked(ArrayList<ResidueAnnotation> allAnnotation, ChartMouseEvent cme) {
final Range oldRange = ((CategoryPlot) coverageChart.getChart().getPlot()).getRangeAxis().getRange();
if (allAnnotation.size() == 1 && allAnnotation.get(0).clickable) {
// select the peptide
peptideShakerGUI.setSelectedItems(peptideShakerGUI.getSelectedProteinKey(), allAnnotation.get(0).identifier, null, null);
updateSelection(true);
// update the protein
peptideShakerGUI.setSelectedItems(peptideShakerGUI.getSelectedProteinKey(), allAnnotation.get(0).identifier, null, null);
// update the psm selection
updatePsmSelection(peptideTable.getSelectedRow(), false);
// new peptide, reset spectrum boundaries
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) psmTable.getModel();
updateSpectrum(tableModel.getViewIndex(psmTable.getSelectedRow()), true);
} catch (Exception e) {
peptideShakerGUI.catchException(e);
}
}
});
// reset the range
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
((CategoryPlot) coverageChart.getChart().getPlot()).getRangeAxis().setRange(oldRange);
coverageChart.revalidate();
coverageChart.repaint();
} catch (Exception e) {
peptideShakerGUI.catchException(e);
}
}
});
} else {
// show popup menu
JPopupMenu peptidesPopupMenu = new JPopupMenu();
for (ResidueAnnotation currentAnnotation : allAnnotation) {
if (currentAnnotation.clickable) {
String text = "<html>" + (peptidesPopupMenu.getComponentCount() + 1) + ": " + currentAnnotation.annotation + "</html>";
final long peptideKey = currentAnnotation.identifier;
JMenuItem menuItem = new JMenuItem(text);
menuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
try {
// select the peptide
peptideShakerGUI.setSelectedItems(peptideShakerGUI.getSelectedProteinKey(), peptideKey, null, null);
updateSelection(true);
// update the protein
peptideShakerGUI.setSelectedItems(peptideShakerGUI.getSelectedProteinKey(), peptideKey, null, null);
// update the psm selection
updatePsmSelection(peptideTable.getSelectedRow(), false);
// new peptide, reset spectrum boundaries
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) psmTable.getModel();
updateSpectrum(tableModel.getViewIndex(psmTable.getSelectedRow()), true);
} catch (Exception e) {
peptideShakerGUI.catchException(e);
}
}
});
// reset the range
// invoke later to give time for components to update
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
((CategoryPlot) coverageChart.getChart().getPlot()).getRangeAxis().setRange(oldRange);
coverageChart.revalidate();
coverageChart.repaint();
} catch (Exception e) {
peptideShakerGUI.catchException(e);
}
}
});
} catch (Exception e) {
peptideShakerGUI.catchException(e);
}
}
});
peptidesPopupMenu.add(menuItem);
}
}
peptidesPopupMenu.show(cme.getTrigger().getComponent(), cme.getTrigger().getX(), cme.getTrigger().getY());
}
}
use of eu.isas.peptideshaker.gui.protein_sequence.ResidueAnnotation in project peptide-shaker by compomics.
the class DisplayFeaturesGenerator method getResidueAnnotation.
/**
* Returns the residue annotation for a given protein in a map for enzymatic
* or not enzymatic peptides only. Residue number > annotations. 0 is the
* first amino acid.
*
* @param proteinMatchKey the key of the match of interest
* @param sequenceMatchingPreferences The sequence matching preferences
* @param identificationFeaturesGenerator the identification feature
* generator
* @param metrics the metrics
* @param identification the identification
* @param allPeptides if true, all peptides are considered
* @param searchParameters the search parameters
* @param enzymatic whether enzymatic only or not enzymatic only peptides
* should be considered
*
* @return the residue annotation for a given protein
*/
public HashMap<Integer, ArrayList<ResidueAnnotation>> getResidueAnnotation(long proteinMatchKey, SequenceMatchingParameters sequenceMatchingPreferences, IdentificationFeaturesGenerator identificationFeaturesGenerator, Metrics metrics, Identification identification, boolean allPeptides, SearchParameters searchParameters, boolean enzymatic) {
ProteinMatch proteinMatch = identification.getProteinMatch(proteinMatchKey);
String sequence = sequenceProvider.getSequence(proteinMatch.getLeadingAccession());
HashMap<Integer, ArrayList<ResidueAnnotation>> residueAnnotation = new HashMap<>(sequence.length());
double[] coverage = identificationFeaturesGenerator.getCoverableAA(proteinMatchKey);
double lastP = coverage[0];
int lastIndex = 0;
for (int i = 0; i < coverage.length; i++) {
double p = coverage[i];
if (p != lastP) {
StringBuilder annotation = new StringBuilder();
annotation.append(lastIndex + 1).append('-').append(i + 1);
if (metrics.getPeptideLengthDistribution() != null) {
annotation.append(", ").append(Util.roundDouble(100 * lastP, 1)).append("% chance of coverage");
} else if (lastP > 0.01) {
annotation.append(", possible to cover");
}
ArrayList<ResidueAnnotation> annotations = new ArrayList<>(1);
annotations.add(new ResidueAnnotation(annotation.toString(), 0l, false));
for (int j = lastIndex; j < i; j++) {
residueAnnotation.put(j, new ArrayList<>(annotations));
}
lastP = p;
lastIndex = i;
}
}
int i = coverage.length;
StringBuilder annotation = new StringBuilder();
annotation.append(lastIndex + 1).append("-").append(i);
if (metrics.getPeptideLengthDistribution() != null) {
annotation.append(", ").append(Util.roundDouble(100 * lastP, 1)).append("% chance of coverage");
} else if (lastP > 0.01) {
annotation.append(", possible to cover");
}
ArrayList<ResidueAnnotation> annotations = new ArrayList<>(1);
annotations.add(new ResidueAnnotation(annotation.toString(), 0l, false));
for (int j = lastIndex; j < i; j++) {
residueAnnotation.put(j, new ArrayList<>(annotations));
}
for (long peptideMatchKey : proteinMatch.getPeptideMatchesKeys()) {
PeptideMatch peptideMatch = identification.getPeptideMatch(peptideMatchKey);
String peptideSequence = peptideMatch.getPeptide().getSequence();
boolean enzymaticPeptide = true;
if (!allPeptides) {
DigestionParameters digestionPreferences = searchParameters.getDigestionParameters();
if (digestionPreferences.getCleavageParameter() == DigestionParameters.CleavageParameter.enzyme) {
PeptideUtils.isEnzymatic(peptideMatch.getPeptide(), sequenceProvider, digestionPreferences.getEnzymes());
}
}
if (allPeptides || (enzymatic && enzymaticPeptide) || (!enzymatic && !enzymaticPeptide)) {
String modifiedSequence = getTaggedPeptideSequence(peptideMatch, true, false, true);
AminoAcidPattern aminoAcidPattern = AminoAcidPattern.getAminoAcidPatternFromString(peptideSequence);
int[] startIndexes = aminoAcidPattern.getIndexes(sequence, sequenceMatchingPreferences);
for (int startIndex : startIndexes) {
int endIndex = startIndex + peptideSequence.length() - 1;
String peptideTempStart = Integer.toString(startIndex);
String peptideTempEnd = Integer.toString(endIndex);
ResidueAnnotation newAnnotation = new ResidueAnnotation(String.join(" - ", peptideTempStart, modifiedSequence, peptideTempEnd), peptideMatchKey, true);
for (int j = startIndex - 1; j < endIndex; j++) {
annotations = residueAnnotation.get(j);
if (annotations == null) {
annotations = new ArrayList<>(1);
residueAnnotation.put(j, annotations);
} else if (annotations.size() == 1 && !annotations.get(0).clickable) {
annotations.clear();
}
annotations.add(newAnnotation);
}
}
}
}
return residueAnnotation;
}
Aggregations