Package com.compomics.util.experiment.identification

Examples of com.compomics.util.experiment.identification.SequenceFactory


                    }
                    result.append(accession);
                }
                return result.toString();
            case protein_description:
                SequenceFactory sequenceFactory = SequenceFactory.getInstance();
                StringBuilder descriptions = new StringBuilder();
                accessions = peptideAssumption.getPeptide().getParentProteins(sequenceMatchingPreferences);
                Collections.sort(accessions);
                for (String accession : accessions) {
                    if (descriptions.length() > 0) {
                        descriptions.append("; ");
                    }
                    descriptions.append(sequenceFactory.getHeader(accession).getDescription());
                }
                return descriptions.toString();
            case algorithm_confidence:
                return psParameter.getSearchEngineConfidence() + "";
            case algorithm_delta_confidence:
View Full Code Here


                        if (finalAccessionsOnly) {
                            exportType = FastaExport.ExportType.getTypeFromIndex(proteinExportCmb1.getSelectedIndex());
                        } else {
                            exportType = FastaExport.ExportType.getTypeFromIndex(proteinExportCmb2.getSelectedIndex());
                        }
                        SequenceFactory sequenceFactory = SequenceFactory.getInstance();
                        IdentificationFeaturesGenerator identificationFeaturesGenerator = peptideShakerGUI.getIdentificationFeaturesGenerator();

                        progressDialog.setPrimaryProgressCounterIndeterminate(false);
                        if (exportType == FastaExport.ExportType.non_validated) {
                            progressDialog.setMaxPrimaryProgressCounter(sequenceFactory.getAccessions().size());
                        } else {
                            progressDialog.setMaxPrimaryProgressCounter(identificationFeaturesGenerator.getNValidatedProteins());
                        }

                        FastaExport.export(selectedFile, peptideShakerGUI.getIdentification(), identificationFeaturesGenerator, exportType, progressDialog, peptideShakerGUI.getFilterPreferences(), finalAccessionsOnly);
View Full Code Here

                    }
                    proteins.append(accession);
                }
                return proteins.toString();
            case protein_description:
                SequenceFactory sequenceFactory = SequenceFactory.getInstance();
                StringBuilder descriptions = new StringBuilder();
                accessions = peptideMatch.getTheoreticPeptide().getParentProteins(sequenceMatchingPreferences);
                Collections.sort(accessions);
                for (String accession : accessions) {
                    if (descriptions.length() > 0) {
                        descriptions.append("; ");
                    }
                    descriptions.append(sequenceFactory.getHeader(accession).getDescription());
                }
                return descriptions.toString();
            case confidence:
                return psParameter.getPeptideConfidence() + "";
            case decoy:
