Skip to content

Commit

Permalink
Allow minirmd to run on .fasta files
Browse files Browse the repository at this point in the history
Patches a segfault that occurs when sequences are longer than the first sequence in a file.

Minimal performance hit to check all string lengths.

Elapsed time for max_strlen: 0.331280s

This was to find the longest sequence  for 13,835,165 sequences
  • Loading branch information
Thernn88 committed Feb 13, 2023
1 parent f35cc6e commit e7000a2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/minirmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,19 @@ inline void removeLongDuplicate() {
// cout << "Time of removeLongDuplicate() = " << rdt.stop() << std::endl;
// cout << "--------------\n";
}
int max_strlen() {
int supposed_max = 0;
int curr_len = 0;

for (int rid = 0; rid < max_rid; rid++) {
curr_len = strlen(seq1[rid].seq);
if (curr_len > supposed_max) {
supposed_max = curr_len;
}
}

return supposed_max;
}
int main(int argc, char* argv[]) {
// stopwatch.start();
init();
Expand All @@ -1250,7 +1262,7 @@ int main(int argc, char* argv[]) {
return 0;
}
}
L = strlen(seq1[0].seq);
L = max_strlen()
if (iskf) {
kmervecsize = 0;
kmervec = new int[32];
Expand Down

0 comments on commit e7000a2

Please sign in to comment.