Ejemplo n.º 1
0
        public void WriteProteins(string outputFilepath, bool addDecoys)
        {
            var pd = new ProteomeData();
            var pl = new ProteinListSimple();

            var queryRows = session.CreateQuery("SELECT DISTINCT pro.Accession, pro.IsDecoy, pro.Description, pro.Sequence " +
                                                DataFilter.GetFilteredQueryString(DataFilter.FromProtein))
                            .List <object[]>();

            foreach (var queryRow in queryRows)
            {
                if ((bool)queryRow[1] == false)  // skip decoys from the query
                {
                    pl.proteins.Add(new proteome.Protein((string)queryRow[0],
                                                         pl.proteins.Count,
                                                         (string)queryRow[2],
                                                         (string)queryRow[3]));
                }
            }

            if (addDecoys)
            {
                foreach (var queryRow in queryRows)
                {
                    if ((bool)queryRow[1] == false)  // skip decoys from the query
                    {
                        pl.proteins.Add(new proteome.Protein("rev_" + (string)queryRow[0],
                                                             pl.proteins.Count,
                                                             String.Empty, // decoys have no description
                                                             new string(((string)queryRow[3]).Reverse().ToArray())));
                    }
                }
            }

            pd.proteinList = pl;
            ProteomeDataFile.write(pd, outputFilepath);
        }