Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add createdb support for sequence db input #545

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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;
matchy233 marked this conversation as resolved.
Show resolved Hide resolved
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);
matchy233 marked this conversation as resolved.
Show resolved Hide resolved
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