#include <mal.h>
Inheritance diagram for MAl:
Public Member Functions | |
MAl (size_t bufsize, std::set< db_recno_t > &recnolist, TrapperDoc *pdoc) | |
~MAl () | |
void | set_seq_row (size_t ID, size_t row) |
size_t | create_seq (size_t length) |
void | set_DNP (size_t ID, size_t index, bool status) |
void | set_DNP_global (size_t ID, size_t index, bool status) |
void | set_DNP_ID (size_t ID, size_t index, int dnpID) |
void | set_DNP_ID_global (size_t ID, size_t index, int dnpID) |
void | set_DNP_type (size_t ID, size_t index, int type) |
void | set_DNP_type_global (size_t ID, size_t index, int type) |
void | set_base (size_t ID, size_t index, base_t base) |
void | set_base_global (size_t ID, size_t index, base_t base) |
void | set_qual (size_t ID, size_t index, qual_t qual) |
void | set_qual_global (size_t ID, size_t index, qual_t qual) |
void | insert_gap (size_t ID, size_t index) |
void | insert_gap_global (size_t ID, size_t index) |
void | remove_gap (size_t ID, size_t index) |
void | remove_gap_global (size_t ID, size_t index) |
void | set_seq_begin_global (size_t ID, size_t index) |
void | set_seq_end (size_t ID, size_t index) |
void | set_seq_end_global (size_t ID, size_t index) |
void | set_beginGood (size_t ID, size_t index) |
void | set_beginGood_global (size_t ID, size_t index) |
void | set_endGood (size_t ID, size_t index) |
void | set_endGood_global (size_t ID, size_t index) |
Private Member Functions | |
virtual void | flush_buffer (size_t buffID) |
void | commit_seq_to_db (size_t buffID) |
void | commit_feat_to_db (size_t buffID, const string &feat_data_name) |
Private Attributes | |
std::vector< Q_UINT32 > | last_gap_vec |
Future plans: If neccesary, make the writeable features plug ins, for efficiency.
Definition at line 17 of file mal.h.
|
|
|
Definition at line 16 of file mal.cc. References flush_buffer(), and MAl_Readonly::put_in_db. 00017 { 00018 cerr<<"~MAl(): flushing buffer... "; 00019 00020 for( size_t i = 1; i < put_in_db.size(); i++ ) { 00021 00022 if ( put_in_db[ i ] ) { 00023 flush_buffer( i ); 00024 } 00025 } 00026 cerr<<"Done "<<endl; 00027 }
|
|
Definition at line 352 of file mal.cc. References Database::PrimaryIterator< T >::answer(), MAl_Readonly::buffID_to_dbID, Database::Creator< T >::create(), Database::Creator< T >::data(), Database::Creator< T >::destroy(), MAl_Readonly::DNPs, MAl_Readonly::doc, last_gap_vec, MAl_Readonly::quals, MAl_Readonly::seq_begin_global, MAl_Readonly::seq_end_global, MAl_Readonly::seqs, Database::PrimaryIterator< T >::setFromRecno(), and FeatureData::setReadRecno(). Referenced by flush_buffer(). 00353 { 00354 db_recno_t readrec = buffID_to_dbID[ buffID ]; 00355 00356 assert( readrec != 0 ); 00357 Database::Creator<FeatureData> a_creator(doc, feat_data_name); 00358 00359 a_creator.data()->setReadRecno( readrec ); 00360 00361 if ( DnaStrData* data = dynamic_cast<DnaStrData*>(a_creator.data()) ) { 00362 //NB, seq data has same recno as the read itself 00363 data->setRecno( readrec ); 00364 data->setStartPos( 0 ); 00365 data->setEndPos( seq_end_global[buffID] - seq_begin_global[buffID] - 1 ); 00366 // data->dnaVector.stlVector() = seqs[ buffID ]; 00367 00368 data->dnaVector.stlVector().clear(); 00369 last_gap_vec.clear(); 00370 size_t numgap(0); 00371 for( size_t i = 0; i < seqs[ buffID ].size(); i++ ) { 00372 data->dnaVector.stlVector().push_back( seqs[ buffID ][i] ); 00373 if ( seqs[ buffID ][i] == '*' ) { 00374 numgap++; 00375 } 00376 last_gap_vec.push_back(numgap); 00377 } 00378 00379 a_creator.create(true); 00380 } 00381 else if ( QualityData* data = dynamic_cast<QualityData*>(a_creator.data()) ) { 00382 //NB, qual data has same recno as the read itself 00383 data->setRecno( readrec ); 00384 data->setStartPos( 0 ); 00385 data->setEndPos( seq_end_global[buffID] - seq_begin_global[buffID] - 1); 00386 data->qualityVector.stlVector() = quals[ buffID ]; 00387 00388 a_creator.create(true); 00389 00390 } 00391 else if ( ChromatData* data = dynamic_cast<ChromatData*>(a_creator.data()) ) { 00392 //NB, chromat data has same recno as the read itself 00393 Database::PrimaryIterator<ChromatData>* chr_it = 00394 new Database::PrimaryIterator<ChromatData>(doc, "ChromatData"); 00395 00396 int ret_chr = chr_it->setFromRecno(readrec); 00397 ChromatData* chr_test = (ret_chr != DB_NOTFOUND) ? chr_it->answer() : 0; 00398 assert( chr_test ); 00399 00400 data->copy( chr_test ); 00401 delete chr_it; 00402 00403 data->setStartPos( 0 ); 00404 data->setEndPos( seq_end_global[buffID] - seq_begin_global[buffID] - 1); 00405 data->gap_vec.stlVector() = last_gap_vec; 00406 00407 a_creator.create(true); 00408 00409 } 00410 else if ( DnpData* data = dynamic_cast<DnpData*>(a_creator.data()) ) { 00411 00412 for( size_t i = 0; i < DNPs[buffID].size(); i++ ) { 00413 00414 if ( DNPs[buffID][i].isDNP || DNPs[buffID][i].recno != 0 ) { 00415 bool recno_flag( DNPs[buffID][i].recno != 0 ); 00416 data->setRecno( DNPs[buffID][i].recno ); 00417 data->set_dnpID( DNPs[buffID][i].ID ); 00418 data->set_dnp_type( DNPs[buffID][i].type ); 00419 if ( DNPs[buffID][i].isDNP ) { 00420 //Commit DNP to DB 00421 data->setStartPos( i ); 00422 data->setEndPos( i ); 00423 00424 a_creator.create( recno_flag ); 00425 00426 } 00427 else { 00428 //Remove old DNP from DB 00429 assert( DNPs[buffID][i].recno != 0 ); 00430 a_creator.destroy(); 00431 00432 } 00433 00434 00435 } 00436 00437 } 00438 } 00439 00440 00441 }
|
|
Definition at line 323 of file mal.cc. References MAl_Readonly::buffID_to_dbID, Database::Creator< T >::create(), Database::Creator< T >::data(), MAl_Readonly::doc, MAl_Readonly::mate_lengths, MAl_Readonly::mates, MAl_Readonly::names, MAl_Readonly::seq_begin_global, MAl_Readonly::seq_beginGood, MAl_Readonly::seq_end_global, MAl_Readonly::seq_endGood, MAl_Readonly::seq_rows, ReadData::setBeginGood(), ReadData::setEndGood(), ReadData::setEndPos(), ReadData::setMate(), ReadData::setMateLength(), ReadData::setName(), GeneralData::setRecno(), ReadData::setRow(), ReadData::setStartPos(), ReadData::setStrand(), and MAl_Readonly::strands. Referenced by flush_buffer(). 00324 { 00325 db_recno_t recno = buffID_to_dbID[ buffID ]; 00326 00327 bool create_flag = ( recno != 0 ); 00328 00329 Database::Creator<ReadData> a_creator(doc, "ReadData"); 00330 00331 // cerr<<"Committing seq: "<<endl; 00332 // cerr<<"recno: "<<recno<<endl; 00333 // cerr<<"start: "<<start<<endl; 00334 // cerr<<"end: "<<end<<endl; 00335 00336 a_creator.data()->setRecno( recno ); 00337 a_creator.data()->setRow( seq_rows[buffID] ); 00338 a_creator.data()->setStartPos( seq_begin_global[ buffID ] ); 00339 a_creator.data()->setEndPos( seq_end_global[ buffID ] - 1 ); 00340 a_creator.data()->setName( names[ buffID ] ); 00341 a_creator.data()->setMate( mates[ buffID ] ); 00342 a_creator.data()->setMateLength( mate_lengths[ buffID ] ); 00343 a_creator.data()->setStrand( strands[ buffID ] ); 00344 a_creator.data()->setBeginGood( seq_beginGood[ buffID ] ); 00345 a_creator.data()->setEndGood( seq_endGood[ buffID ] - 1); 00346 recno = a_creator.create( create_flag ); 00347 00348 }
|
|
Definition at line 40 of file mal.cc. References MAl_Readonly::DNPs, MAl_Readonly::get_buffID(), MAl_Readonly::ID_to_buffID, MAl_Readonly::ID_to_dbID, MAl_Readonly::num_seq, MAl_Readonly::quals, and MAl_Readonly::seqs. 00041 { 00042 num_seq++; 00043 ID_to_dbID.push_back(0); 00044 ID_to_buffID.push_back(0); 00045 00046 size_t newID( num_seq - 1 ); 00047 00048 size_t buffID = get_buffID( newID ); 00049 00050 seqs[ buffID ] = vector<base_t>( length ); 00051 quals[ buffID ] = vector<qual_t>( length ); 00052 DNPs[ buffID ] = vector<dnp_struct>( length ); 00053 00054 return newID; 00055 }
|
|
Reimplemented from MAl_Readonly. Definition at line 293 of file mal.cc. References MAl_Readonly::buffID_to_dbID, MAl_Readonly::buffID_to_ID, commit_feat_to_db(), commit_seq_to_db(), MAl_Readonly::ID_to_buffID, and MAl_Readonly::put_in_db. Referenced by ~MAl(). 00294 { 00295 00296 //1. Get recno 00297 00298 // db_recno_t recno = buffID_to_dbID[ buffID ]; 00299 00300 //2. Commit stuff to DB... 00301 00302 // commit_seq_to_db( recno, seq_begin_global[ buffID ], seq_end_global[ buffID ] - 1, seq_rows[buffID] ); 00303 commit_seq_to_db( buffID ); 00304 00305 // commit_feat_to_db( recno, buffID, "DnaStrData" ); 00306 // commit_feat_to_db( recno, buffID, "QualityData" ); 00307 // commit_feat_to_db( recno, buffID, "DnpData" ); 00308 commit_feat_to_db( buffID, "DnaStrData" ); 00309 commit_feat_to_db( buffID, "QualityData" ); 00310 commit_feat_to_db( buffID, "ChromatData" ); 00311 commit_feat_to_db( buffID, "DnpData" ); 00312 00313 // commit_feat_to_db( recno, "header", headers[ buffID ] ); 00314 00315 ID_to_buffID[ buffID_to_ID[ buffID ] ] = 0; 00316 buffID_to_dbID[ buffID ] = 0; 00317 put_in_db[ buffID ] = false; 00318 00319 }
|
|
Definition at line 152 of file mal.cc. References MAl_Readonly::DNPs, MAl_Readonly::get_beginGood(), MAl_Readonly::get_buffID(), MAl_Readonly::get_endGood(), MAl_Readonly::get_seq_end(), MAl_Readonly::quals, MAl_Readonly::seqs, set_beginGood(), set_endGood(), and set_seq_end(). Referenced by insert_gap_global(), and MAlWrapper< alphabet >::swap(). 00153 { 00154 int rowID = ID; 00155 00156 //Inserts a gap BEFORE position "index" 00157 // cerr<<"NB, dummy qual inserted... "<<endl; 00158 00159 ID = get_buffID( ID ); 00160 00161 assert( ID < seqs.size()); 00162 assert( index < seqs[ ID ].size() ); 00163 00164 seqs[ ID ].insert( seqs[ ID ].begin() + index, '*' ); 00165 00166 qual_t dummy_qual_val = 0; 00167 assert( index < quals[ ID ].size() ); 00168 assert( index > 0 ); 00169 dummy_qual_val = (quals[ ID ][index -1] + quals[ ID ][index])/2; 00170 00171 quals[ ID ].insert( quals[ ID ].begin() + index, dummy_qual_val ); 00172 00173 DNPs[ ID ].insert( DNPs[ ID ].begin() + index, dnp_struct() ); 00174 00175 set_seq_end( rowID, get_seq_end( rowID ) + 1 ); 00176 00177 if ( index <= get_beginGood( rowID ) ) { 00178 set_beginGood( rowID, get_beginGood( rowID ) + 1 ); 00179 } 00180 00181 if ( index <= get_endGood( rowID ) ) { 00182 set_endGood( rowID , get_endGood( rowID ) + 1); 00183 } 00184 00185 }
|
|
Definition at line 187 of file mal.cc. References MAl_Readonly::get_seq_begin_global(), and insert_gap(). Referenced by MAlWrapper< alphabet >::insert(). 00188 { 00189 insert_gap( ID, index - get_seq_begin_global( ID ) ); 00190 00191 }
|
|
Definition at line 193 of file mal.cc. References MAl_Readonly::DNPs, MAl_Readonly::get_beginGood(), MAl_Readonly::get_buffID(), MAl_Readonly::get_endGood(), MAl_Readonly::get_seq_end(), MAl_Readonly::quals, MAl_Readonly::seqs, set_beginGood(), set_endGood(), and set_seq_end(). Referenced by remove_gap_global(), and MAlWrapper< alphabet >::swap(). 00194 { 00195 int rowID = ID; 00196 00197 ID = get_buffID( ID ); 00198 00199 assert( ID < seqs.size()); 00200 assert( index < seqs[ ID ].size() ); 00201 if ( seqs[ ID ][ index ] != '*' ) { 00202 cerr<<"Error, calling remove gap with base "<<seqs[ ID ][ index ]<<endl; 00203 } 00204 assert( seqs[ ID ][ index ] == '*' ); 00205 00206 00207 seqs[ ID ].erase( seqs[ ID ].begin() + index ); 00208 quals[ ID ].erase( quals[ ID ].begin() + index ); 00209 DNPs[ ID ].erase( DNPs[ ID ].begin() + index ); 00210 00211 set_seq_end( rowID, get_seq_end( rowID ) - 1 ); 00212 00213 if ( index < get_beginGood( rowID ) ) { 00214 set_beginGood( rowID , get_beginGood( rowID ) - 1 ); 00215 } 00216 00217 if ( index < get_endGood( rowID ) ) { 00218 set_endGood( rowID , get_endGood( rowID ) - 1 ); 00219 } 00220 00221 }
|
|
Definition at line 223 of file mal.cc. References MAl_Readonly::get_seq_begin_global(), and remove_gap(). Referenced by MAlWrapper< alphabet >::erase(). 00224 { 00225 remove_gap( ID, index - get_seq_begin_global( ID ) ); 00226 00227 }
|
|
Definition at line 114 of file mal.cc. References MAl_Readonly::get_buffID(), and MAl_Readonly::seqs. Referenced by set_base_global(). 00115 { 00116 if (base == '-') 00117 base = '*'; 00118 00119 ID = get_buffID( ID ); 00120 00121 assert( ID < seqs.size()); 00122 assert( index < seqs[ ID ].size() ); 00123 00124 seqs[ ID ][ index ] = base; 00125 }
|
|
Definition at line 127 of file mal.cc. References MAl_Readonly::get_seq_begin_global(), and set_base(). 00128 { 00129 00130 set_base( ID, index - get_seq_begin_global( ID ), base ); 00131 00132 }
|
|
Definition at line 258 of file mal.cc. References MAl_Readonly::get_buffID(), and MAl_Readonly::seq_beginGood. Referenced by insert_gap(), TrashAlgo::kill_read(), remove_gap(), set_beginGood_global(), TrashRemoveAlgo::start(), and TrashAlgo::trash(). 00259 { 00260 ID = get_buffID( ID ); 00261 00262 assert( ID < seq_beginGood.size() ); 00263 00264 seq_beginGood[ ID ] = index; 00265 00266 }
|
|
Definition at line 268 of file mal.cc. References MAl_Readonly::get_seq_begin_global(), and set_beginGood(). 00269 { 00270 set_beginGood( ID, index - get_seq_begin_global( ID ) ); 00271 00272 }
|
|
Definition at line 61 of file mal.cc. References MAl_Readonly::DNPs, and MAl_Readonly::get_buffID(). Referenced by set_DNP_global(), and RemoveAlgo::start(). 00062 { 00063 ID = get_buffID( ID ); 00064 00065 00066 assert( ID < DNPs.size() ); 00067 00068 if ( index >= DNPs[ ID ].size() ) { 00069 cerr<<"index: "<<index<<endl; 00070 cerr<<"DNPs[ ID ].size(): "<<DNPs[ ID ].size()<<endl; 00071 } 00072 00073 assert( index < DNPs[ ID ].size() ); 00074 00075 DNPs[ ID ][ index ].isDNP = status; 00076 }
|
|
Definition at line 78 of file mal.cc. References MAl_Readonly::get_seq_begin_global(), and set_DNP(). Referenced by MAl_addon::set_DNP(). 00079 { 00080 00081 set_DNP( ID, index - get_seq_begin_global( ID ), status ); 00082 }
|
|
Definition at line 84 of file mal.cc. References MAl_Readonly::DNPs, and MAl_Readonly::get_buffID(). Referenced by set_DNP_ID_global(). 00085 { 00086 ID = get_buffID( ID ); 00087 00088 assert( ID < DNPs.size() ); 00089 assert( index < DNPs[ ID ].size() ); 00090 00091 DNPs[ ID ][ index ].ID = dnpID; 00092 }
|
|
Definition at line 94 of file mal.cc. References MAl_Readonly::get_seq_begin_global(), and set_DNP_ID(). Referenced by MAl_addon::set_DNP(). 00095 { 00096 set_DNP_ID( ID, index - get_seq_begin_global( ID ), dnpID ); 00097 }
|
|
Definition at line 99 of file mal.cc. References MAl_Readonly::DNPs, and MAl_Readonly::get_buffID(). Referenced by set_DNP_type_global(). 00100 { 00101 ID = get_buffID( ID ); 00102 00103 assert( ID < DNPs.size() ); 00104 assert( index < DNPs[ ID ].size() ); 00105 00106 DNPs[ ID ][ index ].type = type; 00107 }
|
|
Definition at line 109 of file mal.cc. References MAl_Readonly::get_seq_begin_global(), and set_DNP_type(). Referenced by MAl_addon::set_DNP(). 00110 { 00111 set_DNP_type( ID, index - get_seq_begin_global( ID ), type ); 00112 }
|
|
Definition at line 274 of file mal.cc. References MAl_Readonly::get_buffID(), and MAl_Readonly::seq_endGood. Referenced by insert_gap(), TrashAlgo::kill_read(), remove_gap(), set_endGood_global(), TrashRemoveAlgo::start(), and TrashAlgo::trash(). 00275 { 00276 ID = get_buffID( ID ); 00277 00278 assert( ID < seq_endGood.size() ); 00279 00280 seq_endGood[ ID ] = index; 00281 00282 }
|
|
Definition at line 284 of file mal.cc. References MAl_Readonly::get_seq_begin_global(), and set_endGood(). 00285 { 00286 set_endGood( ID, index - get_seq_begin_global( ID ) ); 00287 00288 }
|
|
Definition at line 134 of file mal.cc. References MAl_Readonly::get_buffID(), and MAl_Readonly::quals. Referenced by set_qual_global(). 00135 { 00136 ID = get_buffID( ID ); 00137 00138 assert( ID < quals.size()); 00139 assert( index < quals[ ID ].size() ); 00140 00141 quals[ ID ][ index ] = qual; 00142 00143 }
|
|
Definition at line 145 of file mal.cc. References MAl_Readonly::get_seq_begin_global(), and set_qual(). 00146 { 00147 00148 set_qual( ID, index - get_seq_begin_global( ID ), qual ); 00149 00150 }
|
|
Definition at line 229 of file mal.cc. References MAl_Readonly::get_buffID(), and MAl_Readonly::seq_begin_global. Referenced by MAlWrapper< alphabet >::decrement_first_pos(), MAlWrapper< alphabet >::move_read_left(), MAlWrapper< alphabet >::move_read_right(), and MAlWrapper< alphabet >::swap(). 00231 { 00232 // cerr << "set_seq_begin_global: r = " << ID << ", index = " << index << endl; 00233 ID = get_buffID( ID ); 00234 00235 assert( ID < seq_begin_global.size() ); 00236 00237 seq_begin_global[ ID ] = index; 00238 }
|
|
Definition at line 241 of file mal.cc. References MAl_Readonly::get_seq_begin_global(), and set_seq_end_global(). Referenced by insert_gap(), and remove_gap(). 00242 { 00243 set_seq_end_global( ID, index + get_seq_begin_global( ID ) ); 00244 00245 }
|
|
Definition at line 247 of file mal.cc. References MAl_Readonly::get_buffID(), and MAl_Readonly::seq_end_global. Referenced by MAlWrapper< alphabet >::adjust_last_pos(), MAlWrapper< alphabet >::decrement_last_pos(), MAlWrapper< alphabet >::erase(), MAlWrapper< alphabet >::insert(), MAlWrapper< alphabet >::move_read_left(), MAlWrapper< alphabet >::move_read_right(), set_seq_end(), and MAlWrapper< alphabet >::swap(). 00248 { 00249 // cerr << "set_seq_end_global: r = " << ID << ", index = " << index << endl; 00250 ID = get_buffID( ID ); 00251 00252 assert( ID < seq_end_global.size() ); 00253 00254 seq_end_global[ ID ] = index; 00255 00256 }
|
|
Definition at line 32 of file mal.cc. References MAl_Readonly::get_buffID(), and MAl_Readonly::seq_rows. Referenced by SortAlgo::old_start(), SortAlgo::start(), and DnpSortAlgo::start(). 00033 { 00034 ID = get_buffID( ID ); 00035 00036 assert( ID < seq_rows.size() ); 00037 seq_rows[ ID ] = row; 00038 }
|
|
Definition at line 74 of file mal.h. Referenced by commit_feat_to_db(). |