Package com.compomics.util.preferences

Examples of com.compomics.util.preferences.ModificationProfile


                                String peptideSequence = peptide.getSequence();

                                // map the algorithm specific modifications on utilities modifications
                                // If there are not enough sites to put them all on the sequence, add an unknown modifcation
                                // Note: this needs to be done for tag based assumptions as well since the protein mapping can return erroneous modifications for some pattern based PTMs
                                ModificationProfile modificationProfile = searchParameters.getModificationProfile();

                                boolean fixedPtmIssue = false;
                                try {
                                    ptmFactory.checkFixedModifications(modificationProfile, peptide, sequenceMatchingPreferences);
                                } catch (IllegalArgumentException e) {
                                    if (idFilter.removeUnknownPTMs()) {
                                        // Exclude peptides with aberrant PTM mapping
                                        System.out.println(e.getMessage());
                                        spectrumMatch.removeAssumption(assumption);
                                        ptmIssue++;
                                        fixedPtmIssue = true;
                                    } else {
                                        throw e;
                                    }
                                }

                                if (!fixedPtmIssue) {

                                    HashMap<Integer, ArrayList<String>> expectedNames = new HashMap<Integer, ArrayList<String>>();
                                    HashMap<ModificationMatch, ArrayList<String>> modNames = new HashMap<ModificationMatch, ArrayList<String>>();

                                    for (ModificationMatch modMatch : peptide.getModificationMatches()) {
                                        HashMap<Integer, ArrayList<String>> tempNames = new HashMap<Integer, ArrayList<String>>();
                                        if (modMatch.isVariable()) {
                                            String sePTM = modMatch.getTheoreticPtm();
                                            if (fileReader instanceof OMSSAIdfileReader) {
                                                Integer omssaIndex = null;
                                                try {
                                                    omssaIndex = new Integer(sePTM);
                                                } catch (Exception e) {
                                                    waitingHandler.appendReport("Impossible to parse OMSSA modification " + sePTM + ".", true, true);
                                                }
                                                if (omssaIndex != null) {
                                                    String omssaName = modificationProfile.getModification(omssaIndex);
                                                    if (omssaName == null) {
                                                        if (!ignoredOMSSAModifications.contains(omssaIndex)) {
                                                            waitingHandler.appendReport("Impossible to find OMSSA modification of index "
                                                                    + omssaIndex + ". The corresponding peptides will be ignored.", true, true);
                                                            ignoredOMSSAModifications.add(omssaIndex);
                                                        }
                                                        omssaName = PTMFactory.unknownPTM.getName();
                                                    }
                                                    tempNames = ptmFactory.getExpectedPTMs(modificationProfile, peptide, omssaName, ptmMassTolerance, sequenceMatchingPreferences);
                                                }
                                            } else if (fileReader instanceof MascotIdfileReader
                                                    || fileReader instanceof XTandemIdfileReader
                                                    || fileReader instanceof MsAmandaIdfileReader
                                                    || fileReader instanceof MzIdentMLIdfileReader
                                                    || fileReader instanceof PepxmlIdfileReader) {
                                                String[] parsedName = sePTM.split("@");
                                                double seMass = 0;
                                                try {
                                                    seMass = new Double(parsedName[0]);
                                                } catch (Exception e) {
                                                    throw new IllegalArgumentException("Impossible to parse \'" + sePTM + "\' as a tagged modification.\n"
                                                            + "Error encountered in peptide " + peptideSequence + " spectrum " + spectrumTitle + " in spectrum file " + fileName + ".\n"
                                                            + "Identification file: " + idFile.getName());
                                                }
                                                tempNames = ptmFactory.getExpectedPTMs(modificationProfile, peptide, seMass, ptmMassTolerance, sequenceMatchingPreferences);
                                            } else if (fileReader instanceof DirecTagIdfileReader) {
                                                PTM ptm = ptmFactory.getPTM(sePTM);
                                                if (ptm == PTMFactory.unknownPTM) {
                                                    throw new IllegalArgumentException("PTM not recognized spectrum " + spectrumTitle + " of file " + fileName + ".");
                                                }
                                                tempNames = ptmFactory.getExpectedPTMs(modificationProfile, peptide, ptm.getMass(), ptmMassTolerance, sequenceMatchingPreferences);
                                            } else {
                                                throw new IllegalArgumentException("PTM mapping not implemented for the parsing of " + idFile.getName() + ".");
                                            }

                                            ArrayList<String> allNames = new ArrayList<String>();
                                            for (ArrayList<String> namesAtAA : tempNames.values()) {
                                                for (String name : namesAtAA) {
                                                    if (!allNames.contains(name)) {
                                                        allNames.add(name);
                                                    }
                                                }
                                            }
                                            modNames.put(modMatch, allNames);
                                            for (int pos : tempNames.keySet()) {
                                                ArrayList<String> namesAtPosition = expectedNames.get(pos);
                                                if (namesAtPosition == null) {
                                                    namesAtPosition = new ArrayList<String>(2);
                                                    expectedNames.put(pos, namesAtPosition);
                                                }
                                                for (String ptmName : tempNames.get(pos)) {
                                                    if (!namesAtPosition.contains(ptmName)) {
                                                        namesAtPosition.add(ptmName);
                                                    }
                                                }
                                            }
                                        }
                                    }

                                    // If a terminal modification cannot be elsewhere lock the terminus
                                    ModificationMatch nTermModification = null;
                                    for (ModificationMatch modMatch : peptide.getModificationMatches()) {
                                        if (modMatch.isVariable() && !modMatch.getTheoreticPtm().equals(PTMFactory.unknownPTM.getName())) {
                                            double refMass = getRefMass(modMatch.getTheoreticPtm(), modificationProfile);
                                            int modSite = modMatch.getModificationSite();
                                            if (modSite == 1) {
                                                ArrayList<String> expectedNamesAtSite = expectedNames.get(modSite);
                                                if (expectedNamesAtSite != null) {
                                                    ArrayList<String> filteredNamesAtSite = new ArrayList<String>(expectedNamesAtSite.size());
                                                    for (String ptmName : expectedNamesAtSite) {
                                                        PTM ptm = ptmFactory.getPTM(ptmName);
                                                        if (Math.abs(ptm.getMass() - refMass) < searchParameters.getFragmentIonAccuracy()) {
                                                            filteredNamesAtSite.add(ptmName);
                                                        }
                                                    }
                                                    for (String modName : filteredNamesAtSite) {
                                                        PTM ptm = ptmFactory.getPTM(modName);
                                                        if (ptm.isNTerm()) {
                                                            boolean otherPossibleMod = false;
                                                            for (String tempName : modificationProfile.getAllNotFixedModifications()) {
                                                                if (!tempName.equals(modName)) {
                                                                    PTM tempPTM = ptmFactory.getPTM(tempName);
                                                                    if (tempPTM.getMass() == ptm.getMass() && !tempPTM.isNTerm()) {
                                                                        otherPossibleMod = true;
                                                                        break;
                                                                    }
                                                                }
                                                            }
                                                            if (!otherPossibleMod) {
                                                                nTermModification = modMatch;
                                                                modMatch.setTheoreticPtm(modName);
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    if (nTermModification != null) {
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    ModificationMatch cTermModification = null;
                                    for (ModificationMatch modMatch : peptide.getModificationMatches()) {
                                        if (modMatch.isVariable() && !modMatch.getTheoreticPtm().equals(PTMFactory.unknownPTM.getName()) && modMatch != nTermModification) {
                                            double refMass = getRefMass(modMatch.getTheoreticPtm(), modificationProfile);
                                            int modSite = modMatch.getModificationSite();
                                            if (modSite == peptideSequence.length()) {
                                                ArrayList<String> expectedNamesAtSite = expectedNames.get(modSite);
                                                if (expectedNamesAtSite != null) {
                                                    ArrayList<String> filteredNamesAtSite = new ArrayList<String>(expectedNamesAtSite.size());
                                                    for (String ptmName : expectedNamesAtSite) {
                                                        PTM ptm = ptmFactory.getPTM(ptmName);
                                                        if (Math.abs(ptm.getMass() - refMass) < searchParameters.getFragmentIonAccuracy()) {
                                                            filteredNamesAtSite.add(ptmName);
                                                        }
                                                    }
                                                    for (String modName : filteredNamesAtSite) {
                                                        PTM ptm = ptmFactory.getPTM(modName);
                                                        if (ptm.isCTerm()) {
                                                            boolean otherPossibleMod = false;
                                                            for (String tempName : modificationProfile.getAllNotFixedModifications()) {
                                                                if (!tempName.equals(modName)) {
                                                                    PTM tempPTM = ptmFactory.getPTM(tempName);
                                                                    if (tempPTM.getMass() == ptm.getMass() && !tempPTM.isCTerm()) {
                                                                        otherPossibleMod = true;
                                                                        break;
View Full Code Here


     * Verifies that the modifications targeted by the quick acetyl and quick
     * pyrolidone are included in the search parameters.
     */
    private synchronized void verifyXTandemPtms() {
        if (!xTandemPtmsCheck) {
            ModificationProfile modificationProfile = searchParameters.getModificationProfile();
            IdentificationAlgorithmParameter algorithmParameter = searchParameters.getIdentificationAlgorithmParameter(Advocate.xtandem.getIndex());
            if (algorithmParameter != null) {
                XtandemParameters xtandemParameters = (XtandemParameters) algorithmParameter;
                if (xtandemParameters.isProteinQuickAcetyl() && !modificationProfile.contains("acetylation of protein n-term")) {
                    PTM ptm = PTMFactory.getInstance().getPTM("acetylation of protein n-term");
                    modificationProfile.addVariableModification(ptm);
                }
                String[] pyroMods = {"pyro-cmc", "pyro-glu from n-term e", "pyro-glu from n-term q"};
                if (xtandemParameters.isQuickPyrolidone()) {
                    for (String ptmName : pyroMods) {
                        if (!modificationProfile.getVariableModifications().contains(ptmName)) {
                            PTM ptm = PTMFactory.getInstance().getPTM(ptmName);
                            modificationProfile.addVariableModification(ptm);
                        }
                    }
                }
            }
            xTandemPtmsCheck = true;
View Full Code Here

     * computing the score
     */
    private void attachProbabilisticScore(Identification identification, SpectrumMatch spectrumMatch, SearchParameters searchParameters,
            AnnotationPreferences annotationPreferences, PTMScoringPreferences scoringPreferences, SequenceMatchingPreferences sequenceMatchingPreferences) throws Exception {

        ModificationProfile ptmProfile = searchParameters.getModificationProfile();

        PSPtmScores ptmScores = new PSPtmScores();
        if (spectrumMatch.getUrParam(new PSPtmScores()) != null) {
            ptmScores = (PSPtmScores) spectrumMatch.getUrParam(new PSPtmScores());
        }

        HashMap<Double, ArrayList<PTM>> modifications = new HashMap<Double, ArrayList<PTM>>();
        HashMap<Double, Integer> nMod = new HashMap<Double, Integer>();
        HashMap<Double, ModificationMatch> modificationMatches = new HashMap<Double, ModificationMatch>();
        Peptide peptide = spectrumMatch.getBestPeptideAssumption().getPeptide();

        for (ModificationMatch modificationMatch : peptide.getModificationMatches()) {
            if (modificationMatch.isVariable()) {
                PTM refPTM = ptmFactory.getPTM(modificationMatch.getTheoreticPtm());
                double ptmMass = refPTM.getMass();
                if (!modifications.containsKey(ptmMass)) {
                    ArrayList<PTM> ptms = new ArrayList<PTM>();
                    for (String ptm : ptmProfile.getSimilarNotFixedModifications(ptmMass)) {
                        ptms.add(ptmFactory.getPTM(ptm));
                    }
                    modifications.put(ptmMass, ptms);
                    nMod.put(ptmMass, 1);
                } else {
View Full Code Here

     */
    private void ptmSiteInference(SpectrumMatch spectrumMatch, PTMScoringPreferences ptmScoringPreferences, SearchParameters searchParameters, SequenceMatchingPreferences sequenceMatchingPreferences)
            throws IOException, IllegalArgumentException, InterruptedException, FileNotFoundException, ClassNotFoundException, SQLException {

        Peptide psPeptide = spectrumMatch.getBestPeptideAssumption().getPeptide();
        ModificationProfile modificationProfile = searchParameters.getModificationProfile();
        PSPtmScores ptmScores = (PSPtmScores) spectrumMatch.getUrParam(new PSPtmScores());
        HashMap<Double, ArrayList<ModificationMatch>> modMatchesMap = new HashMap<Double, ArrayList<ModificationMatch>>();
        HashMap<Double, HashMap<Integer, String>> possiblePositions = new HashMap<Double, HashMap<Integer, String>>();
        for (ModificationMatch modificationMatch : psPeptide.getModificationMatches()) {
            if (modificationMatch.isVariable()) {
                String modName = modificationMatch.getTheoreticPtm();
                PTM ptm = ptmFactory.getPTM(modName);
                if (ptm.getType() == PTM.MODAA) {
                    double ptmMass = ptm.getMass();
                    ArrayList<ModificationMatch> ptmOccurence = modMatchesMap.get(ptmMass);
                    if (ptmOccurence == null) {
                        ptmOccurence = new ArrayList<ModificationMatch>();
                        modMatchesMap.put(ptmMass, ptmOccurence);
                    }
                    ptmOccurence.add(modificationMatch);

                    HashMap<Integer, String> ptmPossibleSites = possiblePositions.get(ptmMass);
                    if (ptmPossibleSites == null) {
                        ptmPossibleSites = new HashMap<Integer, String>();
                        possiblePositions.put(ptmMass, ptmPossibleSites);
                    }
                    for (String similarPtmName : modificationProfile.getSimilarNotFixedModifications(ptmMass)) {
                        PTM similarPtm = ptmFactory.getPTM(similarPtmName);
                        for (int pos : psPeptide.getPotentialModificationSites(similarPtm, sequenceMatchingPreferences)) {
                            ptmPossibleSites.put(pos, similarPtmName);
                        }
                    }
View Full Code Here

     * @return the modification profile of the project
     */
    public ModificationProfile getModificationProfile() {
        // Compatibility check
        if (utilitiesModificationProfile == null) {
            utilitiesModificationProfile = new ModificationProfile();
            for (String utilitesName : modificationProfile.getUtilitiesNames()) {
                String psName = modificationProfile.getFamilyName(utilitesName);
                PTM modification = PTMFactory.getInstance().getPTM(psName);
                utilitiesModificationProfile.addVariableModification(modification);
                if (modificationProfile.getShortName(psName) != null) {
View Full Code Here

TOP

Related Classes of com.compomics.util.preferences.ModificationProfile

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.