Пример #1
0
        private static void createTestPeptideInstances (NHibernate.ISession session, BulkInserter bulkInserter, Peptide pep)
        {
            // store instances even though the association is inverse:
            // the PeptideModification.Offset property needs access to the protein sequence
            pep.Instances = new List<PeptideInstance>();

            foreach (Protein pro in session.Query<Protein>())
            {
                int start = pro.Sequence.IndexOf(pep.Sequence, 0);
                while (start >= 0)
                {
                    int end = start + pep.Sequence.Length;
                    bool nTerminusIsSpecific = start == 0 || pro.Sequence[start - 1] == 'K' || pro.Sequence[start - 1] == 'R';
                    bool cTerminusIsSpecific = end == pro.Sequence.Length || pro.Sequence[end - 1] == 'K' || pro.Sequence[end - 1] == 'R';
                    var instance = new TestPI()
                    {
                        Peptide = pep,
                        Protein = pro,
                        Offset = start,
                        Length = pep.Sequence.Length,
                        MissedCleavages = pep.Sequence.ToCharArray(0, pep.Sequence.Length - 1).Count(o => o == 'K' || o == 'R'),
                        NTerminusIsSpecific = nTerminusIsSpecific,
                        CTerminusIsSpecific = cTerminusIsSpecific,
                    };

                    var instanceAccessor = new PrivateObject(instance);
                    instanceAccessor.SetProperty("SpecificTermini", (nTerminusIsSpecific ? 1 : 0) + (cTerminusIsSpecific ? 1 : 0));

                    bulkInserter.Add(instance);
                    pep.Instances.Add(instance);

                    start = pro.Sequence.IndexOf(pep.Sequence, start + 1);
                }
            }

            if (pep.Instances.Count == 0)
                throw new ArgumentException("peptide " + pep.Sequence + " does not occur in any proteins");
        }
Пример #2
0
        static void Main(string[] args)
        {
            Peptide peptideList = new Peptide();

            List<string> peptideSeqList = new List<string>();
            string file = "C:\\Users\\Dong\\Desktop\\test.pep.list";
            TextReader tr = new StreamReader(file);
            string line;
            while ((line = tr.ReadLine()) != null)
            {
                string peptide;
                if (line.Contains("."))
                {
                    string[] strs = line.Split('.');
                    peptide = strs[1];
                }
                else
                    peptide = line;
                peptideSeqList.Add(peptide);
            }

            //remove duplicates of the peptides
            //make it a unique list
            peptideSeqList = removeDuplicate(peptideSeqList);
            //generate the peptide list
            //by putting the peptide
            foreach (var pep in peptideSeqList)
            { 
                //something wrong here!!!
                peptideList.Add(1, "");
            }

            //Pep2Pro pp = new Pep2Pro();
            string database = "C:\\Users\\Dong\\Desktop\\yates.fasta";
            ProteomeDataFile foo = new ProteomeDataFile(database);
            pwiz.CLI.proteome.ProteinList proteinList = foo.proteinList;
            List<Protein> finalProteinList = new List<Protein>();
            
            
            for (int i = 0; i < proteinList.size(); i++)
            {
                Protein protein = proteinList.protein(i, true);
                if (!protein.id.Contains("Reverse"))
                {
                    string sequence = protein.sequence;
                    //Console.WriteLine(protein.index);
                    foreach (var pep in peptideSeqList)
                    {
                        if (sequence.Contains(pep) && !finalProteinList.Contains(protein))
                        {
                            finalProteinList.Add(protein);
                        }
                    }
                    
                }
            }

            //test
            //results: got a protein list which corresponding all peptides
            //the "finalProteinList" is ready for filters. 
            //Console.WriteLine(proteinList.size());
            //Console.WriteLine(finalProteinList.Count);


            //filter by minDistinctPeptides

            //filter by filterByDistinctPeptides

            //filterByMinimumCoveringSet

            //done it!
        }