Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/liulab-dfci/TRUST4
Browse files Browse the repository at this point in the history
  • Loading branch information
mourisl committed May 23, 2023
2 parents dd7b010 + 773a142 commit b8135de
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions BarcodeTranslator.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#ifndef _MOURISL_BARCODETRANSLATOR
#define _MOURISL_BARCODETRANSLATOR

#include <cinttypes>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <string>
Expand Down Expand Up @@ -41,28 +39,19 @@ class BarcodeTranslator {

void SetTranslateTable(const std::string &file) {
barcode_translate_table_ = kh_init(barcodeHash);

if (1) {
gzFile barcode_translate_file = gzopen(file.c_str(), "r");
const uint32_t line_buffer_size = 512;
char file_line[line_buffer_size];
while (gzgets(barcode_translate_file, file_line, line_buffer_size) != NULL) {
int line_len = strlen(file_line);
if (file_line[line_len - 1] == '\n') {
file_line[line_len - 1] = '\0';
}
std::string tmp_string(file_line);
ProcessTranslateFileLine(tmp_string);
}
gzclose(barcode_translate_file) ;
} else {
// Old implementation, which does not support gzipped input.
std::ifstream file_stream(file);
std::string file_line;
while (getline(file_stream, file_line)) {
ProcessTranslateFileLine(file_line);

gzFile barcode_translate_file = gzopen(file.c_str(), "r");
const uint32_t line_buffer_size = 512;
char file_line[line_buffer_size];
while (gzgets(barcode_translate_file, file_line, line_buffer_size) != NULL) {
int line_len = strlen(file_line);
if (file_line[line_len - 1] == '\n') {
file_line[line_len - 1] = '\0';
}
std::string tmp_string(file_line);
ProcessTranslateFileLine(tmp_string);
}
gzclose(barcode_translate_file) ;
}

std::string Translate(char *bc, uint32_t bc_length) {
Expand Down

0 comments on commit b8135de

Please sign in to comment.