File: pp_fastBlockSearcher.cc

package info (click to toggle)
augustus 3.3.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 486,188 kB
  • sloc: cpp: 51,969; perl: 20,926; ansic: 1,251; makefile: 935; python: 120; sh: 118
file content (73 lines) | stat: -rw-r--r-- 2,065 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "pp_fastBlockSearcher.hh"

#include <sstream>

int    PP::FsHitType::maxIntronLen = 100000;
double PP::FsHitType::intronMalus  = 1e-5;

int    PP::FsSeedCollection::expSeedCount = 10000;
double PP::FsSeedCollection::maxCoverage  = 0.8;

void PP::FsHitCollection::newHit(FsHitType* ht) {
    allHits.push_back(ht);
    vector<HitQueue>& allQueues = pendingHits[ht->reverse];
    int b = ht->reverse ? ht->blockNo+1 : ht->blockNo-1;
    if (b>=0 && b<size) 
	ht->linkTo(allQueues[b]);
    if (ht->reverse) 
	for (b=ht->blockNo; b>0; b--)
	    ht->pushOn(allQueues[b]);
    else
	for (b=ht->blockNo; b<size-1; b++)
	    ht->pushOn(allQueues[b]);

    // Put this entry in to the final result container
    if (finalResult.empty()) {
	finalResult.push_back(ht);
	return;
    }
    int i = finalResult.size()-1;
    while (i>=0 && finalResult[i]->start() > ht->start()) 
	i--;
    if (i>=0 && finalResult[i]->head == ht->head) {
	if (finalResult[i]->pathScore < ht->pathScore) 
	    finalResult[i] = ht;
    } else if (i == finalResult.size()-1) {
	finalResult.push_back(ht);
    } else  {
	int j = finalResult.size()-1;
	finalResult.push_back(finalResult.back());
	while (--j>i)
	    finalResult[j+1] = finalResult[j];
	finalResult[i+1] = ht;
    }
}

void PP::FsHitCollection::storeBestResults(multimap<double, FsHitType>& result, int mincount, double threshold) {
    int maxcount = finalResult.size();
    result.clear();
	
    if (mincount > maxcount)
	mincount = maxcount;
    int i;
    for (i=0; i<mincount; i++) {
	FsHitType* ht = finalResult[i];
	result.insert(make_pair(ht->pathScore, *ht));
    }
    if (mincount) for(; i<maxcount; i++) {
	FsHitType* ht = finalResult[i];
	double sc = ht->pathScore;
	double listSc = result.begin()->second.pathScore;
	if (listSc > threshold)
	    break;
	if (listSc > sc)
	    continue;
	result.erase(result.begin());
	result.insert(make_pair(sc, *ht));
    }
    for (; i<maxcount; i++) {
	FsHitType* ht = finalResult[i];
	if (ht->pathScore > threshold)
	    result.insert(make_pair(ht->pathScore, *ht));
    }
}