#include <readdata.h>
Inheritance diagram for ReadData:
Public Member Functions | |
ReadData (TR_DNA row=0, TR_DNA startPos=0, TR_DNA endPos=0) | |
ReadData (const ReadData &other) | |
~ReadData () | |
void | print_debug_info () |
std::string | uniqueName () |
TrDb::IndexMap | getIndexMap () |
void | setRow (TR_DNA row) |
void | setStartPos (TR_DNA startPos) |
void | setEndPos (TR_DNA endPos) |
TR_DNA | row () |
TR_DNA | startPos () |
TR_DNA | endPos () |
void | writeXml (std::ostream &stream) |
void | readStream (QDataStream &stream) |
void | writeStream (QDataStream &stream) |
void | readAttributes (const QXmlAttributes &attr) |
Static Public Member Functions | |
static int | getRowPos (Db *dbp, const Dbt *pkey, const Dbt *pdata, Dbt *skey) |
static int | bt_compare_rowPos (DB *db, const DBT *a, const DBT *b) |
static int | bt_compare_end (DB *db, const DBT *dbt1, const DBT *dbt2) |
static int | bt_compare_start (DB *db, const DBT *dbt1, const DBT *dbt2) |
Protected Attributes | |
StorageData | s |
Classes | |
struct | StorageData |
to keep the order of the data members when serializing/unserializing More... |
The index value of this read, m_recno, is used as a secondary search index for subclasses of FeatureData.
Definition at line 32 of file readdata.h.
ReadData::ReadData | ( | TR_DNA | row = 0 , |
|
TR_DNA | startPos = 0 , |
|||
TR_DNA | endPos = 0 | |||
) | [inline] |
Definition at line 48 of file readdata.h.
References endPos(), ReadData::StorageData::endPos, row(), ReadData::StorageData::row, s, startPos(), and ReadData::StorageData::startPos.
00048 : GeneralData() 00049 { 00050 s.row = row; 00051 s.startPos = startPos; 00052 s.endPos = endPos; 00053 }
ReadData::ReadData | ( | const ReadData & | other | ) |
Definition at line 21 of file readdata.cpp.
References s.
00021 : GeneralData(other) 00022 { 00023 s = other.s;//Works since StorageData is trivial 00024 00025 // name_ = other.name_; 00026 // mate_ = other.mate_; 00027 // matelen_ = other.matelen_; 00028 // strand_ = other.strand_; 00029 // beginGood_ = other.beginGood_; 00030 // endGood_ = other.endGood_; 00031 // tc_vec = other.tc_vec; 00032 }
ReadData::~ReadData | ( | ) |
void ReadData::print_debug_info | ( | ) | [virtual] |
Prints some info for debugging, this should be removed in release version!
Reimplemented from GeneralData.
Definition at line 38 of file readdata.cpp.
References endPos(), GeneralData::getRecno(), row(), startPos(), and uniqueName().
00039 { 00040 cerr<<"This is class "<<uniqueName()<<endl; 00041 cerr<<"recno: "<<getRecno()<<endl; 00042 cerr<<"row: "<<row()<<endl; 00043 cerr<<"startPos: "<<startPos()<<endl; 00044 cerr<<"endPos: "<<endPos()<<endl; 00045 }
std::string ReadData::uniqueName | ( | ) | [inline, virtual] |
Specifies a name that uniquely should identify this class. It will be used for lookups in the GeneralMaker class.
Implements GeneralData.
Definition at line 57 of file readdata.h.
Referenced by print_debug_info().
TrDb::IndexMap ReadData::getIndexMap | ( | ) | [virtual] |
Returns a TrDb::IndexMap that specifies which secondary indexes should be generated for stored data objects of this class in the Berkeley Db backend. Each record in the TrDb::IndexMap generates a secondary index built as a btree ( a DB_BTREE in Berkeley Db wording ). The secondary index is sorted which makes it possible to do queries like "Give me the object that has the smallest value, bigger or equal than x".
And about speed performance, a quote from Berkeley Db documentation says: "Searches take O(log base_b N) time, where base_b is the average number of keys per page, and N is the total number of keys stored"
Implements GeneralData.
Definition at line 154 of file readdata.cpp.
References QString::ascii(), bt_compare_end(), bt_compare_rowPos(), bt_compare_start(), getRowPos(), and TrDb::Index::name.
00155 { 00156 TrDb::IndexMap iMap; 00157 TrDb::Index i = { 00158 &ReadData::bt_compare_rowPos, 00159 &ReadData::getRowPos, 00160 QString("pos"), 00161 NULL 00162 }; 00163 iMap.insert( make_pair( i.name.ascii(), i ) ); 00164 00165 TrDb::Index i2 = { 00166 &ReadData::bt_compare_end, 00167 &ReadData::getRowPos, 00168 QString("end"), 00169 NULL 00170 }; 00171 iMap.insert( make_pair( i2.name.ascii(), i2 ) ); 00172 00173 // TrDb::Index i3 = { 00174 // &ReadData::bt_compare_name, 00175 // &ReadData::getName, 00176 // QString("name"), 00177 // NULL 00178 // }; 00179 // iMap.insert( make_pair( i3.name.ascii(), i3 ) ); 00180 00181 TrDb::Index i4 = { 00182 &ReadData::bt_compare_start, 00183 &ReadData::getRowPos, 00184 QString("start"), 00185 NULL 00186 }; 00187 iMap.insert( make_pair( i4.name.ascii(), i4 ) ); 00188 00189 return iMap; 00190 }
void ReadData::setRow | ( | TR_DNA | row | ) | [inline] |
Set the row where this "read" is placed in the contig
Definition at line 60 of file readdata.h.
References ReadData::StorageData::row, and s.
Referenced by MacsimParser::endElement(), ReadsInRect::find(), optimize_layout(), TrapperView::selectCols(), TrapperView::selectRows(), MoveAlgo::start(), and TrapperParser::startElement().
void ReadData::setStartPos | ( | TR_DNA | startPos | ) | [inline] |
Set the start position in DNA coordinates where this "read" is placed in the contig
Definition at line 62 of file readdata.h.
References s, and ReadData::StorageData::startPos.
Referenced by TrapperView::scrollToNextCluster(), TrapperView::selectRows(), and MoveAlgo::start().
void ReadData::setEndPos | ( | TR_DNA | endPos | ) | [inline] |
Set the end position in DNA coordinates where this "read" is placed in the contig
Definition at line 64 of file readdata.h.
References ReadData::StorageData::endPos, and s.
Referenced by ReadsInRect::find(), TrapperView::selectCols(), and MoveAlgo::start().
TR_DNA ReadData::row | ( | ) | [inline] |
Returns the row where this "read" is placed in the contig
Definition at line 72 of file readdata.h.
References ReadData::StorageData::row, and s.
Referenced by ReadsInRect::find(), TrapperView::fitContentsizeToData(), ReadsInRect::hasAnythingInsideWindow(), optimize_layout(), print_debug_info(), MAl_Readonly::read_seq_from_db(), ReadData(), TrapperView::selectRows(), MoveAlgo::start(), and TrapperParser::startElement().
TR_DNA ReadData::startPos | ( | ) | [inline] |
Returns the start position in DNA coordinates where this "read" is placed in the contig
Definition at line 74 of file readdata.h.
References s, and ReadData::StorageData::startPos.
Referenced by TrapperView::getInfo(), ReadsInRect::hasAnythingInsideWindow(), optimize_layout(), print_debug_info(), MAl_Readonly::read_seq_from_db(), ReadData(), TrapperView::scrollToNextCluster(), TrapperView::selectCols(), and MoveAlgo::start().
TR_DNA ReadData::endPos | ( | ) | [inline] |
Returns the end position in DNA coordinates where this "read" is placed in the contig
Definition at line 76 of file readdata.h.
References ReadData::StorageData::endPos, and s.
Referenced by ReadsInRect::find(), TrapperView::fitContentsizeToData(), TrapperView::getInfo(), ReadsInRect::hasAnythingInsideWindow(), ReadsInRect::hasRightEndInsideWindow(), optimize_layout(), print_debug_info(), MAl_Readonly::read_seq_from_db(), ReadData(), and TrapperView::selectCols().
int ReadData::getRowPos | ( | Db * | dbp, | |
const Dbt * | pkey, | |||
const Dbt * | pdata, | |||
Dbt * | skey | |||
) | [static] |
Definition at line 259 of file readdata.cpp.
Referenced by getIndexMap().
00261 { 00262 // memset(skey, 0, sizeof(Dbt)); 00263 // ReadData::StorageData * data = ( ReadData::StorageData * ) pdata->get_data(); 00264 // skey->set_data( ( u_int8_t * ) (& (data->readRecno)) ); 00265 // skey->set_size(sizeof( db_recno_t )); 00266 00267 memset(skey, 0, sizeof(Dbt)); 00268 skey->set_data( pdata->get_data() ); 00269 skey->set_size(sizeof( struct ReadData::StorageData )); 00270 return(0); 00271 }
int ReadData::bt_compare_rowPos | ( | DB * | db, | |
const DBT * | a, | |||
const DBT * | b | |||
) | [static] |
Definition at line 192 of file readdata.cpp.
References ReadData::StorageData::endPos, and ReadData::StorageData::row.
Referenced by getIndexMap().
00193 { 00194 /* order after row and then after end position */ 00195 00196 ReadData::StorageData * seqData1 = ( ReadData::StorageData *) dbt1->data; 00197 ReadData::StorageData * seqData2 = ( ReadData::StorageData *) dbt2->data; 00198 if ( seqData1->row > seqData2->row ) 00199 return 1; 00200 if ( seqData1->row < seqData2->row ) 00201 return -1; 00202 if ( seqData1->endPos == seqData2->endPos ) 00203 return 0; 00204 if ( seqData1->endPos > seqData2->endPos ) 00205 return 1; 00206 if ( seqData1->endPos < seqData2->endPos ) 00207 return -1; 00208 00209 /* should never reach this point */ 00210 return 0; 00211 }
int ReadData::bt_compare_end | ( | DB * | db, | |
const DBT * | dbt1, | |||
const DBT * | dbt2 | |||
) | [static] |
Definition at line 213 of file readdata.cpp.
References ReadData::StorageData::endPos.
Referenced by getIndexMap().
00214 { 00215 /* order after end position */ 00216 00217 ReadData::StorageData * seqData1 = ( ReadData::StorageData *) dbt1->data; 00218 ReadData::StorageData * seqData2 = ( ReadData::StorageData *) dbt2->data; 00219 if ( seqData1->endPos > seqData2->endPos ) 00220 return 1; 00221 if ( seqData1->endPos < seqData2->endPos ) 00222 return -1; 00223 if ( seqData1->endPos == seqData2->endPos ) 00224 return 0; 00225 00226 /* should never reach this point */ 00227 return 0; 00228 }
int ReadData::bt_compare_start | ( | DB * | db, | |
const DBT * | dbt1, | |||
const DBT * | dbt2 | |||
) | [static] |
Definition at line 230 of file readdata.cpp.
References ReadData::StorageData::startPos.
Referenced by getIndexMap().
00231 { 00232 /* order after end position */ 00233 00234 ReadData::StorageData * seqData1 = ( ReadData::StorageData *) dbt1->data; 00235 ReadData::StorageData * seqData2 = ( ReadData::StorageData *) dbt2->data; 00236 if ( seqData1->startPos > seqData2->startPos ) 00237 return 1; 00238 if ( seqData1->startPos < seqData2->startPos ) 00239 return -1; 00240 if ( seqData1->startPos == seqData2->startPos ) 00241 return 0; 00242 00243 /* should never reach this point */ 00244 return 0; 00245 }
void ReadData::writeXml | ( | std::ostream & | stream | ) | [virtual] |
Writes the state of this object to a stream as an XML entry. This method is used for exporting
Implements GeneralData.
Referenced by TrapperDoc::saveExport().
void ReadData::readStream | ( | QDataStream & | stream | ) | [virtual] |
Loads the state of this object from a byte stream. Or in other words reads and unserializes a byte stream to set the values of this class object. This method is used for loading a GeneralData object from Berkeley Db.
Implements GeneralData.
Definition at line 47 of file readdata.cpp.
References QDataStream::device(), QDataStream::readRawBytes(), and s.
00048 { 00049 QIODevice * dev = stream.device(); 00050 Q_ASSERT( dev ); 00051 stream.readRawBytes( ( char * ) &s, sizeof ( StorageData ) ); 00052 00053 // QString tmp; 00054 // stream>>tmp; 00055 // name_ = tmp.ascii(); 00056 // stream>>tmp; 00057 // mate_ = tmp.ascii(); 00058 // stream>>matelen_; 00059 // stream>>tmp; 00060 // strand_ = tmp.ascii(); 00061 // stream>>beginGood_; 00062 // stream>>endGood_; 00063 // tc_vec.stlVector().clear(); 00064 // stream>>tc_vec; 00065 }
void ReadData::writeStream | ( | QDataStream & | stream | ) | [virtual] |
Saves the state of this object to a byte stream. Or in other words serializes and writes the internal data held in this class object to a byte stream. This method is used for storing a GeneralData object into Berkeley Db.
Implements GeneralData.
Definition at line 67 of file readdata.cpp.
References QDataStream::device(), QIODevice::mode(), s, and QDataStream::writeRawBytes().
Referenced by TrapperView::writeSelected().
00068 { 00069 QIODevice * dev = stream.device(); 00070 Q_ASSERT( dev ); 00071 if ( ! ( IO_WriteOnly & dev->mode() ) ) 00072 { 00073 cerr << "data stream should be writeonly" << endl; 00074 exit(1); 00075 } 00076 stream.writeRawBytes( ( char * ) &s, sizeof ( StorageData ) ); 00077 00078 // QString tmp; 00079 // tmp = name_; 00080 // stream<<tmp; 00081 // tmp = mate_; 00082 // stream<<tmp; 00083 // stream<<matelen_; 00084 // tmp = strand_; 00085 // stream<<tmp; 00086 // stream<<beginGood_; 00087 // stream<<endGood_; 00088 // stream<<tc_vec; 00089 }
void ReadData::readAttributes | ( | const QXmlAttributes & | attr | ) | [virtual] |
Loads the state of this object from QXmlAttributes.This method is used for importing.
Implements GeneralData.
Definition at line 91 of file readdata.cpp.
References ReadData::StorageData::endPos, ReadData::StorageData::row, s, ReadData::StorageData::startPos, and QXmlAttributes::value().
Referenced by MacsimParser::endElement().
00092 { 00093 if ( attr.value("row") != "" ) { 00094 QString rowPosStr = attr.value("row"); 00095 s.row = rowPosStr.toLong(); 00096 } 00097 if ( attr.value("startPos") != "" ) { 00098 QString startPosStr = attr.value("startPos"); 00099 s.startPos = startPosStr.toLong(); 00100 } 00101 if ( attr.value("endPos") != "" ) { 00102 QString endPosStr = attr.value("endPos"); 00103 s.endPos = endPosStr.toLong(); 00104 // endGood_ = s.endPos - s.startPos; 00105 } 00106 // if ( attr.value("name") != "" ) { 00107 // name_ = attr.value("name").ascii(); 00108 // } 00109 // if ( attr.value("mate") != "" ) { 00110 // mate_ = attr.value("mate").ascii(); 00111 // } 00112 // if ( attr.value("matelen") != "" ) { 00113 // matelen_ = attr.value("matelen").toInt(); 00114 // } 00115 // if ( attr.value("strand") != "" ) { 00116 // strand_ = attr.value("strand").ascii(); 00117 // } 00118 // if ( attr.value("beginGood") != "" ) { 00119 // beginGood_ = attr.value("beginGood").toInt(); 00120 // } 00121 // if ( attr.value("endGood") != "" ) { 00122 // endGood_ = attr.value("endGood").toInt(); 00123 // } 00124 // if ( attr.value("tc") != "" ) { 00125 // QString str = attr.value("tc"); 00126 // tc_vec.readString(str); 00127 // } 00128 00129 }
StorageData ReadData::s [protected] |
Definition at line 112 of file readdata.h.
Referenced by endPos(), readAttributes(), ReadData(), readStream(), row(), setEndPos(), setRow(), setStartPos(), startPos(), and writeStream().