/** * This method outlines the first decision to test quality data and return whether it resides * in the higher ASCII regions greater than character J or in the lower regions below this * point * @param fastqFile */ private void DecisionTree(IFqFile fastqFile) { stopwatch.Start(); Boolean upper = false, lower = false; int i = 0, j = 0; for (i = 0; i < index; i++) { fastqSeq = fastqFile.getFastqSequenceByPosition(i); for (j = 0; j < fastqSeq.getFastqSeqSize(); j++) { char qualityValue = map[fastqSeq.getFastqSeqAtPosition(j)].getQualityRead(); if (qualityValue > 'J') { upper = true; goto search; } else if (qualityValue < ';') { lower = true; goto search; } } } search: if (upper == true) { upperTree(i, j); } else if (lower == true) { lowerTree(i, j); } }
private void illuminaEightNine(int startPosition, int startPos) { Boolean illuminaEight = false; int i = startPosition, j = startPos; for (i = startPosition; i < index; i++) { fastqSeq = fastqFile.getFastqSequenceByPosition(i); for (j = startPos; j < fastqSeq.getFastqSeqSize(); j++) { char qualityValue = map[fastqSeq.getFastqSeqAtPosition(j)].getQualityRead(); if (qualityValue < '#') { illuminaEight = true; goto search; } else if (i == ASSUMPTION_POINT + startPosition) { sequencerType = "Illumina 1.9"; end(i); goto search; } } } search: if (illuminaEight == true) { sequencerType = "Illumina 1.8"; end(i); } }
private void solexaIllumina3(int startPosition, int startPos) { Boolean solexa = false; int i, j; Console.WriteLine("uppersearch - solexa illumina3"); for (i = startPosition; i < index; i++) { fastqSeq = fastqFile.getFastqSequenceByPosition(i); for (j = startPos; j < fastqSeq.getFastqSeqSize(); j++) { char qualityValue = map[fastqSeq.getFastqSeqAtPosition(j)].getQualityRead(); if (qualityValue < '@') { solexa = true; goto search; } else if (i == ASSUMPTION_POINT + startPosition) { sequencerType = "Illumina 1.3"; end(i); goto search; } } } search: if (solexa == true) { sequencerType = "Solexa"; end(i); } }
/*--------------Upper ASCII ISequencer Types-------------------*/ /** * This method is created if the data set shows that the sequencer is likely from the * solexa, illumina 1.3 or 1.5 branches. startPosition is the starting point to iterate * through array * @param startPosition */ private void upperTree(int startPosition, int startPos) { Boolean solexa = false, jointSolexaIllumina = false; int i = startPosition, j = startPos; Console.WriteLine("uppersearch - upper tree"); for (i = startPosition; i < index; i++) { fastqSeq = fastqFile.getFastqSequenceByPosition(i); for (j = startPos; j < fastqSeq.getFastqSeqSize(); j++) { char qualityValue = map[fastqSeq.getFastqSeqAtPosition(j)].getQualityRead(); if (qualityValue < 'B') { jointSolexaIllumina = true; goto search; } else if (qualityValue < '@') { solexa = true; goto search; } else if (i == ASSUMPTION_POINT + startPosition) { sequencerType = "Illumina 1.5"; end(i); goto search; } } } search: if (solexa == true) { sequencerType = "Solexa"; end(i); } else if (jointSolexaIllumina == true) { this.solexaIllumina3(i, j); } }
private void sangerIlluminaEight(int startPosition, int startPos) { Boolean illumina8 = false; int i, j; for (i = startPosition; i < index; i++) { fastqSeq = fastqFile.getFastqSequenceByPosition(i); for (j = startPos; j < fastqSeq.getFastqSeqSize(); j++) { char qualityValue = map[fastqSeq.getFastqSeqAtPosition(j)].getQualityRead(); if (qualityValue > 'I') { illumina8 = true; goto search; } else if (i == ASSUMPTION_POINT + startPosition) { sequencerType = "Sanger"; end(i); goto search; } } } search: if (illumina8 == true) { sequencerType = "Illumina 1.8"; end(i); } }
/*-----------------Lower ASCII ISequencer Regions-------------------*/ private void lowerTree(int startPosition, int startPos) { Boolean sangerEight = false, illuminaEightNine = false; int i = startPosition; int j = startPos; for (i = startPosition; i < index; i++) { fastqSeq = fastqFile.getFastqSequenceByPosition(i); for (j = startPos; j < fastqSeq.getFastqSeqSize(); j++) { char qualityValue = map[fastqSeq.getFastqSeqAtPosition(j)].getQualityRead(); if (qualityValue < '#') { sangerEight = true; goto search; } else if (qualityValue > 'I') { illuminaEightNine = true; goto search; } else if (i == ASSUMPTION_POINT + startPosition) { sequencerType = "Illumina 1.9"; end(i); goto search; } } } search: if (sangerEight == true) { this.sangerIlluminaEight(i, j); } else if (illuminaEightNine == true) { this.illuminaEightNine(i, j); } }
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()); } }
private void sequencer(IFqFile fastqFile) { String sequencer = null; Boolean completed = false; Boolean sangerLowerBoundary = false, sangerUpperBoundary = false, solexaLowerBoundary = false, sharedUpperBoundary = false, illuminaThreeLowerBoundary = false, illuminaFiveLowerBoundary = false, illuminaEightLowerBoundary = false, illuminaNineLowerBoundary = false, illuminaEightNineUpperBoundary = false; // char variables for the upper and lower boundaries of the sequencer types char sangerLower = '!'; char sangerUpper = 'I'; char solexaLower = ';'; char solilmixedUpper = 'h'; char illuminathreeLower = '@'; char illuminafiveLower = 'B'; char illuminaeightLower = '!'; char illuminanineLower = '#'; char illuminamixedUpper = 'J'; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); while (completed != true) { for (int i = 0; i < fastqFile.getFastqArraySize(); i++) { FqSequence fqSeq = fastqFile.getFastqSequenceByPosition(i); for (int j = 0; j < fqSeq.getFastqSeqSize(); j++) { char qualityValue = map[fqSeq.getFastqSeqAtPosition(j)].getQualityRead(); if (qualityValue == sangerLower) { sangerLowerBoundary = true; } else if (qualityValue == sangerUpper) { sangerUpperBoundary = true; } else if (qualityValue == solexaLower) { solexaLowerBoundary = true; } else if (qualityValue == solilmixedUpper) { sharedUpperBoundary = true; } else if (qualityValue == illuminathreeLower) { illuminaThreeLowerBoundary = true; } else if (qualityValue == illuminafiveLower) { illuminaFiveLowerBoundary = true; } else if (qualityValue == illuminaeightLower) { illuminaEightLowerBoundary = true; } else if (qualityValue == illuminanineLower) { illuminaNineLowerBoundary = true; } else if (qualityValue == illuminamixedUpper) { illuminaEightNineUpperBoundary = true; } } } if (sangerLowerBoundary != false && sangerUpperBoundary != false && illuminaEightNineUpperBoundary != true) { sequencer = "Sanger"; completed = true; } else if (solexaLowerBoundary != false && sharedUpperBoundary != false) { sequencer = "Solexa"; completed = true; } else if (illuminaThreeLowerBoundary != false && sharedUpperBoundary != false && solexaLowerBoundary != true) { sequencer = "Illumina 1.3"; completed = true; } else if (illuminaFiveLowerBoundary != false && sharedUpperBoundary != false && illuminaThreeLowerBoundary != true) { sequencer = "Illumina 1.5"; completed = true; } else if (illuminaEightLowerBoundary != false && illuminaEightNineUpperBoundary != false) { sequencer = "Illumina 1.8"; completed = true; } else if (illuminaNineLowerBoundary != false && illuminaEightNineUpperBoundary != false && illuminaEightLowerBoundary != true) { sequencer = "Illumina 1.9"; completed = true; } else if (completed != true) { sequencer = "Default"; completed = true; } else if ((sequencer == null)) { sequencer = "Default"; completed = true; } } this.sequencerType = sequencer; fastqFile.setSequencerType(sequencerType); if (fastqFile is FqFile_Component) { fastqFile.setFqHashMap(FastqController.getInstance().GetFqFileMap().ConstructSequencerSpecificReadMap(sequencerType)); Console.WriteLine("Calculating and setting sequencer specific file map to component"); } stopwatch.Stop(); Console.WriteLine("Time To Determine ISequencer: " + stopwatch.Elapsed); Console.WriteLine("ISequencer Name: " + sequencer); Console.WriteLine("File contains {0} sequences", fastqFile.getFastqArraySize()); }