12 #ifndef SEQ_SEARCH_HXX
13 #define SEQ_SEARCH_HXX
30 #ifndef BI_BASEPOS_HXX
33 #ifndef ARB_GLOBAL_DEFS_H
38 #define fa_assert(bed) arb_assert(bed)
41 #define MAX_TRIPLES (SEQ_CHARS*SEQ_CHARS*SEQ_CHARS+1) // one faked triple for all non-char triples
43 inline int max(
int i1,
int i2) {
return i1>i2 ? i1 : i2; }
45 #define GAP_CHARS ".-~?" // Characters treated as gaps // @@@ sometimes as well just ".-" (see is_gap)
58 BeforeBase = before_base;
78 int *gapsBeforePosition;
86 const char *
get_name()
const {
return myName; }
89 const char *
text(
int i=0)
const {
return myText+i; }
105 return basepos.
abs_2_rel(xPos-myStartOffset);
117 leftMostGap = myStartOffset;
128 rightMostGap = basepos.
abs_count()+myStartOffset-1;
135 else dots =
new Dots(beforePos);
148 mutable const Dots *dots;
150 int currentDotPosition()
const {
153 if (pos>(myLength+1)) {
166 myLength(mySeq->
length()),
167 myText(mySeq->
text()+myPos),
172 : mySeq(other.mySeq),
174 myLength(other.myLength),
175 myText(other.myText),
179 : mySeq(other.mySeq),
180 myPos(other.myPos + rel_pos),
182 myText(mySeq->
text()+myPos),
189 const char *
text()
const {
return myText; }
218 res = currentDotPosition();
230 res = currentDotPosition();
235 #if defined(ASSERTION_USED)
249 int distanceTo(
const SequencePosition& other)
const {
fa_assert(mySequence==other.mySequence);
return myPos-other.myPos; }
256 myText(seq.
text(pos)) {}
258 : mySequence(pos.mySequence),
260 myText(pos.myText+
offset) {}
264 const char *
text()
const {
return myText; }
288 void IV()
const {
fa_assert(myNext!=
this); }
296 long offset()
const { IV();
return myOffset; }
316 void set_used(
long newVal) {
320 void add_used(
long toAdd) {
321 set_used(toAdd+used);
324 int isGlobalGap(
long off) {
326 return (myBuffer[off]==
'-' || myBuffer[off]==
'.') && myQuality[off]==
'-';
328 void moveUnaligned(
long from,
long to) {
329 myBuffer[to] = myBuffer[from];
330 myQuality[to] = myQuality[from];
331 myBuffer[from] =
'-';
332 myQuality[from] =
'-';
340 myBuffer =
new char[size+1];
342 myQuality =
new char[size+1];
355 long free()
const {
return mySize-used; }
357 void copy(
const char *
s,
char q,
long len) {
359 memcpy(myBuffer+used, s, len);
360 memset(myQuality+used, q, len);
363 void set(
char c,
char q) {
369 void set(
char c,
char q,
long len) {
371 memset(myBuffer+used, c, len);
372 memset(myQuality+used, q, len);
376 fa_assert(newOffset>=0 && newOffset<mySize);
388 long insert_at_offset;
395 insert_at_offset = Offset;
396 inserted_gaps = Gaps;
405 printf(
" offset=%5li gaps=%3li\n", insert_at_offset, inserted_gaps);
413 long offset()
const {
return insert_at_offset; }
414 long gaps()
const {
return inserted_gaps; }
421 long mismatchedBases;
423 char *my_master_name;
424 bool showGapsMessages;
438 showGapsMessages = show_Gaps_Messages;
441 if (first)
delete first;
442 free(my_master_name);
447 last = last->
append(offset, gaps);
450 if (showGapsMessages)
aw_message(
"---- gaps needed.");
454 if (showGapsMessages) {
455 char *messi = ARB_alloc<char>(100);
457 sprintf(messi,
"'%s' needs %li gaps at offset %li.", my_master_name, gaps, offset+1);
469 printf(
"fast_align_report:\n"
470 " alignedBases = %li (=%f%%)\n"
471 " mismatchedBases = %li\n"
472 " unalignedBases = %li\n"
473 "inserts in master-sequence:\n",
474 alignedBases, (
float)alignedBases/(alignedBases+unalignedBases),
486 static int triple_index(
const char *triple) {
501 int max_seq_length,
int matchScore,
int mismatchScore,
505 const TripleOffset *
find(
const char *triple)
const {
return myOffset[triple_index(triple)]; }
519 : mySequence(Sequence)
521 myOffset = mySequence.
find(triple);
526 bool found()
const { assertValid();
return myOffset; }
534 #error seq_search.hxx included twice
535 #endif // SEQ_SEARCH_HXX
SequencePosition & operator-=(long l)
const CompactedSubSequence & sequence() const
int expdPosition(int cPos) const
void restoreDots(CompactedSubSequence &slaveSequence)
int no_of_gaps_after(int cPos) const
FastAlignReport(const char *master_name, bool show_Gaps_Messages)
long expdPosition() const
const FastAlignInsertion * insertion() const
DECLARE_ASSIGNMENT_OPERATOR(CompactedSubSequence)
void count_aligned_base(int mismatched)
int rel_2_abs(int rel) const
ARB_ERROR fast_align(const CompactedSubSequence &align_to, AlignBuffer *alignBuffer, int max_seq_length, int matchScore, int mismatchScore, FastAlignReport *report) const
#define implicated(hypothesis, conclusion)
bool may_refer_to_same_part_as(const CompactedSubSequence &other) const
CompactedSequence(const char *text, int length, const char *name, int start_offset=0)
TripleOffset(long Offset, TripleOffset *next_toff)
CompactedSubSequence(const CompactedSubSequence &other, int rel_pos, int length_)
int firstDotPosition() const
const Dots * next() const
const char * get_name() const
SequencePosition(const SequencePosition &pos, long offset=0)
const char * text() const
char * ARB_strdup(const char *str)
char operator[](int i) const
FastAlignInsertion * append(long Offset, long Gaps)
SequencePosition & operator--()
const char * name() const
void set(char c, char q, long len)
int no_of_gaps_before(int cPos) const
int abs_2_rel(int abs) const
int expdStartPosition() const
int operator<(const SequencePosition &other) const
void reset(long newOffset=0)
int no_of_gaps_after(int cPos) const
const int * gapsBefore(int offset=0) const
void copy(const char *s, char q, long len)
const CompactedSubSequence & sequence() const
const Dots * getDotlist() const
FastAlignInsertion(long Offset, long Gaps)
char operator[](int i) const
const char * text() const
void correctUnalignedPositions()
SequencePosition & operator+=(long l)
TripleOffset * next() const
int no_of_gaps_before(int cPos) const
long expdPosition(int offset)
void count_unaligned_base(int no_of_bases)
const char * text(int i) const
int compPosition(int xPos) const
const char * text(int i=0) const
int operator>(const SequencePosition &other) const
const char * text() const
SequencePosition(const CompactedSubSequence &seq, long pos=0)
const FastAlignInsertion * next() const
FastSearchSequence(const CompactedSubSequence &seq)
DECLARE_ASSIGNMENT_OPERATOR(SequencePosition)
void aw_message(const char *msg)
SequencePosition & operator++()
int expdPosition(int cPos) const
bool is_std_gap(const char c)
int nextDotPosition() const
void storeDots(int beforePos)
CompactedSubSequence(const CompactedSubSequence &other)
const CompactedSubSequence & sequence() const
const TripleOffset * find(const char *triple) const
const int * gapsBefore(int offset=0) const
void memorize_insertion(long offset, long gaps)
CompactedSubSequence(const char *seq, int length_, const char *name_, int start_offset=0)
int compPosition(int xPos) const
FastSearchOccurrence(const FastSearchSequence &Sequence, const char *triple)
const char * quality() const
void setDotsAtEOSequence()
GB_write_int const char s