00001 #ifndef CHAINAVGRANGE_H 00002 #define CHAINAVGRANGE_H 00003 00004 #include "alnrange.h" 00005 #include <vector> 00006 #include <iostream> 00007 00008 /* 00009 * To buiild a chain of average ranges for chimera detection 00010 */ 00011 00012 using namespace std; 00013 00014 class ChainAvgrange { 00015 public: 00016 ChainAvgrange(const string &id, int len) 00017 : seqid(id), seqlen(len), chain() {} 00018 /* this object will deallocate the memory given by the 00019 * addRange method 00020 */ 00021 ~ChainAvgrange(); 00022 00023 /* either r merge with one of the chain element 00024 * or create a new avgrange object out of r 00025 */ 00026 void addRange(const alnrange* r); 00027 int size() const { return chain.size(); } 00028 00029 /* fill the list with rows of db formated 00030 * quoted string values. 00031 */ 00032 void dbrows(list<string>& rows, const char dlm[]=",") const; 00033 /* tab-dlimited output, good for database loading */ 00034 friend ostream& operator<<(ostream &ous, const ChainAvgrange &ar); 00035 bool isChimera() const { return chain.size()>1; } 00036 00037 /* Accumulate results to the tablerows, also output the 00038 * result in tab-delimited format to the output stream 00039 */ 00040 int checkSplits(list<string> &tablerows, ostream &ous) const; 00041 typedef vector<avgrange*>::iterator chain_iterator; 00042 00043 private: 00044 string seqid; 00045 int seqlen; 00046 vector<avgrange*> chain; 00047 }; 00048 00049 #endif
1.5.6