Exemple #1
0
        public void TestProteomeDb()
        {
            using (var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE))
            {
                string fastaPath  = testFilesDir.GetTestPath("high_ipi.Human.20060111.fasta");
                string protDbPath = testFilesDir.GetTestPath("test.protdb");

                using (ProteomeDb proteomeDb = ProteomeDb.CreateProteomeDb(protDbPath))
                {
                    IProgressStatus status = new ProgressStatus(string.Empty);
                    using (var reader = new StreamReader(fastaPath))
                    {
                        proteomeDb.AddFastaFile(reader, new SilentProgressMonitor(), ref status, true); // Delay indexing
                    }
                    // perform digestion
                    Digestion digestion         = proteomeDb.GetDigestion();
                    var       digestedProteins0 = digestion.GetProteinsWithSequence("EDGWVK");
                    Assert.IsTrue(digestedProteins0.Count >= 1);
                }
            }
        }
        public void TestProteomeDb()
        {
            using (var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE))
            {
                string fastaPath  = testFilesDir.GetTestPath("high_ipi.Human.20060111.fasta");
                string protDbPath = testFilesDir.GetTestPath("test.protdb");

                using (ProteomeDb proteomeDb = ProteomeDb.CreateProteomeDb(protDbPath))
                {
                    Enzyme trypsin = EnzymeList.GetDefault();
                    using (var reader = new StreamReader(fastaPath))
                    {
                        proteomeDb.AddFastaFile(reader, (msg, progress) => true);
                    }
                    // perform digestion
                    proteomeDb.Digest(new ProteaseImpl(trypsin), (msg, progress) => true);
                    Digestion digestion         = proteomeDb.GetDigestion(trypsin.Name);
                    var       digestedProteins0 = digestion.GetProteinsWithSequencePrefix("EDGWVK", 100);
                    Assert.IsTrue(digestedProteins0.Count >= 1);
                }
            }
        }
Exemple #3
0
        public void TestProteomeDb()
        {
            using (var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE))
            {
                string fastaPath  = testFilesDir.GetTestPath("high_ipi.Human.20060111.fasta");
                string protDbPath = testFilesDir.GetTestPath("test.protdb");

                using (ProteomeDb proteomeDb = ProteomeDb.CreateProteomeDb(protDbPath))
                {
                    Enzyme          trypsin = EnzymeList.GetDefault();
                    IProgressStatus status  = new ProgressStatus(string.Empty);
                    using (var reader = new StreamReader(fastaPath))
                    {
                        proteomeDb.AddFastaFile(reader, new SilentProgressMonitor(), ref status, true); // Delay indexing
                    }
                    // perform digestion
                    proteomeDb.Digest(new ProteaseImpl(trypsin), ProteomeDb.PROTDB_MAX_MISSED_CLEAVAGES, new SilentProgressMonitor(), ref status);
                    Digestion digestion         = proteomeDb.GetDigestion(trypsin.Name);
                    var       digestedProteins0 = digestion.GetProteinsWithSequencePrefix("EDGWVK", 100);
                    Assert.IsTrue(digestedProteins0.Count >= 1);
                }
            }
        }
