Beispiel #1
0
        static void OldMain(string[] args)
        {
            StreamWriter SW = new StreamWriter(HOME + "CountsByDate.csv");
            StreamReader SR = new StreamReader("FileLocations.csv");

            string[] lines = SR.ReadToEnd().Split('\n');
            lines = lines.Skip(1).ToArray();
            //  Parallel.ForEach(lines, line =>
            Console.WriteLine("Starting");
            foreach (string line in lines)
            {
                Console.WriteLine(line);

                try
                {
                    string[]       split     = line.Split(',');
                    string         fname     = split[0];
                    string         patientid = split[1];
                    string         date      = split[2];
                    var            mtReads   = MitoDataGrabber.OutputMitoReadsFromBamFile(fname);
                    FastAFormatter fao       = new FastAFormatter(HOME + patientid + ".fa");
                    long           count     = 0;
                    foreach (var seq in mtReads)
                    {
                        count++;
                        fao.Write(seq);
                    }
                    fao.Close();
                    FileInfo FI   = new FileInfo(fname);
                    string   size = FI.Length.ToString();
                    lock (SW)
                    {
                        SW.WriteLine(String.Join(",", patientid, count.ToString(), size, date));
                        Console.WriteLine(patientid + " has " + count.ToString() + " reads");
                    }
                    if (args.Length > 2)
                    {
                        break;
                    }
                }
                catch (Exception thrown)
                { Console.WriteLine(thrown.Message); }
            }
            //);
            SW.Close();
        }
        public void OutputMTReads()
        {
            if (String.IsNullOrEmpty(Filename))
            {
                throw new ArgumentNullException("No input file specified");
            }
            if (!Filename.EndsWith(BAM_FILE_SUFFIX))
            {
                throw new ArgumentNullException("Input file must be a .BAM file");
            }
            if (string.IsNullOrEmpty(OutputFile))
            {
                OutputFile = Filename.Remove(Filename.Length - BAM_FILE_SUFFIX.Length) + DEFAULT_EXPORT_SUFFIX;
            }
            IEnumerable <ISequence> mtReads;

            if (CRSAlignedOnly)
            {
                mtReads = MitoDataGrabber.OutputMitoReadsFromBamFileAlignedToCRSOnly(Filename, pfractionToOutput);
            }
            else
            {
                mtReads = MitoDataGrabber.OutputMitoReadsFromBamFile(Filename);
            }

            FastAFormatter fao   = new FastAFormatter(OutputFile);
            long           count = 0;

            foreach (var seq in mtReads)
            {
                count++;
                fao.Write(seq);
            }
            fao.Close();
            FileInfo FI = new FileInfo(OutputFile);

            Console.WriteLine("Wrote " + count.ToString() + " reads to output file.");
            Console.WriteLine("Of Size: " + GetMTDataFromBAM.Program.FormatMemorySize(FI.Length));
        }