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); }
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()); } }