public override IEnumerable <string> Process() { var countfiles = options.GetCountFiles(); List <CountItem> counts = new List <CountItem>(); foreach (var file in countfiles) { Progress.SetMessage("reading " + file.File + " ..."); var count = new CountItem() { Dir = file.Name, Data = (from line in File.ReadAllLines(file.File).Skip(1) let parts = line.Split('\t') where parts.Length >= 6 select parts).ToDictionary(m => m[0]) }; counts.Add(count); } var features = (from c in counts from k in c.Data.Keys select k).Distinct().OrderBy(m => m).ToList(); var checkSequence = counts.First().Data.First().Value[2]; double value; var hasSequence = !double.TryParse(checkSequence, out value); var seqheader = hasSequence ? "\tSequence" : ""; var startIndex = hasSequence ? 3 : 2; using (StreamWriter sw = new StreamWriter(options.OutputFile)) using (StreamWriter swIso = new StreamWriter(options.IsomirFile)) { sw.WriteLine("Feature\tLocation{0}\t{1}", seqheader, (from c in counts select c.Dir).Merge("\t")); swIso.WriteLine("Feature\tLocation{0}\t{1}", seqheader, (from c in counts select c.Dir).Merge("\t")); foreach (var feature in features) { OutputCount(counts, sw, feature, startIndex, "", hasSequence); OutputCount(counts, swIso, feature, startIndex + 1, "_+_0", hasSequence); OutputCount(counts, swIso, feature, startIndex + 2, "_+_1", hasSequence); OutputCount(counts, swIso, feature, startIndex + 3, "_+_2", hasSequence); } } var result = new[] { options.OutputFile, options.IsomirFile }.ToList(); var infofile = Path.ChangeExtension(options.OutputFile, ".info"); if (CountUtils.WriteInfoSummaryFile(infofile, options.GetCountFiles().ToDictionary(m => m.Name, m => m.File))) { result.Add(infofile); } return(result); }
public override IEnumerable <string> Process() { var countfiles = options.GetCountFiles(); var dic = new Dictionary <string, Dictionary <string, MappedMirnaGroup> >(); foreach (var file in countfiles) { Progress.SetMessage("Reading miRNA mapped file " + file.File + " ..."); var mirnas = new MappedMirnaGroupXmlFileFormat().ReadFromFile(file.File); dic[file.Name] = mirnas.ToDictionary(m => m.DisplayName); } var features = (from c in dic.Values from k in c.Keys select k).Distinct().OrderBy(m => m).ToList(); var names = dic.Keys.OrderBy(m => m).ToList(); using (StreamWriter sw = new StreamWriter(options.OutputFile)) using (StreamWriter swNTA = new StreamWriter(options.NTAFile)) using (StreamWriter swIso = new StreamWriter(options.IsomirFile)) using (StreamWriter swIsoNTA = new StreamWriter(options.IsomirNTAFile)) { sw.WriteLine("Feature\tLocation\tSequence\t{0}", names.Merge("\t")); swNTA.WriteLine("Feature\tLocation\tSequence\t{0}", names.Merge("\t")); swIso.WriteLine("Feature\tLocation\tSequence\t{0}", names.Merge("\t")); swIsoNTA.WriteLine("Feature\tLocation\tSequence\t{0}", names.Merge("\t")); foreach (var feature in features) { OutputCount(sw, dic, feature, names, MirnaConsts.NO_OFFSET, false, ""); OutputCount(swNTA, dic, feature, names, MirnaConsts.NO_OFFSET, true, ""); OutputCount(swIso, dic, feature, names, 0, false, "_+_0"); OutputCount(swIso, dic, feature, names, 1, false, "_+_1"); OutputCount(swIso, dic, feature, names, 2, false, "_+_2"); OutputCount(swIsoNTA, dic, feature, names, 0, true, "_+_0"); OutputCount(swIsoNTA, dic, feature, names, 1, true, "_+_1"); OutputCount(swIsoNTA, dic, feature, names, 2, true, "_+_2"); } } var result = new[] { options.OutputFile, options.IsomirFile, options.NTAFile, options.IsomirNTAFile }.ToList(); return(result); }