File: searchdatabase.hpp

package info (click to toggle)
mothur 1.48.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 13,684 kB
  • sloc: cpp: 161,854; makefile: 122; sh: 31
file content (80 lines) | stat: -rwxr-xr-x 2,614 bytes parent folder | download | duplicates (4)
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
74
75
76
77
78
79
80
#ifndef DATABASE_HPP
#define DATABASE_HPP

/*
 *  searchdatabase.hpp
 *  
 *
 *  Created by Pat Schloss on 12/16/08.
 *  Copyright 2008 Patrick D. Schloss. All rights reserved.
 *
 */


/* This class is a parent to kmerdb, suffixdb.  */

#include "mothur.h"
#include "sequence.hpp"
#include "currentfile.h"
#include "utils.hpp"


/**************************************************************************************************/
struct seqMatch {  //used to select top n matches
		int seq;
		int match;
    seqMatch()=default;
		seqMatch(int s, int m) : seq(s), match(m) {}
};
/**************************************************************************************************/
inline bool compareSeqMatches (seqMatch member, seqMatch member2){ //sorts largest to smallest
	if(member.match > member2.match){
		return true;   }   
	else{
		return false; 
	}
}
/**************************************************************************************************/
inline bool compareSeqMatchesReverse (seqMatch member, seqMatch member2){ //sorts largest to smallest
	if(member.match < member2.match){
		return true;   }   
	else{
		return false; 
	}
}

/**************************************************************************************************/
class SearchDatabase {

public:
    SearchDatabase(){ longest = 0; numSeqs = 0; m = MothurOut::getInstance();  }
    
    virtual ~SearchDatabase(){};
    virtual void generateDB() = 0;
    virtual void readDB(ifstream&){};
    virtual void addSequence(Sequence) = 0;  //add sequence to search engine
    virtual void addSequences(vector<Sequence> seqs) { for (int i = 0; i < seqs.size(); i++) { addSequence(seqs[i]); } }

	virtual void setNumSeqs(int i) {	numSeqs = i; 	}
    
	virtual vector<int> findClosestSequences(Sequence*, int, vector<float>&) const = 0;  // returns indexes of n closest sequences to query
	
    virtual vector< vector<int> > get(int i, char& s) { s='x'; vector< vector<int> > blank; return blank; }
    virtual vector<int> getIndicatorColumns() { return nullIntVector; }
    virtual map<int, int> getFilteredIndicatorColumns(string, vector<int>&) { return nullIntMap; }
    virtual int getLongestBase() {	return longest+1;		}
    virtual vector<int> getSequencesWithKmer(int){ vector<int> filler; return filler; };
	virtual int getReversed(int) { return 0; } 
	virtual int getMaxKmer(){	return 1;	}
    virtual string getName(int) { return ""; }
	
protected:
    
    MothurOut* m;
	int numSeqs, longest;
    Utils util;
	
	
};
/**************************************************************************************************/
#endif