Changeset 3221


Ignore:
Timestamp:
May 6, 2014, 7:39:36 AM (9 years ago)
Author:
Peter
Message:

deprecate BamRead::cigar(vector<uint32_t>) and provide a new function to set cigar that takes new Aligner::Cigar class.

Location:
branches/0.12-stable
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/0.12-stable/NEWS

    r3215 r3221  
    66
    77version 0.12 (released NOT YET)
     8  - BamRead::cigar(const std::vector<uint32_t>&) is deprecated
    89  - Aligner(double, double) is now explicit (see r3207)
    910  - GetlineIterator(istream&, char) is now explicit (see r3148)
  • branches/0.12-stable/test/bam.cc

    r3201 r3221  
    2424#include "yat/omic/BamRead.h"
    2525#endif
     26
     27#include "yat/utility/Aligner.h"
    2628
    2729#include <cassert>
     
    7173  suite.out() << bam.cigar_str() << "\n";
    7274  OutBamFile os("cigar_test.bam", hdr);
    73   std::vector<uint32_t> cig;
     75  utility::Aligner::Cigar cig;
    7476
    7577  bam.cigar(cig);
     
    7880  os.write(bam);
    7981
    80   cig.resize(1);
    81   cig[0] = bam_cigar_gen(bam.sequence_length(), BAM_CMATCH);
     82  cig.push_back(BAM_CMATCH, bam.sequence_length());
    8283  bam.cigar(cig);
    8384  suite.out() << bam.cigar_str() << "\n";
     
    8586  os.write(bam);
    8687
    87   cig.resize(3);
    88   cig[0] = bam_cigar_gen(50, BAM_CMATCH);
    89   cig[1] = bam_cigar_gen(2, BAM_CDEL);
    90   cig[2] = bam_cigar_gen(50, BAM_CMATCH);
     88  cig.clear();
     89  cig.push_back(BAM_CMATCH, 50);
     90  cig.push_back(BAM_CDEL, 2);
     91  cig.push_back(BAM_CMATCH, 50);
    9192  bam.cigar(cig);
    9293  suite.out() << bam.cigar_str() << "\n";
     
    132133
    133134  // just for consistency
    134   std::vector<uint32_t> cig;
     135  utility::Aligner::Cigar cig;
    135136  bam.cigar(cig);
    136137  bam.core().flag &= ~BAM_FUNMAP;
  • branches/0.12-stable/yat/omic/BamRead.cc

    r3210 r3221  
    149149
    150150  void BamRead::cigar(const std::vector<uint32_t>& c)
     151  {
     152    // use the new function cigar(1) to implement this old deprecated variant
     153    utility::Aligner::Cigar cig;
     154    for (size_t i=0; i<c.size(); ++i)
     155      cig.push_back(bam_cigar_op(c[i]), bam_cigar_oplen(c[i]));
     156    cigar(cig);
     157  }
     158
     159
     160  void BamRead::cigar(const utility::Aligner::Cigar& c)
    151161  {
    152162    int offset = 4*c.size() - 4*core().n_cigar;
     
    161171
    162172    // copy new cigar
    163     if (c.size())
    164       // each cigar element is 4 bytes
    165       memcpy(bam1_cigar(bam_), &c[0], 4*c.size());
     173    for (size_t i=0; i<c.size(); ++i)
     174      bam1_cigar(bam_)[i] = c[i];
     175
    166176    bam_->data_len += offset;
    167177    core().n_cigar = c.size();
  • branches/0.12-stable/yat/omic/BamRead.h

    r3212 r3221  
    2727#include YAT_SAM_HEADER
    2828
     29#include "yat/utility/Aligner.h"
    2930// This file has to be included to keep compatibility with yat 0.11
    30 #include <yat/utility/Cigar.h>
     31#include "yat/utility/Cigar.h"
     32#include "yat/utility/deprecate.h"
    3133
    3234#include <functional>
     
    171173
    172174       \param c new cigar
     175
     176       \deprecated Provided for backward compatibility with 0.11
     177       API. Use cigar(const utility::Aligner::Cigar&) instead.
    173178    */
    174     void cigar(const std::vector<uint32_t>& c);
     179    void cigar(const std::vector<uint32_t>& c) YAT_DEPRECATE;
     180
     181    /**
     182       \brief set CIGAR
     183
     184       \param cigar new cigar
     185
     186       \since new in yat 0.12
     187    */
     188    void cigar(const utility::Aligner::Cigar& cigar);
    175189
    176190    /**
  • branches/0.12-stable/yat/utility/deprecate.h

    r2124 r3221  
    11#ifndef _theplu_yat_utility_deprecate_
    2 #define _theplu_yat_utility_deprecate_ 
     2#define _theplu_yat_utility_deprecate_
    33
    44// $Id$
Note: See TracChangeset for help on using the changeset viewer.