Imported Debian patch 0.12.7-3
[bowtie.git] / search_23mm_phase1.c
1 /*
2  * This is a fragment, included from multiple places in ebwt_search.cpp.
3  * It implements the logic of the first phase of the 2/3-mismatch search
4  * routine.  It is implemented as a code fragment so that it can be
5  * reused in both the half-index-in-memory and full-index-in-memory
6  * situations.
7  */
8 {
9         // If requested, check that this read has the same length
10         // as all the previous ones
11         btr1.setReportExacts(true);
12
13         if(plen < 3 && two) {
14                 cerr << "Error: Read (" << name << ") is less than 3 characters long" << endl;
15                 throw 1;
16         }
17         else if(plen < 4) {
18                 cerr << "Error: Read (" << name << ") is less than 4 characters long" << endl;
19                 throw 1;
20         }
21         if(!nofw) {
22                 // Do an exact-match search on the forward pattern, just in
23                 // case we can pick it off early here
24                 params.setFw(true);
25                 btr1.setQuery(patsrc->bufa());
26                 btr1.setOffs(0, 0, plen, plen, plen, plen);
27                 if(btr1.backtrack()) {
28                         DONEMASK_SET(patid);
29                         continue;
30                 }
31         }
32         if(!norc) {
33                 // Set up backtracker with reverse complement
34                 params.setFw(false);
35                 // Set up the revisitability of the halves
36                 btr1.setQuery(patsrc->bufa());
37                 btr1.setOffs(0, 0, s5, s5, two ? s : s5, s);
38                 if(btr1.backtrack()) {
39                         DONEMASK_SET(patid);
40                         continue;
41                 }
42         }
43         if(nofw && sink->finishedWithStratum(0)) { // no more exact hits are possible
44                 DONEMASK_SET(patid);
45                 continue;
46         }
47 }