Example #1
0
        public static void Intersection(params string[] files)
        {
            List <List <string> > listlist = new List <List <string> >();

            foreach (string file in files)
            {
                List <string> cleavagelist = new List <string>();
                using (StreamReader sr = new StreamReader(file))
                {
                    while (!sr.EndOfStream)
                    {
                        string line = sr.ReadLine();
                        if (string.IsNullOrWhiteSpace(line))
                        {
                            continue;
                        }

                        cleavagelist.Add(line);
                    }
                }
                listlist.Add(cleavagelist);
            }

            var intersect = ListExtension <string> .Intersect(listlist);

            using (StreamWriter sw = new StreamWriter(@"F:\JIC\Arabidopsis\CleavageSites\intersect.txt"))
            {
                foreach (string key in intersect)
                {
                    sw.WriteLine(key);
                }
                sw.Flush();
                sw.Close();
            }
        }
Example #2
0
        public static void ToCleavageEfficiency()
        {
            var abundance = GetReads(Config.CleavageBaseFile);
            Dictionary <string, float> abundance_per_gene = new Dictionary <string, float>();

            foreach (var kv in abundance)
            {
                abundance_per_gene.Add(kv.Key, kv.Value.Sum());
            }
            float abundance_total = abundance_per_gene.Values.Sum();


            foreach (DegradomeType dType in EnumUtil.GetValues <DegradomeType>())
            {
                var reads = GetReads(Config.GetDegradomeFile(dType));
                Dictionary <string, float[]> ce_dict = new Dictionary <string, float[]>();
                foreach (var kv in reads)
                {
                    if (!Config.ValidNames.Contains(kv.Key))
                    {
                        continue;
                    }

                    if (!abundance.ContainsKey(kv.Key))
                    {
                        continue;
                    }
                    float times = 1.0f / abundance_per_gene[kv.Key] / abundance[kv.Key].Length;

                    float[] values = new float[reads[kv.Key].Length];
                    for (int i = 0; i < reads[kv.Key].Length; i++)
                    {
                        values[i] = reads[kv.Key][i] * times;
                    }
                    ce_dict.Add(kv.Key, values);
                }
                Dictionary <string, Dictionary <int, float> > dict_dict = ListExtension.ToDict(ce_dict);
                Efficiency.dict[dType] = dict_dict;
                Serializer.Serialize($"ce_{dType}_dict.bin", dict_dict);
            }
        }