Skip to content

Commit ebaedb7

Browse files
committed
Fix createdb support for db input
1 parent 92deb92 commit ebaedb7

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/util/createdb.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,12 @@ int createdb(int argc, const char **argv, const Command& command) {
9898

9999
size_t fileCount = filenames.size();
100100
DBReader<unsigned int>* reader = NULL;
101+
DBReader<unsigned int>* hdrReader = nullptr;
101102
if (dbInput == true) {
102103
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);
103104
reader->open(DBReader<unsigned int>::LINEAR_ACCCESS);
105+
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);
106+
hdrReader->open(DBReader<unsigned int>::LINEAR_ACCCESS);
104107
fileCount = reader->getSize();
105108
}
106109

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

128131
KSeqWrapper* kseq = NULL;
132+
std::string seq = ">";
129133
if (dbInput == true) {
130-
kseq = new KSeqBuffer(reader->getData(fileIdx, 0), reader->getEntryLen(fileIdx) - 1);
134+
seq.append(hdrReader->getData(fileIdx, 0));
135+
seq.append(reader->getData(fileIdx, 0));
136+
kseq = new KSeqBuffer(seq.c_str(), seq.length());
131137
} else {
132138
kseq = KSeqFactory(filenames[fileIdx].c_str());
133139
}
@@ -260,6 +266,8 @@ int createdb(int argc, const char **argv, const Command& command) {
260266
if (dbInput == true) {
261267
reader->close();
262268
delete reader;
269+
hdrReader->close();
270+
delete hdrReader;
263271
}
264272

265273
if (entries_num == 0) {

0 commit comments

Comments
 (0)