Ejemplo n.º 1
0
        public IEnumerable <DigestedPeptide> Digest(Protein protein)
        {
            Regex regex = new Regex(Regex);
            int   begin = 0;
            int   len   = protein.Sequence.Length;

            while (begin < len)
            {
                int end      = begin;
                int endFirst = begin;
                int missed   = 0;
                do
                {
                    string sequence = protein.Sequence;
                    Match  m        = regex.Match(sequence, end);
                    end = (m.Success ? m.Index + 1 : len);

                    // Save the end of the first cleavage
                    if (missed == 0)
                    {
                        endFirst = end;
                    }
                    // TODO(nicksh)
                    //// Deal with 'ragged ends', or cleavages one amino acid apart
                    //// i.e. KR, RR, etc. for trypsin
                    //if (settings.ExcludeRaggedEnds && end < len)
                    //{
                    //    Match mNext = regex.Match(sequence, end);
                    //    if (mNext.Success && mNext.Index == end)
                    //    {
                    //        // If there are no missed cleavages, then move the
                    //        // begin index to the next cleavage point that is
                    //        // not part of a run.
                    //        if (missed == 0)
                    //            endFirst = GetDiscontiguousCleavageIndex(regex, mNext, sequence);
                    //        break;
                    //    }
                    //}

                    // Single amino acid peptides have no fragment ions.
                    int count = end - begin;
                    if (count > 1 && sequence.IndexOfAny(new[] { '*', '-' }, begin, count) == -1) // Not L10N
                    {
                        DigestedPeptide peptide = new DigestedPeptide
                        {
                            Index    = begin,
                            Sequence = sequence.Substring(begin, end - begin)
                        };
                        yield return(peptide);
                    }

                    // Increment missed cleavages for next loop.
                    missed++;
                }while (end < len);

                begin = endFirst;
            }
        }
Ejemplo n.º 2
0
        public IEnumerable<DigestedPeptide> Digest(Protein protein)
        {
            Regex regex = new Regex(Regex);
            int begin = 0;
            int len = protein.Sequence.Length;
            while (begin < len)
            {
                int end = begin;
                int endFirst = begin;
                int missed = 0;
                do
                {
                    string sequence = protein.Sequence;
                    Match m = regex.Match(sequence, end);
                    end = (m.Success ? m.Index + 1 : len);

                    // Save the end of the first cleavage
                    if (missed == 0)
                        endFirst = end;
                    // TODO(nicksh)
                    //// Deal with 'ragged ends', or cleavages one amino acid apart
                    //// i.e. KR, RR, etc. for trypsin
                    //if (settings.ExcludeRaggedEnds && end < len)
                    //{
                    //    Match mNext = regex.Match(sequence, end);
                    //    if (mNext.Success && mNext.Index == end)
                    //    {
                    //        // If there are no missed cleavages, then move the
                    //        // begin index to the next cleavage point that is
                    //        // not part of a run.
                    //        if (missed == 0)
                    //            endFirst = GetDiscontiguousCleavageIndex(regex, mNext, sequence);
                    //        break;
                    //    }
                    //}

                    // Single amino acid peptides have no fragment ions.
                    int count = end - begin;
                    if (count > 1 && sequence.IndexOfAny(new[] { '*', '-' }, begin, count) == -1) // Not L10N
                    {
                        DigestedPeptide peptide = new DigestedPeptide
                                                      {
                                                          Index = begin,
                                                          Sequence = sequence.Substring(begin, end - begin)
                                                      };
                        yield return peptide;
                    }

                    // Increment missed cleavages for next loop.
                    missed++;

                }
                while (end < len);

                begin = endFirst;
            }
        }
Ejemplo n.º 3
0
 public IEnumerable<DigestedPeptide> Digest(Protein protein)
 {
     if (string.IsNullOrEmpty(protein.Sequence))
     {
         yield break;
     }
     FastaSequence fastaSequence;
     try
     {
         fastaSequence = new FastaSequence("name", "description", new List<ProteinMetadata>(), protein.Sequence); // Not L10N
     }
     catch (InvalidDataException)
     {
         // It's possible that the peptide sequence in the fasta file was bogus, in which case we just don't digest it.
         yield break;
     }
     DigestSettings digestSettings = new DigestSettings(6, false);
     foreach (var digest in _enzyme.Digest(fastaSequence, digestSettings))
     {
         var digestedPeptide = new DigestedPeptide
         {
             Index = digest.Begin ?? 0,
             Sequence = digest.Sequence
         };
         yield return digestedPeptide;
     }
 }