Changeset 3774


Ignore:
Timestamp:
Oct 26, 2018, 9:19:12 AM (4 years ago)
Author:
Peter
Message:

implement VcfIterator?. refs #905

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/vcf_file.cc

    r3773 r3774  
    2727#include "yat/omic/VcfFile.h"
    2828#include "yat/omic/VcfHeader.h"
     29#include "yat/omic/VcfIterator.h"
    2930
     31#include "yat/random/random.h"
     32
     33#include <algorithm>
     34#include <iterator>
    3035#include <sstream>
     36#include <vector>
    3137
    3238using namespace theplu::yat;
     
    5056  omic::VCF entry;
    5157  vcf.read(entry);
     58  // create a vector VCFs from iterator range
     59  omic::VcfIterator begin(vcf);
     60  omic::VcfIterator end;
     61  std::vector<omic::VCF> vec(begin, end);
     62  if (vec.empty()) {
     63    suite.add(false);
     64    suite.err() << "error: vector is empty\n";
     65  }
     66
     67  // randomise variants
     68  random::random_shuffle(vec.begin(), vec.end());
     69
     70  // just illustrating how to output vcfs using ostream_iterator
     71  std::stringstream os;
     72  std::copy(vec.begin(), vec.end(),std::ostream_iterator<omic::VCF>(os, "\n"));
     73  suite.out() << "output:\n" << os.str().substr(0, 100)
     74              << "--->8 cut\n";
     75  if (os.str().size() < 100) {
     76    suite.add(false);
     77    suite.err() << "error: too small output\n";
     78  }
     79
    5280  vcf.close();
    5381  return suite.return_value();
  • trunk/yat/omic/Makefile.am

    r3762 r3774  
    4040yat_libyat_la_SOURCES += yat/omic/VcfFile.cc
    4141yat_libyat_la_SOURCES += yat/omic/VcfHeader.cc
     42yat_libyat_la_SOURCES += yat/omic/VcfIterator.cc
    4243
    4344nobase_include_HEADERS += $(srcdir)/yat/omic/algorithm.h
     
    6566nobase_include_HEADERS += $(srcdir)/yat/omic/VcfFile.h
    6667nobase_include_HEADERS += $(srcdir)/yat/omic/VcfHeader.h
     68nobase_include_HEADERS += $(srcdir)/yat/omic/VcfIterator.h
  • trunk/yat/omic/VcfFile.h

    r3773 r3774  
    120120    boost::scoped_ptr<std::ifstream> file_stream_;
    121121    std::string name_;
     122    friend class VcfIterator;
    122123  };
    123124
Note: See TracChangeset for help on using the changeset viewer.