예제 #1
0
        public UnparsedFile ReadFile(string [] lines)
        {
            var unparsedFile = new UnparsedFile();

            foreach (string line in lines)
            {
                if (line.StartsWith("S"))
                {
                    unparsedFile.CommentLineFromFile = line;
                }
                else if (line.StartsWith("f"))
                {
                    unparsedFile.FamilyLinesFromFile.Add(line);
                }
                else if (line.StartsWith("a"))
                {
                    unparsedFile.AccessionLinesFromFile.Add(line);
                }
                else if (line.StartsWith(">") || line.StartsWith("A") || line.StartsWith("T") || line.StartsWith("C") || line.StartsWith("G"))
                {
                    unparsedFile.FastaLinesFromFile.Add(line);
                }
            }
            return(unparsedFile);
        }
예제 #2
0
        public ParsedFile ParseFile(string fileName, UnparsedFile unparsedFile)
        {
            var partiallyParsedFileC   = ParseCommentLine(fileName, unparsedFile);
            var partiallyParsedFileCF  = ParseFamilySection(partiallyParsedFileC, unparsedFile);
            var partiallyParsedFileCFA = ParseAccessionSection(partiallyParsedFileCF, unparsedFile);
            var parsedFile             = ParseFastaSection(partiallyParsedFileCFA, unparsedFile);
            var finishedFile           = CreateDbEntry(parsedFile);

            return(finishedFile);
        }
예제 #3
0
        public ParsedFile ParseAccessionSection(ParsedFile partiallyParsedFileCF, UnparsedFile unparsedFile)
        {
            int i = 1;

            string[] temp;
            foreach (string line in unparsedFile.AccessionLinesFromFile)
            {
                temp = line.Split(new char[] { ';' });
                var accessionSection = ParseAccessionSectionLine(temp, i, unparsedFile.Sra);
                partiallyParsedFileCF.AccessionSections.Add(accessionSection);
                i++;
            }
            var partiallyParsedFileCFA = partiallyParsedFileCF;

            return(partiallyParsedFileCFA);
        }
예제 #4
0
        public ParsedFile ParseFamilySection(ParsedFile partiallyParsedFileC, UnparsedFile unparsedFile)
        {
            int i = 1;

            string[] temp;
            foreach (string line in unparsedFile.FamilyLinesFromFile)
            {
                temp = line.Split(new char[] { ';' });
                var familySection = ParseFamilySectionLine(temp, i, unparsedFile.Sra);
                partiallyParsedFileC.FamilySections.Add(familySection);
                i++;
            }
            var partiallyParsedFileCF = partiallyParsedFileC;

            return(partiallyParsedFileCF);
        }
예제 #5
0
        public ParsedFile ParseCommentLine(string fileName, UnparsedFile unparsedFile)
        {
            string[] split = unparsedFile.CommentLineFromFile.Split(new char[] { ',' });
            string[] sra   = split[0].Split(new char[] { '=' });
            string[] gen   = split[1].Split(new char[] { '=' });
            string[] date  = split[2].Split(new char[] { '=' });
            unparsedFile.Sra = sra[2];
            var run = new Run();

            run.FileName = fileName;
            run.Sra      = sra[2];
            run.Genome   = gen[1];
            run.Date     = date[1];
            var partiallyParsedFile = new ParsedFile();

            partiallyParsedFile.Run = run;
            return(partiallyParsedFile);
        }
예제 #6
0
        public ParsedFile ParseFastaSection(ParsedFile partiallyParsedFileCFA, UnparsedFile unparsedFile)
        {
            bool          first      = true;
            bool          second     = false;
            int           i          = 1;
            int           j          = 0;
            List <string> firstLine  = new List <string>();
            List <string> secondLine = new List <string>();
            List <int>    lineNumber = new List <int>();

            foreach (string line in unparsedFile.FastaLinesFromFile)
            {
                if (first)
                {
                    firstLine.Add(line);
                    first = !first;
                }
                if (second)
                {
                    secondLine.Add(line);
                    lineNumber.Add(i);
                    i++;
                    first = !first;
                    partiallyParsedFileCFA.FastaSections.Add(new FastaSection
                    {
                        FastaSectionLineId = lineNumber[j],
                        Sra        = unparsedFile.Sra,
                        SequenceId = firstLine[j],
                        Sequence   = secondLine[j]
                    });
                    j++;
                }
                second = !second;
            }
            var parsedFile = partiallyParsedFileCFA;

            return(parsedFile);
        }