00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __Index_AMOS_HH
00011 #define __Index_AMOS_HH 1
00012
00013 #include "universals_AMOS.hh"
00014 #include <utility>
00015
00016
00017
00018
00019 namespace AMOS {
00020
00021
00032
00033 class Index_t : public Universal_t
00034 {
00035
00036 private:
00037
00038 std::pair<NCode_t, NCode_t> type_m;
00039 HASHMAP::hash_multimap<ID_t, ID_t> index_m;
00040
00041
00042 protected:
00043
00044
00045 virtual void readRecord (std::istream & fix, std::istream & var);
00046
00047
00048
00049 virtual void readRecordFix (std::istream & fix);
00050
00051
00052
00053 virtual void writeRecord (std::ostream & fix, std::ostream & var) const;
00054
00055
00056 public:
00057
00058 static const NCode_t NCODE;
00060
00061
00062 typedef HASHMAP::hash_multimap<ID_t, ID_t>::iterator iterator;
00064
00065 typedef HASHMAP::hash_multimap<ID_t, ID_t>::const_iterator const_iterator;
00067
00068
00069
00074 Index_t ( )
00075 {
00076 type_m . first = type_m . second = NULL_NCODE;
00077 }
00078
00079
00080
00083 Index_t (NCode_t a, NCode_t b)
00084 {
00085 type_m . first = a;
00086 type_m . second = b;
00087 }
00088
00089
00090
00093 Index_t (const Index_t & source)
00094 {
00095 *this = source;
00096 }
00097
00098
00099
00102 ~Index_t ( )
00103 {
00104
00105 }
00106
00107
00108
00116 iterator begin ( )
00117 {
00118 return index_m . begin( );
00119 }
00120
00121
00122
00123 const_iterator begin ( ) const
00124 {
00125 return index_m . begin( );
00126 }
00127
00128
00129
00141 void buildContigFeature (const std::string bankname);
00142
00143
00144
00156 void buildContigScaffold (const std::string bankname);
00157
00158
00159
00171 void buildReadContig (const std::string bankname);
00172
00173
00174
00186 void buildReadLibrary (const std::string bankname);
00187
00188
00189
00199 void buildReadMate (const std::string bankname);
00200
00201
00202
00214 void buildScaffoldFeature (const std::string bankname);
00215
00216
00217
00225 iterator end ( )
00226 {
00227 return index_m . end( );
00228 }
00229
00230
00231
00232 const_iterator end ( ) const
00233 {
00234 return index_m . end( );
00235 }
00236
00237
00238
00243 bool empty ( ) const
00244 {
00245 return index_m . empty( );
00246 }
00247
00248
00249
00250 virtual void clear ( )
00251 {
00252 Universal_t::clear( );
00253
00254 type_m . first = type_m . second = NULL_NCODE;
00255 index_m . clear( );
00256 }
00257
00258
00259
00264 Size_t count (ID_t key) const
00265 {
00266 return index_m . count (key);
00267 }
00268
00269
00270
00271 virtual NCode_t getNCode ( ) const
00272 {
00273 return Index_t::NCODE;
00274 }
00275
00276
00277
00282 Size_t getSize ( ) const
00283 {
00284 return index_m . size( );
00285 }
00286
00287
00288
00296 std::pair<NCode_t, NCode_t> getType( ) const
00297 {
00298 return type_m;
00299 }
00300
00301
00302
00312 void insert (ID_t key, ID_t value)
00313 {
00314 insert (std::make_pair(key, value));
00315 }
00316
00317
00318
00319 void insert (std::pair<ID_t, ID_t> iids)
00320 {
00321 index_m . insert (iids);
00322 }
00323
00324
00325
00330 bool isMulti (ID_t key) const
00331 {
00332 return (count (key) > 1);
00333 }
00334
00335
00336
00346 ID_t lookup (ID_t key) const
00347 {
00348 const_iterator i = index_m . find (key);
00349 return ( i == end( ) ? NULL_ID : i -> second );
00350 }
00351
00352
00353
00364 std::pair<iterator, iterator> lookupAll (ID_t key)
00365 {
00366 return index_m . equal_range (key);
00367 }
00368
00369
00370
00371 std::pair<const_iterator, const_iterator> lookupAll (ID_t key) const
00372 {
00373 return index_m . equal_range (key);
00374 }
00375
00376
00377
00378 virtual void readMessage (const Message_t & msg);
00379
00380
00381
00390 Size_t remove (ID_t key)
00391 {
00392 return index_m . erase (key);
00393 }
00394
00395
00396
00402 void remove (iterator itr)
00403 {
00404 index_m . erase (itr);
00405 }
00406
00407
00408
00417 void setType (std::pair<NCode_t, NCode_t> type)
00418 {
00419 type_m = type;
00420 }
00421
00422
00423
00424 void setType (NCode_t a, NCode_t b)
00425 {
00426 setType (std::make_pair (a, b));
00427 }
00428
00429
00430
00431 virtual void writeMessage (Message_t & msg) const;
00432
00433 };
00434
00435 }
00436
00437 #endif // #ifndef __Index_AMOS_HH