Skip to content

Commit

Permalink
Made sure we properly check the size.
Browse files Browse the repository at this point in the history
  • Loading branch information
val-antonescu committed Mar 4, 2014
1 parent 15aba3d commit ec36352
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
29 changes: 29 additions & 0 deletions btypes.h
@@ -0,0 +1,29 @@


#ifndef BOWTIE_INDEX_TYPES_H
#define BOWTIE_INDEX_TYPES_H

#ifdef BOWTIE_64BIT_INDEX
#define OFF_MASK 0xffffffffffffffff
#define OFF_LEN_MASK 0xc000000000000000
#define LS_SIZE 0x100000000000000
#define OFF_SIZE 8

typedef uint64_t TIndexOffU;
typedef int64_t TIndexOff;

#else
#define OFF_MASK 0xffffffff
#define OFF_LEN_MASK 0xc0000000
#define LS_SIZE 0x10000000
#define OFF_SIZE 4

typedef uint32_t TIndexOffU;
typedef int TIndexOff;

#endif /* BOWTIE_64BIT_INDEX */

extern const std::string gEbwt_ext;

#endif /* BOWTIE_INDEX_TYPES_H */

10 changes: 7 additions & 3 deletions ref_read.cpp
Expand Up @@ -235,7 +235,7 @@ fastaRefReadSizes(vector<FileBuf*>& in,
BitpairOutFileBuf* bpout,
int& numSeqs)
{
uint32_t unambigTot = 0;
TIndexOffU unambigTot = 0;
uint32_t bothTot = 0;
assert_gt(in.size(), 0);
uint32_t both = 0, unambig = 0;
Expand All @@ -258,9 +258,13 @@ fastaRefReadSizes(vector<FileBuf*>& in,
if(rec.len == 0) rec.first = false;
#endif
if((unambigTot + rec.len) < unambigTot) {
#ifdef BOWTIE_64BIT_INDEX
cerr << "Error: Reference sequence has more than 2^32-1 characters! Please divide the" << endl
<< "reference into batches or chunks of about 3.6 billion characters or less each" << endl
<< "and index each independently." << endl;
<< "reference into smaller chunks and index each independently." << endl;
#else
cerr << "Error: Reference sequence has more than 2^32-1 characters! Please try to" << endl
<< "build a large index instead using the appropiate options." << endl;
#endif
throw 1;
}
// Add the length of this record.
Expand Down
1 change: 1 addition & 0 deletions word_io.h
Expand Up @@ -6,6 +6,7 @@
#include <fstream>
#include "assert_helpers.h"
#include "endian_swap.h"
#include "btypes.h"

/**
* Write a 32-bit unsigned to an output stream being careful to
Expand Down

0 comments on commit ec36352

Please sign in to comment.