Exemplo n.º 1
0
        public static void GenerateMatrix()
        {
            var sites = CleavageSiteUtility.Deserialize();

            float[,] matrix = new float[sites.Count, 21];

            for (int i = 0; i < sites.Count; i++)
            {
                System.Console.WriteLine(sites[i].Gene);
                for (int j = 0; j < 21; j++)
                {
                    matrix[i, j] = Reactivity.GetReactivity(sites[i].Gene, sites[i].StartAt + j - 1);
                }
            }

            //print
            string content = string.Empty;

            for (int i = 0; i < matrix.GetLength(0); i++)
            {
                for (int j = 0; j < matrix.GetLength(1); j++)
                {
                    content += matrix[i, j].ToString() + ",";
                }
                content = content.TrimEnd(',') + "\n";
            }

            FileExtension.Save(content, Config.WorkingFolder + "cs_21_reactivity.csv");
        }
Exemplo n.º 2
0
        private static void GenerateShapeFile(CleavageSite site, int startAt, int endAt, string fileName)
        {
            string content = string.Empty;

            for (int position = startAt; position < endAt; position++)
            {
                content += $"{position - startAt + 1} {Reactivity.GetReactivity(site.Gene, position)}\r\n";
            }
            FileExtension.Save(content, fileName);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Genes that can be found in the cleavage efficiency files and the reactivity file.
 /// </summary>
 public static string[] GetValidNamesAll()
 {
     if (File.Exists(Config.WorkingFolder + "genes_have_all.txt"))
     {
         return(FileExtension.ReadList(Config.WorkingFolder + "genes_have_all.txt"));
     }
     string[] csNames      = GetValidNames();
     string[] eNames       = Degradome.GetValidNames();
     string[] rNames       = Reactivity.GetValidNames();
     string[] intersection = csNames.Intersect(eNames).Intersect(rNames).ToArray();
     FileExtension.SaveList(Config.WorkingFolder + "genes_have_all.txt", intersection);
     return(intersection);
 }
Exemplo n.º 4
0
 public static void GenerateAll()
 {
     GetValidNamesAll();
     Degradome.ToCleavageEfficiency();
     Reactivity.Serialise();
     Gene.Serialise();
     GenerateCleavegeSites();
     GenerateCleavageSiteFiles();
     GenerateAverageReactivity();
     GenerateStructureFiles();
     // step 9
     GenerateRnaStructPlots();
     // step 10
     RnaDistancePreprocess.Process();
 }
Exemplo n.º 5
0
        private static float[][] GetAverageAndStandardDeviation(int datasetIndex, DegradomeType dType)
        {
            var list = ReadCleavageSite($"{Config.WorkingFolder}\\cleavage_sites_{dType}_{datasetIndex}.csv");

            float[][] matrix = new float[21][];
            float[][] stats  = new float[2][];
            //average

            stats[AVG] = new float[21];
            //StandardDeviation

            stats[SD] = new float[21];

            for (int col = 0; col < 21; col++)
            {
                matrix[col] = new float[list.Count];
                for (int row = 0; row < list.Count; row++)
                {
                    try
                    {
                        var site = list[row];
                        matrix[col][row] = Reactivity.GetReactivity(site.Gene, site.StartAt - 1 + col);
                    }
                    catch
                    {
                    }
                }
            }

            for (int col = 0; col < 21; col++)
            {
                stats[AVG][col] = matrix[col].Average();
                stats[SD][col]  = (float)matrix[col].StandardDeviation();
            }

            return(stats);
        }
Exemplo n.º 6
0
        public static void Filter()
        {
            var    sites = CleavageSiteUtility.Deserialize();
            string deletedCleavageSite   = string.Empty;
            List <CleavageSite> toDelete = new List <CleavageSite>();

            foreach (var site in sites)
            {
                if (!Reactivity.HasReactivity(site.Gene))
                {
                    toDelete.Add(site);
                    deletedCleavageSite += site.ToString() + "\r\n";
                }
            }

            foreach (var site in toDelete)
            {
                sites.Remove(site);
            }
            FileExtension.Save(deletedCleavageSite, "CleavageSite_Filtered_by_Reactivity.txt");

            Serializer.Serialize("cleavage_sites.bin", sites);
            //return sites;
        }
Exemplo n.º 7
0
        public static void GenerateCleavageSiteFiles()
        {
            List <CleavageSite> sites = new List <CleavageSite>();

            string[] lines = FileExtension.ReadList(Config.WorkingFolder + "cleavage_sites.csv");
            Console.WriteLine($"Total Cleavage Sites:{lines.Length}");
            foreach (string line in lines)
            {
                var          arr  = line.Split('_');
                CleavageSite site = CleavageSite.Parse(line);
                sites.Add(site);
            }
            Console.WriteLine($"After filtered by cleavage efficiency and reactivity:{sites.Count}");

            //Generate 4 files filtered by 4 degradome datasets.
            foreach (DegradomeType dType in EnumUtil.GetValues <DegradomeType>())
            {
                string site_content           = string.Empty;
                string efficiency_content     = string.Empty;
                string efficiency_log_content = string.Empty;
                string reactivity_content     = string.Empty;
                string reactivity_25_content  = string.Empty;
                string reactivity_50_content  = string.Empty;
                //string reactivity_75_content = string.Empty;
                //string reactivity_100_content = string.Empty;

                foreach (CleavageSite site in sites)
                {
                    if (site.Extendability < 50)
                    {
                        break;
                    }

                    //if the cleavage efficiency is zero,
                    //we can say that this is not a cleavage site.
                    //filter it out.
                    float efficiency = Efficiency.GetEfficiency(site, dType);
                    if (efficiency == 0)
                    {
                        continue;
                    }

                    site_content           += site.ToString() + "\n";
                    efficiency_content     += efficiency.ToString() + "\n";
                    efficiency_log_content += Math.Log(efficiency).ToString() + "\n";
                    for (int j = 0; j < 21; j++)
                    {
                        reactivity_content += Reactivity.GetReactivity(site.Gene, site.StartAt - 1 + j) + ",";
                    }

                    for (int j = 0 - 25; j < 21 + 25; j++)
                    {
                        reactivity_25_content += Reactivity.GetReactivity(site.Gene, site.StartAt - 1 + j) + ",";
                    }

                    for (int j = 0 - 50; j < 21 + 50; j++)
                    {
                        reactivity_50_content += Reactivity.GetReactivity(site.Gene, site.StartAt - 1 + j) + ",";
                    }

                    reactivity_content    = reactivity_content.TrimEnd(',') + "\n";
                    reactivity_25_content = reactivity_25_content.TrimEnd(',') + "\n";
                    reactivity_50_content = reactivity_50_content.TrimEnd(',') + "\n";
                }
                FileExtension.Save(site_content, Config.WorkingFolder + "\\cleavage_site_" + dType + ".csv");
                FileExtension.Save(efficiency_content, Config.WorkingFolder + "\\cs_efficiencies_" + dType + ".csv");
                FileExtension.Save(efficiency_log_content, Config.WorkingFolder + "\\cs_efficiencies_log_" + dType + ".csv");
                FileExtension.Save(reactivity_content, Config.WorkingFolder + "\\cs_reactivity_" + dType + ".csv");
                FileExtension.Save(reactivity_25_content, Config.WorkingFolder + "\\cs_reactivity_" + dType + "_25.csv");
                FileExtension.Save(reactivity_50_content, Config.WorkingFolder + "\\cs_reactivity_" + dType + "_50.csv");
                //FileExtension.Save(reactivity_75_content, Config.WorkingFoler + "\\cs_reactivity_" + dType + "_75.csv");
                //FileExtension.Save(reactivity_100_content, Config.WorkingFoler + "\\cs_reactivity_" + dType + "_100.csv");
            }
        }