Skip to content

Commit

Permalink
Fix padded seq db creation
Browse files Browse the repository at this point in the history
  • Loading branch information
milot-mirdita committed Dec 7, 2023
1 parent 1806c0c commit 2fad714
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions src/util/makepaddedseqdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@
#include "Util.h"

int makepaddedseqdb(int argc, const char **argv, const Command &command) {
const char AA_TO_20[256] = {
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 0, 20, 4, 3, 6, 13, 7, 8, 9, 20, 11, 10, 12, 2, 20,
14, 5, 1, 15, 16, 20, 19, 17, 20, 18, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20
};

Parameters &par = Parameters::getInstance();
par.parseParameters(argc, argv, command, true, 0, 0);
DBReader<unsigned int> dbr(par.db1.c_str(), par.db1Index.c_str(), 1,
Expand All @@ -19,11 +38,15 @@ int makepaddedseqdb(int argc, const char **argv, const Command &command) {
char *data = dbr.getData(id, 0);
size_t seqLen = dbr.getSeqLen(id);
const size_t sequencepadding = (seqLen % ALIGN == 0) ? 0 : ALIGN - seqLen % ALIGN;
result.append(data, seqLen);
result.append(sequencepadding, ' ');
writer.writeData(data, seqLen + sequencepadding, key, 0, false);
for (size_t i = 0; i < seqLen; i++) {
result.append(1, AA_TO_20[(unsigned char)data[i]]);
}
result.append(sequencepadding, static_cast<char>(20));
writer.writeData(result.c_str(), result.size(), key, 0, false, false);
writer.writeIndexEntry(key, writer.getStart(0), seqLen, 0);
result.clear();
}
writer.close(true);
writer.close(true, false);
DBReader<unsigned int>::softlinkDb(par.db1, par.db2, DBFiles::SEQUENCE_ANCILLARY);

dbr.close();
Expand Down

0 comments on commit 2fad714

Please sign in to comment.