Beispiel #1
0
        public override GenericFastqInputs perform(GenericFastqInputs inputs)
        {
            StreamWriter writer;
            String       extension = Path.GetExtension(inputs.SaveFileName);
            String       fileName  = Path.GetFileNameWithoutExtension(inputs.SaveFileName);

            String[] part      = Path.GetFileNameWithoutExtension(inputs.FastqFile.getFileName()).Split('_');
            String   directory = Path.GetDirectoryName(inputs.SaveFileName);
            String   number    = part[part.Length - 1];

            String FullName = String.Format(@"{0}{1}{2}_{3}{4}", directory, Path.DirectorySeparatorChar, fileName, number, extension);

            string COMMA_DELIMITER = ",";

            string[] output;

            IFqFile fqFile = inputs.FastqFile;

            writer = new StreamWriter(FullName);

            output = new string[] { "Sequence Index", "Header", "Total Nucleotides", "G Count", "C Count", "Misread Count", "Lower Threshold", "First Quartile",
                                    "Median", "Mean", "Third Quartile", "Upper Threshold" };
            writer.WriteLine(string.Join(COMMA_DELIMITER, output));

            for (int i = 0; i < fqFile.getFastqArraySize(); i++)
            {
                FqSequence fqSeq = fqFile.getFastqSequenceByPosition(i);
                output = new string[] { fqSeq.getSeqIndex().ToString(), fqSeq.getSequenceHeader(), fqSeq.getFastqSeqSize().ToString(), fqSeq.getGCount().ToString(),
                                                                        fqSeq.getCCount().ToString(), fqSeq.getNCount().ToString(), fqSeq.getLowerThreshold().ToString(),
                                                                        fqSeq.getFirstQuartile().ToString(), fqSeq.getMedian().ToString(), fqSeq.getMean().ToString(),
                                                                        fqSeq.getThirdQuartile().ToString(), fqSeq.getUpperThreshold().ToString(),
                                                                        fqSeq.createSequenceString(fqFile.getMap()) };
                writer.WriteLine(string.Join(COMMA_DELIMITER, output));
            }

            Console.WriteLine("Saving CSV TO: {0}", FullName);
            writer.Flush();
            writer.Close();
            return(inputs);
        }
 /// <summary>
 /// Outputs the data for a FastqFile to the console, keeping code clean in other classes
 /// </summary>
 /// <param name="fqFile"></param>
 public void OutputFileDataToConsole(IFqFile fqFile)
 {
     Console.WriteLine("Joint Test Results Completed on " + fqFile.getTotalNucleotides() + " Nucleotides");
     Console.WriteLine("Joint Test Results: " + fqFile.getGCount() + "G   " + Math.Round(fqFile.gContents(), 2) + "%   " + fqFile.getCCount() + "C " + Math.Round(fqFile.cContents(), 2) + " %");
     Console.WriteLine("Misreads:  " + fqFile.getNCount());
     Console.WriteLine("Nucleotides Cleaned: {0}", fqFile.getNucleotidesCleaned());
     Console.WriteLine("Distribution:  " + fqFile.getDistribution().Count);
     Console.WriteLine("Stats Performed");
     for (int i = 0; i < 20; i++)
     {
         FqSequence fqSeq = fqFile.getFastqSequenceByPosition(i);
         Console.WriteLine("--  -Stats for Sequence " + (i + 1) + ": LB: {0}  1Q: {1}  Median: {2} Mean: {3} 3Q: {4} UB: {5}", fqSeq.getLowerThreshold(), fqSeq.getFirstQuartile(), fqSeq.getMedian(), Math.Round(fqSeq.getMean(), 2), fqSeq.getThirdQuartile(), fqSeq.getUpperThreshold());
     }
     for (int i = 0; i < fqFile.getDistribution().Count; i++)
     {
         Console.WriteLine("--->  Quality Score: {0}   Count: {1}", i, fqFile.getDistribution()[i]);
     }
     for (int i = 0; i < fqFile.GetPerBaseStatisticsArray().Length; i++)
     {
         Console.WriteLine("===> BaseStatistic: {0} \tCount: {1} LB: {2}  1Q: {3}  Median: {4} Mean: {5} 3Q: {6} UB: {7}", i, fqFile.GetPerBaseStatisticsArray()[i].BaseCount, fqFile.GetPerBaseStatisticsArray()[i].LowerThreshold, fqFile.GetPerBaseStatisticsArray()[i].FirstQuartile, fqFile.GetPerBaseStatisticsArray()[i].Median, fqFile.GetPerBaseStatisticsArray()[i].Mean, fqFile.GetPerBaseStatisticsArray()[i].ThirdQuartile, fqFile.GetPerBaseStatisticsArray()[i].UpperThreshold);
     }
 }
        private void SaveCSVAction(IFqFile fq, String fileName)
        {
            StreamWriter writer;

            string COMMA_DELIMITER = ",";

            string[] output;

            try
            {
                writer = new StreamWriter(@fileName);
                saveWorker.ReportProgress(30, "[CREATING CSV FORMAT]");

                output = new string[] { "Sequence Index", "Header", "Total Nucleotides", "G Count", "C Count", "Misread Count", "Lower Threshold", "First Quartile",
                                        "Median", "Mean", "Third Quartile", "Upper Threshold" };
                writer.WriteLine(string.Join(COMMA_DELIMITER, output));

                for (int i = 0; i < fqFile.getFastqArraySize(); i++)
                {
                    FqSequence fqSeq = fqFile.getFastqSequenceByPosition(i);
                    output = new string[] { fqSeq.getSeqIndex().ToString(), fqSeq.getSequenceHeader(), fqSeq.getFastqSeqSize().ToString(), fqSeq.getGCount().ToString(),
                                                                            fqSeq.getCCount().ToString(), fqSeq.getNCount().ToString(), fqSeq.getLowerThreshold().ToString(),
                                                                            fqSeq.getFirstQuartile().ToString(), fqSeq.getMedian().ToString(), fqSeq.getMean().ToString(),
                                                                            fqSeq.getThirdQuartile().ToString(), fqSeq.getUpperThreshold().ToString(),
                                                                            fqSeq.createSequenceString(fqFile.getMap()) };
                    writer.WriteLine(string.Join(COMMA_DELIMITER, output));
                }
                saveWorker.ReportProgress(100, "[FASTQ FORMAT CREATED]");
                writer.Flush();
                writer.Close();
            }
            catch (IOException exception)
            {
                Console.WriteLine(exception.ToString());
                UserResponse.ErrorResponse(exception.ToString());
            }
        }