<
typenamet_
int>
70 char buf[
sizeof( t_int )];
73 template<
typenamet_
int>
74 voidReadInt( std::istream & is, t_int & v )
76UIntHolder< t_int > h;
77is.read( h.buf,
sizeof( t_int ) );
81 template<
typenamet_
int>
82 voidWriteInt( std::ostream & os,
constt_int & v )
84UIntHolder< t_int > h;
86os.write( h.buf,
sizeof( t_int ) );
91 if( is.eof() || is.bad() ) {
108std::ostringstream os;
109os << idxname <<
"."<< setw(2) << setfill(
'0')
110<< volume <<
".idx";
117 union{
Uint4 a;
unsigned char b[4]; } x;
118x.a = (
Uint4)0x01020304ULL;
123 #define M_CHECK_STREAM(_s,_f,_m) { \ 124 std::ostringstream _os; \ 125 _os << '[' << _f << "] "<< _m; \
126CheckStream( _s, _os.str() ); \
137std::ostringstream os;
138os <<
"file "<< fname <<
" does not exist";
143std::ostringstream os;
144os <<
"read access denied for "<< fname;
148 size_tfile_size( (
size_t)fl.
GetLength() );
149std::ifstream is( fname.c_str() );
152ReadInt( is, endianness );
154endianness = (endianness == 0) ?
169file_size, endianness,
version, fname, is ) );
173std::ostringstream os;
185: actual_size_(
size), endianness_( endianness ), version_(
version)
191: endianness_( GetSystemEndianness() ), version_(
version)
212 if(
size!= EXPECTED_SIZE ) {
213std::ostringstream os;
214os <<
": expected "<< EXPECTED_SIZE <<
"; got "<<
size;
219ReadInt( is, num_seq_ );
221ReadInt( is, num_vol_ );
236num_seq_( n_seq ), num_vol_( n_vol )
245std::ofstream os( fname.c_str() );
248WriteInt( os, num_seq_ );
250WriteInt( os, num_vol_ );
257std::ifstream is( fname.c_str() );
259 for(
int i( 0 );
i< 7; ++
i) { ReadInt( is,
t); }
261ReadInt( is, start );
265 if( is.bad() ) start = end = 0;
269 #undef M_CHECK_STREAM 273 voidCheckIndexEndianness(
void*
map)
275 static const TWordMAX_KEY_SIZE = 15;
277 if( key_size <= MAX_KEY_SIZE )
return;
280 TWordrev_key_size( 0 );
281rev_key_size += ((key_size&0xFF)<<24);
282rev_key_size += (((key_size>>8)&0xFF)<<16);
283rev_key_size += (((key_size>>16)&0xFF)<<8);
284rev_key_size += (key_size>>24);
286 if( rev_key_size <= MAX_KEY_SIZE ) {
289 "possible index endianness mismatch: check " 290 "if the index was created for the " 291 "architecture with different endianness");
295 "index header validation failed");
304CheckIndexEndianness(
map);
308 result.hkey_width_ = (
unsignedlong)(*ptr++);
310 tmp= (
unsignedlong)(*ptr++);
311 tmp= (
unsignedlong)(*ptr++);
331CheckIndexEndianness(
map);
334 result.hkey_width_ = (
unsignedlong)(*ptr++);
335 result.stride_ = (
unsignedlong)(*ptr++);
336 result.ws_hint_ = (
unsignedlong)(*ptr++);
373 case eBadOption:
return "bad index creation option";
376 case eBadData:
return "corrupt index data";
377 case eIO:
return "I/O error";
411 return(
unsigned long)
version;
419 if( !index_stream ) {
424index_stream.close();
427 case VERSION:
returnLoadIndex< true >( fname, nomap );
428 case VERSION+ 1:
returnLoadIndex< false >( fname, nomap );
433 "wrong index version");
441 do{ stride >>= 1; ++
result; }
while( stride != 0 );
464 for(
unsigned long i= 0;
i< n_subjects; ++
i) {
465cerr <<
i<<
" ---> "<<
subjects_[
i] - 1 << endl;
480 c2s_map_.push_back( make_pair(
i- 1, chunk ) );
501 TWordnlengths = *(*map)++;
502nlengths /=
sizeof(
TWord);
509 for(
unsigned long i= 0;
i< nlengths; ++
i) {
510cerr <<
"length( "<<
i<<
") = "<<
lengths_[
i] << endl;
514 TWordnlidmap = *(*map)++;
515nlidmap /=
sizeof(
TWord);
528 TWordnlengths = *(*map)++;
529nlengths /=
sizeof(
TWord);
536 for(
unsigned long i= 0;
i< nlengths; ++
i) {
537cerr <<
"length( "<<
i<<
") = "<<
lengths_[
i] << endl;
541 TWordnlidmap = *(*map)++;
542nlidmap /=
sizeof(
TWord);
546 Load(
map, start, stop, stride );
551 TWord**
map,
unsigned longhkey_width,
552 unsigned longstride,
unsigned longws_hint )
553: total_( 0 ), hkey_width_( hkey_width ), stride_( stride ),
554ws_hint_( ws_hint ), min_offset_(
GetMinOffset( stride ) )
562*
map+= hash_table_size + 1;
Structures and functions prototypes used for BLAST gapped extension.
#define MAX_DBSEQ_LEN
Split subject sequences if longer than this.
Structures and API used for saving BLAST hits.
#define DBSEQ_CHUNK_OVERLAP
By how much should the chunks of a subject sequence overlap if it is too long and has to be split.
Types of exception the indexing library can throw.
@ eBadOption
Bad index creation/search option.
@ eBadVersion
Wrong index version.
@ eBadData
Bad index data.
@ eBadSequence
Bad input sequence data.
virtual const char * GetErrCodeString() const override
Get a human readable description of the exception type.
static SOptions DefaultSOptions()
Creates an SOptions instance initialized with default values.
static const unsigned long STRIDE
Only process every STRIDEth nmer.
static const unsigned char VERSION
Index version that this library handles.
static CRef< CDbIndex > Load(const std::string &fname, bool nomap=false)
Load index.
THashTable hash_table_
The hash table (mapping from Nmer values to the lists of offsets.
COffsetData_Base(TWord **map, unsigned long hkey_width, unsigned long stride, unsigned long ws_hint)
Object constructor.
TWord total_
Auxiliary data member used for importing the offset list data.
CDbIndex::TWord TWord
Index word type (public to support Solaris).
unsigned long hkey_width_
Hash key width in bp.
TLengths lengths_
Subject lengths storage.
TWord offset_mask_
Mask to extract offsets.
unsigned long stride_
Index stride value.
unsigned long max_chunk_size_
void Load(TWord **map, TSeqNum start, TSeqNum stop, unsigned long stride)
Loads index by mapping to the memory segment.
unsigned long min_offset_
Minimum offset used by the index.
Uint1 offset_bits_
Number of bits used to encode offset.
TWord total_
Size in bytes of the raw sequence storage.
TLIdMap lid_map_
Local id -> chunk map storage.
TSubjects subjects_
Mapping from database oids to the chunk info.
TChunks chunks_
Collection of individual chunk descriptors.
TSeqStore seq_store_
Storage for the raw subject sequence data.
unsigned long chunk_overlap_
void SetSeqDataFromMap(TWord **map)
Set up the sequence store from the memory segment.
CSubjectMap()
Trivial constructor.
TSCPairMap c2s_map_
CId -> (SId, RCId) map.
CDbIndex::TSeqNum TSeqNum
TVector::size_type size_type
void SetPtr(T *base, size_type sz)
Make the object hold an external sequence.
size_type size() const
Get the sequence size.
unsigned long GetIndexStride< true >(const SIndexHeader &header)
CRef< CIndexSuperHeader_Base > GetIndexSuperHeader(const std::string &fname)
Read superheader structure from the file.
#define M_CHECK_STREAM(_s, _f, _m)
unsigned long GetIndexStride< false >(const SIndexHeader &header)
const SIndexHeader ReadIndexHeader< false >(void *map)
unsigned long GetMinOffset(unsigned long stride)
Compute the minimum offset value needed encode offsets based on stride.
const SIndexHeader ReadIndexHeader< true >(void *map)
unsigned long GetIndexWSHint< false >(const SIndexHeader &header)
unsigned long GetCodeBits(unsigned long stride)
Compute the number of bits to encode special offsets based on stride.
unsigned long GetIndexWSHint< true >(const SIndexHeader &header)
unsigned long GetIndexVersion(CNcbiIstream &is)
Get the index format version for the index data represented by the input stream.
size_t GetIdxVolNumOIDs(const std::string &fname)
Read the index header information from the given file.
const unsigned long REPORT_NORMAL
Normal reporting.
void ReadWord(CNcbiIstream &is, word_t &data)
Read a word from the input stream.
CDbIndex::TSeqNum TSeqNum
Forwarding declarations for convenience.
TErrCode GetErrCode(void) const
Get error code.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
Int8 GetLength(void) const
Get size of file.
bool CheckAccess(TMode access_mode) const
Check access rights.
virtual bool Exists(void) const
Check existence of file.
uint8_t Uint1
1-byte (8-bit) unsigned integer
uint32_t Uint4
4-byte (32-bit) unsigned integer
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
const string version
version string
const struct ncbi::grid::netcache::search::fields::SIZE size
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
Simple record type used to specify index creation parameters.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4