Changeset 4038
- Timestamp:
- Jan 25, 2021, 5:33:35 AM (2 years ago)
- Location:
- branches/kendall-score
- Files:
-
- 4 deleted
- 41 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/kendall-score
- Property svn:mergeinfo changed
/branches/0.18-stable (added) merged: 4000,4006-4008,4012-4017,4020,4028-4030 /trunk (added) merged: 4003-4005,4009-4011,4019,4021-4027,4032,4034-4036
- Property svn:mergeinfo changed
-
branches/kendall-score/NEWS
r4001 r4038 10 10 yat 0.18.x series from http://dev.thep.lu.se/yat/svn/branches/0.18-stable 11 11 12 version 0.18 (released NOT YET) 12 version 0.18.1 (released 21 January 2021) 13 - SegmentTree::key_comp() and ::value_comp() now compile (bug #970). 14 15 A complete list of closed tickets can be found here [[br]] 16 http://dev.thep.lu.se/yat/query?status=closed&milestone=yat+0.18.1 17 18 version 0.18 (released 6 November 2020) 13 19 - regression::NegativeBinomial now inherits from 14 20 regression::Multivariate (ticket #957) … … 558 564 Copyright (C) 2010, 2011 Peter Johansson 559 565 Copyright (C) 2012 Jari Häkkinen, Peter Johansson 560 Copyright (C) 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Peter Johansson566 Copyright (C) 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Peter Johansson 561 567 562 568 This file is part of yat library, http://dev.thep.lu.se/yat -
branches/kendall-score/build_support/Makefile.am
r3987 r4038 89 89 --exec-prefix="$(exec_prefix)" \ 90 90 --libdir="$(libdir)" --includedir="$(includedir)" \ 91 --input=" ../$(srcdir)/build_support/yat.pc.in" > yat.pc-t \91 --input="$(abs_srcdir)/build_support/yat.pc.in" > yat.pc-t \ 92 92 && mv yat.pc-t yat.pc -
branches/kendall-score/doc/Makefile.am
r3987 r4038 47 47 EXTRA_DIST += doc/doxygen.config.in 48 48 49 doc/doxygen.config: doc/doxygen.config.in 49 # config file needs to be updated when $(DOXYGEN_INPUT) is 50 # changed. That variable is set in various Makefile.am, but instead we 51 # depend on Makefile.in, since that dependency is easier to maintain. 52 doc/doxygen.config: doc/doxygen.config.in $(srcdir)/Makefile.in 50 53 $(AM_V_GEN)echo "# $@ generated by make from doc/doxygen.config.in." \ 51 54 > $@-t \ -
branches/kendall-score/m4/version.m4
r4001 r4038 2 2 # 3 3 # Copyright (C) 2008, 2009 Jari Häkkinen, Peter Johansson 4 # Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2017, 2018, 2019, 2020 Peter Johansson4 # Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2017, 2018, 2019, 2020, 2021 Peter Johansson 5 5 # 6 6 # This file is part of the yat library, http://dev.thep.lu.se/yat … … 95 95 # yat-0.17.1 14:1:0 96 96 # yat-0.17.2 14:2:0 97 # yat-0.18 15:0:0 98 # yat-0.18.1 15:1:0 97 99 # 98 100 # *Accidently, the libtool number was not updated for yat 0.5 -
branches/kendall-score/m4/yat_check_htslib.m4
r3890 r4038 1 1 ## $Id$ 2 2 # 3 # serial 7 (yat 0.18)3 # serial 8 (yat 0.19) 4 4 # 5 5 # Copyright (C) 2016, 2018, 2020 Peter Johansson … … 45 45 _YAT_CHECK_ZLIB 46 46 _YAT_CHECK_HTSLIB 47 YAT_VAR_BAM_CIGAR_TABLE([ 48 AC_DEFINE([HAVE_BAM_CIGAR_TABLE], [1], 49 [Define to 1 if bam_cigar_table is available]) 50 ]) 47 51 ]) 48 52 _YAT_PROG_SAMTOOLS … … 110 114 [$2]) 111 115 ]) # YAT_LIB_HTS 116 117 118 # YAT_VAR_BAM_CIGAR_TABLE([action-if-found], [action-if-not-found]) 119 # ===================== 120 # Check if variable bam_cigar_table is available. 121 AC_DEFUN([YAT_VAR_BAM_CIGAR_TABLE], 122 [ 123 AC_CACHE_CHECK([if bam_cigar_table is available], 124 [yat_cv_var_bam_cigar_table], 125 [AC_COMPILE_IFELSE([ 126 AC_LANG_PROGRAM([@%:@include <htslib/sam.h>], 127 [int8_t x = bam_cigar_table@<:@0@:>@;]) 128 ], [ 129 yat_cv_var_bam_cigar_table=yes 130 ], [ 131 yat_cv_var_bam_cigar_table=no 132 ]) 133 ]) 134 AS_VAR_IF([yat_cv_var_bam_cigar_table], [yes], [$1], [$2]) 135 ]) 112 136 113 137 -
branches/kendall-score/m4/yat_check_libs.m4
r3884 r4038 1 1 ## $Id$ 2 2 # 3 # serial 2(yat 0.18)3 # serial 3 (yat 0.18) 4 4 # 5 5 # see http://www.gnu.org/software/automake/manual/automake.html#Serials … … 42 42 AC_DEFUN([YAT_CHECK_LIBS], 43 43 [ 44 m4_pushdef([yat_message], [$1]) 45 m4_pushdef([yat_cache], [$2]) 46 m4_pushdef([yat_search_libs], [$3]) 44 m4_pushdef([yat_MESSAGE], [$1]) 45 m4_pushdef([yat_CACHE], [$2]) 46 m4_pushdef([yat_SEARCH_LIBS], [$3]) 47 m4_pushdef([yat_DEFAULT_RESULT], ["none required"]) 47 48 AC_LANG_CONFTEST([$4]) 48 AC_CACHE_CHECK([yat_ message], [$2], [49 AC_CACHE_CHECK([yat_MESSAGE], [yat_CACHE], [ 49 50 save_LIBS=$LIBS 50 for yat_lib in '' yat_ search_libs; do51 for yat_lib in '' yat_SEARCH_LIBS; do 51 52 AS_VAR_IF([yat_lib], [''],[ 52 yat_result= "non required"53 yat_result=yat_DEFAULT_RESULT 53 54 ], [ 54 55 yat_result=-l$yat_lib 55 56 LIBS="-l$yat_lib $save_LIBS" 56 57 ]) 57 AC_LINK_IFELSE([], [yat_ cache=$yat_result])58 AS_VAR_SET_IF([yat_ cache], [break])58 AC_LINK_IFELSE([], [yat_CACHE=$yat_result]) 59 AS_VAR_SET_IF([yat_CACHE], [break]) 59 60 done 60 AS_VAR_SET_IF([yat_ cache], [], [yat_cache=no])61 AS_VAR_SET_IF([yat_CACHE], [], [yat_CACHE=no]) 61 62 rm conftest.$ac_ext 62 63 LIBS=$save_LIBS 63 64 ]) 64 yat_result=$yat_ cache65 yat_result=$yat_CACHE 65 66 66 67 # action 67 68 AS_VAR_IF([yat_result], [no], [$6], [ 68 AS_VAR_IF([yat_result], ["none required"], [], [LIBS="$yat_result $LIBS"]) 69 AS_VAR_IF([yat_result], [yat_DEFAULT_RESULT], [], 70 [LIBS="$yat_result $LIBS"]) 69 71 $5 70 72 ]) 71 73 72 73 m4_popdef([yat_ message])74 m4_popdef([yat_ cache])75 m4_popdef([yat_ search_libs])74 m4_popdef([yat_MESSAGE]) 75 m4_popdef([yat_CACHE]) 76 m4_popdef([yat_SEARCH_LIBS]) 77 m4_popdef([yat_DEFAULT_RESULT]) 76 78 ]) -
branches/kendall-score/test/Makefile.am
r4037 r4038 33 33 EXTRA_DIST += test/init.sh 34 34 35 EXTRA_PROGRAMS = test/alignment.test \35 CXX_TESTS = test/alignment.test \ 36 36 test/alignment2.test \ 37 37 test/averager.test \ … … 94 94 test/ostream_iterator.test \ 95 95 test/pca.test \ 96 test/percentile_confidence_interval.test \ 96 97 test/perceptron.test \ 97 98 test/phred.test \ … … 131 132 test/view.test 132 133 134 EXTRA_PROGRAMS = $(CXX_TESTS) 135 133 136 CLEANFILES += $(EXTRA_PROGRAMS) 134 137 … … 162 165 test/yat_use_libtool_tag_test.sh 163 166 164 TESTS = $(DISTRIBUTED_TESTS) $( EXTRA_PROGRAMS)167 TESTS = $(DISTRIBUTED_TESTS) $(CXX_TESTS) 165 168 EXTRA_DIST += $(DISTRIBUTED_TESTS) 166 169 -
branches/kendall-score/test/cigar.cc
r3840 r4038 2 2 3 3 /* 4 Copyright (C) 2014, 2019 Peter Johansson4 Copyright (C) 2014, 2019, 2020 Peter Johansson 5 5 6 6 This file is part of the yat library, http://dev.thep.lu.se/yat … … 25 25 26 26 #include "yat/utility/Aligner.h" 27 27 #include "yat/utility/Exception.h" 28 28 #include "yat/utility/Matrix.h" 29 #include "yat/utility/utility.h" 29 30 30 31 #include <sstream> … … 83 84 } 84 85 suite.out() << "\n"; 86 utility::Aligner::Cigar cig2(os.str()); 87 if (std::distance(cig.begin(), cig.end())!= 88 std::distance(cig2.begin(), cig2.end()) || 89 !std::equal(cig.begin(), cig.end(), cig2.begin())) { 90 suite.add(false); 91 suite.err() << "error: incorrect construction from Cigar(string)\n"; 92 suite.err() << ": " << cig2 << "\nexpected:" << cig << "\n"; 93 } 94 try { 95 utility::Aligner::Cigar cig3("BANANA"); 96 suite.add(false); 97 suite.err() << "error: Cigar(\"BANANA\") did not throw\n"; 98 suite.err() << "cigar: " << cig3 << "\n"; 99 } 100 catch (utility::invalid_argument& e) { 101 suite.out() << "expected exception: "; 102 utility::print_what(e, suite.out()); 103 suite.out() << "\n"; 104 } 85 105 86 106 if (!suite.add(cig.length()==17)) -
branches/kendall-score/test/deleter.cc
r2881 r4038 26 26 #include "yat/utility/Deleter.h" 27 27 28 #include < boost/shared_ptr.hpp>28 #include <memory> 29 29 30 30 using namespace theplu::yat; … … 41 41 42 42 int* p0 = new int(2); 43 boost::shared_ptr<int> smartp(p0, del);43 std::shared_ptr<int> smartp(p0, del); 44 44 45 45 Deleter del2(false); 46 46 int* p = new int(3); 47 47 if (true) { 48 boost::shared_ptr<int> sp(p, del2);48 std::shared_ptr<int> sp(p, del2); 49 49 suite.out() << *sp << "\n"; 50 50 } -
branches/kendall-score/test/rnd.cc
r3893 r4038 54 54 suite.err() << "Checking that all random generators can be constructed\n"; 55 55 theplu::yat::statistics::Histogram histogram(0,100,1000); 56 std::vector<DiscreteGeneral> discrete(10); 56 57 DiscreteGeneral dg(histogram); 57 58 DiscreteUniform du; -
branches/kendall-score/test/segment.cc
r3661 r4038 2 2 3 3 /* 4 Copyright (C) 2010, 2011, 2012, 2014, 2015, 2016, 2017 Peter Johansson4 Copyright (C) 2010, 2011, 2012, 2014, 2015, 2016, 2017, 2021 Peter Johansson 5 5 6 6 This file is part of the yat library, http://dev.thep.lu.se/yat … … 30 30 using namespace theplu::yat; 31 31 using namespace utility; 32 void test_comp(test::Suite& suite); 32 33 void test_compare(test::Suite& suite); 33 34 void test_count(test::Suite&); … … 41 42 void test_operator(test::Suite& suite); 42 43 void test_segment_map(test::Suite& suite); 44 void test_segment_set(test::Suite& suite); 43 45 void test_set_bound(test::Suite&); 44 46 void test_union(test::Suite&); … … 51 53 test::Suite suite(argc, argv); 52 54 55 test_comp(suite); 53 56 test_compare(suite); 54 57 test_count(suite); … … 64 67 65 68 test_segment_map(suite); 69 test_segment_set(suite); 66 70 67 71 return suite.return_value(); 72 } 73 74 75 void test_comp(test::Suite& suite) 76 { 77 Segment<double> key; 78 { 79 SegmentSet<double> set; 80 SegmentSet<double>::key_compare kcompare = set.key_comp(); 81 if (kcompare(key, key)) 82 suite.add(false); 83 test::avoid_compiler_warning(kcompare); 84 SegmentSet<double>::value_compare vcompare = set.value_comp(); 85 if (vcompare(key, key)) 86 suite.add(false); 87 test::avoid_compiler_warning(vcompare); 88 } 89 90 { 91 SegmentMap<double, std::string> map; 92 std::pair<const Segment<double>, std::string> value(key, "hello"); 93 SegmentMap<double, std::string>::key_compare kcompare = map.key_comp(); 94 if (kcompare(key, key)) 95 suite.add(false); 96 test::avoid_compiler_warning(kcompare); 97 SegmentMap<double, std::string>::value_compare vcompare = map.value_comp(); 98 if (vcompare(value, value)) 99 suite.add(false); 100 test::avoid_compiler_warning(vcompare); 101 } 68 102 } 69 103 … … 267 301 } 268 302 303 269 304 void test_segment_map(test::Suite& suite) 270 305 { … … 303 338 } 304 339 340 341 void test_segment_set(test::Suite& suite) 342 { 343 SegmentSet<double> set; 344 Segment<double> segment(0.12,23.2); 345 set.insert_merge(segment); 346 set.insert_merge(Segment<double>(0.12,23.2)); 347 SegmentSet<double>::iterator hint = set.begin(); 348 set.insert_merge(hint, segment); 349 set.insert_merge(hint, Segment<double>(0.12,23.2)); 350 SegmentSet<double>::const_iterator chint = set.begin(); 351 set.insert_merge(chint, segment); 352 set.insert_merge(chint, Segment<double>(0.12,23.2)); 353 std::vector<Segment<double>> vec(set.begin(), set.end()); 354 set.insert_merge(vec.begin(), vec.end()); 355 356 // test functions inherited from SegmentTree 357 SegmentSet<double>::const_iterator citer = set.begin(); 358 SegmentSet<double>::const_iterator iter = set.begin(); 359 360 citer = set.end(); 361 iter = set.end(); 362 363 if (set.count(0.13)!=1) { 364 suite.add(false); 365 suite.err() << "error: expected count = 1\n"; 366 } 367 if (set.count(0.02)!=0) { 368 suite.add(false); 369 suite.err() << "error: expected count = 0\n"; 370 } 371 if (set.empty()) { 372 suite.add(false); 373 suite.err() << "error: expected empty() return false"; 374 } 375 if (set.find(0.15) == set.end()) { 376 suite.add(false); 377 suite.err() << "error: find returned end()"; 378 } 379 set.erase(set.begin()); 380 set.clear(); 381 set.erase(set.begin(), set.end()); 382 383 set.insert(segment); 384 set.insert(Segment<double>(102, 200)); 385 386 iter = set.lower_bound(1.0); 387 citer = set.lower_bound(1.0); 388 iter = set.upper_bound(1.0); 389 citer = set.upper_bound(1.0); 390 SegmentSet<double>::size_type s = set.size(); 391 test::avoid_compiler_warning(s); 392 } 393 394 305 395 void test_segment(test::Suite& suite) 306 396 { -
branches/kendall-score/test/vcf.cc
r3747 r4038 24 24 25 25 #include "yat/omic/VCF.h" 26 #include "yat/utility/utility.h" 26 27 27 28 #include <fstream> … … 41 42 if (false) { 42 43 std::ifstream is("nonsense.vcf"); 43 VCF vcf ;44 VCF vcf(is); 44 45 test::avoid_compiler_warning(vcf); 45 46 } … … 121 122 } 122 123 124 // test getting int when value is a String 125 try { 126 double x; 127 vcf.info().get(x, "FOO"); 128 suite.add(false); 129 } 130 catch (utility::runtime_error& e) { 131 std::ostringstream os; 132 utility::print_what(e, os); 133 suite.out() << "expected exception: what: " << os.str(); 134 if (os.str().find("FOO")==std::string::npos) { 135 suite.add(false); 136 suite.err() << "error: expected 'FOO' mentioned in what()\n"; 137 } 138 } 139 123 140 suite.out() << "test data\n"; 124 141 std::vector<std::string> GT; … … 148 165 ID.push_back("baz"); 149 166 vcf.data().add("ID", ID); 167 168 // test unknown key 169 try { 170 vcf.data().get("banana", GT); 171 } 172 catch (utility::runtime_error& e) { 173 std::ostringstream os; 174 utility::print_what(e, os); 175 suite.out() << "expected exception: what: " << os.str(); 176 std::vector<std::string> tags = { "unknown key", "banana"}; 177 for (size_t i=0; i<tags.size(); ++i) 178 if (os.str().find(tags[i]) == std::string::npos) { 179 suite.add(false); 180 suite.err() << "error: expected '" << tags[i] 181 << "' in error message\n"; 182 } 183 } 184 185 // test getting int when value is a String 186 try { 187 std::vector<int> p; 188 vcf.data().get("ID", p); 189 } 190 catch (utility::runtime_error& e) { 191 std::ostringstream os; 192 utility::print_what(e, os); 193 suite.out() << "expected exception: what: " << os.str(); 194 if (os.str().find("ID")==std::string::npos) { 195 suite.add(false); 196 suite.err() << "error: expected 'ID' mentioned in what()\n"; 197 } 198 } 150 199 } 151 200 catch (std::exception& e) { -
branches/kendall-score/test/yat_pc_test.sh
r3966 r4038 81 81 CXX = `yat-config --cxx` 82 82 # add -I flags to include local header files; 2nd term needed for VPATH build 83 CPPFLAGS = -I$abs_top_srcdir -I$abs_top_builddir/yat/utility \ 83 CPPFLAGS = -I$abs_top_srcdir -I$abs_top_builddir \ 84 -I$abs_top_builddir/yat/utility \ 84 85 `$PKG_CONFIG yat --cflags-only-I` 85 86 CXXFLAGS = `$PKG_CONFIG yat --cflags-only-other` -
branches/kendall-score/yat/classifier/KernelLookup.h
r3330 r4038 8 8 Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér 9 9 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 10 Copyright (C) 2010, 2012 Peter Johansson10 Copyright (C) 2010, 2012, 2020 Peter Johansson 11 11 12 12 This file is part of the yat library, http://dev.thep.lu.se/yat … … 32 32 #include "yat/utility/StrideIterator.h" 33 33 34 #include < boost/shared_ptr.hpp>34 #include <memory> 35 35 36 36 namespace theplu { … … 324 324 325 325 utility::Index column_index_; 326 boost::shared_ptr<const Kernel> kernel_;326 std::shared_ptr<const Kernel> kernel_; 327 327 utility::Index row_index_; 328 328 }; // class KernelLookup -
branches/kendall-score/yat/classifier/MatrixLookup.h
r3330 r4038 8 8 Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér 9 9 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 10 Copyright (C) 2009, 2010, 2012 Peter Johansson10 Copyright (C) 2009, 2010, 2012, 2020 Peter Johansson 11 11 12 12 This file is part of the yat library, http://dev.thep.lu.se/yat … … 33 33 34 34 #include <boost/iterator/permutation_iterator.hpp> 35 #include <boost/shared_ptr.hpp>36 35 37 36 #include <iosfwd> 37 #include <memory> 38 38 #include <vector> 39 39 … … 327 327 328 328 utility::Index column_index_; 329 typedef boost::shared_ptr<const utility::Matrix> MatrixP;329 typedef std::shared_ptr<const utility::Matrix> MatrixP; 330 330 MatrixP data_; 331 331 utility::Index row_index_; -
branches/kendall-score/yat/classifier/MatrixLookupWeighted.h
r3330 r4038 7 7 Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér 8 8 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 9 Copyright (C) 2009, 2010, 2012 Peter Johansson9 Copyright (C) 2009, 2010, 2012, 2020 Peter Johansson 10 10 11 11 This file is part of the yat library, http://dev.thep.lu.se/yat … … 33 33 34 34 #include <boost/iterator/permutation_iterator.hpp> 35 #include <boost/shared_ptr.hpp>36 35 37 36 #include <iosfwd> 37 #include <memory> 38 38 #include <utility> 39 39 #include <vector> … … 296 296 297 297 private: 298 typedef boost::shared_ptr<const utility::MatrixWeighted> MatrixWP;298 typedef std::shared_ptr<const utility::MatrixWeighted> MatrixWP; 299 299 utility::Index column_index_; 300 300 MatrixWP data_; -
branches/kendall-score/yat/omic/BamPair.cc
r3792 r4038 37 37 BamPair::BamPair(const BamRead& first, const BamRead& second) 38 38 : first_(first), second_(second) {} 39 40 41 BamPair::BamPair(BamRead&& first, BamRead&& second) 42 : first_(std::move(first)), second_(std::move(second)) {} 39 43 40 44 -
branches/kendall-score/yat/omic/BamPair.h
r3792 r4038 46 46 */ 47 47 BamPair(const BamRead& first, const BamRead& second); 48 49 /** 50 \brief Move constructor 51 52 \since New in yat 0.19 53 */ 54 BamPair(BamRead&& first, BamRead&& second); 48 55 49 56 /** -
branches/kendall-score/yat/omic/BamPairIterator.h
r3999 r4038 32 32 #include <boost/iterator/iterator_concepts.hpp> 33 33 #include <boost/iterator/iterator_facade.hpp> 34 #include <boost/shared_ptr.hpp>35 34 36 35 #include <iterator> 37 36 #include <map> 37 #include <memory> 38 38 #include <utility> 39 39 … … 115 115 Base end_; 116 116 const BamRead* mate_; 117 boost::shared_ptr<std::map<std::string, BamRead> > siam_reads_;117 std::shared_ptr<std::map<std::string, BamRead> > siam_reads_; 118 118 typedef std::pair<int32_t, int32_t> Position; 119 boost::shared_ptr<std::multimap<Position, BamRead> > reads_;119 std::shared_ptr<std::multimap<Position, BamRead> > reads_; 120 120 friend class boost::iterator_core_access; 121 121 -
branches/kendall-score/yat/omic/BamPairIterator2.h
r3881 r4038 32 32 #include <boost/iterator/iterator_concepts.hpp> 33 33 #include <boost/iterator/iterator_facade.hpp> 34 #include <boost/shared_ptr.hpp>35 34 36 35 #include <iterator> 37 36 #include <map> 37 #include <memory> 38 38 #include <utility> 39 39 … … 118 118 // multimap with reads' position as key 119 119 typedef std::multimap<Position, BamRead> MultiMap; 120 boost::shared_ptr<MultiMap> reads_;120 std::shared_ptr<MultiMap> reads_; 121 121 MultiMap::iterator first_; 122 122 MultiMap::iterator second_; -
branches/kendall-score/yat/omic/BamReadIterator.cc
r3883 r4038 28 28 #include "yat/utility/Exception.h" 29 29 30 #include <cassert> 30 31 #include <cstddef> 31 32 #include <sstream> … … 36 37 37 38 BamReadIterator::BamReadIterator(void) 39 : actor_(new AllActor) 38 40 { 39 a ctor_ = boost::shared_ptr<Actor>(new AllActor);41 assert(actor_); 40 42 } 41 43 42 44 43 45 BamReadIterator::BamReadIterator(InBamFile& in) 46 : actor_(new AllActor(in)) 44 47 { 45 a ctor_ = boost::shared_ptr<Actor>(new AllActor(in));48 assert(actor_); 46 49 increment(); 47 50 } … … 50 53 BamReadIterator::BamReadIterator(InBamFile& bf, int32_t tid, int32_t start, 51 54 int32_t end) 55 : actor_(new IndexActor(bf, tid, start, end)) 52 56 { 53 actor_ = boost::shared_ptr<Actor>(new IndexActor(bf, tid, start, end));54 57 assert(actor_); 55 58 increment(); … … 58 61 59 62 BamReadIterator::BamReadIterator(InBamFile& bf, int32_t tid, int32_t start) 63 : actor_(new IndexActor(bf, tid, start, bf.header().target_length(tid))) 60 64 { 61 actor_ =62 boost::shared_ptr<Actor>(new IndexActor(bf, tid, start,63 bf.header().target_length(tid)));64 65 assert(actor_); 65 66 increment(); … … 83 84 actor_->increment(); 84 85 } 86 87 88 void BamReadIterator::IndexDestroyer::operator()(hts_itr_t* i) const 89 { 90 bam_itr_destroy(i); 91 } 92 85 93 86 94 … … 120 128 BamReadIterator::IndexActor::IndexActor(InBamFile& bf, int32_t tid, 121 129 int32_t begin,int32_t end) 122 : Actor(&bf) 130 : Actor(&bf), 131 iter_(sam_itr_queryi(bf.index(), tid, begin, end), IndexDestroyer()) 123 132 { 124 using boost::shared_ptr;125 iter_ = shared_ptr<hts_itr_t>(sam_itr_queryi(bf.index(), tid, begin, end),126 IndexDestroyer());127 133 if (!iter_.get()) { 128 134 std::stringstream ss; -
branches/kendall-score/yat/omic/BamReadIterator.h
r3999 r4038 29 29 30 30 #include <boost/iterator/iterator_facade.hpp> 31 #include <boost/shared_ptr.hpp>32 31 33 32 #include <iterator> 33 #include <memory> 34 34 35 35 namespace theplu { … … 118 118 void increment(void); 119 119 120 120 121 /* 121 122 Interface class for the actor that handles difference between … … 142 143 }; 143 144 145 // functor calling bam_itr_destroy 146 struct IndexDestroyer 147 { 148 void operator()(hts_itr_t* i) const; 149 }; 150 144 151 // class used when iterating over a sub-region of the bam file 145 152 class IndexActor : public Actor … … 149 156 void increment(void); 150 157 private: 151 boost::shared_ptr<hts_itr_t> iter_;158 std::unique_ptr<hts_itr_t, IndexDestroyer> iter_; 152 159 }; 153 160 154 boost::shared_ptr<Actor> actor_;161 std::shared_ptr<Actor> actor_; 155 162 156 struct IndexDestroyer157 {158 void operator()(hts_itr_t* i) const159 {160 bam_itr_destroy(i);161 }162 };163 163 }; 164 164 }}} -
branches/kendall-score/yat/omic/Fasta.cc
r3999 r4038 166 166 { 167 167 // allocate a new char* 168 boost::shared_array<char> ptr(new char[seq.size()+1]); 168 std::shared_ptr<char> ptr(new char[seq.size()+1], 169 std::default_delete<char[]>()); 169 170 std::copy(seq.seq_.get(), seq.seq_.get()+seq.size(), ptr.get()); 170 171 // calculate reverse complement -
branches/kendall-score/yat/omic/Fasta.h
r3999 r4038 21 21 #include <htslib/faidx.h> 22 22 23 #include <boost/shared_array.hpp>24 #include <boost/shared_ptr.hpp>25 26 23 #include <iosfwd> 27 24 #include <map> 25 #include <memory> 28 26 #include <string> 29 27 #include <vector> … … 114 112 friend class Fasta; 115 113 friend Sequence reverse_complement(const Fasta::Sequence&); 116 boost::shared_array<constchar> seq_;114 std::shared_ptr<char> seq_; 117 115 int size_; 118 116 }; … … 134 132 135 133 private: 136 boost::shared_ptr<faidx_t> faidx_;134 std::shared_ptr<faidx_t> faidx_; 137 135 // using compiler generated copy 138 136 //FastaIndex(const FastaIndex& other); -
branches/kendall-score/yat/omic/Pileup.h
r3999 r4038 31 31 #include <boost/iterator/iterator_concepts.hpp> 32 32 #include <boost/concept/assert.hpp> 33 #include <boost/shared_ptr.hpp>34 33 35 34 #include <algorithm> 36 35 #include <list> 36 #include <memory> 37 37 38 38 namespace theplu { … … 139 139 size_t qpos(void) const { return qpos_; } 140 140 private: 141 boost::shared_ptr<BamRead> bam_;141 std::shared_ptr<BamRead> bam_; 142 142 // index of base pointed to 143 143 size_t qpos_; -
branches/kendall-score/yat/omic/VCF.h
r3999 r4038 600 600 size_t begin = str_.find(k); 601 601 602 if (begin == std::string::npos) { 603 converter(value, result); 604 return; 605 } 606 607 if (begin && str_[begin-1]!=';') { 608 k = ";" + key + "="; 609 begin = str_.find(k, begin+key.size()); 602 try { 610 603 if (begin == std::string::npos) { 611 604 converter(value, result); 612 605 return; 613 606 } 607 608 if (begin && str_[begin-1]!=';') { 609 k = ";" + key + "="; 610 begin = str_.find(k, begin+key.size()); 611 if (begin == std::string::npos) { 612 converter(value, result); 613 return; 614 } 615 } 616 617 begin += k.size(); 618 int end = str_.find(";", begin); 619 value = str_.substr(begin, end-begin); 620 converter(value, result); 614 621 } 615 616 begin += k.size();617 int end = str_.find(";", begin);618 value = str_.substr(begin, end-begin);619 converter(value, result);622 catch (utility::runtime_error& e) { 623 std::ostringstream msg; 624 msg << "invalid VCF::Info format for key '" << key << "'"; 625 std::throw_with_nested(utility::runtime_error(msg.str())); 626 } 620 627 } 621 628 … … 642 649 detail::Converter<T> converter; 643 650 data.resize(data_.size()); 644 for (size_t i=0; i<data.size(); ++i) 645 converter(data_[i][idx], data[i]); 646 } 647 648 649 /* 650 template<typename T> 651 void VCF::add_data(const std::string& key, const std::vector<T>& val) 652 { 653 if (format() != "") 654 format() += ":"; 655 format() += key; 656 657 658 YAT_ASSERT(val.size()+9 == vec_.size()); 659 for (size_t i=0; i<val.size(); ++i) { 660 std::string& data = vec_[i+9]; 661 if (data != "") 662 data += ":"; 663 append(data, val[i]); 651 try { 652 for (size_t i=0; i<data.size(); ++i) 653 converter(data_[i][idx], data[i]); 654 } 655 catch (utility::runtime_error& e) { 656 std::ostringstream msg; 657 msg << "invalid VCF::Data format for key '" << key << "'"; 658 std::throw_with_nested(utility::runtime_error(msg.str())); 664 659 } 665 660 } 666 */ 661 662 667 663 }}} 668 664 #endif -
branches/kendall-score/yat/random/Makefile.am
r3999 r4038 22 22 yat_libyat_la_SOURCES += yat/random/random.cc 23 23 24 nobase_include_HEADERS += $(srcdir)/yat/random/ContinuousDistribution.h25 24 nobase_include_HEADERS += $(srcdir)/yat/random/copy_k_of_n.h 26 nobase_include_HEADERS += $(srcdir)/yat/random/DiscreteDistribution.h27 nobase_include_HEADERS += $(srcdir)/yat/random/Distribution.h28 25 nobase_include_HEADERS += $(srcdir)/yat/random/random.h -
branches/kendall-score/yat/random/random.cc
r3999 r4038 219 219 220 220 221 DiscreteGeneral::DiscreteGeneral(void) 222 : gen_(nullptr) 223 {} 224 225 221 226 DiscreteGeneral::DiscreteGeneral(const statistics::Histogram& hist) 222 227 : gen_(NULL) … … 233 238 { 234 239 preproc(); 240 } 241 242 243 DiscreteGeneral::DiscreteGeneral(DiscreteGeneral&& other) 244 : Discrete(std::move(other)), gen_(nullptr), p_(std::move(other.p_)) 245 { 246 gen_ = std::move(other.gen_); 235 247 } 236 248 … … 262 274 DiscreteGeneral& DiscreteGeneral::operator=(const DiscreteGeneral& rhs) 263 275 { 264 free(); 265 p_ = rhs.p_; 266 preproc(); 276 DiscreteGeneral tmp(rhs); 277 swap(*this, tmp); 267 278 return *this; 268 279 } 269 280 270 281 282 DiscreteGeneral& DiscreteGeneral::operator=(DiscreteGeneral&& rhs) 283 { 284 DiscreteGeneral tmp(std::move(rhs)); 285 swap(*this, tmp); 286 return *this; 287 } 288 289 271 290 unsigned long DiscreteGeneral::operator()(void) const 272 291 { 273 292 return gsl_ran_discrete(rng_->rng(), gen_); 293 } 294 295 296 void swap(DiscreteGeneral& lhs, DiscreteGeneral& rhs) 297 { 298 std::swap(lhs.gen_, rhs.gen_); 299 std::swap(lhs.p_, rhs.p_); 274 300 } 275 301 -
branches/kendall-score/yat/random/random.h
r3959 r4038 341 341 { 342 342 public: 343 /** 344 Default constructor leaves the object uninitialized and 345 behaviour of operator() is undefined. 346 347 \since New in yat 0.19 348 */ 349 DiscreteGeneral(void); 350 343 351 /// 344 352 /// @brief Constructor … … 354 362 */ 355 363 DiscreteGeneral(const DiscreteGeneral&); 364 365 /** 366 \brief Move constructor 367 368 \since New in yat 0.19 369 */ 370 DiscreteGeneral(DiscreteGeneral&&); 356 371 357 372 /// … … 377 392 DiscreteGeneral& operator=(const DiscreteGeneral&); 378 393 394 /** 395 \brief Move assignment operator 396 397 \since New in yat 0.19 398 */ 399 DiscreteGeneral& operator=(DiscreteGeneral&&); 400 379 401 private: 380 402 void free(void); … … 383 405 gsl_ran_discrete_t* gen_; 384 406 std::vector<double> p_; 385 }; 407 friend void swap(DiscreteGeneral& lhs, DiscreteGeneral& rhs); 408 }; 409 410 /** 411 \relates DiscreteGeneral 412 413 \since Specialisation new in yat 0.19 414 */ 415 void swap(DiscreteGeneral& lhs, DiscreteGeneral& rhs); 386 416 387 417 /** -
branches/kendall-score/yat/statistics/Makefile.am
r3999 r4038 36 36 yat/statistics/LikelihoodRatioTestBinomial.cc \ 37 37 yat/statistics/Pearson.cc \ 38 yat/statistics/PearsonCorrelation.cc yat/statistics/Percentiler.cc \ 38 yat/statistics/PearsonCorrelation.cc \ 39 yat/statistics/PercentileConfidenceInterval.cc \ 40 yat/statistics/Percentiler.cc \ 39 41 yat/statistics/ROC.cc \ 40 42 yat/statistics/SAMScore.cc yat/statistics/Score.cc \ … … 73 75 $(srcdir)/yat/statistics/PearsonCorrelation.h \ 74 76 $(srcdir)/yat/statistics/PearsonDistance.h \ 77 $(srcdir)/yat/statistics/PercentileConfidenceInterval.h \ 75 78 $(srcdir)/yat/statistics/Percentiler.h \ 76 79 $(srcdir)/yat/statistics/ROC.h \ -
branches/kendall-score/yat/utility/Aligner.cc
r3840 r4038 28 28 #include <algorithm> 29 29 #include <cassert> 30 #include <cctype> 30 31 #include <limits> 31 32 #include <ostream> 32 33 34 #include <iostream> 33 35 namespace theplu { 34 36 namespace yat { … … 158 160 // ================ Cigar ======================= 159 161 162 Aligner::Cigar::Cigar(const std::string& s) 163 { 164 try { 165 std::cerr << "Cigar: " << s << "\n"; 166 std::istringstream is(s); 167 while (parse_element(is)); 168 } 169 catch (invalid_argument& e) { 170 std::ostringstream msg; 171 msg << "Aligner::Cigar: " << s; 172 std::throw_with_nested(invalid_argument(msg.str())); 173 } 174 } 175 176 160 177 Aligner::Cigar::const_iterator Aligner::Cigar::begin(void) const 161 178 { … … 210 227 assert(i<cigar_.size()); 211 228 return bam_cigar_oplen(cigar_[i]); 229 } 230 231 232 bool Aligner::Cigar::parse_element(std::istream& is) 233 { 234 char c = is.get(); 235 if (!is.good()) 236 return false; 237 if (!isdigit(c)) { 238 std::string msg("not a digit: '"); 239 msg += c; 240 msg += "'"; 241 throw invalid_argument(msg); 242 } 243 uint32_t len = c - '0'; 244 245 while (is.get(c).good()) { 246 if (isdigit(c)) 247 len = 10 * len + (c - '0'); 248 else { 249 push_back(cigar_table(static_cast<uint8_t>(c)), len); 250 return true; 251 } 252 } 253 throw invalid_argument("Cigar::parse_element: missing operator"); 254 return true; 212 255 } 213 256 -
branches/kendall-score/yat/utility/Aligner.h
r3847 r4038 190 190 191 191 /** 192 Default constructor 193 */ 194 Cigar(void) = default; 195 196 /** 197 \param s string in same format as output from operator<<, 198 i.e., an concatenated string of integer followed by one of 199 "MIDNSHP=XB". 200 201 \since New in yat 0.19 202 */ 203 explicit Cigar(const std::string& s); 204 205 /** 192 206 \return iterator pointing to first element 193 207 … … 302 316 private: 303 317 std::deque<uint32_t> cigar_; 318 319 // parse a string of type 12M and push_back into cigar. Format 320 // is is first an integer followed by a 1-char describing the 321 // operation (see Cigar.h) 322 bool parse_element(std::istream& is); 304 323 305 324 // calculate length only counting operations whose type is set -
branches/kendall-score/yat/utility/Cigar.h
r3999 r4038 30 30 // allow inclusion of config_bam.h so this file is available also without bam.h 31 31 #ifdef YAT_HAVE_HTSLIB 32 #include "yat/omic/config_bam.h"33 32 #include <htslib/sam.h> 34 33 #else // if sam.h is not available #define CIGAR 34 #include <cstdint> // needed for int8_t 35 35 /// describe how CIGAR operation/length is packed into a 32-bit 36 36 #define BAM_CIGAR_SHIFT 4 … … 85 85 #endif // end of backport 86 86 87 namespace theplu { 88 namespace yat { 89 namespace utility { 90 91 /** 92 The inverse of BAM_CIGAR_STR[x], where BAM_CIGAR_STR is 93 "MIDNSHP=XB". 94 95 \throws if input is not one of "MIDNSHP=XB". 96 97 \since New in yat 0.19 98 */ 99 int8_t cigar_table(unsigned char c); 100 101 }}} // end of namespace utility, yat and theplu 102 87 103 #endif // end of file -
branches/kendall-score/yat/utility/Deleter.h
r2858 r4038 23 23 */ 24 24 25 #include <new> // for delete operator 26 25 27 namespace theplu { 26 28 namespace yat { … … 31 33 32 34 The class is typically used as second argument to a 33 boost::shared_ptr, which enables to decide at runtime whether the35 std::shared_ptr, which enables to decide at runtime whether the 34 36 shared_ptr should own the pointee, i.e., should the pointee be 35 37 destructed at destruction of last shared_ptr pointing to the -
branches/kendall-score/yat/utility/Exception.cc
r2919 r4038 35 35 namespace utility { 36 36 37 invalid_argument::invalid_argument(const std::string& message) 38 : std::invalid_argument(message) 39 {} 40 41 37 42 runtime_error::runtime_error(std::string message) 38 43 : std::runtime_error(message) -
branches/kendall-score/yat/utility/Exception.h
r2526 r4038 31 31 namespace utility { 32 32 33 33 /** 34 \brief Class used for all invalid arguments detected within yat library. 35 36 \since New in yat 0.19 37 */ 38 class invalid_argument : public std::invalid_argument 39 { 40 public: 41 /** 42 \brief Constructor 43 44 \param message message to be displayed using function what(). 45 */ 46 invalid_argument(const std::string& message); 47 }; 48 34 49 35 50 /** -
branches/kendall-score/yat/utility/Makefile.am
r4037 r4038 23 23 yat/utility/Alignment.cc \ 24 24 yat/utility/BasicMatrix.cc \ 25 yat/utility/Cigar.cc \ 25 26 yat/utility/ColumnStream.cc \ 26 27 yat/utility/CommandLine.cc \ -
branches/kendall-score/yat/utility/Segment.h
r3855 r4038 66 66 Segment(const T& begin, const T& end) 67 67 : begin_(begin), end_(end) {} 68 69 /** 70 \brief Constructor 71 72 Creates a segment [begin, end) 73 74 \since New in yat 0.19 75 */ 76 Segment(T&& begin, T&& end) 77 : begin_(std::move(begin)), end_(std::move(end)) {} 68 78 69 79 /** -
branches/kendall-score/yat/utility/SegmentSet.h
r3550 r4038 7 7 Copyright (C) 2010 Peter Johansson 8 8 Copyright (C) 2012 Jari Häkkinen 9 Copyright (C) 2014, 2016 Peter Johansson9 Copyright (C) 2014, 2016, 2021 Peter Johansson 10 10 11 11 This file is part of the yat library, http://dev.thep.lu.se/yat … … 45 45 */ 46 46 template<typename T, class Compare = std::less<T> > 47 class SegmentSet 48 : public SegmentTree<std::set<Segment<T, Compare>, 47 class SegmentSet 48 : public SegmentTree<std::set<Segment<T, Compare>, 49 49 SegmentCompare<T, Compare> >, 50 50 Compare, … … 67 67 std::pair<typename me::iterator, typename me::iterator> p = 68 68 this->overlap_range(segment); 69 return insert_merge(p, segment); 69 Segment<T> tmp(segment); 70 return move_insert_merge(p, std::move(tmp)); 71 } 72 73 /** 74 insert \a segment into set. If there is no gap between \a 75 segment and neighboring segments the segments are merged. 76 77 \since New in yat 0.19 78 */ 79 typename me::const_iterator 80 insert_merge(typename me::value_type&& segment) 81 { 82 std::pair<typename me::iterator, typename me::iterator> p = 83 this->overlap_range(segment); 84 return move_insert_merge(p, std::move(segment)); 70 85 } 71 86 … … 83 98 const typename me::value_type& segment) 84 99 { 100 typename me::value_type tmp(segment); 101 return insert_merge(hint, std::move(tmp)); 102 } 103 104 105 /** 106 \since New in yat 0.19 107 */ 108 typename me::iterator 109 insert_merge(typename me::iterator hint, 110 typename me::value_type&& segment) 111 { 85 112 std::pair<typename me::iterator, typename me::iterator> p(hint, hint); 86 113 if (this->container_.empty()) 87 return insert_merge(p, segment);114 return move_insert_merge(p, std::move(segment)); 88 115 89 116 // If hint points to an element that is less than segment, hint 90 117 // is no good and we ignore the hint. 91 118 if (hint!=this->end() && compare(*hint, segment)) 92 return insert_merge(s egment);119 return insert_merge(std::move(segment)); 93 120 94 121 if (p.first!=this->begin()) { … … 97 124 // no good. 98 125 if (compare(segment, *p.first)) 99 return insert_merge(s egment);126 return insert_merge(std::move(segment)); 100 127 // find first element that is smaller than segment 101 128 while (p.first!=this->begin() && !compare(*p.first, segment)) … … 111 138 ++p.second; 112 139 113 return insert_merge(p, segment); 114 } 140 return move_insert_merge(p, std::move(segment)); 141 } 142 115 143 116 144 /** … … 132 160 } 133 161 private: 134 // used by public functions insert_merge. 162 // used by functions merge_basic. This function does the actual 163 // work. Note that it takes an rvalue; functions that only have 164 // access to an lvalue const& need to create a (temporary) copy 165 // that can be moved in. 135 166 // 136 167 // p.first points to the first segment that overlaps with \a segment or … … 138 169 // p.second points to the first segment that is greater than \a segment 139 170 typename me::const_iterator 140 insert_merge(const std::pair<typename me::iterator,141 142 const typename me::value_type& segment)171 move_insert_merge(const std::pair<typename me::iterator, 172 typename me::iterator>& p, 173 typename me::value_type&& segment) 143 174 { 144 175 YAT_ASSERT(p.first==this->end() || !compare(*p.first, segment)); 145 176 YAT_ASSERT(p.second==this->end() || compare(segment, *p.second)); 146 177 if (p.first==p.second) { // no overlap between set and segment 147 return this->container_.insert(p.first, s egment);178 return this->container_.insert(p.first, std::move(segment)); 148 179 } 149 180 /* … … 166 197 167 198 this->container_.erase(p.first, p.second); 168 return this->container_.insert(p.second, s egment2);199 return this->container_.insert(p.second, std::move(segment2)); 169 200 } 170 201 -
branches/kendall-score/yat/utility/SegmentTree.h
r3114 r4038 5 5 6 6 /* 7 Copyright (C) 2010, 2011, 2012, 2013 Peter Johansson7 Copyright (C) 2010, 2011, 2012, 2013, 2021 Peter Johansson 8 8 9 9 This file is part of the yat library, http://dev.thep.lu.se/yat … … 29 29 #include <algorithm> 30 30 #include <functional> 31 #include <utility> 31 32 32 33 namespace theplu { … … 180 181 181 182 /** 183 Same as insert(const&) but move \a value rather than copy. 184 185 \since New in yat 0.19 186 */ 187 std::pair<iterator, bool> insert(value_type&& value); 188 189 /** 182 190 \return Comparison functor to compare two keys (Segment) 183 191 */ 184 192 key_compare key_comp(void) const 185 193 { 186 return key_compare(compare);194 return container_.key_comp(); 187 195 } 188 196 … … 226 234 \c values 227 235 */ 228 value_compare value_comp(void) const { return key_comp(); }236 value_compare value_comp(void) const { return container_.value_comp(); } 229 237 230 238 protected: … … 301 309 302 310 template<typename T, class Compare, class Value2Key> 311 std::pair<typename SegmentTree<T, Compare, Value2Key>::iterator, bool> 312 SegmentTree<T, Compare,Value2Key>::insert(value_type&& segment) 313 { 314 return container_.insert(std::move(segment)); 315 } 316 317 318 template<typename T, class Compare, class Value2Key> 303 319 typename SegmentTree<T, Compare, Value2Key>::iterator 304 320 SegmentTree<T, Compare,Value2Key>::lower_bound(const element_type& element)
Note: See TracChangeset
for help on using the changeset viewer.