From ba605ceab22645d6ec007a803817a05e158ada67 Mon Sep 17 00:00:00 2001 From: walaj Date: Wed, 22 Mar 2017 21:22:23 -0400 Subject: [PATCH] fixed seq_test issuees with BFC simplification --- README.md | 21 +++++++++++---------- seq_test/seq_test.cpp | 9 +++++---- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 0a831c0c9..6671ca3b3 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/seq_test/seq_test.cpp b/seq_test/seq_test.cpp index 0940a4e65..e692da77c 100644 --- a/seq_test/seq_test.cpp +++ b/seq_test/seq_test.cpp @@ -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(); @@ -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);