Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/util/createdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,12 @@ int createdb(int argc, const char **argv, const Command& command) {

size_t fileCount = filenames.size();
DBReader<unsigned int>* reader = NULL;
DBReader<unsigned int>* hdrReader = nullptr;
if (dbInput == true) {
reader = new DBReader<unsigned int>(par.db1.c_str(), par.db1Index.c_str(), 1, DBReader<unsigned int>::USE_DATA | DBReader<unsigned int>::USE_INDEX | DBReader<unsigned int>::USE_LOOKUP);
reader->open(DBReader<unsigned int>::LINEAR_ACCCESS);
hdrReader = new DBReader<unsigned int>((par.db1 + "_h").c_str(), (par.db1 + "_h.index").c_str(), 1, DBReader<unsigned int>::USE_DATA | DBReader<unsigned int>::USE_INDEX);
hdrReader->open(DBReader<unsigned int>::LINEAR_ACCCESS);
fileCount = reader->getSize();
}

Expand All @@ -126,8 +129,11 @@ int createdb(int argc, const char **argv, const Command& command) {
}

KSeqWrapper* kseq = NULL;
std::string seq = ">";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this into the if condition?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we can't :( we need to refer to the address of this string later. Variables defined inside if {} block is not accessible to the outer scope.

if (dbInput == true) {
kseq = new KSeqBuffer(reader->getData(fileIdx, 0), reader->getEntryLen(fileIdx) - 1);
seq.append(hdrReader->getData(fileIdx, 0));
seq.append(reader->getData(fileIdx, 0));
kseq = new KSeqBuffer(seq.c_str(), seq.length());
} else {
kseq = KSeqFactory(filenames[fileIdx].c_str());
}
Expand Down Expand Up @@ -260,6 +266,8 @@ int createdb(int argc, const char **argv, const Command& command) {
if (dbInput == true) {
reader->close();
delete reader;
hdrReader->close();
delete hdrReader;
}

if (entries_num == 0) {
Expand Down