refSeqs = getBlastSeqs(query, numWanted);
}
-//ofstream out;
-//string name = toString(numi+1);
-//cout << name << endl;
-//name = name.substr(name.find_first_of("|")+1);
-//cout << name << endl;
-//name = name.substr(name.find_first_of("|")+1);
-//cout << name << endl;
-//name = name.substr(0, name.find_last_of("|"));
-//cout << name << endl;
-//string filename = name + ".seqsformaligner";
-//openOutputFile(filename, out);
-//for (int u = 0; u < refSeqs.size(); u++) { refSeqs[u]->printSequence(out); }
-//out.close();
-//filename = name + ".fasta";
-//openOutputFile(filename, out);
-//query->printSequence(out);
-//out.close();
-
-//for (int i = 0; i < refSeqs.size(); i++) { cout << refSeqs[i]->getName() << endl; }
-//cout << "before = " << refSeqs.size() << endl;
refSeqs = minCoverageFilter(refSeqs);
-//cout << "after = " << refSeqs.size() << endl;
+
if (refSeqs.size() < 2) {
for (int i = 0; i < refSeqs.size(); i++) { delete refSeqs[i]; }
percentIdenticalQueryChimera = 0.0;
}
int chimeraPenalty = computeChimeraPenalty();
-//cout << chimeraPenalty << endl;
+
//fills outputResults
chimera = chimeraMaligner(chimeraPenalty, decalc);
}
//***************************************************************************************************************
vector<Sequence*> Maligner::getBlastSeqs(Sequence* q, int num) {
- try {
-cout << q->getName() << endl;
+ try {
//generate blastdb
Database* database = new BlastDB(-2.0, -1.0, matchScore, misMatchPenalty);
for (int i = 0; i < db.size(); i++) { database->addSequence(*db[i]); }
database->setNumSeqs(db.size());
//get parts of query
- string queryAligned = q->getAligned();
- string leftQuery = queryAligned.substr(0, (queryAligned.length() / 3)); //first 1/3 of the sequence
- string rightQuery = queryAligned.substr(((queryAligned.length() / 3)*2)); //last 1/3 of the sequence
-
+ string queryUnAligned = q->getUnaligned();
+ string leftQuery = queryUnAligned.substr(0, int(queryUnAligned.length() * 0.33)); //first 1/3 of the sequence
+ string rightQuery = queryUnAligned.substr(int(queryUnAligned.length() * 0.66)); //last 1/3 of the sequence
+
Sequence* queryLeft = new Sequence(q->getName(), leftQuery);
Sequence* queryRight = new Sequence(q->getName(), rightQuery);
- map<int, float> tempIndexesRight = database->findClosest(queryRight, num);
- map<int, float> tempIndexesLeft = database->findClosest(queryLeft, num);
-
- //merge results
- vector<rank> mergedResults;
+ vector<int> tempIndexesRight = database->findClosestMegaBlast(queryRight, num+1);
+ vector<int> tempIndexesLeft = database->findClosestMegaBlast(queryLeft, num+1);
- map<int, float>::iterator it;
- map<int, float>::iterator it2;
+ //merge results
+ map<int, int> seen;
+ map<int, int>::iterator it;
- //add in right guys merging common finds
- for (it = tempIndexesRight.begin(); it != tempIndexesRight.end(); it++) {
- it2 = tempIndexesLeft.find(it->first);
-
- if (it2 == tempIndexesLeft.end()) { //result only present in right
- rank temp(it->first, it->second);
- mergedResults.push_back(temp);
+ vector<int> mergedResults;
+ for (int i = 0; i < tempIndexesLeft.size(); i++) {
+ //add left if you havent already
+ it = seen.find(tempIndexesLeft[i]);
+ if (it == seen.end()) {
+ mergedResults.push_back(tempIndexesLeft[i]);
+ seen[tempIndexesLeft[i]] = tempIndexesLeft[i];
+ }
- }else { //result present in both save best score
- float bestscore;
- if (it->second > it2->second) { bestscore = it->second; }
- else { bestscore = it2->second; }
-
- rank temp(it->first, bestscore);
- mergedResults.push_back(temp);
-
- tempIndexesLeft.erase(it2);
+ //add right if you havent already
+ it = seen.find(tempIndexesRight[i]);
+ if (it == seen.end()) {
+ mergedResults.push_back(tempIndexesRight[i]);
+ seen[tempIndexesRight[i]] = tempIndexesRight[i];
}
}
- //add in unique left guys
- for (it = tempIndexesLeft.begin(); it != tempIndexesLeft.end(); it++) {
- rank temp(it->first, it->second);
- mergedResults.push_back(temp);
- }
-
- sort(mergedResults.begin(), mergedResults.end(), compareMembers);
vector<Sequence*> refResults;
for (int i = 0; i < numWanted; i++) {
- Sequence* temp = new Sequence(db[mergedResults[i].num]->getName(), db[mergedResults[i].num]->getAligned());
+ Sequence* temp = new Sequence(db[mergedResults[i]]->getName(), db[mergedResults[i]]->getAligned());
refResults.push_back(temp);
-cout << db[mergedResults[i].num]->getName() << endl;
}
delete queryRight;