FormattedFile::readRecord is slow with std::string

Open
#866 10 comments 0 reactions 1 assignee View on GitHub

@temehi is already working on this.

Since Nov 9, 2015.

Assessment

This issue has not been assessed yet.

Description

enhancement Port to SeqAn3

stream/tokenization.h:311 Assertion failed : optr < ochunk.end should be true but was 0

Here's a minimal test case:

(env)mcrusoe@athyra:~/khmer/gl-master$ g++ -I/home/mcrusoe/src/seqan/seqan-1.4.2/core/include/ seqan-std-string-test-1.4.cc -o seqan-std-string-test-1.4 -g
(env)mcrusoe@athyra:~/khmer/gl-master$ g++ -I/home/mcrusoe/src/seqan/seqan-seqan-v2.0.0/include/ seqan-std-string-test-2.0.cc -o seqan-std-string-test-2.0 -g
(env)mcrusoe@athyra:~/khmer/gl-master$ ./seqan-std-string-test-1.4 tests/test-data/random-20-a.fa | head
35      CGCAGGCTGGATTCTAGAGGCAGAGGTGAGCTATAAGATATTGCATACGTTGAGCCAGC
16      CGGAAGCCCAATGAGTTGTCAGAGTCACCTCCACCCCGGGCCCTGTTAGCTACGTCCGT
46      GGTCGTGTTGGGTTAACAAAGGATCCCTGACTCGATCCAGCTGGGTAGGGTAACTATGT
40      GGCTGAAGGAGCGGGCGTACGTGTTTACGGCATGATGGCCGGTGATTATGGGGGACGGG
33      GCAGCGGCTTTGAATGCCGAATATATAACAGCGACGGGGTTCAATAAGCTGCACATGCG
98      ACCAGATGCATAGCCCAACAGCTGAGACATTCCCAGCTCGCGAACCAAGACGTGAGAGC
17      CCCTGTTAGCTACGTCCGTCTAAGGATATTAACATAGTTGCGACTGCGTCCTGTGCTCA
89      GCGAGATACTAGCAAAGGTTCATCAACAGCTACACCCGACGAACCCCGAGAAATTGGGA
30      GTTATGGTCCAGGATGAATGCGCGTACCGGGCGCCTATCACTCCTCTTGTCATTCAGAA
82      ATGCACTATATTTAAGAGGTCTAGAGTGTAAAAAGTGTACCCTTCGGGGTGGAGCTGTT
(env)mcrusoe@athyra:~/khmer/gl-master$ ./seqan-std-string-test-2.0 tests/test-data/random-20-a.fa
/home/mcrusoe/src/seqan/seqan-seqan-v2.0.0/include/seqan/stream/tokenization.h:311 Assertion failed : optr < ochunk.end should be true but was 0
Aborted (core dumped)

Seqan 1.4 version:

#include <seqan/seq_io.h>

int main(int argc, char const ** argv) {
        seqan::SequenceStream _stream;
        seqan::open(_stream, argv[1]);
        std::string name;
        std::string sequence;
        std::string quality;
        while (!seqan::atEnd(_stream)) {
                seqan::readRecord(name, sequence, quality, _stream);
                std::cout << name << '\t' << sequence << '\t' << quality << '\n';
        } 
}

Seqan 2.0 version

#include <seqan/seq_io.h>

int main(int argc, char const ** argv) {
        seqan::SeqFileIn _file;
        seqan::open(_file, argv[1]);
        std::string name;
        std::string sequence;
        std::string quality;
        //seqan::readRecord(name, sequence, _file);
        while (!seqan::atEnd(_file)) {
                seqan::readRecord(name, sequence, quality, _file);
                std::cout << name << '\t' << sequence << '\t' << quality << '\n';
        } 
}

(I ran into this by implementing the Seqan 2.0 changes as recommended by @esiragusa in https://github.com/esiragusa/khmer/commit/66f8c688d74acf06362dc91c35953f6c460c5bba )

Dominant language
C++
Stars
502
Forks
172
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from seqan/seqan

All issues in seqan/seqan

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.