librostlab-blast
1.0.1
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
rostlab
blast-result.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2011 Laszlo Kajan, Technical University of Munich, Germany
3
4
This file is part of librostlab.
5
6
librostlab is free software: you can redistribute it and/or modify
7
it under the terms of the GNU Lesser General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU Lesser General Public License for more details.
15
16
You should have received a copy of the GNU Lesser General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
#ifndef ROSTLAB_BLAST_RESULT_H
20
#define ROSTLAB_BLAST_RESULT_H
21
#include <stdint.h>
22
#include <sstream>
23
#include <string>
24
#include <vector>
25
#include <rostlab/aux_functions.h>
26
27
namespace
rostlab {
28
29
namespace
blast {
30
32
struct
round
{
34
size_t
oneline_idx
;
36
size_t
oneline_cnt
;
38
size_t
hit_idx
;
40
size_t
hit_cnt
;
42
size_t
oneline_new_idx
;
44
size_t
oneline_new_cnt
;
45
static
const
size_t
noidx
=
static_cast<
size_t
>
(-1);
46
public
:
47
round
(
size_t
__oneline_idx = 0,
size_t
__oneline_cnt = 0,
size_t
__hit_idx = 0,
size_t
__hit_cnt = 0,
size_t
__oneline_new_idx =
noidx
,
size_t
__oneline_new_cnt = 0 ) :
oneline_idx
( __oneline_idx),
oneline_cnt
(__oneline_cnt),
hit_idx
( __hit_idx ),
hit_cnt
(__hit_cnt),
oneline_new_idx
(__oneline_new_idx),
oneline_new_cnt
(__oneline_new_cnt){}
48
virtual
~round
(){}
49
};
50
52
53
struct
hsp
{
55
56
typedef
enum
ECompoAdjustModes
{
57
eNoCompositionBasedStats
= 0,
58
eCompositionBasedStats
= 1,
59
eCompositionMatrixAdjust
= 2,
60
eCompoForceFullMatrixAdjust
= 3,
61
eNumCompoAdjustModes
62
}
ECompoAdjustModes
;
// ncbi-tools6-6.1.20090809/algo/blast/composition_adjustment/composition_constants.h:51 // a copy is made so we do not have to depend on that library only for this
63
public
:
64
double
bit_score
;
65
size_t
raw_score
;
66
double
e_value
;
67
ECompoAdjustModes
method
;
68
size_t
identities
;
69
size_t
positives
;
70
size_t
gaps
;
72
std::string
q_strand
;
74
std::string
s_strand
;
76
77
int8_t
q_frame
;
79
80
int8_t
s_frame
;
82
size_t
q_start
;
84
std::string
q_ali
;
86
size_t
q_end
;
88
std::string
match_line
;
90
size_t
s_start
;
92
std::string
s_ali
;
94
size_t
s_end
;
95
public
:
96
hsp
(
double
__bit_score = 0,
size_t
__raw_score = 0 ) :
bit_score
(__bit_score),
raw_score
(__raw_score),
e_value
(0),
method
(
eNoCompositionBasedStats
),
identities
(0),
positives
(0),
gaps
(0),
q_frame
(32),
s_frame
(32),
97
q_start
(0),
q_end
(0),
s_start
(0),
s_end
(0){}
98
virtual
~hsp
(){}
99
101
107
inline
static
std::string
108
methodstr
(
const
ECompoAdjustModes
__m )
109
{
110
switch
( __m )
111
{
112
case
eCompositionBasedStats
:
113
return
"Composition-based stats"
;
break
;
114
case
eCompositionMatrixAdjust
:
115
return
"Compositional matrix adjust"
;
break
;
116
default
:
117
std::stringstream ss; ss << __m;
return
ss.str();
118
}
119
}
121
122
inline
static
ECompoAdjustModes
123
methfromstr
( std::string __m )
124
{
125
if
( __m.size() > 0 && __m[ __m.size()-1 ] ==
'.'
) __m.resize( __m.size()-1 );
126
// 1
127
// 012345678901
128
// Composition-based stats
129
// Compositional matrix adjust
130
if
( __m.size() >= 12 )
131
{
132
if
( __m[11] ==
'-'
)
return
eCompositionBasedStats
;
133
if
( __m[11] ==
'a'
)
return
eCompositionMatrixAdjust
;
134
}
135
return
eNoCompositionBasedStats
;
136
}
137
};
138
140
141
struct
hit
{
142
std::string
name
;
143
std::string
desc
;
145
size_t
length
;
146
std::vector<hsp>
hsps
;
147
public
:
148
hit
(
const
std::string& __name =
""
,
const
std::string& __desc =
""
,
size_t
__length = 0 ) :
name
(__name),
desc
(__desc),
length
(__length) {}
149
virtual
~hit
(){}
150
};
151
153
struct
oneline
{
154
std::string
name
;
155
std::string
desc
;
157
double
bit_score
;
158
double
e_value
;
159
oneline
(
const
std::string& __name =
""
,
const
std::string& __desc =
""
,
double
__bit_score = 0,
double
__e_value = 0 ) :
name
(__name),
desc
(__desc),
bit_score
(__bit_score),
e_value
(__e_value){}
160
oneline
(
const
hit
& __h ) :
name
(__h.
name
),
desc
(__h.
desc
),
bit_score
(__h.hsps.at(0).
bit_score
),
e_value
(__h.hsps.at(0).
e_value
){}
161
virtual
~oneline
(){}
162
};
163
165
struct
result
{
166
bool
empty
;
167
std::string
blast_version
;
168
std::vector<std::string>
169
references
;
171
std::vector<rostlab::blast::round>
172
rounds
;
174
std::string
q_name
;
176
std::string
q_desc
;
178
size_t
q_length
;
180
std::string
db_name
;
182
size_t
db_nseq
;
184
size_t
db_nletter
;
186
std::vector<rostlab::blast::oneline>
187
onelines
;
189
bool
converged
;
191
std::vector<rostlab::blast::hit>
192
hits
;
194
std::string
tail
;
195
public
:
196
result
() :
empty
(true),
q_length
(0),
db_nseq
(0),
db_nletter
(0),
converged
(false) {}
197
virtual
~result
(){}
198
200
201
operator
bool()
const
{
return
!
empty
; }
202
};
203
204
}
// namespace blast
205
207
inline
208
std::ostream&
operator<<
( std::ostream& __os,
const
rostlab::blast::round
& __r )
209
{
210
__os <<
"ol_idx = "
<< __r.
oneline_idx
<<
", ol_cnt = "
<< __r.
oneline_cnt
<<
", hit_idx = "
<< __r.
hit_idx
<<
", hit_cnt = "
<< __r.
hit_cnt
<<
", ol_new_idx = "
<< __r.
oneline_new_idx
<<
", ol_new_cnt = "
<< __r.
oneline_new_cnt
;
211
return
__os;
212
}
213
215
inline
216
std::ostream&
operator<<
( std::ostream& __os,
const
rostlab::blast::oneline
& __r )
217
{
218
__os <<
"n = "
<< __r.
name
<<
" d = "
<< __r.
desc
<<
": "
<< __r.
bit_score
<<
" bits, "
<< __r.
e_value
<<
" E"
;
219
return
__os;
220
}
221
223
inline
224
std::ostream&
operator<<
( std::ostream& __os,
const
rostlab::blast::hsp
& __r )
225
{
226
__os <<
"bits = "
<< __r.
bit_score
<<
", raw = "
<< __r.
raw_score
<<
", E = "
<< __r.
e_value
<<
", method = "
<<
blast::hsp::methodstr
(__r.
method
) <<
", ident = "
<< __r.
identities
<<
227
", pos = "
<< __r.
positives
<<
", gaps = "
<< __r.
gaps
<<
", q_strand = "
<< __r.
q_strand
<<
", s_strand = "
<< __r.
s_strand
<<
", q_frame = "
<< (int)__r.
q_frame
<<
228
", s_frame = "
<< (
int
)__r.
s_frame
<<
", q_start = "
<< __r.
q_start
<<
", q_ali = "
<< __r.
q_ali
<<
", q_end = "
<< __r.
q_end
<<
", match_line = "
<< __r.
match_line
<<
229
", s_start = "
<< __r.
s_start
<<
", s_ali = "
<< __r.
s_ali
<<
", s_end = "
<< __r.
s_end
;
230
return
__os;
231
}
232
234
inline
235
std::ostream&
operator<<
( std::ostream& __os,
const
rostlab::blast::hit
& __r )
236
{
237
__os <<
"n = "
<< __r.
name
<<
" d = "
<< __r.
desc
<<
" Length = "
<< __r.
length
<<
" "
<< __r.
hsps
;
238
return
__os;
239
}
240
242
inline
243
std::ostream&
operator<<
( std::ostream& __os,
const
rostlab::blast::result
& __r )
244
{
245
__os << __r.
blast_version
<<
"\n\nreferences: "
<< __r.
references
<<
"\n\nrounds: "
<< __r.
rounds
<<
"\n\nn = "
<< __r.
q_name
<<
" d = "
<< __r.
q_desc
<<
" ("
<< __r.
q_length
<<
246
" letters)\n\nDatabase: "
<< __r.
db_name
<<
" "
<< __r.
db_nseq
<<
" sequences; "
<< __r.
db_nletter
<<
" total letters\n\none-line desc: "
<< __r.
onelines
<<
"\n\n"
<<
247
( __r.
converged
?
"CONVERGED!\n\n"
:
""
) <<
"hits: "
<< __r.
hits
<<
"\n\n"
<< __r.
tail
;
248
return
__os;
249
}
250
251
}
// namespace rostlab
252
253
#endif // ROSTLAB_BLAST_RESULT_H
254
// vim:et:ts=4:ai:
Generated on Mon May 13 2013 22:30:06 for librostlab-blast by
1.8.3.1