Skip to content

Commit

Permalink
fixed seq_test issuees with BFC simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
walaj committed Mar 23, 2017
1 parent 721eb22 commit ba605ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,21 +301,22 @@ w.Close(); // Optional. Will close on destruction
using namespace SeqLib;
// brv is some set of reads to train the error corrector
b.TrainCorrection(brv);
for (BamRecordVector::const_iterator r = brv.begin(); r != brv.end(); ++r)
b.AddSequence(r->Sequence().c_str(), r->Qualities().c_str(), r->Qname().c_str());
b.Train();
b.clear(); // clear the training sequences. Training parameters saved in BFC object
// brv2 is some set to correct
b.ErrorCorrect(brv2);
for (BamRecordVector::const_iterator r = brv2.begin(); r != brv2.end(); ++r)
b.AddSequence(r->Sequence().c_str(), r->Qualities().c_str(), r->Qname().c_str());
b.ErrorCorrect();
// retrieve the sequences
UnalignedSequenceVector v;
b.GetSequences(v);
// alternatively, to train and correct the same set of reads
b.TrainAndCorrect(brv);
b.GetSequences(v);
std::string name, seq;
while (b.GetSequences(seq, name))
v.push_back({name, seq});
// alternatively, train and correct, and modify the sequence in-place
b.TrainCorrection(brv);
b.ErrorCorrectInPlace(brv);
```

Support
Expand Down
9 changes: 5 additions & 4 deletions seq_test/seq_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ BOOST_AUTO_TEST_CASE( correct_and_assemble ) {
BamRecordVector brv, brv2;
size_t count = 0;
while(br.GetNextRecord(rec) && count++ < 10000)
brv.push_back(rec);

//b.TrainAndCorrect(brv);
b.AddSequence(rec.Sequence().c_str(), rec.Qualities().c_str(), rec.Qname().c_str());

b.Train();
b.ErrorCorrect();

float kcov = b.GetKCov();
int kmer = b.GetKMer();
Expand Down Expand Up @@ -990,7 +991,7 @@ BOOST_AUTO_TEST_CASE( set_qualities ) {
SeqLib::BamRecord r;
while (br.GetNextRecord(r)) {
r.SetQualities("", 0);
BOOST_CHECK_EQUAL(r.Qualities(), std::string());
BOOST_CHECK_EQUAL(r.Qualities().at(0), '!');
r.SetQualities(std::string(r.Length(), '#'), 33);
BOOST_CHECK_EQUAL(r.Qualities(), std::string(r.Length(), '#'));
BOOST_CHECK_THROW(r.SetQualities(std::string(8, '#'), 0), std::invalid_argument);
Expand Down

0 comments on commit ba605ce

Please sign in to comment.