Skip to content

Commit

Permalink
used checked index files
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasrausch committed Jul 31, 2019
1 parent 647e65a commit 99e4d53
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 32 deletions.
35 changes: 5 additions & 30 deletions src/fmindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,36 +136,11 @@ namespace tracy
// Load FM index
boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
std::cout << '[' << boost::posix_time::to_simple_string(now) << "] " << "Load FM-Index" << std::endl;
if (!load_from_file(fm_index, index_file)) {
std::cout << '[' << boost::posix_time::to_simple_string(now) << "] " << "Build FM-Index" << std::endl;
// Dump fasta
bool firstSeq = true;
std::ofstream tmpout(outfile.string().c_str());
std::ifstream file(c.genome.string().c_str(), std::ios_base::in | std::ios_base::binary);
boost::iostreams::filtering_streambuf<boost::iostreams::input> dataIn;
dataIn.push(boost::iostreams::gzip_decompressor());
dataIn.push(file);
std::istream instream(&dataIn);
std::string line;
while(std::getline(instream, line)) {
if ((!line.empty()) && (line[0] == '>')) {
if (!firstSeq) tmpout << std::endl;
else firstSeq = false;
} else {
tmpout << boost::to_upper_copy(line);
}
}
tmpout << std::endl;
file.close();
tmpout.close();

now = boost::posix_time::second_clock::local_time();
std::cout << '[' << boost::posix_time::to_simple_string(now) << "] " << "Create FM-Index" << std::endl;

// Build index
construct(fm_index, outfile.string().c_str(), 1);
store_to_file(fm_index, index_file);
boost::filesystem::remove(outfile);

// Check if that's an old index file
if (!load_from_checked_file(fm_index, index_file)) {
std::cerr << "Old index data format. Please rebuild your reference genome index!" << std::endl;
return -1;
}
} else if (traceFormat(c.genome.string()) >= 0) {
rs.filetype = 2;
Expand Down
4 changes: 2 additions & 2 deletions src/index.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace tracy

// Load FM index
now = boost::posix_time::second_clock::local_time();
if (!load_from_file(fm_index, index_file)) {
if (!load_from_checked_file(fm_index, index_file)) {
std::cout << '[' << boost::posix_time::to_simple_string(now) << "] " << "Prepare FM-Index" << std::endl;
// Dump fasta
bool firstSeq = true;
Expand Down Expand Up @@ -136,7 +136,7 @@ namespace tracy

// Build index
construct(fm_index, dumpfile.string().c_str(), 1);
store_to_file(fm_index, index_file);
store_to_checked_file(fm_index, index_file);
boost::filesystem::remove(dumpfile);
}
}
Expand Down

0 comments on commit 99e4d53

Please sign in to comment.