Changeset 4316


Ignore:
Timestamp:
Feb 17, 2023, 2:40:50 AM (3 months ago)
Author:
Peter
Message:

Merged release 0.20.2 into trunk

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/NEWS

    r4308 r4316  
    1111
    1212yat 0.20.x series from http://dev.thep.lu.se/yat/svn/branches/0.20-stable
     13
     14version 0.20.2 (released 17 February 2023)
     15  - Fixed bug in VCF::Info::set(2) (bug #995)
     16
     17  A complete list of closed tickets can be found here [[br]]
     18  http://dev.thep.lu.se/yat/query?status=closed&milestone=yat+0.20.2
    1319
    1420version 0.20.1 (released 10 February 2023)
  • trunk/m4/version.m4

    r4308 r4316  
    102102# yat-0.20   17:0:0
    103103# yat-0.20.1 17:1:0
     104# yat-0.20.2 17:2:0
    104105#
    105106# *Accidently, the libtool number was not updated for yat 0.5
  • trunk/test/vcf.cc

    r4170 r4316  
    11// $Id$
    22//
    3 // Copyright (C) 2018, 2020, 2022 Peter Johansson
     3// Copyright (C) 2018, 2020, 2022, 2023 Peter Johansson
    44//
    55// This program is free software; you can redistribute it and/or modify
     
    3232using namespace theplu::yat;
    3333
     34template<typename T>
     35void equal_vec(test::Suite& suite, std::vector<T> x, std::vector<T> y)
     36{
     37  if (x != y) {
     38    suite.add(false);
     39    if (x.size() != y.size())
     40      suite.err() << "error: vectors not the same\n"
     41                  << "x size: " << x.size() << "\n"
     42                  << "y size: " << y.size() << "\n";
     43    else
     44      for (size_t i=0; i<x.size(); ++i)
     45        std::cerr << "'" << x[i] << "' : '" << y[i] << "'\n";
     46  }
     47}
     48
     49
     50template<typename T1, typename T2>
     51void equal(test::Suite& suite, T1 x, T2 y)
     52{
     53  if (x != y) {
     54    suite.add(false);
     55    suite.err() << "error: " << x << " != " << y << "\n";
     56  }
     57}
     58
     59
     60void test_info(test::Suite& suite, omic::VCF::Info info)
     61{
     62  std::string value;
     63  info.add("FOO", "foo");
     64  info.get(value, "FOO");
     65  equal(suite, value, "foo");
     66
     67  info.set("FOO", "foo2");
     68  info.get(value, "FOO");
     69  equal(suite, value, "foo2");
     70
     71  int x;
     72  info.add("X", "1");
     73  info.get(x, "X");
     74  equal(suite, x, 1);
     75
     76  info.set("X", 2);
     77  info.get(x, "X");
     78  equal(suite, x, 2);
     79
     80  std::vector<std::string> values;
     81  std::vector<std::string> foos(2, "fu");
     82  info.add("FOOS", foos);
     83  info.get(values, "FOOS");
     84  equal_vec(suite, values, foos);
     85  info.set("FOOS", foos);
     86  info.get(value, "FOOS");
     87  equal_vec(suite, values, foos);
     88
     89  std::vector<int> y;
     90  std::vector<int> bars(2, 13);
     91  info.add("BARS", bars);
     92  info.get(y, "BARS");
     93  equal_vec(suite, y, bars);
     94  info.set("BARS", bars);
     95  info.get(y, "BARS");
     96  equal_vec(suite, y, bars);
     97}
     98
     99
    34100int main(int argc, char* argv[])
    35101{
     
    104170
    105171    suite.out() << "test info\n";
     172    test_info(suite, vcf.info());
    106173    suite.add(vcf.info().str() == "");
    107174    vcf.info().set("SNV");
  • trunk/yat/omic/VCF.h

    r4171 r4316  
    55
    66/*
    7   Copyright (C) 2018, 2019, 2020, 2022 Peter Johansson
     7  Copyright (C) 2018, 2019, 2020, 2022, 2023 Peter Johansson
    88
    99  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    221221      /**
    222222         Add entry \a key to semicolon-delimited list of entries.
     223
     224         If \a key is already present, the behaviour is undefined.
    223225       */
    224226      void add(const std::string& key);
     
    227229         T is either string or numeric or a std::vector with strings
    228230         or numerics.
     231
     232         If \a key is already present, the behaviour is undefined.
    229233       */
    230234      template<typename T>
     
    242246
    243247      /**
    244         get value corresponding to \a key
     248        get value corresponding to \a key. If \a key is not present,
     249        result is as value is empty string.
    245250
    246251        T is string, numeric, vector<string> or vector<numeric>
     
    270275
    271276      /**
     277         If \a key is absent, equivalent to call add(key, value). If
     278         \a key present, erase its value and set to \a value.
     279
    272280         T is either string or numeric or a std::vector with strings
    273281         or numerics.
     
    685693    str_ = "";
    686694    auto it = map_.lower_bound(key);
    687     if (it==map_.end() && it->first!=key) {
     695    if (it==map_.end() || it->first!=key) {
    688696      keys_.push_back(key);
    689697      it = map_.insert(it, std::make_pair(key, ""));
    690698    }
     699    else
     700      it->second.clear();
    691701    detail::Appender<T> append(',');
    692702    append(it->second, value);
Note: See TracChangeset for help on using the changeset viewer.