1 // ==========================================================================
2 // SeqAn - The Library for Sequence Analysis
3 // ==========================================================================
4 // Copyright (c) 2006-2010, Knut Reinert, FU Berlin
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
9 //
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 // * Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 // * Neither the name of Knut Reinert or the FU Berlin nor the names of
16 // its contributors may be used to endorse or promote products derived
17 // from this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
23 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
29 // DAMAGE.
30 //
31 // ==========================================================================
32
33 #ifndef SEQAN_HEADER_BLAST_PARSING_H
34 #define SEQAN_HEADER_BLAST_PARSING_H
35
36
37 namespace SEQAN_NAMESPACE_MAIN
38 {
39
40 //////////////////////////////////////////////////////////////////////////////
41 // Internal Blast Parsing Functions
42 // remark: uses a lot of functions from graph_utility_parsing.h
43 //////////////////////////////////////////////////////////////////////////////
44
45
46
47 /////////////////////////////////////////////////////////////////////////////////
48 // read alignment string (letters and gaps)
49 // steht am ende dahinter
50 template<typename TFile, typename TChar>
51 inline String<char>
_parseReadAlignmentString(TFile & file,TChar & c)52 _parseReadAlignmentString(TFile & file, TChar& c)
53 {
54 SEQAN_CHECKPOINT
55 // Read word
56 String<char> str(c);
57 while (!_streamEOF(file)) {
58 c = _streamGet(file);
59 if (!_parseIsLetter(c) && !(c=='-')) break;
60 append(str, c);
61 }
62 return str;
63 }
64
65
66
67
68
69 ////////////////////////////////////////////////////////////////////////////
70 // parses query and database name (file should be pointing to the beginning of the file)
71 template<typename TFile, typename TChar>
72 typename Position<TFile>::Type
_parseReadQueryAndDBName(TFile & file,TChar & c,String<char> & query_name,String<char> & db_name)73 _parseReadQueryAndDBName(TFile & file,
74 TChar & c,
75 String<char> & query_name,
76 String<char> & db_name)
77 {
78 SEQAN_CHECKPOINT
79 typedef typename Position<TFile>::Type TPosition;
80 typedef typename Value<TFile>::Type TValue;
81
82 TChar c_before = c;
83 TPosition act_pos = _streamTellG(file);
84 TPosition query_pos,db_pos;
85
86 //String<char> delim = "DQ";
87 //_parseUntilBeginLineOneOf(file,c,delim,2);
88
89
90 String<char> query = "Query";
91 if(_parseUntilBeginLine(file,c,query,6))
92 query_pos = _streamTellG(file);
93 else
94 return act_pos;
95 _streamSeekG(file,act_pos);
96 c = c_before;
97 String<char> database = "Database";
98 if(_parseUntilBeginLine(file,c,database,8))
99 db_pos = _streamTellG(file);
100 else
101 return act_pos;
102
103
104 //getQueryName
105 _streamSeekG(file,query_pos);
106 _parseSkipWhitespace(file,c);
107 c = _streamGet(file);
108 _parseSkipWhitespace(file,c);
109 query_name = _parseReadWord(file, c);
110 while (!_streamEOF(file) && c != '\n' && c != '\r')
111 query_name += _parseReadWord(file, c);
112
113 //getDBName
114 _streamSeekG(file,db_pos);
115 c = _streamGet(file);
116 _parseSkipWhitespace(file,c);
117 db_name = _parseReadWord(file, c);
118 while (!_streamEOF(file) && c != '\n' && c != '\r')
119 db_name += _parseReadWord(file, c);
120 _parseSkipWhitespace(file,c);
121
122 c = _streamGet(file);
123
124 return _streamTellG(file);
125
126 }
127
128
129
130
131
132
133
134
135 }// namespace SEQAN_NAMESPACE_MAIN
136
137 #endif //#ifndef SEQAN_HEADER_...
138