Package com.compomics.util.experiment.identification.matches

Examples of com.compomics.util.experiment.identification.matches.ProteinMatch


                int currentRow = selectedRows[row];
                SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) proteinTable.getModel();
                int proteinIndex = tableModel.getViewIndex(currentRow);
                String proteinKey = proteinKeys.get(proteinIndex);
                ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinKey);

                try {
                    peptideKeys = peptideShakerGUI.getIdentificationFeaturesGenerator().getSortedPeptideKeys(proteinKey);
                } catch (Exception e) {
                    peptideShakerGUI.catchException(e);
                    try {
                        // Let's try without order
                        peptideKeys = proteinMatch.getPeptideMatchesKeys();
                    } catch (Exception e1) {
                        peptideShakerGUI.catchException(e1);
                        // ok you are really unlucky... Just hope the GUI holds...
                        peptideKeys = new ArrayList<String>();
                    }
                }

                // get the current protein and protein sequence
                Protein currentProtein = sequenceFactory.getProtein(proteinMatch.getMainMatch());
                String currentProteinSequence = sequenceFactory.getProtein(proteinMatch.getMainMatch()).getSequence();

                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 (int j = 0; j < peptideKeys.size(); j++) {

                        String peptideKey = peptideKeys.get(j);

                        try {
                            psParameter = (PSParameter) peptideShakerGUI.getIdentification().getPeptideMatchParameter(peptideKey, psParameter);

                            if (psParameter.getFractions() != null && psParameter.getFractions().contains(fraction)) {
                                if (psParameter.getMatchValidationLevel().isValidated()) {

                                    String peptideSequence = Peptide.getSequence(peptideKey);

                                    boolean includePeptide = false;

                                    if (coverageShowAllPeptidesJRadioButtonMenuItem.isSelected()) {
                                        includePeptide = true;
                                    } else if (coverageShowEnzymaticPeptidesOnlyJRadioButtonMenuItem.isSelected()) {
                                        includePeptide = currentProtein.isEnzymaticPeptide(peptideSequence,
                                                peptideShakerGUI.getSearchParameters().getEnzyme(),
                                                peptideShakerGUI.getSequenceMatchingPreferences());
                                    } else if (coverageShowTruncatedPeptidesOnlyJRadioButtonMenuItem.isSelected()) {
                                        includePeptide = !currentProtein.isEnzymaticPeptide(peptideSequence,
                                                peptideShakerGUI.getSearchParameters().getEnzyme(),
                                                peptideShakerGUI.getSequenceMatchingPreferences());
                                    }

                                    if (includePeptide && selectedRows.length == 1) {

                                        AminoAcidPattern aminoAcidPattern = new AminoAcidPattern(peptideSequence);
                                        for (int startIndex : aminoAcidPattern.getIndexes(currentProteinSequence, peptideShakerGUI.getSequenceMatchingPreferences())) {
                                            int peptideTempStart = startIndex -1;
                                            int peptideTempEnd = peptideTempStart + peptideSequence.length();
                                            for (int k = peptideTempStart; k < peptideTempEnd; k++) {
                                                coverage[i][k]++;
                                            }
                                        }
                                    }
                                }
                            }
                        } catch (Exception e) {
                            peptideShakerGUI.catchException(e);
                        }
                    }
                }

                psParameter = new PSParameter();
                psParameter = (PSParameter) peptideShakerGUI.getIdentification().getProteinMatchParameter(proteinKey, psParameter);

                for (int i = 0; i < fileNames.size(); i++) {
                    String fraction = fileNames.get(i);
                    psParameter = (PSParameter) peptideShakerGUI.getIdentification().getProteinMatchParameter(proteinKey, psParameter);

                    if (selectedRows.length == 1) {
                        peptidePlotDataset.addValue(psParameter.getFractionValidatedPeptides(fraction), "Validated Peptides", "" + (i + 1));
                    } else {
                        peptidePlotDataset.addValue(psParameter.getFractionValidatedPeptides(fraction), proteinMatch.getMainMatch()
                                + ": " + sequenceFactory.getHeader(proteinMatch.getMainMatch()).getSimpleProteinDescription(), "" + (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<JSparklinesDataSeries>();

                        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<Double>();
                            data.add(new Double(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<Integer, ArrayList<ResidueAnnotation>>(), 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);
                    psParameter = (PSParameter) peptideShakerGUI.getIdentification().getProteinMatchParameter(proteinKey, psParameter);

                    if (selectedRows.length == 1) {
                        spectrumPlotDataset.addValue(psParameter.getFractionValidatedSpectra(fraction), "Validated Spectra", "" + (i + 1));
                        intensityPlotDataset.addValue(psParameter.getPrecursorIntensitySummedPerFraction(fraction), "Summed Intensity", "" + (i + 1));
                    } else {
                        spectrumPlotDataset.addValue(psParameter.getFractionValidatedSpectra(fraction), proteinMatch.getMainMatch()
                                + ": " + sequenceFactory.getHeader(proteinMatch.getMainMatch()).getSimpleProteinDescription(), "" + (i + 1));
                        intensityPlotDataset.addValue(psParameter.getPrecursorIntensitySummedPerFraction(fraction), proteinMatch.getMainMatch()
                                + ": " + sequenceFactory.getHeader(proteinMatch.getMainMatch()).getSimpleProteinDescription(), "" + (i + 1));
                    }
                }
            }

            // molecular mass plot
View Full Code Here


        if (proteinKey.equals(PeptideShakerGUI.NO_SELECTION)
                && !peptideKey.equals(PeptideShakerGUI.NO_SELECTION)) {
            for (String possibleKey : peptideShakerGUI.getIdentification().getProteinIdentification()) {
                try {
                    ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(possibleKey);
                    if (proteinMatch.getPeptideMatchesKeys().contains(peptideKey)) {
                        proteinKey = possibleKey;
                        peptideShakerGUI.setSelectedItems(proteinKey, peptideKey, psmKey);
                        break;
                    }
                } catch (Exception e) {
View Full Code Here

                        }
                        Double sequenceCoverageConfident = 100 * sequenceCoverage.get(MatchValidationLevel.confident.getIndex());
                        Double sequenceCoverageDoubtful = 100 * sequenceCoverage.get(MatchValidationLevel.doubtful.getIndex());
                        value = sequenceCoverageConfident + sequenceCoverageDoubtful;
                } else if (proteinSequenceLengthJRadioButton.isSelected()) {
                    ProteinMatch proteinMatch = identification.getProteinMatch(proteinKey);
                    Protein currentProtein = sequenceFactory.getProtein(proteinMatch.getMainMatch());
                    value = currentProtein.getSequence().length();
                }

                proteinParameter = (PSParameter) identification.getProteinMatchParameter(proteinKey, proteinParameter);

View Full Code Here

                            for (String protein : peptideMatch.getTheoreticPeptide().getParentProteins(peptideShakerGUI.getSequenceMatchingPreferences())) {

                                // write the protein node
                                if (!proteinsAdded.contains(protein)) {
                                    proteinsAdded.add(protein);
                                    ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(protein);
                                    if (proteinMatch != null) {
                                        probabilities = (PSParameter) peptideShakerGUI.getIdentification().getProteinMatchParameter(protein, probabilities);

                                        if (((String) graphDatabaseFormat.getSelectedItem()).equalsIgnoreCase("Neo4j")) {
                                            nodeWriter.write("create n={id:'" + protein + "', name:'" + protein + "', type:'Protein'};\n");
                                        } else {
                                            nodeWriter.write(protein + "\t" + protein + "\tprotein" + "\t" + probabilities.getMatchValidationLevel() + "\t" + proteinMatch.isDecoy() + "\n"); // @TODO: add more information?
                                        }
                                    } else {
                                        if (((String) graphDatabaseFormat.getSelectedItem()).equalsIgnoreCase("Neo4j")) {
                                            nodeWriter.write("create n={id:'" + protein + "', name:'" + protein + "', type:'Protein'};\n");
                                        } else {
View Full Code Here

        @Override
        public Object getValueAt(int row, int column) {
            try {
                String proteinKey = identification.getProteinIdentification().get(row);
                PSParameter psParameter;
                ProteinMatch proteinMatch;

                switch (column) {
                    case 0:
                        return row + 1;
                    case 1:
                        psParameter = (PSParameter) identification.getProteinMatchParameter(proteinKey, new PSParameter());
                        return psParameter.isStarred();
                    case 2:
                        psParameter = (PSParameter) identification.getProteinMatchParameter(proteinKey, new PSParameter());
                        return psParameter.isHidden();
                    case 3:
                        psParameter = (PSParameter) identification.getProteinMatchParameter(proteinKey, new PSParameter());
                        return psParameter.getProteinInferenceClass();
                    case 4:
                        proteinMatch = identification.getProteinMatch(proteinKey);
                        return proteinMatch.getMainMatch();
                    case 5:
                        String otherAccessions = "";
                        proteinMatch = identification.getProteinMatch(proteinKey);
                        for (String accession : ProteinMatch.getAccessions(proteinKey)) {
                            if (!accession.equals(proteinMatch.getMainMatch())) {
                                otherAccessions += accession + " ";
                            }
                        }
                        return otherAccessions;
                    case 6:
                        proteinMatch = identification.getProteinMatch(proteinKey);
                        return sequenceFactory.getHeader(proteinMatch.getMainMatch()).getSimpleProteinDescription().toLowerCase();
                    case 7:
                        Double coverage;
                        try {
                            HashMap<Integer, Double> sequenceCoverage;
                            try {
                                sequenceCoverage = peptideShakerGUI.getIdentificationFeaturesGenerator().getSequenceCoverage(proteinKey);
                            } catch (Exception e) {
                                peptideShakerGUI.catchException(e);
                                sequenceCoverage = new HashMap<Integer, Double>();
                            }
                            Double sequenceCoverageConfident = 100 * sequenceCoverage.get(MatchValidationLevel.confident.getIndex());
                            Double sequenceCoverageDoubtful = 100 * sequenceCoverage.get(MatchValidationLevel.doubtful.getIndex());
                            coverage = sequenceCoverageConfident + sequenceCoverageDoubtful;
                        } catch (Exception e) {
                            peptideShakerGUI.catchException(e);
                            coverage = Double.NaN;
                        }
                        return coverage;
                    case 8:
                        proteinMatch = identification.getProteinMatch(proteinKey);
                        return proteinMatch.getPeptideCount();
                    case 9:
                        proteinMatch = identification.getProteinMatch(proteinKey);
                        int cpt = 0;
                        PeptideMatch peptideMatch;
                        identification.loadPeptideMatches(proteinMatch.getPeptideMatchesKeys(), null);
                        for (String peptideKey : proteinMatch.getPeptideMatchesKeys()) {
                            peptideMatch = identification.getPeptideMatch(peptideKey);
                            cpt += peptideMatch.getSpectrumCount();
                        }
                        return cpt;
                    case 10:
View Full Code Here

                String proteinKey = proteinKeys.get(proteinIndex);
                peptideShakerGUI.setSelectedItems(proteinKeys.get(proteinIndex), PeptideShakerGUI.NO_SELECTION, PeptideShakerGUI.NO_SELECTION);

                try {
                    ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinKey);
                    String proteinAccession = proteinMatch.getMainMatch();

                    try {
                        proteinSequence = sequenceFactory.getProtein(proteinAccession).getSequence();
                    } catch (Exception e) {
                        peptideShakerGUI.catchException(e);
View Full Code Here

                DefaultTableModel dm = (DefaultTableModel) peptideTable.getModel();
                dm.getDataVector().removeAllElements();
                dm.fireTableDataChanged();

                String proteinMatchKey = proteinKeys.get(proteinIndex);
                ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinMatchKey);
                peptideTableMap = new HashMap<Integer, String>();

                PSParameter probabilities = new PSParameter();
                int index = 0;

                ArrayList<String> peptideKeys;
                try {
                    peptideKeys = peptideShakerGUI.getIdentificationFeaturesGenerator().getSortedPeptideKeys(proteinMatchKey);
                } catch (Exception e) {
                    peptideShakerGUI.catchException(e);
                    try {
                        // Let's try without order
                        peptideKeys = proteinMatch.getPeptideMatchesKeys();
                    } catch (Exception e1) {
                        peptideShakerGUI.catchException(e1);
                        // ok you are really unlucky... Just hope the GUI holds...
                        peptideKeys = new ArrayList<String>();
                    }
                }

                for (String peptideKey : peptideKeys) {
                    PeptideMatch currentMatch = peptideShakerGUI.getIdentification().getPeptideMatch(peptideKey);
                    probabilities = (PSParameter) peptideShakerGUI.getIdentification().getPeptideMatchParameter(peptideKey, probabilities);

                    if (!probabilities.isHidden()) {

                        // find and add the peptide start and end indexes
                        int peptideStart = 0;
                        String peptideSequence = currentMatch.getTheoreticPeptide().getSequence();

                        try {
                            String proteinAccession = proteinMatch.getMainMatch();
                            String tempProteinSequence = sequenceFactory.getProtein(proteinAccession).getSequence();
                            peptideStart = tempProteinSequence.lastIndexOf(peptideSequence) + 1; //@TODO: allow multiple start indexes and use amino acid matching
                        } catch (Exception e) {
                            peptideShakerGUI.catchException(e);
                            e.printStackTrace();
                        }
                        int proteinInferenceType = probabilities.getProteinInferenceClass();

                        // @TODO: should be replaced by a table model!!!
                        ((DefaultTableModel) peptideTable.getModel()).addRow(new Object[]{
                            index + 1,
                            probabilities.isStarred(),
                            proteinInferenceType,
                            peptideShakerGUI.getDisplayFeaturesGenerator().getTaggedPeptideSequence(currentMatch, true, true, true),
                            peptideStart,
                            false,
                            probabilities.getMatchValidationLevel().getIndex()
                        });

                        peptideTableMap.put(index + 1, currentMatch.getKey());
                        index++;
                    }
                }

                ((DefaultTableModel) peptideTable.getModel()).fireTableDataChanged();

                String title = PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Peptides (";
                try {
                    IdentificationFeaturesGenerator identificationFeaturesGenerator = peptideShakerGUI.getIdentificationFeaturesGenerator();
                    int nValidatedPeptides = identificationFeaturesGenerator.getNValidatedPeptides(proteinMatchKey);
                    int nConfidentPeptides = identificationFeaturesGenerator.getNConfidentPeptides(proteinMatchKey);
                    int nPeptides = proteinMatch.getPeptideCount();
                    if (nConfidentPeptides > 0) {
                        title += nValidatedPeptides + "/" + nPeptides + " - " + nConfidentPeptides + " confident, " + (nValidatedPeptides - nConfidentPeptides) + " doubtful";
                    } else {
                        title += nValidatedPeptides + "/" + nPeptides;
                    }
                } catch (Exception e) {
                    peptideShakerGUI.catchException(e);
                }
                title += ")" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING;
                ((TitledBorder) peptidesPanel.getBorder()).setTitle(title);

                peptidesPanel.repaint();

                String tempSequence = sequenceFactory.getProtein(proteinMatch.getMainMatch()).getSequence();
                peptideTable.getColumn("Start").setCellRenderer(new JSparklinesIntervalChartTableCellRenderer(
                        PlotOrientation.HORIZONTAL, (double) tempSequence.length(),
                        ((double) tempSequence.length()) / 50, peptideShakerGUI.getSparklineColor()));
                ((JSparklinesIntervalChartTableCellRenderer) peptideTable.getColumn("Start").getCellRenderer()).showReferenceLine(true, 0.02, Color.BLACK);
                ((JSparklinesIntervalChartTableCellRenderer) peptideTable.getColumn("Start").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 10);
View Full Code Here

            @Override
            public void run() {

                try {
                    // get the accession number of the main match
                    ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinKey);
                    String tempAccession = proteinMatch.getMainMatch();

                    // find the pdb matches
                    uniProtPdb = new FindPdbForUniprotAccessions(tempAccession, progressDialog); // @TODO: make it possible to cancel this process...

                    // delete the previous matches
View Full Code Here

        }

        if (proteinKey.equals(PeptideShakerGUI.NO_SELECTION) && !peptideKey.equals(PeptideShakerGUI.NO_SELECTION)) {
            for (String possibleKey : peptideShakerGUI.getIdentification().getProteinIdentification()) {
                try {
                    ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(possibleKey);
                    if (proteinMatch != null && proteinMatch.getPeptideMatchesKeys().contains(peptideKey)) {
                        proteinKey = possibleKey;
                        peptideShakerGUI.setSelectedItems(proteinKey, peptideKey, psmKey);
                        break;
                    }
                } catch (Exception e) {
View Full Code Here

        if (keys == null) {
            keys = identification.getProteinIdentification();
        }
        int line = 1;
        PSParameter psParameter = new PSParameter();
        ProteinMatch proteinMatch = null;

        if (peptideSection != null) {
            if (waitingHandler != null) {
                waitingHandler.setWaitingText("Loading Peptides. Please Wait...");
                waitingHandler.resetSecondaryProgressCounter();
            }
            identification.loadPeptideMatches(waitingHandler);
            if (waitingHandler != null) {
                waitingHandler.setWaitingText("Loading Peptide Details. Please Wait...");
                waitingHandler.resetSecondaryProgressCounter();
            }
            identification.loadPeptideMatchParameters(psParameter, waitingHandler);
        }

        if (waitingHandler != null) {
            waitingHandler.setWaitingText("Loading Proteins. Please Wait...");
            waitingHandler.resetSecondaryProgressCounter();
        }
        identification.loadProteinMatches(keys, waitingHandler);
        if (waitingHandler != null) {
            waitingHandler.setWaitingText("Loading Protein Details. Please Wait...");
            waitingHandler.resetSecondaryProgressCounter();
        }
        identification.loadProteinMatchParameters(keys, psParameter, waitingHandler);

        if (waitingHandler != null) {
            waitingHandler.setWaitingText("Exporting. Please Wait...");
            waitingHandler.resetSecondaryProgressCounter();
            waitingHandler.setMaxSecondaryProgressCounter(keys.size());
        }

        for (String proteinKey : keys) {

            if (waitingHandler != null) {
                if (waitingHandler.isRunCanceled()) {
                    return;
                }
                waitingHandler.increaseSecondaryProgressCounter();
            }

            if (decoys || !ProteinMatch.isDecoy(proteinKey)) {

                psParameter = (PSParameter) identification.getProteinMatchParameter(proteinKey, psParameter);

                if (!validatedOnly || psParameter.getMatchValidationLevel().isValidated()) {

                    boolean first = true;

                    if (indexes) {
                        writer.write(line + "");
                        first = false;
                    }

                    proteinMatch = identification.getProteinMatch(proteinKey);

                    for (ExportFeature exportFeature : proteinFeatures) {
                        if (!first) {
                            writer.addSeparator();
                        } else {
                            first = false;
                        }
                        PsProteinFeature tempProteinFeatures = (PsProteinFeature) exportFeature;
                        writer.write(getFeature(identificationFeaturesGenerator, searchParameters, annotationPreferences, keys, nSurroundingAas, proteinKey, proteinMatch, psParameter, tempProteinFeatures, waitingHandler));
                    }
                    writer.newLine();
                    if (peptideSection != null) {
                        writer.increaseDepth();
                        peptideSection.writeSection(identification, identificationFeaturesGenerator, searchParameters, annotationPreferences, sequenceMatchingPreferences, proteinMatch.getPeptideMatchesKeys(), nSurroundingAas, line + ".", validatedOnly, decoys, null);
                        writer.decreseDepth();
                    }
                    line++;
                }
            }
View Full Code Here

TOP

Related Classes of com.compomics.util.experiment.identification.matches.ProteinMatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.