Changeset 4038


Ignore:
Timestamp:
Jan 25, 2021, 5:33:35 AM (2 years ago)
Author:
Peter
Message:

merge trunk into branch

Location:
branches/kendall-score
Files:
4 deleted
41 edited
4 copied

Legend:

Unmodified
Added
Removed
  • branches/kendall-score

  • branches/kendall-score/NEWS

    r4001 r4038  
    1010yat 0.18.x series from http://dev.thep.lu.se/yat/svn/branches/0.18-stable
    1111
    12 version 0.18 (released NOT YET)
     12version 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
     18version 0.18 (released 6 November 2020)
    1319  - regression::NegativeBinomial now inherits from
    1420    regression::Multivariate (ticket #957)
     
    558564Copyright (C) 2010, 2011 Peter Johansson
    559565Copyright (C) 2012 Jari Häkkinen, Peter Johansson
    560 Copyright (C) 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Peter Johansson
     566Copyright (C) 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Peter Johansson
    561567
    562568This file is part of yat library, http://dev.thep.lu.se/yat
  • branches/kendall-score/build_support/Makefile.am

    r3987 r4038  
    8989  --exec-prefix="$(exec_prefix)" \
    9090  --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 \
    9292  && mv yat.pc-t yat.pc
  • branches/kendall-score/doc/Makefile.am

    r3987 r4038  
    4747EXTRA_DIST += doc/doxygen.config.in
    4848
    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.
     52doc/doxygen.config: doc/doxygen.config.in $(srcdir)/Makefile.in
    5053  $(AM_V_GEN)echo "# $@ generated by make from doc/doxygen.config.in." \
    5154  > $@-t \
  • branches/kendall-score/m4/version.m4

    r4001 r4038  
    22#
    33# Copyright (C) 2008, 2009 Jari Häkkinen, Peter Johansson
    4 # Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2017, 2018, 2019, 2020 Peter Johansson
     4# Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2017, 2018, 2019, 2020, 2021 Peter Johansson
    55#
    66# This file is part of the yat library, http://dev.thep.lu.se/yat
     
    9595# yat-0.17.1 14:1:0
    9696# yat-0.17.2 14:2:0
     97# yat-0.18   15:0:0
     98# yat-0.18.1 15:1:0
    9799#
    98100# *Accidently, the libtool number was not updated for yat 0.5
  • branches/kendall-score/m4/yat_check_htslib.m4

    r3890 r4038  
    11## $Id$
    22#
    3 # serial 7 (yat 0.18)
     3# serial 8 (yat 0.19)
    44#
    55#   Copyright (C) 2016, 2018, 2020 Peter Johansson
     
    4545  _YAT_CHECK_ZLIB
    4646  _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  ])
    4751])
    4852_YAT_PROG_SAMTOOLS
     
    110114                [$2])
    111115]) # 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.
     121AC_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])
    112136
    113137
  • branches/kendall-score/m4/yat_check_libs.m4

    r3884 r4038  
    11## $Id$
    22#
    3 # serial 2 (yat 0.18)
     3# serial 3 (yat 0.18)
    44#
    55# see http://www.gnu.org/software/automake/manual/automake.html#Serials
     
    4242AC_DEFUN([YAT_CHECK_LIBS],
    4343[
    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"])
    4748  AC_LANG_CONFTEST([$4])
    48   AC_CACHE_CHECK([yat_message], [$2], [
     49  AC_CACHE_CHECK([yat_MESSAGE], [yat_CACHE], [
    4950    save_LIBS=$LIBS
    50     for yat_lib in '' yat_search_libs; do
     51    for yat_lib in '' yat_SEARCH_LIBS; do
    5152      AS_VAR_IF([yat_lib], [''],[
    52         yat_result="non required"
     53        yat_result=yat_DEFAULT_RESULT
    5354      ], [
    5455        yat_result=-l$yat_lib
    5556        LIBS="-l$yat_lib $save_LIBS"
    5657      ])
    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])
    5960    done
    60     AS_VAR_SET_IF([yat_cache], [], [yat_cache=no])
     61    AS_VAR_SET_IF([yat_CACHE], [], [yat_CACHE=no])
    6162    rm conftest.$ac_ext
    6263    LIBS=$save_LIBS
    6364  ])
    64   yat_result=$yat_cache
     65  yat_result=$yat_CACHE
    6566
    6667  # action
    6768  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"])
    6971    $5
    7072  ])
    7173
    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])
    7678])
  • branches/kendall-score/test/Makefile.am

    r4037 r4038  
    3333EXTRA_DIST += test/init.sh
    3434
    35 EXTRA_PROGRAMS = test/alignment.test \
     35CXX_TESTS = test/alignment.test \
    3636  test/alignment2.test \
    3737  test/averager.test \
     
    9494  test/ostream_iterator.test \
    9595  test/pca.test \
     96  test/percentile_confidence_interval.test \
    9697  test/perceptron.test \
    9798  test/phred.test \
     
    131132  test/view.test
    132133
     134EXTRA_PROGRAMS = $(CXX_TESTS)
     135
    133136CLEANFILES += $(EXTRA_PROGRAMS)
    134137
     
    162165test/yat_use_libtool_tag_test.sh
    163166
    164 TESTS = $(DISTRIBUTED_TESTS) $(EXTRA_PROGRAMS)
     167TESTS = $(DISTRIBUTED_TESTS) $(CXX_TESTS)
    165168EXTRA_DIST += $(DISTRIBUTED_TESTS)
    166169
  • branches/kendall-score/test/cigar.cc

    r3840 r4038  
    22
    33/*
    4   Copyright (C) 2014, 2019 Peter Johansson
     4  Copyright (C) 2014, 2019, 2020 Peter Johansson
    55
    66  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2525
    2626#include "yat/utility/Aligner.h"
    27 
     27#include "yat/utility/Exception.h"
    2828#include "yat/utility/Matrix.h"
     29#include "yat/utility/utility.h"
    2930
    3031#include <sstream>
     
    8384  }
    8485  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  }
    85105
    86106  if (!suite.add(cig.length()==17))
  • branches/kendall-score/test/deleter.cc

    r2881 r4038  
    2626#include "yat/utility/Deleter.h"
    2727
    28 #include <boost/shared_ptr.hpp>
     28#include <memory>
    2929
    3030using namespace theplu::yat;
     
    4141
    4242  int* p0 = new int(2);
    43   boost::shared_ptr<int> smartp(p0, del);
     43  std::shared_ptr<int> smartp(p0, del);
    4444
    4545  Deleter del2(false);
    4646  int* p = new int(3);
    4747  if (true) {
    48     boost::shared_ptr<int> sp(p, del2);
     48    std::shared_ptr<int> sp(p, del2);
    4949    suite.out() << *sp << "\n";
    5050  }
  • branches/kendall-score/test/rnd.cc

    r3893 r4038  
    5454  suite.err() << "Checking that all random generators can be constructed\n";
    5555  theplu::yat::statistics::Histogram histogram(0,100,1000);
     56  std::vector<DiscreteGeneral> discrete(10);
    5657  DiscreteGeneral dg(histogram);
    5758  DiscreteUniform du;
  • branches/kendall-score/test/segment.cc

    r3661 r4038  
    22
    33/*
    4   Copyright (C) 2010, 2011, 2012, 2014, 2015, 2016, 2017 Peter Johansson
     4  Copyright (C) 2010, 2011, 2012, 2014, 2015, 2016, 2017, 2021 Peter Johansson
    55
    66  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3030using namespace theplu::yat;
    3131using namespace utility;
     32void test_comp(test::Suite& suite);
    3233void test_compare(test::Suite& suite);
    3334void test_count(test::Suite&);
     
    4142void test_operator(test::Suite& suite);
    4243void test_segment_map(test::Suite& suite);
     44void test_segment_set(test::Suite& suite);
    4345void test_set_bound(test::Suite&);
    4446void test_union(test::Suite&);
     
    5153  test::Suite suite(argc, argv);
    5254
     55  test_comp(suite);
    5356  test_compare(suite);
    5457  test_count(suite);
     
    6467
    6568  test_segment_map(suite);
     69  test_segment_set(suite);
    6670
    6771  return suite.return_value();
     72}
     73
     74
     75void 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  }
    68102}
    69103
     
    267301}
    268302
     303
    269304void test_segment_map(test::Suite& suite)
    270305{
     
    303338}
    304339
     340
     341void 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
    305395void test_segment(test::Suite& suite)
    306396{
  • branches/kendall-score/test/vcf.cc

    r3747 r4038  
    2424
    2525#include "yat/omic/VCF.h"
     26#include "yat/utility/utility.h"
    2627
    2728#include <fstream>
     
    4142    if (false) {
    4243      std::ifstream is("nonsense.vcf");
    43       VCF vcf;
     44      VCF vcf(is);
    4445      test::avoid_compiler_warning(vcf);
    4546    }
     
    121122    }
    122123
     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
    123140    suite.out() << "test data\n";
    124141    std::vector<std::string> GT;
     
    148165    ID.push_back("baz");
    149166    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    }
    150199  }
    151200  catch (std::exception& e) {
  • branches/kendall-score/test/yat_pc_test.sh

    r3966 r4038  
    8181CXX = `yat-config --cxx`
    8282# 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 \
     83CPPFLAGS = -I$abs_top_srcdir -I$abs_top_builddir \
     84-I$abs_top_builddir/yat/utility \
    8485`$PKG_CONFIG yat --cflags-only-I`
    8586CXXFLAGS = `$PKG_CONFIG yat --cflags-only-other`
  • branches/kendall-score/yat/classifier/KernelLookup.h

    r3330 r4038  
    88  Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
    99  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    10   Copyright (C) 2010, 2012 Peter Johansson
     10  Copyright (C) 2010, 2012, 2020 Peter Johansson
    1111
    1212  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3232#include "yat/utility/StrideIterator.h"
    3333
    34 #include <boost/shared_ptr.hpp>
     34#include <memory>
    3535
    3636namespace theplu {
     
    324324
    325325    utility::Index column_index_;
    326     boost::shared_ptr<const Kernel> kernel_;
     326    std::shared_ptr<const Kernel> kernel_;
    327327    utility::Index row_index_;
    328328  }; // class KernelLookup
  • branches/kendall-score/yat/classifier/MatrixLookup.h

    r3330 r4038  
    88  Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
    99  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    10   Copyright (C) 2009, 2010, 2012 Peter Johansson
     10  Copyright (C) 2009, 2010, 2012, 2020 Peter Johansson
    1111
    1212  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3333
    3434#include <boost/iterator/permutation_iterator.hpp>
    35 #include <boost/shared_ptr.hpp>
    3635
    3736#include <iosfwd>
     37#include <memory>
    3838#include <vector>
    3939
     
    327327
    328328    utility::Index column_index_;
    329     typedef boost::shared_ptr<const utility::Matrix> MatrixP;
     329    typedef std::shared_ptr<const utility::Matrix> MatrixP;
    330330    MatrixP data_;
    331331    utility::Index row_index_;
  • branches/kendall-score/yat/classifier/MatrixLookupWeighted.h

    r3330 r4038  
    77  Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
    88  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    9   Copyright (C) 2009, 2010, 2012 Peter Johansson
     9  Copyright (C) 2009, 2010, 2012, 2020 Peter Johansson
    1010
    1111  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3333
    3434#include <boost/iterator/permutation_iterator.hpp>
    35 #include <boost/shared_ptr.hpp>
    3635
    3736#include <iosfwd>
     37#include <memory>
    3838#include <utility>
    3939#include <vector>
     
    296296
    297297  private:
    298     typedef boost::shared_ptr<const utility::MatrixWeighted> MatrixWP;
     298    typedef std::shared_ptr<const utility::MatrixWeighted> MatrixWP;
    299299    utility::Index column_index_;
    300300    MatrixWP data_;
  • branches/kendall-score/yat/omic/BamPair.cc

    r3792 r4038  
    3737  BamPair::BamPair(const BamRead& first, const BamRead& second)
    3838    : first_(first), second_(second) {}
     39
     40
     41  BamPair::BamPair(BamRead&& first, BamRead&& second)
     42    : first_(std::move(first)), second_(std::move(second)) {}
    3943
    4044
  • branches/kendall-score/yat/omic/BamPair.h

    r3792 r4038  
    4646     */
    4747    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);
    4855
    4956    /**
  • branches/kendall-score/yat/omic/BamPairIterator.h

    r3999 r4038  
    3232#include <boost/iterator/iterator_concepts.hpp>
    3333#include <boost/iterator/iterator_facade.hpp>
    34 #include <boost/shared_ptr.hpp>
    3534
    3635#include <iterator>
    3736#include <map>
     37#include <memory>
    3838#include <utility>
    3939
     
    115115    Base end_;
    116116    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_;
    118118    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_;
    120120    friend class boost::iterator_core_access;
    121121
  • branches/kendall-score/yat/omic/BamPairIterator2.h

    r3881 r4038  
    3232#include <boost/iterator/iterator_concepts.hpp>
    3333#include <boost/iterator/iterator_facade.hpp>
    34 #include <boost/shared_ptr.hpp>
    3534
    3635#include <iterator>
    3736#include <map>
     37#include <memory>
    3838#include <utility>
    3939
     
    118118    // multimap with reads' position as key
    119119    typedef std::multimap<Position, BamRead> MultiMap;
    120     boost::shared_ptr<MultiMap> reads_;
     120    std::shared_ptr<MultiMap> reads_;
    121121    MultiMap::iterator first_;
    122122    MultiMap::iterator second_;
  • branches/kendall-score/yat/omic/BamReadIterator.cc

    r3883 r4038  
    2828#include "yat/utility/Exception.h"
    2929
     30#include <cassert>
    3031#include <cstddef>
    3132#include <sstream>
     
    3637
    3738  BamReadIterator::BamReadIterator(void)
     39    : actor_(new AllActor)
    3840  {
    39     actor_ = boost::shared_ptr<Actor>(new AllActor);
     41    assert(actor_);
    4042  }
    4143
    4244
    4345  BamReadIterator::BamReadIterator(InBamFile& in)
     46    : actor_(new AllActor(in))
    4447  {
    45     actor_ = boost::shared_ptr<Actor>(new AllActor(in));
     48    assert(actor_);
    4649    increment();
    4750  }
     
    5053  BamReadIterator::BamReadIterator(InBamFile& bf, int32_t tid, int32_t start,
    5154                                   int32_t end)
     55    : actor_(new IndexActor(bf, tid, start, end))
    5256  {
    53     actor_ = boost::shared_ptr<Actor>(new IndexActor(bf, tid, start, end));
    5457    assert(actor_);
    5558    increment();
     
    5861
    5962  BamReadIterator::BamReadIterator(InBamFile& bf, int32_t tid, int32_t start)
     63    : actor_(new IndexActor(bf, tid, start, bf.header().target_length(tid)))
    6064  {
    61     actor_ =
    62       boost::shared_ptr<Actor>(new IndexActor(bf, tid, start,
    63                                               bf.header().target_length(tid)));
    6465    assert(actor_);
    6566    increment();
     
    8384    actor_->increment();
    8485  }
     86
     87
     88  void BamReadIterator::IndexDestroyer::operator()(hts_itr_t* i) const
     89  {
     90    bam_itr_destroy(i);
     91  }
     92
    8593
    8694
     
    120128  BamReadIterator::IndexActor::IndexActor(InBamFile& bf, int32_t tid,
    121129                                          int32_t begin,int32_t end)
    122     : Actor(&bf)
     130    : Actor(&bf),
     131      iter_(sam_itr_queryi(bf.index(), tid, begin, end), IndexDestroyer())
    123132  {
    124     using boost::shared_ptr;
    125     iter_ = shared_ptr<hts_itr_t>(sam_itr_queryi(bf.index(), tid, begin, end),
    126                                   IndexDestroyer());
    127133    if (!iter_.get()) {
    128134      std::stringstream ss;
  • branches/kendall-score/yat/omic/BamReadIterator.h

    r3999 r4038  
    2929
    3030#include <boost/iterator/iterator_facade.hpp>
    31 #include <boost/shared_ptr.hpp>
    3231
    3332#include <iterator>
     33#include <memory>
    3434
    3535namespace theplu {
     
    118118    void increment(void);
    119119
     120
    120121    /*
    121122       Interface class for the actor that handles difference between
     
    142143    };
    143144
     145    // functor calling bam_itr_destroy
     146    struct IndexDestroyer
     147    {
     148      void operator()(hts_itr_t* i) const;
     149    };
     150
    144151    // class used when iterating over a sub-region of the bam file
    145152    class IndexActor : public Actor
     
    149156      void increment(void);
    150157    private:
    151       boost::shared_ptr<hts_itr_t> iter_;
     158      std::unique_ptr<hts_itr_t, IndexDestroyer> iter_;
    152159    };
    153160
    154     boost::shared_ptr<Actor> actor_;
     161    std::shared_ptr<Actor> actor_;
    155162
    156     struct IndexDestroyer
    157     {
    158       void operator()(hts_itr_t* i) const
    159       {
    160         bam_itr_destroy(i);
    161       }
    162     };
    163163  };
    164164}}}
  • branches/kendall-score/yat/omic/Fasta.cc

    r3999 r4038  
    166166  {
    167167    // 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[]>());
    169170    std::copy(seq.seq_.get(), seq.seq_.get()+seq.size(), ptr.get());
    170171    // calculate reverse complement
  • branches/kendall-score/yat/omic/Fasta.h

    r3999 r4038  
    2121#include <htslib/faidx.h>
    2222
    23 #include <boost/shared_array.hpp>
    24 #include <boost/shared_ptr.hpp>
    25 
    2623#include <iosfwd>
    2724#include <map>
     25#include <memory>
    2826#include <string>
    2927#include <vector>
     
    114112      friend class Fasta;
    115113      friend Sequence reverse_complement(const Fasta::Sequence&);
    116       boost::shared_array<const char> seq_;
     114      std::shared_ptr<char> seq_;
    117115      int size_;
    118116    };
     
    134132
    135133  private:
    136     boost::shared_ptr<faidx_t> faidx_;
     134    std::shared_ptr<faidx_t> faidx_;
    137135    // using compiler generated copy
    138136    //FastaIndex(const FastaIndex& other);
  • branches/kendall-score/yat/omic/Pileup.h

    r3999 r4038  
    3131#include <boost/iterator/iterator_concepts.hpp>
    3232#include <boost/concept/assert.hpp>
    33 #include <boost/shared_ptr.hpp>
    3433
    3534#include <algorithm>
    3635#include <list>
     36#include <memory>
    3737
    3838namespace theplu {
     
    139139      size_t qpos(void) const { return qpos_; }
    140140    private:
    141       boost::shared_ptr<BamRead> bam_;
     141      std::shared_ptr<BamRead> bam_;
    142142      // index of base pointed to
    143143      size_t qpos_;
  • branches/kendall-score/yat/omic/VCF.h

    r3999 r4038  
    600600    size_t begin = str_.find(k);
    601601
    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 {
    610603      if (begin == std::string::npos) {
    611604        converter(value, result);
    612605        return;
    613606      }
     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);
    614621    }
    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    }
    620627  }
    621628
     
    642649    detail::Converter<T> converter;
    643650    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()));
    664659    }
    665660  }
    666   */
     661
     662
    667663}}}
    668664#endif
  • branches/kendall-score/yat/random/Makefile.am

    r3999 r4038  
    2222yat_libyat_la_SOURCES += yat/random/random.cc
    2323
    24 nobase_include_HEADERS += $(srcdir)/yat/random/ContinuousDistribution.h
    2524nobase_include_HEADERS += $(srcdir)/yat/random/copy_k_of_n.h
    26 nobase_include_HEADERS += $(srcdir)/yat/random/DiscreteDistribution.h
    27 nobase_include_HEADERS += $(srcdir)/yat/random/Distribution.h
    2825nobase_include_HEADERS += $(srcdir)/yat/random/random.h
  • branches/kendall-score/yat/random/random.cc

    r3999 r4038  
    219219
    220220
     221  DiscreteGeneral::DiscreteGeneral(void)
     222    : gen_(nullptr)
     223  {}
     224
     225
    221226  DiscreteGeneral::DiscreteGeneral(const statistics::Histogram& hist)
    222227    : gen_(NULL)
     
    233238  {
    234239    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_);
    235247  }
    236248
     
    262274  DiscreteGeneral& DiscreteGeneral::operator=(const DiscreteGeneral& rhs)
    263275  {
    264     free();
    265     p_ = rhs.p_;
    266     preproc();
     276    DiscreteGeneral tmp(rhs);
     277    swap(*this, tmp);
    267278    return *this;
    268279  }
    269280
    270281
     282  DiscreteGeneral& DiscreteGeneral::operator=(DiscreteGeneral&& rhs)
     283  {
     284    DiscreteGeneral tmp(std::move(rhs));
     285    swap(*this, tmp);
     286    return *this;
     287  }
     288
     289
    271290  unsigned long DiscreteGeneral::operator()(void) const
    272291  {
    273292    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_);
    274300  }
    275301
  • branches/kendall-score/yat/random/random.h

    r3959 r4038  
    341341  {
    342342  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
    343351    ///
    344352    /// @brief Constructor
     
    354362     */
    355363    DiscreteGeneral(const DiscreteGeneral&);
     364
     365    /**
     366       \brief Move constructor
     367
     368       \since New in yat 0.19
     369     */
     370    DiscreteGeneral(DiscreteGeneral&&);
    356371
    357372    ///
     
    377392    DiscreteGeneral& operator=(const DiscreteGeneral&);
    378393
     394    /**
     395       \brief Move assignment operator
     396
     397       \since New in yat 0.19
     398     */
     399    DiscreteGeneral& operator=(DiscreteGeneral&&);
     400
    379401  private:
    380402    void free(void);
     
    383405    gsl_ran_discrete_t* gen_;
    384406    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);
    386416
    387417  /**
  • branches/kendall-score/yat/statistics/Makefile.am

    r3999 r4038  
    3636  yat/statistics/LikelihoodRatioTestBinomial.cc \
    3737  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 \
    3941  yat/statistics/ROC.cc \
    4042  yat/statistics/SAMScore.cc yat/statistics/Score.cc \
     
    7375  $(srcdir)/yat/statistics/PearsonCorrelation.h \
    7476  $(srcdir)/yat/statistics/PearsonDistance.h \
     77  $(srcdir)/yat/statistics/PercentileConfidenceInterval.h \
    7578  $(srcdir)/yat/statistics/Percentiler.h \
    7679  $(srcdir)/yat/statistics/ROC.h \
  • branches/kendall-score/yat/utility/Aligner.cc

    r3840 r4038  
    2828#include <algorithm>
    2929#include <cassert>
     30#include <cctype>
    3031#include <limits>
    3132#include <ostream>
    3233
     34#include <iostream>
    3335namespace theplu {
    3436namespace yat {
     
    158160  // ================ Cigar =======================
    159161
     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
    160177  Aligner::Cigar::const_iterator Aligner::Cigar::begin(void) const
    161178  {
     
    210227    assert(i<cigar_.size());
    211228    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;
    212255  }
    213256
  • branches/kendall-score/yat/utility/Aligner.h

    r3847 r4038  
    190190
    191191      /**
     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      /**
    192206         \return iterator pointing to first element
    193207
     
    302316    private:
    303317      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);
    304323
    305324      // calculate length only counting operations whose type is set
  • branches/kendall-score/yat/utility/Cigar.h

    r3999 r4038  
    3030// allow inclusion of config_bam.h so this file is available also without bam.h
    3131#ifdef YAT_HAVE_HTSLIB
    32 #include "yat/omic/config_bam.h"
    3332#include <htslib/sam.h>
    3433#else // if sam.h is not available #define CIGAR
     34#include <cstdint> // needed for int8_t
    3535/// describe how CIGAR operation/length is packed into a 32-bit
    3636#define BAM_CIGAR_SHIFT 4
     
    8585#endif // end of backport
    8686
     87namespace theplu {
     88namespace yat {
     89namespace 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
    87103#endif // end of file
  • branches/kendall-score/yat/utility/Deleter.h

    r2858 r4038  
    2323*/
    2424
     25#include <new> // for delete operator
     26
    2527namespace theplu {
    2628namespace yat {
     
    3133
    3234     The class is typically used as second argument to a
    33      boost::shared_ptr, which enables to decide at runtime whether the
     35     std::shared_ptr, which enables to decide at runtime whether the
    3436     shared_ptr should own the pointee, i.e., should the pointee be
    3537     destructed at destruction of last shared_ptr pointing to the
  • branches/kendall-score/yat/utility/Exception.cc

    r2919 r4038  
    3535namespace utility {
    3636
     37  invalid_argument::invalid_argument(const std::string& message)
     38    : std::invalid_argument(message)
     39  {}
     40
     41
    3742  runtime_error::runtime_error(std::string message)
    3843    : std::runtime_error(message)
  • branches/kendall-score/yat/utility/Exception.h

    r2526 r4038  
    3131namespace utility {
    3232
    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
    3449
    3550  /**
  • branches/kendall-score/yat/utility/Makefile.am

    r4037 r4038  
    2323  yat/utility/Alignment.cc \
    2424  yat/utility/BasicMatrix.cc \
     25  yat/utility/Cigar.cc \
    2526  yat/utility/ColumnStream.cc \
    2627  yat/utility/CommandLine.cc \
  • branches/kendall-score/yat/utility/Segment.h

    r3855 r4038  
    6666    Segment(const T& begin, const T& end)
    6767      : 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)) {}
    6878
    6979    /**
  • branches/kendall-score/yat/utility/SegmentSet.h

    r3550 r4038  
    77  Copyright (C) 2010 Peter Johansson
    88  Copyright (C) 2012 Jari Häkkinen
    9   Copyright (C) 2014, 2016 Peter Johansson
     9  Copyright (C) 2014, 2016, 2021 Peter Johansson
    1010
    1111  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    4545   */
    4646  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>,
    4949                                  SegmentCompare<T, Compare> >,
    5050                         Compare,
     
    6767      std::pair<typename me::iterator, typename me::iterator> p =
    6868        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));
    7085    }
    7186
     
    8398                                       const typename me::value_type& segment)
    8499    {
     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    {
    85112      std::pair<typename me::iterator, typename me::iterator> p(hint, hint);
    86113      if (this->container_.empty())
    87         return insert_merge(p, segment);
     114        return move_insert_merge(p, std::move(segment));
    88115
    89116      // If hint points to an element that is less than segment, hint
    90117      // is no good and we ignore the hint.
    91118      if (hint!=this->end() && compare(*hint, segment))
    92         return insert_merge(segment);
     119        return insert_merge(std::move(segment));
    93120
    94121      if (p.first!=this->begin()) {
     
    97124        // no good.
    98125        if (compare(segment, *p.first))
    99           return insert_merge(segment);
     126          return insert_merge(std::move(segment));
    100127        // find first element that is smaller than segment
    101128        while (p.first!=this->begin() && !compare(*p.first, segment))
     
    111138        ++p.second;
    112139
    113       return insert_merge(p, segment);
    114     }
     140      return move_insert_merge(p, std::move(segment));
     141    }
     142
    115143
    116144    /**
     
    132160    }
    133161  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.
    135166    //
    136167    // p.first points to the first segment that overlaps with \a segment or
     
    138169    // p.second points to the first segment that is greater than \a segment
    139170    typename me::const_iterator
    140     insert_merge(const std::pair<typename me::iterator,
    141                                  typename me::iterator>& p,
    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)
    143174    {
    144175      YAT_ASSERT(p.first==this->end() || !compare(*p.first, segment));
    145176      YAT_ASSERT(p.second==this->end() || compare(segment, *p.second));
    146177      if (p.first==p.second) { // no overlap between set and segment
    147         return this->container_.insert(p.first, segment);
     178        return this->container_.insert(p.first, std::move(segment));
    148179      }
    149180      /*
     
    166197
    167198      this->container_.erase(p.first, p.second);
    168       return this->container_.insert(p.second, segment2);
     199      return this->container_.insert(p.second, std::move(segment2));
    169200    }
    170201
  • branches/kendall-score/yat/utility/SegmentTree.h

    r3114 r4038  
    55
    66/*
    7   Copyright (C) 2010, 2011, 2012, 2013 Peter Johansson
     7  Copyright (C) 2010, 2011, 2012, 2013, 2021 Peter Johansson
    88
    99  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2929#include <algorithm>
    3030#include <functional>
     31#include <utility>
    3132
    3233namespace theplu {
     
    180181
    181182    /**
     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    /**
    182190       \return Comparison functor to compare two keys (Segment)
    183191     */
    184192    key_compare key_comp(void) const
    185193    {
    186       return key_compare(compare);
     194      return container_.key_comp();
    187195    }
    188196
     
    226234       \c values
    227235     */
    228     value_compare value_comp(void) const { return key_comp(); }
     236    value_compare value_comp(void) const { return container_.value_comp(); }
    229237
    230238  protected:
     
    301309
    302310  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>
    303319  typename SegmentTree<T, Compare, Value2Key>::iterator
    304320  SegmentTree<T, Compare,Value2Key>::lower_bound(const element_type& element)
Note: See TracChangeset for help on using the changeset viewer.