Examples of PeptideSpectrumAnnotator


Examples of com.compomics.util.experiment.identification.spectrum_annotators.PeptideSpectrumAnnotator

        if (header) {
            writeHeader();
        }

        MSnSpectrum spectrum = (MSnSpectrum) spectrumFactory.getSpectrum(spectrumMatch.getKey());
        PeptideSpectrumAnnotator spectrumAnnotator = new PeptideSpectrumAnnotator();

        ArrayList<IonMatch> annotations = spectrumAnnotator.getSpectrumAnnotation(annotationPreferences.getIonTypes(),
                annotationPreferences.getNeutralLosses(),
                annotationPreferences.getValidatedCharges(),
                spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().value,
                spectrum,
                spectrumMatch.getBestPeptideAssumption().getPeptide(),
View Full Code Here

Examples of com.compomics.util.experiment.identification.spectrum_annotators.PeptideSpectrumAnnotator

                    selectedIndexes.add((psmIndex + 1) + " " + spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().toString());
                }

                ArrayList<ArrayList<IonMatch>> allAnnotations = new ArrayList<ArrayList<IonMatch>>();
                ArrayList<MSnSpectrum> allSpectra = new ArrayList<MSnSpectrum>();
                PeptideSpectrumAnnotator miniAnnotator = new PeptideSpectrumAnnotator();
                AnnotationPreferences annotationPreferences = peptideShakerGUI.getAnnotationPreferences();

                // iterate the selected psms
                for (String spectrumKey : selectedPsmKeys) {

                    MSnSpectrum currentSpectrum = peptideShakerGUI.getSpectrum(spectrumKey);

                    if (currentSpectrum != null) {
                        SpectrumMatch spectrumMatch = peptideShakerGUI.getIdentification().getSpectrumMatch(spectrumKey);
                        annotationPreferences.setCurrentSettings(
                                spectrumMatch.getBestPeptideAssumption(),
                                !currentSpectrumKey.equalsIgnoreCase(spectrumKey), peptideShakerGUI.getSequenceMatchingPreferences());
                        ArrayList<IonMatch> annotations = miniAnnotator.getSpectrumAnnotation(annotationPreferences.getIonTypes(),
                                annotationPreferences.getNeutralLosses(),
                                annotationPreferences.getValidatedCharges(),
                                spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().value,
                                currentSpectrum,
                                selectedPeptideMatch.getTheoreticPeptide(),
View Full Code Here

Examples of com.compomics.util.experiment.identification.spectrum_annotators.PeptideSpectrumAnnotator

                            spectrumPanel.setBackgroundPeakWidth(peptideShakerGUI.getUtilitiesUserPreferences().getSpectrumBackgroundPeakWidth());

                            // get the spectrum annotations
                            PeptideAssumption peptideAssumption = spectrumMatch.getBestPeptideAssumption();
                            Peptide currentPeptide = peptideAssumption.getPeptide();
                            PeptideSpectrumAnnotator spectrumAnnotator = peptideShakerGUI.getSpectrumAnnotator();
                            AnnotationPreferences annotationPreferences = peptideShakerGUI.getAnnotationPreferences();
                            int identificationCharge = spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().value;
                            annotationPreferences.setCurrentSettings(peptideAssumption, !currentSpectrumKey.equalsIgnoreCase(spectrumKey),
                                    peptideShakerGUI.getSequenceMatchingPreferences());
                            ArrayList<IonMatch> annotations = spectrumAnnotator.getSpectrumAnnotation(annotationPreferences.getIonTypes(),
                                    annotationPreferences.getNeutralLosses(),
                                    annotationPreferences.getValidatedCharges(),
                                    identificationCharge,
                                    currentSpectrum, currentPeptide,
                                    currentSpectrum.getIntensityLimit(annotationPreferences.getAnnotationIntensityLimit()),
View Full Code Here

Examples of com.compomics.util.experiment.identification.spectrum_annotators.PeptideSpectrumAnnotator

        ArrayList<ArrayList<IonMatch>> allAnnotations = new ArrayList<ArrayList<IonMatch>>();

        int[] selectedRows = psmTable.getSelectedRows();

        PeptideSpectrumAnnotator miniAnnotator = new PeptideSpectrumAnnotator();
        AnnotationPreferences annotationPreferences = peptideShakerGUI.getAnnotationPreferences();

        try {
            for (int row : selectedRows) {

                SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) psmTable.getModel();
                int psmIndex = tableModel.getViewIndex(row);
                String spectrumKey = psmKeys.get(psmIndex);
                MSnSpectrum currentSpectrum = peptideShakerGUI.getSpectrum(spectrumKey);

                if (currentSpectrum != null && peptideTable.getSelectedRow() != -1) {

                    SpectrumMatch spectrumMatch = peptideShakerGUI.getIdentification().getSpectrumMatch(spectrumKey);

                    // get the spectrum annotations
                    PeptideAssumption peptideAssumption = spectrumMatch.getBestPeptideAssumption();
                    annotationPreferences.setCurrentSettings(peptideAssumption, !currentSpectrumKey.equalsIgnoreCase(spectrumKey), peptideShakerGUI.getSequenceMatchingPreferences());
                    ArrayList<IonMatch> annotations = miniAnnotator.getSpectrumAnnotation(annotationPreferences.getIonTypes(),
                            annotationPreferences.getNeutralLosses(),
                            annotationPreferences.getValidatedCharges(),
                            spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().value,
                            currentSpectrum, peptideAssumption.getPeptide(),
                            currentSpectrum.getIntensityLimit(annotationPreferences.getAnnotationIntensityLimit()),
View Full Code Here

Examples of com.compomics.util.experiment.identification.spectrum_annotators.PeptideSpectrumAnnotator

        this.annotationPreferences = annotationPreferences;
        this.sequenceMatchingPreferences = sequenceMatchingPreferences;
        this.waitingHandler = waitingHandler;
        PrideObjectsFactory prideObjectsFactory = PrideObjectsFactory.getInstance(); // @TODO: should be renamed!!!
        ptmToPrideMap = prideObjectsFactory.getPtmToPrideMap();
        this.peptideSpectrumAnnotator = new PeptideSpectrumAnnotator();
        r = new FileWriter(outputFile);
        br = new BufferedWriter(r);
    }
View Full Code Here

Examples of com.compomics.util.experiment.identification.spectrum_annotators.PeptideSpectrumAnnotator

        selectedProteinKey = NO_SELECTION;
        selectedPeptideKey = NO_SELECTION;
        selectedPsmKey = NO_SELECTION;

        cpsBean.setProjectDetails(null);
        spectrumAnnotator = new PeptideSpectrumAnnotator();

        try {
            spectrumFactory.closeFiles();
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

Examples of com.compomics.util.experiment.identification.spectrum_annotators.PeptideSpectrumAnnotator

            e.printStackTrace();
        }

        for (String accession : accessions) {

            PeptideSpectrumAnnotator spectrumAnnotator = new PeptideSpectrumAnnotator();

            ArrayList<IonMatch> annotations = spectrumAnnotator.getSpectrumAnnotation(
                    annotationPreferences.getIonTypes(),
                    annotationPreferences.getNeutralLosses(),
                    annotationPreferences.getValidatedCharges(),
                    spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().value,
                    spectrum,
View Full Code Here

Examples of com.compomics.util.experiment.identification.spectrum_annotators.PeptideSpectrumAnnotator

        Identification identification = experiment.getAnalysisSet(sample).getProteomicAnalysis(replicateNumber).getIdentification(IdentificationMethod.MS2_IDENTIFICATION);

        waitingHandler.setSecondaryProgressCounterIndeterminate(false);
        waitingHandler.setMaxSecondaryProgressCounter(identification.getSpectrumIdentificationSize());

        PeptideSpectrumAnnotator spectrumAnnotator = new PeptideSpectrumAnnotator();
        boolean multiSE = inputMap.isMultipleAlgorithms();

        // Keep a map of the spectrum keys grouped by peptide
        HashMap<String, ArrayList<String>> orderedPsmMap = null;
        if (MemoryConsumptionStatus.memoryUsed() < 0.8) {
            orderedPsmMap = new HashMap<String, ArrayList<String>>(identification.getSpectrumIdentificationMap().size());
        }

        for (String spectrumFileName : identification.getSpectrumFiles()) {

            HashMap<String, ArrayList<String>> keysMap = null;
            if (orderedPsmMap != null) {
                keysMap = new HashMap<String, ArrayList<String>>();
            }

            // batch load the spectrum matches
            identification.loadSpectrumMatches(spectrumFileName, null);

            for (String spectrumKey : identification.getSpectrumIdentification(spectrumFileName)) {

                // map of the peptide first hits for this spectrum: score -> max protein count -> max search engine votes -> sequence coverage annotated -> min mass deviation (unless you have a better idea?)
                HashMap<Double, HashMap<Integer, HashMap<Integer, HashMap<Double, HashMap<Double, ArrayList<PeptideAssumption>>>>>> peptideAssumptions
                        = new HashMap<Double, HashMap<Integer, HashMap<Integer, HashMap<Double, HashMap<Double, ArrayList<PeptideAssumption>>>>>>();

                // map of the tag first hits: score -> assumptions
                HashMap<Double, ArrayList<TagAssumption>> tagAssumptions = new HashMap<Double, ArrayList<TagAssumption>>();

                PSParameter psParameter = new PSParameter();
                ArrayList<String> identifications = new ArrayList<String>();

                SpectrumMatch spectrumMatch = identification.getSpectrumMatch(spectrumKey);

                for (int searchEngine1 : spectrumMatch.getAdvocates()) {

                    double bestEvalue = Collections.min(spectrumMatch.getAllAssumptions(searchEngine1).keySet());

                    for (SpectrumIdentificationAssumption assumption1 : spectrumMatch.getAllAssumptions(searchEngine1).get(bestEvalue)) {

                        if (assumption1 instanceof PeptideAssumption) {

                            PeptideAssumption peptideAssumption1 = (PeptideAssumption) assumption1;
                            String id = peptideAssumption1.getPeptide().getKey();

                            if (!identifications.contains(id)) {

                                psParameter = (PSParameter) peptideAssumption1.getUrParam(psParameter);
                                double p;

                                if (multiSE && sequenceFactory.concatenatedTargetDecoy()) {
                                    p = psParameter.getSearchEngineProbability();
                                } else {
                                    p = peptideAssumption1.getScore();
                                }

                                int nSE = 1;
                                int proteinMax = 1;

                                for (String protein : peptideAssumption1.getPeptide().getParentProteins(sequenceMatchingPreferences)) {
                                    Integer tempCount = proteinCount.get(protein);
                                    if (tempCount != null && tempCount > proteinMax) {
                                        proteinMax = tempCount;
                                    }
                                }

                                for (int searchEngine2 : spectrumMatch.getAdvocates()) {

                                    if (searchEngine1 != searchEngine2) {

                                        boolean found = false;
                                        ArrayList<Double> eValues2 = new ArrayList<Double>(spectrumMatch.getAllAssumptions(searchEngine2).keySet());
                                        Collections.sort(eValues2);

                                        for (double eValue2 : eValues2) {
                                            for (SpectrumIdentificationAssumption assumption2 : spectrumMatch.getAllAssumptions(searchEngine2).get(eValue2)) {

                                                if (assumption2 instanceof PeptideAssumption) {

                                                    PeptideAssumption peptideAssumption2 = (PeptideAssumption) assumption2;

                                                    if (peptideAssumption1.getPeptide().isSameSequenceAndModificationStatus(peptideAssumption2.getPeptide(),
                                                            sequenceMatchingPreferences)) {
                                                        PSParameter psParameter2 = (PSParameter) peptideAssumption2.getUrParam(psParameter);
                                                        p = p * psParameter2.getSearchEngineProbability();
                                                        nSE++;
                                                        found = true;
                                                        break;
                                                    }
                                                }
                                            }
                                            if (found) {
                                                break;
                                            }
                                        }
                                    }
                                }

                                identifications.add(id);

                                if (!peptideAssumptions.containsKey(p)) {
                                    peptideAssumptions.put(p, new HashMap<Integer, HashMap<Integer, HashMap<Double, HashMap<Double, ArrayList<PeptideAssumption>>>>>());
                                }

                                if (!peptideAssumptions.get(p).containsKey(proteinMax)) {
                                    peptideAssumptions.get(p).put(proteinMax, new HashMap<Integer, HashMap<Double, HashMap<Double, ArrayList<PeptideAssumption>>>>());
                                }

                                if (!peptideAssumptions.get(p).get(proteinMax).containsKey(nSE)) {
                                    ArrayList<PeptideAssumption> assumptions = new ArrayList<PeptideAssumption>();
                                    assumptions.add(peptideAssumption1);
                                    peptideAssumptions.get(p).get(proteinMax).put(nSE, new HashMap<Double, HashMap<Double, ArrayList<PeptideAssumption>>>());
                                    peptideAssumptions.get(p).get(proteinMax).get(nSE).put(-1.0, new HashMap<Double, ArrayList<PeptideAssumption>>());
                                    peptideAssumptions.get(p).get(proteinMax).get(nSE).get(-1.0).put(-1.0, assumptions);
                                } else {
                                    HashMap<Ion.IonType, HashSet<Integer>> iontypes = annotationPreferences.getIonTypes();
                                    NeutralLossesMap neutralLosses = annotationPreferences.getNeutralLosses();
                                    ArrayList<Integer> charges = annotationPreferences.getValidatedCharges();
                                    MSnSpectrum spectrum = (MSnSpectrum) spectrumFactory.getSpectrum(spectrumKey);
                                    double mzTolerance = searchParameters.getFragmentIonAccuracy();
                                    boolean isPpm = false; //@TODO change this as soon as search engine support fragment ion tolerance in ppm

                                    if (peptideAssumptions.get(p).get(proteinMax).get(nSE).containsKey(-1.0)) {
                                        ArrayList<PeptideAssumption> assumptions = peptideAssumptions.get(p).get(proteinMax).get(nSE).get(-1.0).get(-1.0);
                                        PeptideAssumption tempAssumption = assumptions.get(0);
                                        Peptide peptide = tempAssumption.getPeptide();
                                        int precursorCharge = tempAssumption.getIdentificationCharge().value;
                                        annotationPreferences.setCurrentSettings(tempAssumption, true, sequenceMatchingPreferences);
                                        double nIons = spectrumAnnotator.getCoveredAminoAcids(iontypes, neutralLosses, charges, precursorCharge,
                                                spectrum, peptide, 0, mzTolerance, isPpm, annotationPreferences.isHighResolutionAnnotation()).keySet().size();
                                        double coverage = nIons / peptide.getSequence().length();
                                        peptideAssumptions.get(p).get(proteinMax).get(nSE).put(coverage, new HashMap<Double, ArrayList<PeptideAssumption>>());
                                        peptideAssumptions.get(p).get(proteinMax).get(nSE).get(coverage).put(-1.0, assumptions);
                                        peptideAssumptions.get(p).get(proteinMax).get(nSE).remove(-1.0);
                                    }

                                    Peptide peptide = peptideAssumption1.getPeptide();
                                    int precursorCharge = peptideAssumption1.getIdentificationCharge().value;
                                    annotationPreferences.setCurrentSettings(peptideAssumption1, true, sequenceMatchingPreferences);
                                    double nIons = spectrumAnnotator.getCoveredAminoAcids(iontypes, neutralLosses, charges, precursorCharge,
                                            spectrum, peptide, 0, mzTolerance, isPpm, annotationPreferences.isHighResolutionAnnotation()).keySet().size();
                                    double coverage = nIons / peptide.getSequence().length();

                                    HashMap<Double, ArrayList<PeptideAssumption>> coverageMap = peptideAssumptions.get(p).get(proteinMax).get(nSE).get(coverage);
                                    if (coverageMap == null) {
View Full Code Here

Examples of com.compomics.util.experiment.identification.spectrum_annotators.PeptideSpectrumAnnotator

            SpectrumFactory spectrumFactory = SpectrumFactory.getInstance();
            MSnSpectrum spectrum = (MSnSpectrum) spectrumFactory.getSpectrum(spectrumKey);
            Peptide peptide = peptideAssumption.getPeptide();
            if (peptideSpectrumAnnotator == null) {
                peptideSpectrumAnnotator = new PeptideSpectrumAnnotator();
            }
            HashMap<Integer, ArrayList<IonMatch>> ionMatches = peptideSpectrumAnnotator.getCoveredAminoAcids(annotationPreferences.getIonTypes(),
                    annotationPreferences.getNeutralLosses(), annotationPreferences.getValidatedCharges(),
                    peptideAssumption.getIdentificationCharge().value, spectrum, peptide, spectrum.getIntensityLimit(annotationPreferences.getAnnotationIntensityLimit()),
                    searchParameters.getFragmentIonAccuracy(), false, annotationPreferences.isHighResolutionAnnotation());
View Full Code Here

Examples of com.compomics.util.experiment.identification.spectrum_annotators.PeptideSpectrumAnnotator

     */
    public RunMzDeviation(String spectrumFileName, Identification identification, AnnotationPreferences annotationPreferences,
            WaitingHandler waitingHandler) throws IOException, MzMLUnmarshallerException, SQLException, ClassNotFoundException, InterruptedException {

        // @TODO: the progress bar usage in the code below could be improved
        PeptideSpectrumAnnotator spectrumAnnotator = new PeptideSpectrumAnnotator();
        PSParameter psParameter = new PSParameter();
        ms2Bin = 100 * annotationPreferences.getFragmentIonAccuracy();
        HashMap<Double, HashMap<Double, ArrayList<Double>>> precursorRawMap = new HashMap<Double, HashMap<Double, ArrayList<Double>>>();
        HashMap<Double, HashMap<Double, ArrayList<Double>>> fragmentRawMap = new HashMap<Double, HashMap<Double, ArrayList<Double>>>();
        HashMap<Double, ArrayList<Double>> spectrumFragmentMap;

        identification.loadSpectrumMatchParameters(spectrumFileName, psParameter, waitingHandler);
        identification.loadSpectrumMatches(spectrumFileName, waitingHandler);

        if (waitingHandler != null) {
            waitingHandler.resetSecondaryProgressCounter();
            waitingHandler.setMaxSecondaryProgressCounter(spectrumFactory.getSpectrumTitles(spectrumFileName).size());
        }

        for (String spectrumName : spectrumFactory.getSpectrumTitles(spectrumFileName)) {

            if (waitingHandler != null && waitingHandler.isRunCanceled()) {
                break;
            }

            String spectrumKey = Spectrum.getSpectrumKey(spectrumFileName, spectrumName);

            if (identification.matchExists(spectrumKey)) {

                psParameter = (PSParameter) identification.getSpectrumMatchParameter(spectrumKey, psParameter);

                if (psParameter.getMatchValidationLevel().isValidated()) {

                    Precursor precursor = spectrumFactory.getPrecursor(spectrumKey);
                    double precursorMz = precursor.getMz();
                    double precursorRT = precursor.getRt();

                    if (!precursorRawMap.containsKey(precursorRT)) {
                        precursorRawMap.put(precursorRT, new HashMap<Double, ArrayList<Double>>());
                    }
                    if (!precursorRawMap.get(precursorRT).containsKey(precursorMz)) {
                        precursorRawMap.get(precursorRT).put(precursorMz, new ArrayList<Double>());
                    }

                    SpectrumMatch spectrumMatch = identification.getSpectrumMatch(spectrumKey);

                    if (spectrumMatch.getBestPeptideAssumption() != null) {

                        double error = spectrumMatch.getBestPeptideAssumption().getDeltaMass(precursorMz, false);
                        precursorRawMap.get(precursorRT).get(precursorMz).add(error);

                        MSnSpectrum currentSpectrum = (MSnSpectrum) spectrumFactory.getSpectrum(spectrumKey);
                        ArrayList<IonMatch> annotations = spectrumAnnotator.getSpectrumAnnotation(
                                annotationPreferences.getIonTypes(),
                                annotationPreferences.getNeutralLosses(),
                                annotationPreferences.getValidatedCharges(),
                                spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().value,
                                currentSpectrum,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.