/**
         * 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);
            }
        }
        /**
         * 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);
            }
        }
 ///<summary>
 ///Default constructor for the SaveFile class, accepts string to save and parameters for the savefiledialogue window
 ///</summary>
 ///<param name="output">The string to be saved</param>
 ///<param name="message">Message to be displayed on the save file dialogue window</param>
 ///<param name="filter">String to filter access to file types in the savefiledialogue window</param>
 public SaveFile(IFqFile file, String message, FastqGUI o, String saveType, String filter = "Text File|*.txt|FastqFile|*.fq")
 {
     this.fqFile = file;
     this.message = message;
     this.filter = filter;
     this.observer = o;
     this.saveAction = saveType;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a fqFile_component_details class from the core information that is best still stored within the programs memory.
        /// These classes populate a dictionary within the fqfilemap class where the component filename is their key.
        /// </summary>
        /// <param name="component">The component who's details are to be stored</param>
        public void BuildFqFileMap(IFqFile component)
        {
            FqFile_Component_Details componentDetails = new FqFile_Component_Details();

            componentDetails.ContructComponentDetails(component);

            fqFileMap.GetFqFileComponentDetailsMap()[component.getFileName()] = componentDetails;
        }
 ///<summary>
 ///Default constructor for the SaveFile class, accepts string to save and parameters for the savefiledialogue window
 ///</summary>
 ///<param name="output">The string to be saved</param>
 ///<param name="message">Message to be displayed on the save file dialogue window</param>
 ///<param name="filter">String to filter access to file types in the savefiledialogue window</param>
 public SaveFile(IFqFile file, String message, FastqGUI o, String saveType, String filter = "Text File|*.txt|FastqFile|*.fq")
 {
     this.fqFile     = file;
     this.message    = message;
     this.filter     = filter;
     this.observer   = o;
     this.saveAction = saveType;
 }
 public SequencerDecisionTree(IFqFile aFastqFile)
 {
     ASSUMPTION_POINT = Preferences.getInstance().getAssumptionPref();
     fastqFile        = aFastqFile;
     index            = fastqFile.getFastqArraySize();
     map = fastqFile.getMap();
     Console.WriteLine("Starting to search for sequencer");
     DecisionTree(fastqFile);
 }
 public SequencerDecisionTree(IFqFile aFastqFile)
 {
     ASSUMPTION_POINT = Preferences.getInstance().getAssumptionPref();
     fastqFile = aFastqFile;
     index = fastqFile.getFastqArraySize();
     map = fastqFile.getMap();
     Console.WriteLine("Starting to search for sequencer");
     DecisionTree(fastqFile);
 }
Exemplo n.º 8
0
 public IFqFile Parse()
 {
     if (IsStandardFormat == true)
     {
         FILE_FORMAT_TYPE = "Standard Fastq File Format";
         fastqFile        = ParseStandardFormat();
     }
     else if (IsMultiLineFormat == true)
     {
         FILE_FORMAT_TYPE = "Multi-Line Fastq File Format";
         fastqFile        = ParseMultiLineFormat();
     }
     return(fastqFile);
 }
 /// <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);
 }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
        private void SaveFastqAction(IFqFile fq, String fileName)
        {
            StreamWriter writer;

            try
            {
                writer = new StreamWriter(@fileName);
                saveWorker.ReportProgress(40, "[CREATING FASTQ FORMAT]");
                for (int i = 0; i < fqFile.getFastqArraySize(); i++)
                {
                    writer.Write(fqFile.getFastqSequenceByPosition(i).createFastqBlock(fqFile.getMap()));
                }
                saveWorker.ReportProgress(100, "[FASTQ FORMAT CREATED]");
                writer.Flush();
                writer.Close();
            }
            catch (IOException exception)
            {
                Console.WriteLine(exception.ToString());
                UserResponse.ErrorResponse(exception.ToString());
            }
        }
 /// <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);
     }
 }
 public void ContructComponentDetails(IFqFile component)
 {
     this.ComponentName              = component.getFileName();
     this.FileName                   = component.getFileName();
     this.sequencerType              = component.getSequencerType();
     this.ComponentNumber            = component.getComponentNumber();
     this.TotalNucs                  = component.getTotalNucleotides();
     this.TotalSequences             = component.getFastqArraySize();
     this.NucleotidesCleaned         = component.getNucleotidesCleaned();
     this.Distribution               = component.getDistribution();
     this.SequenceLengthDistribution = component.getSequenceLengthDistribution();
     this.NCount            = component.getNCount();
     this.CCount            = component.getCCount();
     this.GCount            = component.getGCount();
     this.MaxSeqSize        = component.getMaxSeqSize();
     this.MinSeqSize        = component.getMinSeqSize();
     this.NPercent          = component.nContents();
     this.CPercent          = component.cContents();
     this.GPercent          = component.gContents();
     this.SequencesRemoved  = component.getSequencesRemoved();
     this.RemovedAdapters   = component.getRemovedAdapters();
     this.perBaseStatistics = component.GetPerBaseStatisticsArray();
 }
Exemplo n.º 14
0
        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());
            }
        }
Exemplo n.º 15
0
        private void SaveFastaAction(IFqFile fq, String fileName)
        {
            saveWorker.ReportProgress(40, "[CREATING FASTA FORMAT]");
            String output = fqFile.createFastaFormat("");

            saveWorker.ReportProgress(100, "[FASTA FORMAT CREATED]");

            StreamWriter writer;

            try
            {
                writer = new StreamWriter(@fileName);

                writer.Write(output);

                writer.Flush();
                writer.Close();
            }
            catch (IOException exception)
            {
                Console.WriteLine(exception.ToString());
                UserResponse.ErrorResponse(exception.ToString());
            }
        }
Exemplo n.º 16
0
        private void SaveFastaAction(IFqFile fq, String fileName)
        {
            saveWorker.ReportProgress(40, "[CREATING FASTA FORMAT]");
            String output = fqFile.createFastaFormat("");
            saveWorker.ReportProgress(100, "[FASTA FORMAT CREATED]");

            StreamWriter writer;
            try
            {
                writer = new StreamWriter(@fileName);

                writer.Write(output);

                writer.Flush();
                writer.Close();
            }
            catch (IOException exception)
            {
                Console.WriteLine(exception.ToString());
                UserResponse.ErrorResponse(exception.ToString());
            }
        }
 public IFqFile Parse()
 {
     if (IsStandardFormat == true)
     {
         FILE_FORMAT_TYPE = "Standard Fastq File Format";
         fastqFile = ParseStandardFormat();
     }
     else if (IsMultiLineFormat == true)
     {
         FILE_FORMAT_TYPE = "Multi-Line Fastq File Format";
         fastqFile = ParseMultiLineFormat();
     }
     return fastqFile;
 }
        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());
        }
 public SequencerDetermination(IFqFile fastqFile)
 {
     map = fastqFile.getMap();
     sequencer(fastqFile);
 }
        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());
        }
Exemplo n.º 21
0
        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());
            }
        }
 public SequencerDetermination(IFqFile fastqFile)
 {
     map = fastqFile.getMap();
     sequencer(fastqFile);
 }
 public void ContructComponentDetails(IFqFile component)
 {
     this.ComponentName = component.getFileName();
     this.FileName = component.getFileName();
     this.sequencerType = component.getSequencerType();
     this.ComponentNumber = component.getComponentNumber();
     this.TotalNucs = component.getTotalNucleotides();
     this.TotalSequences = component.getFastqArraySize();
     this.NucleotidesCleaned = component.getNucleotidesCleaned();
     this.Distribution = component.getDistribution();
     this.SequenceLengthDistribution = component.getSequenceLengthDistribution();
     this.NCount = component.getNCount();
     this.CCount = component.getCCount();
     this.GCount = component.getGCount();
     this.MaxSeqSize = component.getMaxSeqSize();
     this.MinSeqSize = component.getMinSeqSize();
     this.NPercent = component.nContents();
     this.CPercent = component.cContents();
     this.GPercent = component.gContents();
     this.SequencesRemoved = component.getSequencesRemoved();
     this.RemovedAdapters = component.getRemovedAdapters();
     this.perBaseStatistics = component.GetPerBaseStatisticsArray();
 }
        /// <summary>
        /// Creates a fqFile_component_details class from the core information that is best still stored within the programs memory.
        /// These classes populate a dictionary within the fqfilemap class where the component filename is their key.
        /// </summary>
        /// <param name="component">The component who's details are to be stored</param>
        public void BuildFqFileMap(IFqFile component)
        {
            FqFile_Component_Details componentDetails = new FqFile_Component_Details();
            componentDetails.ContructComponentDetails(component);

            fqFileMap.GetFqFileComponentDetailsMap()[component.getFileName()] = componentDetails;
        }
Exemplo n.º 25
0
 private void SaveFastqAction(IFqFile fq, String fileName)
 {
     StreamWriter writer;
     try
     {
         writer = new StreamWriter(@fileName);
         saveWorker.ReportProgress(40, "[CREATING FASTQ FORMAT]");
         for (int i = 0; i < fqFile.getFastqArraySize(); i++)
         {
             writer.Write(fqFile.getFastqSequenceByPosition(i).createFastqBlock(fqFile.getMap()));
         }
         saveWorker.ReportProgress(100, "[FASTQ FORMAT CREATED]");
         writer.Flush();
         writer.Close();
     }
     catch (IOException exception)
     {
         Console.WriteLine(exception.ToString());
         UserResponse.ErrorResponse(exception.ToString());
     }
 }