Exemple #4
0
 public Digestion GetDigestion(ProteomeDb proteomeDb, PeptideSettings peptideSettings)
 {
     return(proteomeDb.GetDigestion());
 }
        /// <summary>
        /// Tries to match each library peptide to document settings.
        /// </summary>
        public void MatchAllPeptides(ILongWaitBroker broker)
        {
            _chargeSettingsMap = new  AdductMap <SrmSettings>();

            // Build a dictionary mapping sequence to proteins because getting this information is slow.
            var dictSequenceProteins = new Dictionary <string, IList <ProteinInfo> >();
            var dictNewNodePeps      = new Dictionary <PeptideSequenceModKey, PeptideMatch>();

            PeptideMatches      = null;
            MatchedPeptideCount = 0;

            int peptides      = 0;
            int totalPeptides = _libraryPepInfos.Count;

            ProteomeDb        proteomeDb = null;
            IStatelessSession session    = null;

            try
            {
                foreach (ViewLibraryPepInfo pepInfo in _libraryPepInfos)
                {
                    if (broker.IsCanceled)
                    {
                        return;
                    }

                    var charge = pepInfo.Key.Adduct;
                    // Find the matching peptide.
                    var nodePepMatched = AssociateMatchingPeptide(pepInfo, charge).PeptideNode;
                    if (nodePepMatched != null)
                    {
                        MatchedPeptideCount++;

                        PeptideMatch peptideMatchInDict;
                        // If peptide is already in the dictionary of peptides to add, merge the children.
                        if (!dictNewNodePeps.TryGetValue(nodePepMatched.SequenceKey, out peptideMatchInDict))
                        {
                            IList <ProteinInfo> matchedProteins = null;

                            var target = nodePepMatched.Peptide.Target;
                            // This is only set if the user has checked the associate peptide box.
                            if (target.IsProteomic && _backgroundProteome != null)
                            {
                                var sequence = target.Sequence;
                                // We want to query the background proteome as little as possible,
                                // so sequences are mapped to protein lists in a dictionary.
                                if (!dictSequenceProteins.TryGetValue(sequence, out matchedProteins))
                                {
                                    if (proteomeDb == null)
                                    {
                                        proteomeDb = _backgroundProteome.OpenProteomeDb(broker.CancellationToken);
                                        session    = proteomeDb.OpenStatelessSession(false);
                                    }
                                    var digestion = proteomeDb.GetDigestion();
                                    if (sequence.Length >= MIN_PEPTIDE_LENGTH)
                                    {
                                        matchedProteins = digestion.GetProteinsWithSequence(session, sequence)
                                                          .Select(protein => new ProteinInfo(protein)).ToList();
                                    }
                                    if (matchedProteins == null || matchedProteins.Count > MAX_PROTEIN_MATCHES)
                                    {
                                        // If the peptide was too short, or matched too many proteins, then
                                        // treat it as if it was not found in any proteins.
                                        matchedProteins = new List <ProteinInfo>();
                                    }
                                    dictSequenceProteins.Add(sequence, matchedProteins);
                                }
                            }
                            dictNewNodePeps.Add(nodePepMatched.SequenceKey,
                                                new PeptideMatch(nodePepMatched, matchedProteins,
                                                                 MatchesFilter(target, charge)));
                        }
                        else
                        {
                            PeptideDocNode nodePepInDictionary = peptideMatchInDict.NodePep;
                            if (!nodePepInDictionary.HasChildCharge(charge))
                            {
                                List <DocNode> newChildren = nodePepInDictionary.Children.ToList();
                                newChildren.AddRange(nodePepMatched.Children);
                                newChildren.Sort(Peptide.CompareGroups);
                                var key = nodePepMatched.SequenceKey;
                                dictNewNodePeps.Remove(key);
                                dictNewNodePeps.Add(key,
                                                    new PeptideMatch((PeptideDocNode)nodePepInDictionary.ChangeChildren(newChildren),
                                                                     peptideMatchInDict.Proteins, peptideMatchInDict.MatchesFilterSettings));
                            }
                        }
                    }
                    peptides++;
                    int progressValue = (int)((peptides + 0.0) / totalPeptides * PERCENT_PEPTIDE_MATCH);
                    broker.ProgressValue = progressValue;
                }
                PeptideMatches = dictNewNodePeps;
            }
            finally
            {
                using (proteomeDb)
                    using (session)
                    {
                    }
            }
        }
Exemple #6
0
 public Digestion GetDigestion(ProteomeDb proteomeDb, PeptideSettings peptideSettings)
 {
     return(proteomeDb.GetDigestion(peptideSettings.Enzyme.Name));
 }