[med-svn] [python-pbconsensuscore] 04/07: Imported Upstream version 1.0.1
Afif Elghraoui
afif-guest at moszumanska.debian.org
Wed Nov 25 08:26:30 UTC 2015
This is an automated email from the git hooks/post-receive script.
afif-guest pushed a commit to branch master
in repository python-pbconsensuscore.
commit efb807b65485cab5caaeacf6d24e73373ec72c46
Author: Afif Elghraoui <afif at ghraoui.name>
Date: Tue Nov 24 22:44:13 2015 -0800
Imported Upstream version 1.0.1
---
CHANGELOG.md | 4 ++++
include/ConsensusCore/Version.hpp | 2 +-
setup.py | 2 +-
src/C++/Poa/PoaGraphImpl.cpp | 2 +-
src/C++/Poa/PoaGraphImpl.hpp | 35 +++++++++++++++++++++++++++++++
src/C++/Poa/PoaGraphTraversals.cpp | 2 +-
src/C++/Poa/RangeFinder.cpp | 2 +-
src/C++/Quiver/MutationScorer.cpp | 27 ++++++++++++++++--------
src/Tests/TestPoaConsensus.cpp | 42 ++++++++++++++++++++++++++++++++++++++
9 files changed, 104 insertions(+), 14 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 85afbe5..d959193 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+* Version 1.0.1
+ - Fix for a serious memory leak occurring on alpha/beta mating failures. Thanks Nigel!
+ - Fix for nondeterministic POA consensus
+
* Version 1.0.0
- Minor build/deploy system tweaks. No API changes.
diff --git a/include/ConsensusCore/Version.hpp b/include/ConsensusCore/Version.hpp
index 316d02c..2c116ed 100644
--- a/include/ConsensusCore/Version.hpp
+++ b/include/ConsensusCore/Version.hpp
@@ -43,7 +43,7 @@
#define API_MAJOR 1
#define API_MINOR 0
-#define API_PATCH 0
+#define API_PATCH 1
namespace ConsensusCore
{
diff --git a/setup.py b/setup.py
index ccaaeb9..9f91a40 100755
--- a/setup.py
+++ b/setup.py
@@ -94,7 +94,7 @@ if "install" in sys.argv and not "build" in sys.argv:
sys.argv.insert(installPos, "build")
setup(name="ConsensusCore",
- version="1.0.0",
+ version="1.0.1",
author="Pacific Biosciences",
author_email="devnet at pacificbiosciences.com",
url="http://www.github.com/PacificBiosciences/ConsensusCore",
diff --git a/src/C++/Poa/PoaGraphImpl.cpp b/src/C++/Poa/PoaGraphImpl.cpp
index 188fd79..266b0b4 100644
--- a/src/C++/Poa/PoaGraphImpl.cpp
+++ b/src/C++/Poa/PoaGraphImpl.cpp
@@ -155,7 +155,7 @@ namespace detail {
{
vector<const AlignmentColumn*> predecessorColumns;
const AlignmentColumn* predCol;
- foreach (ED e, in_edges(v, g))
+ foreach (ED e, inEdges(v, g))
{
VD u = source(e, g);
predCol = colMap.at(u);
diff --git a/src/C++/Poa/PoaGraphImpl.hpp b/src/C++/Poa/PoaGraphImpl.hpp
index 9aed30c..afa0a20 100644
--- a/src/C++/Poa/PoaGraphImpl.hpp
+++ b/src/C++/Poa/PoaGraphImpl.hpp
@@ -107,6 +107,41 @@ namespace detail {
typedef property_map<BoostGraph, vertex_index_t>::type index_map_t;
static const VD null_vertex = graph_traits<BoostGraph>::null_vertex();
+
+ struct EdgeComparator
+ {
+ EdgeComparator(const BoostGraph& g) : g_(g) {}
+
+ // want lex. comparison... just using pair to get it..
+ bool operator() (ED e1, ED e2)
+ {
+ std::pair<int, int> vt1, vt2;
+ vt1 = std::make_pair(get(vertex_index, g_, source(e1, g_)),
+ get(vertex_index, g_, target(e1, g_)));
+ vt2 = std::make_pair(get(vertex_index, g_, source(e2, g_)),
+ get(vertex_index, g_, target(e2, g_)));
+ return (vt1 < vt2);
+ }
+
+ private:
+ const BoostGraph& g_;
+ };
+
+ inline std::vector<ED> inEdges(VD v, const BoostGraph& g)
+ {
+ // This is a sad workaround the nondeterministic order of iteration
+ // from BGL's in_edges. (see: http://stackoverflow.com/questions/30968690/)
+
+ // Unfortunately, we can't just use the boost::sort range adapter
+ // because it requires an underlying random access iterator, which
+ // we can't get from the std::set container.
+ graph_traits<BoostGraph>::in_edge_iterator begin, end;
+ tie(begin, end) = in_edges(v, g);
+ std::vector<ED> tmp(begin, end);
+ std::sort(tmp.begin(), tmp.end(), EdgeComparator(g));
+ return tmp;
+ }
+
struct AlignmentColumn : noncopyable
{
VD CurrentVertex;
diff --git a/src/C++/Poa/PoaGraphTraversals.cpp b/src/C++/Poa/PoaGraphTraversals.cpp
index e5862ce..dfce3f6 100644
--- a/src/C++/Poa/PoaGraphTraversals.cpp
+++ b/src/C++/Poa/PoaGraphTraversals.cpp
@@ -124,7 +124,7 @@ namespace detail {
vInfo.Score = score;
vInfo.ReachingScore = score;
bestPrevVertex[v] = null_vertex;
- foreach (ED e, in_edges(v, g_))
+ foreach (ED e, inEdges(v, g_))
{
VD sourceVertex = source(e, g_);
float rsc = score + vertexInfoMap_[sourceVertex].ReachingScore;
diff --git a/src/C++/Poa/RangeFinder.cpp b/src/C++/Poa/RangeFinder.cpp
index c4f4d1b..1c300f4 100644
--- a/src/C++/Poa/RangeFinder.cpp
+++ b/src/C++/Poa/RangeFinder.cpp
@@ -123,7 +123,7 @@ namespace detail {
fwdMarks[v] = directRange.get();
} else {
std::vector<Interval> predRangesStepped;
- foreach (ED e, in_edges(v, poaGraph.g_))
+ foreach (ED e, inEdges(v, poaGraph.g_))
{
VD pred = source(e, poaGraph.g_);
Interval predRangeStepped = next(fwdMarks.at(pred), readLength);
diff --git a/src/C++/Quiver/MutationScorer.cpp b/src/C++/Quiver/MutationScorer.cpp
index 5a0606d..1f42fea 100644
--- a/src/C++/Quiver/MutationScorer.cpp
+++ b/src/C++/Quiver/MutationScorer.cpp
@@ -57,15 +57,24 @@ namespace ConsensusCore
: evaluator_(new EvaluatorType(evaluator)),
recursor_(new R(recursor))
{
- // Allocate alpha and beta
- alpha_ = new MatrixType(evaluator.ReadLength() + 1,
- evaluator.TemplateLength() + 1);
- beta_ = new MatrixType(evaluator.ReadLength() + 1,
- evaluator.TemplateLength() + 1);
- // Buffer where we extend into
- extendBuffer_ = new MatrixType(evaluator.ReadLength() + 1, EXTEND_BUFFER_COLUMNS);
- // Initial alpha and beta
- numFlipFlops_ = recursor.FillAlphaBeta(*evaluator_, *alpha_, *beta_);
+ try {
+ // Allocate alpha and beta
+ alpha_ = new MatrixType(evaluator.ReadLength() + 1,
+ evaluator.TemplateLength() + 1);
+ beta_ = new MatrixType(evaluator.ReadLength() + 1,
+ evaluator.TemplateLength() + 1);
+ // Buffer where we extend into
+ extendBuffer_ = new MatrixType(evaluator.ReadLength() + 1, EXTEND_BUFFER_COLUMNS);
+ // Initial alpha and beta
+ numFlipFlops_ = recursor.FillAlphaBeta(*evaluator_, *alpha_, *beta_);
+ }
+ catch(AlphaBetaMismatchException e) {
+ delete alpha_;
+ delete beta_;
+ delete extendBuffer_;
+ delete recursor_;
+ throw;
+ }
}
template<typename R>
diff --git a/src/Tests/TestPoaConsensus.cpp b/src/Tests/TestPoaConsensus.cpp
index 7717c33..5ef7796 100644
--- a/src/Tests/TestPoaConsensus.cpp
+++ b/src/Tests/TestPoaConsensus.cpp
@@ -530,3 +530,45 @@ TEST(PoaConsensus, TestMutations)
delete pc;
}
#endif
+
+
+TEST(PoaConsensus, NondeterminismRegressionTest)
+{
+ //
+ // This is a regression test for a real-world case of
+ // nondeterminism found in the POA on a quiver job on Staph.
+ //
+ std::vector<std::string> reads;
+ reads += \
+ "TATCAATCAACGAAATTCGCCAATTCCGTCATGAATGTCAATATCTAACTACACTTTAGAATACATTCTT"
+ "TGACATGCCTGGCCTATTGATATTTCAATAAAATCAGACTATAAAGACAACTTACAAATGATCCTATAAA"
+ "TTAAAGATCGAGAATCTAAAGAGTGAAATTAAAGCTAATTACTGCTTTAAAAATTTTACGTGCACACAAA"
+ "AATGAATTTATCCTCATTATATCGAAAATACCATGAAGTATAGTAAGCTAACTTGAATATGATCATTAAT"
+ "CGGCTATATGATTATTTTGATAATGCAATGAGCATCAATCTGAATTTATGACCTATCATTCGCGTTGCAT"
+ "TTATTGAAGTGAAAATTCATGTACGCTTTTTTATTTTATTAATATAATCCTTGATATTGGTTATATACCA"
+ "CGCTGTCACATAATTTTCAATAAATTTTTCTACTAAATGAAGTGTCTGTTATCTATCAC";
+ reads += \
+ "TATCAACAACGAAAATGCGCAGTTACGTCATGATTTATGTCAAATAATCTAAACGACACTTTCAGAAATA"
+ "AATACATTCGAGAAGATGAATGCCTGGCGCAAAGTGATTATTTCAATAAAATATTTGTACCTTGAAAGAC"
+ "AATTTACAAATGAATGCTATAAAATTTAAATGGATCCGGAGAATCTTTAAAGTACGTGAAATTAAAGGCT"
+ "AAGATTACTGCGAAAAATTTTCGTGCACAAGAAATGAATGTTCCAGATTAGTATCGGAAAATAAGCCATG"
+ "AAGAAGCTAGCATTAACTTGAATATGATCGATTTAATCGGCAGTATTGGTAATTATCTTGATAAGCAATT"
+ "GAGCATCAACTGAAATTGAATGACTCTACATGCCTCGCTGAGTATGCGATTTATTGAAAGTGAAATTCAG"
+ "TAAAGTTTATTGTTATGAATAAATGCGTACTTGGATGAATATCCCGACGGTAGTTCAAGTGTAAATGGAG"
+ "TGAGGGGGTTCTTTCTTATAGAATAGTTTTATACTACTGATAAGGTGTAACCTGAGTGAGTCGTGATTTT"
+ "AGAGTTACTTGCGAAC";
+
+ std::set<std::string> answers;
+ for (int run=0; run<1000; run++)
+ {
+ const PoaConsensus* pc = PoaConsensus::FindConsensus(reads, GLOBAL);
+#if 0
+ char fname[100];
+ sprintf(fname, "/tmp/gr%03d.dot", run);
+ pc->WriteGraphVizFile(fname, (PoaGraph::VERBOSE_NODES | PoaGraph::COLOR_NODES));
+#endif
+ answers.insert(pc->Sequence);
+ delete pc;
+ }
+ ASSERT_EQ(1, answers.size());
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-pbconsensuscore.git
More information about the debian-med-commit
mailing list