Search in sources :

Example 1 with Variant

use of com.compomics.util.experiment.biology.variants.Variant 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
        }
    }
}
Also used : JSparklinesDataset(no.uib.jsparklines.data.JSparklinesDataset) ResidueAnnotation(eu.isas.peptideshaker.gui.protein_sequence.ResidueAnnotation) DisplayParameters(eu.isas.peptideshaker.preferences.DisplayParameters) Identification(com.compomics.util.experiment.identification.Identification) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) JSparklinesDataSeries(no.uib.jsparklines.data.JSparklinesDataSeries) Variant(com.compomics.util.experiment.biology.variants.Variant) ProteinSequencePanel(eu.isas.peptideshaker.gui.protein_sequence.ProteinSequencePanel)

Aggregations

Peptide (com.compomics.util.experiment.biology.proteins.Peptide)1 Variant (com.compomics.util.experiment.biology.variants.Variant)1 Identification (com.compomics.util.experiment.identification.Identification)1 ProteinSequencePanel (eu.isas.peptideshaker.gui.protein_sequence.ProteinSequencePanel)1 ResidueAnnotation (eu.isas.peptideshaker.gui.protein_sequence.ResidueAnnotation)1 DisplayParameters (eu.isas.peptideshaker.preferences.DisplayParameters)1 JSparklinesDataSeries (no.uib.jsparklines.data.JSparklinesDataSeries)1 JSparklinesDataset (no.uib.jsparklines.data.JSparklinesDataset)1