a little bit code clean up
This commit is contained in:
parent
d70754e234
commit
d2f357af3a
|
|
@ -257,13 +257,11 @@ BWT *BWTCreate(const unsigned int textLength, unsigned int *decodeTable)
|
|||
bwt = (BWT*)calloc(1, sizeof(BWT));
|
||||
|
||||
bwt->textLength = 0;
|
||||
bwt->inverseSa = 0;
|
||||
|
||||
bwt->cumulativeFreq = (unsigned*)calloc((ALPHABET_SIZE + 1), sizeof(unsigned int*));
|
||||
initializeVAL(bwt->cumulativeFreq, ALPHABET_SIZE + 1, 0);
|
||||
|
||||
bwt->bwtSizeInWord = 0;
|
||||
bwt->saValueOnBoundary = NULL;
|
||||
|
||||
// Generate decode tables
|
||||
if (decodeTable == NULL) {
|
||||
|
|
@ -279,14 +277,6 @@ BWT *BWTCreate(const unsigned int textLength, unsigned int *decodeTable)
|
|||
bwt->occSizeInWord = 0;
|
||||
bwt->occValue = NULL;
|
||||
|
||||
bwt->saInterval = ALL_ONE_MASK;
|
||||
bwt->saValueSize = 0;
|
||||
bwt->saValue = NULL;
|
||||
|
||||
bwt->inverseSaInterval = ALL_ONE_MASK;
|
||||
bwt->inverseSaSize = 0;
|
||||
bwt->inverseSa = NULL;
|
||||
|
||||
return bwt;
|
||||
}
|
||||
|
||||
|
|
@ -1047,7 +1037,6 @@ void BWTGenerateOccValueFromBwt(const unsigned int* bwt, unsigned int* __restri
|
|||
wordBetweenOccValue = OCC_INTERVAL / CHAR_PER_WORD;
|
||||
|
||||
// Calculate occValue
|
||||
// [lh3] by default: OCC_INTERVAL_MAJOR=65536, OCC_INTERVAL=256
|
||||
numberOfOccValue = (textLength + OCC_INTERVAL - 1) / OCC_INTERVAL + 1; // Value at both end for bi-directional encoding
|
||||
numberOfOccIntervalPerMajor = OCC_INTERVAL_MAJOR / OCC_INTERVAL;
|
||||
numberOfOccValueMajor = (numberOfOccValue + numberOfOccIntervalPerMajor - 1) / numberOfOccIntervalPerMajor;
|
||||
|
|
@ -1464,11 +1453,7 @@ void BWTFree(BWT *bwt)
|
|||
free(bwt->bwtCode);
|
||||
free(bwt->occValue);
|
||||
free(bwt->occValueMajor);
|
||||
free(bwt->saValue);
|
||||
free(bwt->inverseSa);
|
||||
free(bwt->decodeTable);
|
||||
free(bwt->saIndexRange);
|
||||
free(bwt->saValueOnBoundary);
|
||||
free(bwt);
|
||||
}
|
||||
|
||||
|
|
@ -1503,19 +1488,6 @@ void BWTSaveBwtCodeAndOcc(const BWT *bwt, const char *bwtFileName, const char *o
|
|||
bwtLength = BWTFileSizeInWord(bwt->textLength);
|
||||
fwrite(bwt->bwtCode, sizeof(unsigned int), bwtLength, bwtFile);
|
||||
fclose(bwtFile);
|
||||
/*
|
||||
occValueFile = (FILE*)fopen(occValueFileName, "wb");
|
||||
if (occValueFile == NULL) {
|
||||
fprintf(stderr, "BWTSaveBwtCodeAndOcc(): Cannot open occ value file!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fwrite(&bwt->inverseSa0, sizeof(unsigned int), 1, occValueFile);
|
||||
fwrite(bwt->cumulativeFreq + 1, sizeof(unsigned int), ALPHABET_SIZE, occValueFile);
|
||||
fwrite(bwt->occValue, sizeof(unsigned int), bwt->occSizeInWord, occValueFile);
|
||||
fwrite(bwt->occValueMajor, sizeof(unsigned int), bwt->occMajorSizeInWord, occValueFile);
|
||||
fclose(occValueFile);
|
||||
*/
|
||||
}
|
||||
|
||||
void bwt_bwtgen(const char *fn_pac, const char *fn_bwt)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,11 @@
|
|||
#ifndef BWT_GEN_H
|
||||
#define BWT_GEN_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//typedef int64_t bgint_t;
|
||||
typedef unsigned bgint_t;
|
||||
|
||||
#define ALPHABET_SIZE 4
|
||||
#define BIT_PER_CHAR 2
|
||||
#define CHAR_PER_WORD 16
|
||||
|
|
@ -56,32 +61,17 @@
|
|||
#define truncateRight(value, offset) ( (value) >> (offset) << (offset) )
|
||||
#define DNA_OCC_SUM_EXCEPTION(sum) ((sum & 0xfefefeff) == 0)
|
||||
|
||||
typedef struct SaIndexRange {
|
||||
unsigned int startSaIndex;
|
||||
unsigned int endSaIndex;
|
||||
} SaIndexRange;
|
||||
|
||||
typedef struct BWT {
|
||||
unsigned int textLength; // length of the text
|
||||
unsigned int saInterval; // interval between two SA values stored explicitly
|
||||
unsigned int inverseSaInterval; // interval between two inverse SA stored explicitly
|
||||
unsigned int inverseSa0; // SA-1[0]
|
||||
unsigned int *cumulativeFreq; // cumulative frequency
|
||||
bgint_t textLength; // length of the text
|
||||
bgint_t inverseSa0; // SA-1[0]
|
||||
bgint_t *cumulativeFreq; // cumulative frequency
|
||||
unsigned int *bwtCode; // BWT code
|
||||
unsigned int *occValue; // Occurrence values stored explicitly
|
||||
unsigned int *occValueMajor; // Occurrence values stored explicitly
|
||||
unsigned int *saValue; // SA values stored explicitly
|
||||
unsigned int *inverseSa; // Inverse SA stored explicitly
|
||||
SaIndexRange *saIndexRange; // SA index range
|
||||
int saIndexRangeNumOfChar; // Number of characters indexed in SA index range
|
||||
unsigned int *saValueOnBoundary; // Pre-calculated frequently referred data
|
||||
bgint_t *occValueMajor; // Occurrence values stored explicitly
|
||||
unsigned int *decodeTable; // For decoding BWT by table lookup
|
||||
unsigned int decodeTableGenerated; // == TRUE if decode table is generated on load and will be freed
|
||||
unsigned int bwtSizeInWord; // Temporary variable to hold the memory allocated
|
||||
unsigned int occSizeInWord; // Temporary variable to hold the memory allocated
|
||||
unsigned int occMajorSizeInWord; // Temporary variable to hold the memory allocated
|
||||
unsigned int saValueSize; // Temporary variable to hold the memory allocated
|
||||
unsigned int inverseSaSize; // Temporary variable to hold the memory allocated
|
||||
unsigned int saIndexRangeSize; // Temporary variable to hold the memory allocated
|
||||
} BWT;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue