Ejemplo n.º 1
0
        public IFqFile ParseStandardFormat()
        {
            sw = new Stopwatch();
            sw.Start();
            int seqIndex = 0;

            BufferedStream bs;
            StreamReader   reader;

            try
            {
                bs     = new BufferedStream(fileReader);
                reader = new StreamReader(bs, System.Text.Encoding.ASCII);

                if (IsFastqFile == true)
                {
                    FastqController.getInstance().GetFqFileMap().FastqFileFormatType = FILE_FORMAT_TYPE;
                    FqNucleotideRead fqRead = new FqNucleotideRead(' ', ' ');
                    //fastqFile = FqFileSpecifier.getInstance().getFqFile(Preferences.getInstance().getMultiCoreProcessing());
                    fastqFile.setFastqFileName(fileName);

                    long nLine = -1L;

                    while ((fastqHeader = reader.ReadLine()) != null)
                    {
                        nLine++;

                        if (nLine % 4 != 0)
                        {
                            continue;
                        }

                        String seqlist    = reader.ReadLine();
                        String infoHeader = reader.ReadLine();
                        String qscore     = reader.ReadLine();

                        fqSeq = new FqSequence(seqIndex, fastqHeader, infoHeader, seqlist.Length);
                        seqIndex++;

                        for (int i = 0; i < (seqlist.Length); i++)
                        {
                            fqRead.resetFqNucleotideRead(seqlist[i], qscore[i]);
                            int hashcode = fqRead.getProxyCode();
                            fqSeq.addNucleotideRead(hashcode);
                        }
                        fastqFile.addFastqSequence(fqSeq);
                        nLine += 3;
                    }
                    sw.Stop();
                    Console.WriteLine("Time to Parse File:  " + sw.Elapsed + "s");
                }
            }
            finally
            {
                fileReader.Close();
            }
            return(fastqFile);
        }