View Full Code Here

     *
     * @return the database usage details
     */
    public static String getDatabaseText() {
       
        SequenceFactory sequenceFactory = SequenceFactory.getInstance();
       
        String text = "";
       
        if (sequenceFactory.concatenatedTargetDecoy()) {
            text += "Protein identification was conducted against a concatenated target/decoy [PMID 20013364] version of the ";
        } else {
            text += "Protein identification was conducted against a version of the ";
        }
       
        FastaIndex fastaIndex = sequenceFactory.getCurrentFastaIndex();

        ArrayList<String> species = fastaIndex.getSpecies();
        if (species == null || species.isEmpty()) {
            text += "[add species]";
        } else {
View Full Code Here

     * @throws ClassNotFoundException thrown if ClassNotFoundException occurs
     * @return a boolean indicating whether the loading was successful
     */
    public boolean loadFastaFile(File folder, WaitingHandler waitingHandler) throws FileNotFoundException, IOException, ClassNotFoundException {

        SequenceFactory sequenceFactory = SequenceFactory.getInstance();

        // Load fasta file
        File providedFastaLocation = searchParameters.getFastaFile();
        String fileName = providedFastaLocation.getName();
        File projectFolder = cpsFile.getParentFile();
        File dataFolder = new File(projectFolder, "data");

        if (providedFastaLocation.exists()) {
            sequenceFactory.loadFastaFile(providedFastaLocation, waitingHandler);
        } else if (folder != null && new File(folder, fileName).exists()) {
            sequenceFactory.loadFastaFile(new File(folder, fileName), waitingHandler);
            searchParameters.setFastaFile(new File(folder, fileName));
        } else if (new File(projectFolder, fileName).exists()) {
            sequenceFactory.loadFastaFile(new File(projectFolder, fileName), waitingHandler);
            searchParameters.setFastaFile(new File(projectFolder, fileName));
        } else if (new File(dataFolder, fileName).exists()) {
            sequenceFactory.loadFastaFile(new File(dataFolder, fileName), waitingHandler);
            searchParameters.setFastaFile(new File(dataFolder, fileName));
        } else {
            return false;
        }

View Full Code Here

     * @throws InterruptedException
     */
    public static void export(File destinationFile, Identification identification, IdentificationFeaturesGenerator identificationFeaturesGenerator,
            ExportType exportType, WaitingHandler waitingHandler, FilterPreferences filterPreferences, boolean accessionOnly) throws IOException, SQLException, ClassNotFoundException, InterruptedException {

        SequenceFactory sequenceFactory = SequenceFactory.getInstance();
        FileWriter f = new FileWriter(destinationFile);

        try {

            BufferedWriter b = new BufferedWriter(f);

            try {
                if (exportType == ExportType.non_validated) {

                    PSParameter psParameter = new PSParameter();
                    identification.loadProteinMatchParameters(psParameter, waitingHandler);

                    for (String accession : sequenceFactory.getAccessions()) {

                        if (!sequenceFactory.isDecoyAccession(accession)) {

                            ArrayList<String> matches = identification.getProteinMap().get(accession);

                            if (matches != null) {
                                boolean validated = false;
View Full Code Here

     * @throws java.sql.SQLException
     */
    public static boolean isValidated(String proteinMatchKey, ProteinFilter proteinFilter, Identification identification, IdentificationFeaturesGenerator identificationFeaturesGenerator,
            SearchParameters searchParameters) throws IOException, InterruptedException, ClassNotFoundException, SQLException {

        SequenceFactory sequenceFactory = SequenceFactory.getInstance();

        if (proteinFilter.getExceptions().contains(proteinMatchKey)) {
            return false;
        }

        if (proteinFilter.getManualValidation().size() > 0) {
            return proteinFilter.getManualValidation().contains(proteinMatchKey);
        }

        if (proteinFilter.getIdentifierRegex() != null) {
            String test = "test_" + proteinMatchKey + "_test";
            if (test.split(proteinFilter.getIdentifierRegex()).length == 1) {
                boolean found = false;
                for (String accession : ProteinMatch.getAccessions(proteinMatchKey)) {
                    test = "test_" + sequenceFactory.getHeader(accession).getSimpleProteinDescription().toLowerCase() + "_test";
                    if (test.split(proteinFilter.getIdentifierRegex().toLowerCase()).length > 1) {
                        found = true;
                        break;
                    }
                }
View Full Code Here

     * @throws java.lang.ClassNotFoundException
     * @throws java.lang.InterruptedException
     */
    public static boolean isValidated(String peptideMatchKey, PeptideFilter peptideFilter, Identification identification, IdentificationFeaturesGenerator identificationFeaturesGenerator) throws SQLException, IOException, ClassNotFoundException, InterruptedException {

        SequenceFactory sequenceFactory = SequenceFactory.getInstance();

        if (peptideFilter.getExceptions().contains(peptideMatchKey)) {
            return false;
        }

        if (peptideFilter.getManualValidation().size() > 0) {
            return peptideFilter.getManualValidation().contains(peptideMatchKey);
        }

        if (peptideFilter.getModificationStatus() != null) {
            boolean found = false;
            for (String ptm : peptideFilter.getModificationStatus()) {
                if (ptm.equals(PtmPanel.NO_MODIFICATION)) {
                    if (!Peptide.isModified(peptideMatchKey)) {
                        found = true;
                        break;
                    }
                } else {
                    if (Peptide.isModified(peptideMatchKey, ptm)) {
                        found = true;
                        break;
                    }
                }
            }
            if (!found) {
                return false;
            }
        }

        PSParameter psParameter = new PSParameter();
        psParameter = (PSParameter) identification.getPeptideMatchParameter(peptideMatchKey, psParameter);

        if (peptideFilter.getPi() != 5) {
            if (peptideFilter.getPiComparison() == ComparisonType.NOT_EQUAL
                    && psParameter.getProteinInferenceClass() == peptideFilter.getPi()) {
                return false;
            } else if (peptideFilter.getPiComparison() == ComparisonType.EQUAL
                    && psParameter.getProteinInferenceClass() != peptideFilter.getPi()) {
                return false;
            }
        }

        if (peptideFilter.getPeptideScore() != null) {
            if (peptideFilter.getPeptideScoreComparison() == ComparisonType.AFTER) {
                if (psParameter.getPeptideScore() <= peptideFilter.getPeptideScore()) {
                    return false;
                }
            } else if (peptideFilter.getPeptideScoreComparison() == ComparisonType.BEFORE) {
                if (psParameter.getPeptideScore() >= peptideFilter.getPeptideScore()) {
                    return false;
                }
            } else if (peptideFilter.getPeptideScoreComparison() == ComparisonType.EQUAL) {
                if (psParameter.getPeptideScore() != peptideFilter.getPeptideScore()) {
                    return false;
                }
            } else if (peptideFilter.getPeptideScoreComparison() == ComparisonType.NOT_EQUAL) {
                if (psParameter.getPeptideScore() == peptideFilter.getPeptideScore()) {
                    return false;
                }
            }
        }

        if (peptideFilter.getPeptideConfidence() != null) {
            if (peptideFilter.getPeptideConfidenceComparison() == ComparisonType.AFTER) {
                if (psParameter.getPeptideConfidence() <= peptideFilter.getPeptideConfidence()) {
                    return false;
                }
            } else if (peptideFilter.getPeptideConfidenceComparison() == ComparisonType.BEFORE) {
                if (psParameter.getPeptideConfidence() >= peptideFilter.getPeptideConfidence()) {
                    return false;
                }
            } else if (peptideFilter.getPeptideConfidenceComparison() == ComparisonType.EQUAL) {
                if (psParameter.getPeptideConfidence() != peptideFilter.getPeptideConfidence()) {
                    return false;
                }
            } else if (peptideFilter.getPeptideConfidenceComparison() == ComparisonType.NOT_EQUAL) {
                if (psParameter.getPeptideConfidence() == peptideFilter.getPeptideConfidence()) {
                    return false;
                }
            }
        }

        if (peptideFilter.getNSpectra() != null
                || peptideFilter.getNValidatedSpectra() != null
                || peptideFilter.getNConfidentSpectra() != null
                || peptideFilter.getProtein() != null) {
            PeptideMatch peptideMatch = identification.getPeptideMatch(peptideMatchKey);

            if (peptideFilter.getNSpectra() != null) {
                if (peptideFilter.getnSpectraComparison() == ComparisonType.AFTER) {
                    if (peptideMatch.getSpectrumCount() <= peptideFilter.getNSpectra()) {
                        return false;
                    }
                } else if (peptideFilter.getnSpectraComparison() == ComparisonType.BEFORE) {
                    if (peptideMatch.getSpectrumCount() >= peptideFilter.getNSpectra()) {
                        return false;
                    }
                } else if (peptideFilter.getnSpectraComparison() == ComparisonType.EQUAL) {
                    if (peptideMatch.getSpectrumCount() != peptideFilter.getNSpectra()) {
                        return false;
                    }
                } else if (peptideFilter.getnSpectraComparison() == ComparisonType.NOT_EQUAL) {
                    if (peptideMatch.getSpectrumCount() != peptideFilter.getNSpectra()) {
                        return false;
                    }
                }
            }

            if (peptideFilter.getNValidatedSpectra() != null) {
                int nValidatedSpectra = identificationFeaturesGenerator.getNValidatedSpectraForPeptide(peptideMatchKey);
                if (peptideFilter.getnValidatedSpectraComparison() == ComparisonType.AFTER) {
                    if (nValidatedSpectra <= peptideFilter.getNValidatedSpectra()) {
                        return false;
                    }
                } else if (peptideFilter.getnValidatedSpectraComparison() == ComparisonType.BEFORE) {
                    if (nValidatedSpectra >= peptideFilter.getNValidatedSpectra()) {
                        return false;
                    }
                } else if (peptideFilter.getnValidatedSpectraComparison() == ComparisonType.EQUAL) {
                    if (nValidatedSpectra != peptideFilter.getNValidatedSpectra()) {
                        return false;
                    }
                } else if (peptideFilter.getnValidatedSpectraComparison() == ComparisonType.NOT_EQUAL) {
                    if (nValidatedSpectra != peptideFilter.getNValidatedSpectra()) {
                        return false;
                    }
                }
            }

            if (peptideFilter.getNConfidentSpectra() != null) {
                int nConfidentPeptides = identificationFeaturesGenerator.getNConfidentSpectraForPeptide(peptideMatchKey);
                if (peptideFilter.getnConfidentSpectraComparison() == ComparisonType.AFTER) {
                    if (nConfidentPeptides <= peptideFilter.getNConfidentSpectra()) {
                        return false;
                    }
                } else if (peptideFilter.getnConfidentSpectraComparison() == ComparisonType.BEFORE) {
                    if (nConfidentPeptides >= peptideFilter.getNConfidentSpectra()) {
                        return false;
                    }
                } else if (peptideFilter.getnConfidentSpectraComparison() == ComparisonType.EQUAL) {
                    if (nConfidentPeptides != peptideFilter.getNConfidentSpectra()) {
                        return false;
                    }
                } else if (peptideFilter.getnConfidentSpectraComparison() == ComparisonType.NOT_EQUAL) {
                    if (nConfidentPeptides != peptideFilter.getNConfidentSpectra()) {
                        return false;
                    }
                }
            }

            if (peptideFilter.getProtein() != null) {
                 boolean found = false;
                for (String accession : peptideMatch.getTheoreticPeptide().getParentProteinsNoRemapping()) {
                    if (accession.split(peptideFilter.getProtein()).length > 1) {
                        found = true;
                        break;
                    }
                    if (sequenceFactory.getHeader(accession).getSimpleProteinDescription() != null
                            && sequenceFactory.getHeader(accession).getSimpleProteinDescription().split(peptideFilter.getProtein()).length > 1) {
                        found = true;
                        break;
                    }
                }
                if (!found) {
View Full Code Here

    public static void updateProteinMatchValidationLevel(Identification identification, IdentificationFeaturesGenerator identificationFeaturesGenerator,
            SearchParameters searchParameters, AnnotationPreferences annotationPreferences, TargetDecoyMap targetDecoyMap, double scoreThreshold,
            double confidenceThreshold, boolean noValidated, ArrayList<ProteinFilter> doubtfulMatchFilters,
            String proteinKey) throws SQLException, IOException, ClassNotFoundException, InterruptedException, MzMLUnmarshallerException {

        SequenceFactory sequenceFactory = SequenceFactory.getInstance();
        PSParameter psParameter = new PSParameter();
        psParameter = (PSParameter) identification.getProteinMatchParameter(proteinKey, psParameter);
        psParameter.resetQcResults();

        if (!psParameter.isManualValidation()) {

            if (sequenceFactory.concatenatedTargetDecoy()) {

                if (!noValidated && psParameter.getProteinProbabilityScore() <= scoreThreshold) {
                    String reasonDoubtful = null;
                    boolean filterPassed = true;
                    for (ProteinFilter filter : doubtfulMatchFilters) {
                        boolean validation = filter.isValidated(proteinKey, identification, identificationFeaturesGenerator, searchParameters, annotationPreferences);
                        psParameter.setQcResult(filter.getName(), validation);
                        if (!validation) {
                            filterPassed = false;
                            if (reasonDoubtful == null) {
                                reasonDoubtful = "";
                            } else {
                                reasonDoubtful += ", ";
                            }
                            reasonDoubtful += filter.getDescription();
                        }
                    }
                    boolean confidenceThresholdPassed = psParameter.getProteinConfidence() >= confidenceThreshold; //@TODO: not sure whether we should include all 100% confidence hits by default?
                    if (!confidenceThresholdPassed) {
                        if (reasonDoubtful == null) {
                            reasonDoubtful = "";
                        } else {
                            reasonDoubtful += ", ";
                        }
                        reasonDoubtful += "Low confidence";
                    }
                    boolean enoughHits = targetDecoyMap.getnTargetOnly() > 100;
                    if (!enoughHits) {
                        if (reasonDoubtful == null) {
                            reasonDoubtful = "";
                        } else {
                            reasonDoubtful += ", ";
                        }
                        reasonDoubtful += "Low number of hits";
                    }
                    if (!sequenceFactory.hasEnoughSequences()) {
                        if (reasonDoubtful == null) {
                            reasonDoubtful = "";
                        } else {
                            reasonDoubtful += ", ";
                        }
                        reasonDoubtful += "Database too small";
                    }
                    if (filterPassed && confidenceThresholdPassed && enoughHits && sequenceFactory.hasEnoughSequences()) {
                        psParameter.setMatchValidationLevel(MatchValidationLevel.confident);
                    } else {
                        psParameter.setMatchValidationLevel(MatchValidationLevel.doubtful);
                        if (reasonDoubtful != null) {
                            psParameter.setReasonDoubtful(reasonDoubtful);
View Full Code Here

     */
    public static void updatePeptideMatchValidationLevel(Identification identification, IdentificationFeaturesGenerator identificationFeaturesGenerator,
            SearchParameters searchParameters, PeptideSpecificMap peptideMap, String peptideKey)
            throws SQLException, IOException, ClassNotFoundException, InterruptedException, MzMLUnmarshallerException {

        SequenceFactory sequenceFactory = SequenceFactory.getInstance();
        PSParameter psParameter = new PSParameter();
        psParameter = (PSParameter) identification.getPeptideMatchParameter(peptideKey, psParameter);
        psParameter.resetQcResults();

        if (sequenceFactory.concatenatedTargetDecoy()) {
            TargetDecoyMap targetDecoyMap = peptideMap.getTargetDecoyMap(peptideMap.getCorrectedKey(psParameter.getSpecificMapKey()));
            TargetDecoyResults targetDecoyResults = targetDecoyMap.getTargetDecoyResults();
            double peptideThreshold = targetDecoyResults.getScoreLimit();
            double confidenceThreshold = targetDecoyResults.getConfidenceLimit() + targetDecoyMap.getResolution();
            if (confidenceThreshold > 100) {
                confidenceThreshold = 100;
            }
            boolean noValidated = peptideMap.getTargetDecoyMap(peptideMap.getCorrectedKey(psParameter.getSpecificMapKey())).getTargetDecoyResults().noValidated();
            if (!noValidated && psParameter.getPeptideProbabilityScore() <= peptideThreshold) {
                String reasonDoubtful = null;
                boolean filterPassed = true;
                for (PeptideFilter filter : peptideMap.getDoubtfulMatchesFilters()) {
                    boolean validation = filter.isValidated(peptideKey, identification, identificationFeaturesGenerator);
                    psParameter.setQcResult(filter.getName(), validation);
                    if (!validation) {
                        filterPassed = false;
                        if (reasonDoubtful == null) {
                            reasonDoubtful = "";
                        } else {
                            reasonDoubtful += ", ";
                        }
                        reasonDoubtful += filter.getDescription();
                    }
                }
                boolean confidenceThresholdPassed = psParameter.getPeptideConfidence() >= confidenceThreshold; //@TODO: not sure whether we should include all 100% confidence hits by default?
                if (!confidenceThresholdPassed) {
                    if (reasonDoubtful == null) {
                        reasonDoubtful = "";
                    } else {
                        reasonDoubtful += ", ";
                    }
                    reasonDoubtful += "Low confidence";
                }
                boolean enoughHits = targetDecoyMap.getnTargetOnly() > 100;
                if (!enoughHits) {
                    if (reasonDoubtful == null) {
                        reasonDoubtful = "";
                    } else {
                        reasonDoubtful += ", ";
                    }
                    reasonDoubtful += "Low number of hits";
                }
                if (!sequenceFactory.hasEnoughSequences()) {
                    if (reasonDoubtful == null) {
                        reasonDoubtful = "";
                    } else {
                        reasonDoubtful += ", ";
                    }
                    reasonDoubtful += "Database too small";
                }
                if (filterPassed && confidenceThresholdPassed && enoughHits && sequenceFactory.hasEnoughSequences()) {
                    psParameter.setMatchValidationLevel(MatchValidationLevel.confident);
                } else {
                    psParameter.setMatchValidationLevel(MatchValidationLevel.doubtful);
                    if (reasonDoubtful != null) {
                        psParameter.setReasonDoubtful(reasonDoubtful);
View Full Code Here

TOP

Related Classes of com.compomics.util.experiment.identification.SequenceFactory

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.