use of eu.isas.peptideshaker.gui.protein_sequence.ProteinSequencePanel 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.ProteinSequencePanel 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.ProteinSequencePanel 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.ProteinSequencePanel in project peptide-shaker by compomics.
the class ProteinFractionsPanel method updatePlots.
/**
* Update the peptide counts plot.
*/
private void updatePlots() {
// @TODO: add progress bar
this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
Identification identification = peptideShakerGUI.getIdentification();
// @TODO: this method should be split into smaller methods...
ArrayList<String> fileNames = new ArrayList<>();
for (String fileName : identification.getFractions()) {
fileNames.add(fileName);
}
DefaultCategoryDataset peptidePlotDataset = new DefaultCategoryDataset();
DefaultCategoryDataset spectrumPlotDataset = new DefaultCategoryDataset();
DefaultCategoryDataset intensityPlotDataset = new DefaultCategoryDataset();
int[] selectedRows = proteinTable.getSelectedRows();
// disable the coverage tab if more than one protein is selected
plotsTabbedPane.setEnabledAt(2, selectedRows.length == 1);
if (selectedRows.length > 1 && plotsTabbedPane.getSelectedIndex() == 2) {
plotsTabbedPane.setSelectedIndex(5);
}
for (int row = 0; row < selectedRows.length; row++) {
int currentRow = selectedRows[row];
SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) proteinTable.getModel();
int proteinIndex = tableModel.getViewIndex(currentRow);
long proteinKey = proteinKeys[proteinIndex];
ProteinMatch proteinMatch = identification.getProteinMatch(proteinKey);
peptideKeys = peptideShakerGUI.getIdentificationFeaturesGenerator().getSortedPeptideKeys(proteinKey);
PSParameter proteinPSParameter = (PSParameter) proteinMatch.getUrParam(PSParameter.dummy);
// get the current protein information
String currentAccession = proteinMatch.getLeadingAccession();
String currentProteinSequence = peptideShakerGUI.getSequenceProvider().getSequence(currentAccession);
String currentProteinDescription = peptideShakerGUI.getProteinDetailsProvider().getSimpleDescription(currentAccession);
int[][] coverage = new int[fileNames.size()][currentProteinSequence.length() + 1];
// get the chart data
for (int i = 0; i < fileNames.size(); i++) {
String fraction = fileNames.get(i);
for (long peptideKey : peptideKeys) {
PeptideMatch peptideMatch = identification.getPeptideMatch(peptideKey);
Peptide peptide = peptideMatch.getPeptide();
PSParameter peptidePSParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
if (peptidePSParameter.getFractionScore() != null && peptidePSParameter.getFractions().contains(fraction)) {
if (peptidePSParameter.getMatchValidationLevel().isValidated()) {
String peptideSequence = peptide.getSequence();
boolean includePeptide = false;
DigestionParameters digestionParameters = peptideShakerGUI.getIdentificationParameters().getSearchParameters().getDigestionParameters();
if (coverageShowAllPeptidesJRadioButtonMenuItem.isSelected() || digestionParameters.getCleavageParameter() != DigestionParameters.CleavageParameter.enzyme) {
includePeptide = true;
} else if (coverageShowEnzymaticPeptidesOnlyJRadioButtonMenuItem.isSelected()) {
includePeptide = PeptideUtils.isEnzymatic(peptide, currentAccession, currentProteinSequence, digestionParameters.getEnzymes());
} else if (coverageShowTruncatedPeptidesOnlyJRadioButtonMenuItem.isSelected()) {
includePeptide = !PeptideUtils.isEnzymatic(peptide, currentAccession, currentProteinSequence, digestionParameters.getEnzymes());
}
if (includePeptide && selectedRows.length == 1) {
for (int startIndex : peptide.getProteinMapping().get(currentAccession)) {
int peptideTempStart = startIndex;
int peptideTempEnd = peptideTempStart + peptideSequence.length();
for (int k = peptideTempStart; k < peptideTempEnd; k++) {
coverage[i][k]++;
}
}
}
}
}
}
}
for (int i = 0; i < fileNames.size(); i++) {
String fraction = fileNames.get(i);
if (selectedRows.length == 1) {
peptidePlotDataset.addValue(proteinPSParameter.getFractionValidatedPeptides(fraction), "Validated Peptides", "" + (i + 1));
} else {
peptidePlotDataset.addValue(proteinPSParameter.getFractionValidatedPeptides(fraction), proteinMatch.getLeadingAccession() + ": " + currentProteinDescription, "" + (i + 1));
}
}
double longestFileName = "Fraction".length();
// update the coverage table
if (selectedRows.length == 1) {
DefaultTableModel coverageTableModel = (DefaultTableModel) coverageTable.getModel();
coverageTableModel.getDataVector().removeAllElements();
for (int i = 0; i < fileNames.size(); i++) {
// create the coverage plot
ArrayList<JSparklinesDataSeries> sparkLineDataSeriesCoverage = new ArrayList<>();
for (int j = 0; j < currentProteinSequence.length(); j++) {
boolean covered = coverage[i][j] > 0;
int sequenceCounter = 1;
if (covered) {
while (j + 1 < coverage[0].length && coverage[i][j + 1] > 0) {
sequenceCounter++;
j++;
}
} else {
while (j + 1 < coverage[0].length && coverage[i][j + 1] == 0) {
sequenceCounter++;
j++;
}
}
ArrayList<Double> data = new ArrayList<>();
data.add(Double.valueOf(sequenceCounter));
JSparklinesDataSeries sparklineDataseries;
if (covered) {
sparklineDataseries = new JSparklinesDataSeries(data, peptideShakerGUI.getSparklineColor(), null);
} else {
sparklineDataseries = new JSparklinesDataSeries(data, new Color(0, 0, 0, 0), null);
}
sparkLineDataSeriesCoverage.add(sparklineDataseries);
}
ChartPanel coverageChart = new ProteinSequencePanel(Color.WHITE).getSequencePlot(this, new JSparklinesDataset(sparkLineDataSeriesCoverage), new HashMap<>(), true, true);
((DefaultTableModel) coverageTable.getModel()).addRow(new Object[] { (i + 1), fileNames.get(i), coverageChart });
if (fileNames.get(i).length() > longestFileName) {
longestFileName = fileNames.get(i).length();
}
}
}
// set the preferred size of the fraction name column in the coverage table
Integer width = peptideShakerGUI.getPreferredColumnWidth(coverageTable, coverageTable.getColumn("Fraction").getModelIndex(), 6);
if (width != null) {
coverageTable.getColumn("Fraction").setMinWidth(width);
coverageTable.getColumn("Fraction").setMaxWidth(width);
} else {
coverageTable.getColumn("Fraction").setMinWidth(15);
coverageTable.getColumn("Fraction").setMaxWidth(Integer.MAX_VALUE);
}
// get the psms per fraction
for (int i = 0; i < fileNames.size(); i++) {
String fraction = fileNames.get(i);
if (selectedRows.length == 1) {
spectrumPlotDataset.addValue(proteinPSParameter.getFractionValidatedSpectra(fraction), "Validated Spectra", "" + (i + 1));
intensityPlotDataset.addValue(proteinPSParameter.getPrecursorIntensitySummedPerFraction(fraction), "Summed Intensity", "" + (i + 1));
} else {
spectrumPlotDataset.addValue(proteinPSParameter.getFractionValidatedSpectra(fraction), proteinMatch.getLeadingAccession() + ": " + currentProteinDescription, "" + (i + 1));
intensityPlotDataset.addValue(proteinPSParameter.getPrecursorIntensitySummedPerFraction(fraction), proteinMatch.getLeadingAccession() + ": " + currentProteinDescription, "" + (i + 1));
}
}
}
// molecular mass plot
DefaultBoxAndWhiskerCategoryDataset mwPlotDataset = new DefaultBoxAndWhiskerCategoryDataset();
ArrayList<String> spectrumFiles = peptideShakerGUI.getIdentification().getFractions();
for (int i = 0; i < spectrumFiles.size(); i++) {
try {
if (peptideShakerGUI.getMetrics().getObservedFractionalMassesAll().containsKey(spectrumFiles.get(i))) {
mwPlotDataset.add(peptideShakerGUI.getMetrics().getObservedFractionalMassesAll().get(spectrumFiles.get(i)), "Observed MW (kDa)", "" + (i + 1));
} else {
mwPlotDataset.add(new ArrayList<>(0), "Observed MW (kDa)", "" + (i + 1));
}
} catch (ClassCastException e) {
// do nothing, no data to show
}
}
// total peptides per fraction plot
DefaultCategoryDataset totalPeptidesPerFractionPlotDataset = new DefaultCategoryDataset();
HashMap<String, Integer> totalPeptidesPerFraction = peptideShakerGUI.getMetrics().getTotalPeptidesPerFraction();
for (int i = 0; i < spectrumFiles.size(); i++) {
String spectrumKey = spectrumFiles.get(i);
if (totalPeptidesPerFraction != null && totalPeptidesPerFraction.containsKey(spectrumKey)) {
totalPeptidesPerFractionPlotDataset.addValue(totalPeptidesPerFraction.get(spectrumKey), "Total Peptide Count", "" + (i + 1));
} else {
totalPeptidesPerFractionPlotDataset.addValue(0, "Total Peptide Count", "" + (i + 1));
}
}
// create the peptide chart
JFreeChart chart = ChartFactory.createBarChart(null, "Fraction", "#Peptides", peptidePlotDataset, PlotOrientation.VERTICAL, false, true, true);
ChartPanel chartPanel = new ChartPanel(chart);
AbstractCategoryItemRenderer renderer;
// set up the renderer
// if (selectedRows.length == 1) {
renderer = new BarRenderer();
((BarRenderer) renderer).setShadowVisible(false);
renderer.setSeriesPaint(0, peptideShakerGUI.getSparklineColor());
// } else {
// renderer = new LineAndShapeRenderer(true, false);
// for (int i = 0; i < selectedRows.length; i++) {
// ((LineAndShapeRenderer) renderer).setSeriesStroke(i, new BasicStroke(LINE_WIDTH, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
// }
// }
renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
chart.getCategoryPlot().setRenderer(renderer);
// set background color
chart.getPlot().setBackgroundPaint(Color.WHITE);
chart.setBackgroundPaint(Color.WHITE);
chartPanel.setBackground(Color.WHITE);
// hide the outline
chart.getPlot().setOutlineVisible(false);
// clear the peptide plot
peptidePlotPanel.removeAll();
// add the new plot
peptidePlotPanel.add(chartPanel);
// create the spectrum chart
chart = ChartFactory.createBarChart(null, "Fraction", "#Spectra", spectrumPlotDataset, PlotOrientation.VERTICAL, false, true, true);
chartPanel = new ChartPanel(chart);
// set up the renderer
// if (selectedRows.length == 1) {
renderer = new BarRenderer();
((BarRenderer) renderer).setShadowVisible(false);
renderer.setSeriesPaint(0, peptideShakerGUI.getSparklineColor());
// } else {
// renderer = new LineAndShapeRenderer(true, false);
// for (int i = 0; i < selectedRows.length; i++) {
// ((LineAndShapeRenderer) renderer).setSeriesStroke(i, new BasicStroke(LINE_WIDTH, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
// }
// }
renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
chart.getCategoryPlot().setRenderer(renderer);
// set background color
chart.getPlot().setBackgroundPaint(Color.WHITE);
chart.setBackgroundPaint(Color.WHITE);
chartPanel.setBackground(Color.WHITE);
// hide the outline
chart.getPlot().setOutlineVisible(false);
// clear the peptide plot
spectraPlotPanel.removeAll();
// add the new plot
spectraPlotPanel.add(chartPanel);
// create the intensity chart
chart = ChartFactory.createBarChart(null, "Fraction", "Summed Intensity", intensityPlotDataset, PlotOrientation.VERTICAL, false, true, true);
chartPanel = new ChartPanel(chart);
// set up the renderer
// if (selectedRows.length == 1) {
renderer = new BarRenderer();
((BarRenderer) renderer).setShadowVisible(false);
renderer.setSeriesPaint(0, peptideShakerGUI.getSparklineColor());
// } else {
// renderer = new LineAndShapeRenderer(true, false);
// for (int i = 0; i < selectedRows.length; i++) {
// ((LineAndShapeRenderer) renderer).setSeriesStroke(i, new BasicStroke(LINE_WIDTH, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
// }
// }
renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
chart.getCategoryPlot().setRenderer(renderer);
// set background color
chart.getPlot().setBackgroundPaint(Color.WHITE);
chart.setBackgroundPaint(Color.WHITE);
chartPanel.setBackground(Color.WHITE);
// hide the outline
chart.getPlot().setOutlineVisible(false);
// clear the peptide plot
intensityPlotPanel.removeAll();
// add the new plot
intensityPlotPanel.add(chartPanel);
// create the mw chart
chart = ChartFactory.createBoxAndWhiskerChart(null, "Fraction", "Expected Molecular Weight (kDa)", mwPlotDataset, false);
chartPanel = new ChartPanel(chart);
// set up the renderer
BoxAndWhiskerRenderer boxPlotRenderer = new BoxAndWhiskerRenderer();
boxPlotRenderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
boxPlotRenderer.setSeriesPaint(0, peptideShakerGUI.getSparklineColor());
boxPlotRenderer.setSeriesPaint(1, Color.RED);
chart.getCategoryPlot().setRenderer(boxPlotRenderer);
// set background color
chart.getPlot().setBackgroundPaint(Color.WHITE);
chart.setBackgroundPaint(Color.WHITE);
chartPanel.setBackground(Color.WHITE);
// hide the outline
chart.getPlot().setOutlineVisible(false);
// clear the peptide plot
mwPlotPanel.removeAll();
// add the new plot
mwPlotPanel.add(chartPanel);
// create the total peptides count chart
chart = ChartFactory.createBarChart(null, "Fraction", "Total Peptide Count", totalPeptidesPerFractionPlotDataset, PlotOrientation.VERTICAL, false, true, true);
chartPanel = new ChartPanel(chart);
renderer = new BarRenderer();
((BarRenderer) renderer).setShadowVisible(false);
renderer.setSeriesPaint(0, peptideShakerGUI.getSparklineColor());
renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
chart.getCategoryPlot().setRenderer(renderer);
// set background color
chart.getPlot().setBackgroundPaint(Color.WHITE);
chart.setBackgroundPaint(Color.WHITE);
chartPanel.setBackground(Color.WHITE);
// hide the outline
chart.getPlot().setOutlineVisible(false);
// clear the peptide plot
fractionsPlotPanel.removeAll();
// add the new plot
fractionsPlotPanel.add(chartPanel);
this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
plotsPanel.revalidate();
plotsPanel.repaint();
}
Aggregations