55 template <class Container>
58 #if defined(VERBOSE_DEBUG)
64 typename Container::const_iterator itr = c.begin();
66 for (; itr != c.end(); ++itr) {
74 #if defined(VERBOSE_DEBUG)
76 s_PrintNeutralSeqAlign(ofstream&
out,
const SeqAlign& alignment)
78 out <<
"SeqAlign::score = " << alignment.
score << endl
79 <<
"SeqAlign::num_ident = " << alignment.
num_ident << endl
80 <<
"SeqAlign::evalue = " << alignment.
evalue << endl
81 <<
"SeqAlign::bit_score = " << alignment.
bit_score << endl
82 <<
"SeqAlign::match = " << alignment.match << endl
83 <<
"SeqAlign::query_strand = " << alignment.
query_strand << endl
84 <<
"SeqAlign::subject_strand = " << alignment.
subject_strand << endl
86 << endl <<
"SeqAlign::starts[" << alignment.
starts.size()
89 out << endl <<
"SeqAlign::lengths[" << alignment.
lengths.size()
99 #if defined(VERBOSE_DEBUG)
100 ofstream
out(fname.c_str());
102 throw runtime_error(
"Failed to open " + fname);
107 out <<
"SeqAlign # " << ++index << endl;
108 s_PrintNeutralSeqAlign(
out, *alignment);
117 : m_Ref(ref), m_Test(
test), m_Opts(opts)
136 (*errors) +=
"Different number of alignments:\n";
144 const TSeqAlignSet::size_type kMaxSize =
min(
m_Ref.size(),
m_Test.size());
145 for (TSeqAlignSet::size_type
i = 0;
i < kMaxSize;
i++) {
188 int max_diff_value = 0,
191 invalid_value, max_diff_value),
192 m_Diff(std::
abs(reference_value - test_value))
206 double reference_value,
208 double max_diff_value = 0.0,
210 :
CValueHolder<double>(field_name, reference_value, test_value,
211 invalid_value, max_diff_value),
212 m_Diff(std::
fabs(reference_value - test_value) / reference_value)
242 string* errors =
NULL)
247 (*errors) +=
"align " +
s_ToString(aln_num) +
": ";
248 (*errors) += value_holder.
GetFieldName() +
" present\n";
254 (*errors) +=
"align " +
s_ToString(aln_num) +
": ";
262 (*errors) +=
"align " +
s_ToString(aln_num) +
": ";
263 (*errors) +=
"different " + value_holder.
GetFieldName() +
", ";
265 (*errors) +=
" vs. ";
294 static pair<int, int>
296 const vector<TSeqPos>& lengths)
298 int query_length = 0;
299 int subject_length = 0;
303 for (vector<TSeqPos>::size_type
i = 0;
i < lengths.size();
i++) {
305 query_length += lengths[
i];
308 subject_length += lengths[
i];
312 return make_pair(query_length, subject_length);
320 bool allow_fuzziness)
330 string field(
"evalue");
340 string field(
"bit score");
351 string field(
"raw score");
360 string field(
"num identities");
369 string field(
"number of segments");
371 test->GetNumSegments());
382 string field(
"total query align start");
392 string field(
"total subject align start");
400 pair<int, int> ref_lengths =
402 pair<int, int> test_lengths =
407 string field(
"total query align length");
418 string field(
"total subject align length");
429 string field(
"query strand");
438 string field(
"subject strand");
virtual bool ReportDiffs() const
CDoubleValueHolder(string &field_name, double reference_value, double test_value, double max_diff_value=0.0, double invalid_value=kInvalidDoubleValue)
CIntValueHolder(string &field_name, int reference_value, int test_value, int max_diff_value=0, int invalid_value=kInvalidIntValue)
virtual bool ReportDiffs() const
Configuration options for CSeqAlignCmp class.
int GetMaxOffsetDiff() const
double GetMinEvalue() const
int GetMaxLengthDiff() const
double GetMaxEvalueDiff() const
double GetMaxEvalue() const
const TSeqAlignSet & m_Test
The sequence alignment to be used as test (compared with reference)
const TSeqAlignSet & m_Ref
The sequence alignment to be used as reference (assumed correct)
bool x_MeetsEvalueRequirements(double reference, double test)
If reference and test alignments do not fall into the evalue range specified, don't perform the compa...
int x_CompareOneAlign(const SeqAlign *ref, const SeqAlign *test, int index, string *errors=NULL, bool allow_fuzziness=true)
Compare alignment ref with alignment test (which correspond to entry index in the TMatchedAlignments.
CSeqAlignCmp(const TSeqAlignSet &ref, const TSeqAlignSet &test, const CSeqAlignCmpOpts &options)
Parametrized constructor.
const CSeqAlignCmpOpts & m_Opts
Our configuration options.
bool Run(string *errors=NULL)
Main function for this object, compare the input Seq-aligns.
Interface class to hold values and to determine whether some difference in these values should be rep...
CValueHolder(string &field_name, T reference_value, T test_value, T invalid_value, T max_diff_value)
T GetInvalidValue() const
virtual bool ReportDiffs() const =0
T GetMaximumAcceptableDiff() const
string & GetFieldName() const
std::ofstream out("events_result.xml")
main entry point for tests
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_SCOPE(ns)
Define a new scope.
static string SizetToString(size_t value, TNumToStringFlags flags=0, int base=10)
Convert size_t to string.
static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
@ fDoubleScientific
DoubleToString*(): Use scientific format for double conversions.
unsigned int
A callback function used to compare two keys in a database.
Magic spell ;-) needed for some weird compilers... very empiric.
const int kInvalidIntValue
std::vector< SeqAlign > TSeqAlignSet
Vector of neutral sequence alignments.
const double kInvalidDoubleValue
static pair< int, int > s_GetAlignmentLengths(const vector< int > &starts, const vector< TSeqPos > &lengths)
Returns a pair containing the length of the aligned region in the query and the length of the aligned...
bool s_CompareValues(const CValueHolder< T > &value_holder, int aln_num=0, string *errors=NULL)
Compare values in the CValueHolder object.
string s_ToString(T value)
Template wrapper around NStr::XToString functions, where X is a data type.
static void s_PrintTSeqAlignSet(const string &fname, const TSeqAlignSet &neutral_seqaligns)
void s_PrintContainer(ofstream &out, const Container &c)
BEGIN: Debugging functions.
API to compare CSeq-aligns produced by BLAST.
Neutral sequence alignment (for representing an HSP in BLAST)
int GetNumSegments() const
Return the number of segments in the HSP.
std::vector< TSeqPos > lengths
Lengths of aligned segments.
double bit_score
HSP bit score.
int num_ident
Number of identical residues.
std::vector< int > starts
Query/Subject starting offsets.
int query_strand
Strand of the query sequence.
int subject_strand
Strand of the subject sequence.
int test(int srctype, const void *srcdata, int srclen, int dsttype, int dstlen)