Exemplo n.º 1
0
// Calculates bijective variant of BWT using sais_bwt
std::string bwt (std::string x)
{
	const unsigned char* T = reinterpret_cast <const unsigned char*> (x.c_str());
	unsigned char* U = (unsigned char*) malloc(sizeof(unsigned char) * x.length());
	int* A = (int*) malloc(sizeof(int) * x.length());

	sais_bwt (T, U, A, x.length());

	std::string transform (reinterpret_cast <char*> (U));

	return transform;
}
Exemplo n.º 2
0
Arquivo: lcp.c Projeto: giavjeko/bio
void bwt_transform(char* string, char* result, int len) {
  int i;
  int* A = (int*)malloc(len * sizeof(int));
  int eof_pos = sais_bwt(string, result, A, len);
  assert(eof_pos > 0);
  char eof = result[0];
  for (i = 0; i < eof_pos - 1; i++) {
    result[i] = result[i+1];
  }
  result[eof_pos - 1] = eof;
  result[len] = 0;
  free(A);
}