Пример #1
0
			DArray(std::map<int64_t,uint64_t> const & M, uint64_t const bwtterm)
			: D(bwtterm+1)
			{
				for ( std::map<int64_t,uint64_t>::const_iterator ita = M.begin(); ita != M.end(); ++ita )
					D [ ita->first ] += ita->second;
				D.prefixSums();
			}
Пример #2
0
			ImpWTLF ( iterator BWT, uint64_t const rn, ::libmaus2::util::TempFileNameGenerator & rtmpgen, uint64_t const rmaxval = 0)
			: n(rn)
			{
				if ( n )
				{	
					uint64_t maxval = rmaxval;
					for ( uint64_t i = 0; i < n; ++i )
						maxval = std::max ( maxval, static_cast<uint64_t>(BWT[i]) );
					uint64_t const b = ::libmaus2::math::numbits(maxval);

					::libmaus2::wavelet::ImpExternalWaveletGenerator IEWG(b,rtmpgen);
					for ( uint64_t i = 0; i < n; ++i )
						IEWG.putSymbol(BWT[i]);
					std::string const tmpfilename = rtmpgen.getFileName();
					IEWG.createFinalStream(tmpfilename);
					
					std::ifstream istr(tmpfilename.c_str(),std::ios::binary);
					wt_ptr_type tW(new wt_type(istr));
					W = UNIQUE_PTR_MOVE(tW);
					istr.close();
					remove ( tmpfilename.c_str() );
					
					D = ::libmaus2::autoarray::AutoArray < uint64_t >((1ull<<W->getB())+1);
					for ( uint64_t i = 0; i < (1ull<<W->getB()); ++i )
						D [ i ] = W->rank(i,n-1);
					D.prefixSums();
				}
			}
Пример #3
0
			MultiRankCacheLF ( iterator BWT, uint64_t const rn, uint64_t const rmaxval = 0)
			: n(rn)
			{
				if ( n )
				{
					uint64_t maxval = rmaxval;
					for ( uint64_t i = 0; i < n; ++i )
						maxval = std::max ( maxval, static_cast<uint64_t>(BWT[i]) );
						
					rank_dictionaries = ::libmaus2::autoarray::AutoArray < rank_ptr_type >(maxval+1);
					
					for ( uint64_t i = 0; i < rank_dictionaries.size(); ++i )
					{
						rank_ptr_type trank_dictionariesi(new rank_type(n+1));
						rank_dictionaries[i] = UNIQUE_PTR_MOVE(trank_dictionariesi);
						writer_type writer = rank_dictionaries[i]->getWriteContext();
						
						for ( uint64_t j = 0; j < n; ++j )
							writer.writeBit(BWT[j] == i);
						// write additional bit to make rankm1 defined for n
						writer.writeBit(0);
						
						writer.flush();
					}
					
					D = ::libmaus2::autoarray::AutoArray < uint64_t >(rank_dictionaries.size()+1);
					for ( uint64_t i = 0; i < rank_dictionaries.size(); ++i )
						D [ i ] = rank_dictionaries[i]->rank1(n-1);
					D.prefixSums();
				}
			}
Пример #4
0
			ImpWTLF(std::istream & in)
			: n(::libmaus2::util::NumberSerialisation::deserialiseNumber(in)),
			  W (new wt_type(in))
			{				
				if ( n )
				{
					D = ::libmaus2::autoarray::AutoArray < uint64_t >((1ull<<W->getB())+1);
					for ( uint64_t i = 0; i < (1ull<<W->getB()); ++i )
						D [ i ] = W->rank(i,n-1);
					D.prefixSums();
				}
			}
Пример #5
0
			ImpWTLF (::libmaus2::huffman::RLDecoder & decoder, uint64_t const b, ::libmaus2::util::TempFileNameGenerator & rtmpgen)
			: n(decoder.getN())
			{
				if ( n )
				{	
					::libmaus2::wavelet::ImpExternalWaveletGenerator IEWG(b,rtmpgen);
					for ( uint64_t i = 0; i < n; ++i )
						IEWG.putSymbol(decoder.decode());
					std::string const tmpfilename = rtmpgen.getFileName();
					IEWG.createFinalStream(tmpfilename);
					
					std::ifstream istr(tmpfilename.c_str(),std::ios::binary);
					wt_ptr_type tW(new wt_type(istr));
					W = UNIQUE_PTR_MOVE(tW);
					istr.close();
					remove ( tmpfilename.c_str() );
					
					D = ::libmaus2::autoarray::AutoArray < uint64_t >((1ull<<W->getB())+1);
					for ( uint64_t i = 0; i < (1ull<<W->getB()); ++i )
						D [ i ] = W->rank(i,n-1);
					D.prefixSums();
				}
			}