/libvgio

A dynamic library that provides io for the vg toolkit.

Primary LanguageC++OtherNOASSERTION

libvgio is a library for (de)serializing vg files for use with the vg toolkit (see Sequence variation aware genome references and read mapping with the variation graph toolkit).

This tool is in the development stage, so it may contain bugs and the instructions on how to use it are subject to change.

Compiling

libvgio is implemented in C++11 and is built using CMake.

libvgio's only dependency is protobuf (Google Protocol Buffers) and pthreads, both of which can be easily installed on any Unix style system.

Once protobufs and pthreads are installed, you can build and install libvgio by running the installation script: ./install.sh [INSTALL_LOCATION]. This will install the dynamic library and headers in your home directory unless you provide the script with the optional INSTALL_LOCATION.

Usage

libvgio exposes two header files vg/vg.pb.h and vg/io/basic_stream.hpp. vg/vg.pb.h is the header generated by the vg protobuf (see the vg toolkit Wiki for details) and vg/io/basic_stream.hpp exposes an input stream and an output stream.

The following C++ example reads a vg graph with the input stream and writes it to the standard output with the output stream.

#include <iostream>
#include "vg/vg.pb.h"
#include "vg/io/basic_stream.hpp"

using std::cout;
using std::endl;
using vg::Graph;
using vg::io::inputStream;
using vg::io::outputStream;

int main(int argc, char* argv[])
{
  if (argc != 2) {
    cout << "Usage: " << argv[0] << " VG_FILE" << endl;
    return -1;
  }
  Graph g = inputStream(argv[1]);
  outputStream(g);
  return 0;
}

This can be compiled by linking against libvgio at compile time

g++ -lvgio <myprogram>.cpp

or with CMake

find_package(VGio REQUIRED)
target_link_libraries(myprogram VGio::VGio)