Exemplo n.º 1
0
        public IEnumerable <DigestedPeptide> DigestSequence(string proteinSequence, int maxMissedCleavages, int?maxPeptideSequenceLength)
        {
            if (string.IsNullOrEmpty(proteinSequence))
            {
                yield break;
            }
            FastaSequence fastaSequence;

            try
            {
                fastaSequence = new FastaSequence(@"name", @"description", new List <ProteinMetadata>(), proteinSequence);
            }
            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;
            }
            var digestSettings = new DigestSettings(maxMissedCleavages, false);

            foreach (var digest in _enzyme.Digest(fastaSequence, digestSettings, maxPeptideSequenceLength))
            {
                var digestedPeptide = new DigestedPeptide
                {
                    Index    = digest.Begin ?? 0,
                    Sequence = digest.Target.Sequence
                };
                yield return(digestedPeptide);
            }
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        public static DigestedFastaFile parseDigestedFasta(String fileName)
        {
            // List to store the objects of each in-silico digested peptide
            List <DigestedPeptide> ArrDigest = new List <DigestedPeptide>();

            log.Debug("Parsing the digested FASTA file.");
            try
            {
                log.Debug("File path: " + fileName);
                StreamReader reader = new StreamReader(fileName);
                String       line   = reader.ReadLine();

                // read lines
                while (line != null)
                {
                    /*-
                     * Reads the lines of the file into an array of Strings, after each "tab", text
                     * is stored in new cell. Header shown below:
                     * sequence/protein/mass/missedCleavages/specificity/nTerminusIsSpecific/cTerminusIsSpecific
                     */
                    String[] values = line.Split("\t".ToCharArray());

                    // Skip the header
                    if (values[0].Equals("sequence"))
                    {
                        // Move to the next line
                        line   = reader.ReadLine();
                        values = line.Split("\t".ToCharArray());
                    }

                    String          sequence  = values[0]; // peptide sequence
                    String          accession = values[1]; // accession of the parent protein
                    double          mass      = Double.Parse(values[2]);
                    DigestedPeptide digPeps   = new DigestedPeptide(sequence, accession, mass);
                    ArrDigest.Add(digPeps);

                    line = reader.ReadLine();
                }
                reader.Close();

                log.Debug("Done parsing the digested FASTA file.");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                log.Error("Digested FASTA file not correctly parsed.");
                Environment.Exit(0);
            }
            return(new DigestedFastaFile(fileName, ArrDigest));
        }