vg
tools for working with variation graphs
Classes | Namespaces | Functions
utility.hpp File Reference
#include <string>
#include <vector>
#include <sstream>
#include <omp.h>
#include <signal.h>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_set>
#include <random>
#include <type_traits>
#include <regex>
#include <unistd.h>
#include <vg/vg.pb.h>
#include "types.hpp"
#include "sha1.hpp"
#include "Variant.h"

Classes

struct  vg::TreeNode< T >
 
struct  vg::Tree< T >
 
struct  vg::IncrementIter
 

Namespaces

 vg
 
 vg::temp_file
 

Functions

char vg::reverse_complement (const char &c)
 
string vg::reverse_complement (const string &seq)
 
void vg::reverse_complement_in_place (string &seq)
 
bool vg::is_all_n (const string &seq)
 
double vg::get_fraction_of_ns (const string &seq)
 
int vg::get_thread_count (void)
 
void vg::choose_good_thread_count ()
 
string vg::wrap_text (const string &str, size_t width)
 
bool vg::is_number (const string &s)
 
std::vector< std::string > & vg::split_delims (const std::string &s, const std::string &delims, std::vector< std::string > &elems)
 
std::vector< std::string > vg::split_delims (const std::string &s, const std::string &delims)
 
const std::string vg::sha1sum (const std::string &data)
 
const std::string vg::sha1head (const std::string &data, size_t head)
 
bool vg::isATGC (const char &b)
 Return true if a character is an uppercase A, C, G, or T, and false otherwise. More...
 
bool vg::allATGC (const string &s)
 
bool vg::allATGCN (const string &s)
 
string vg::nonATGCNtoN (const string &s)
 
string vg::allAmbiguousToN (const string &s)
 
string vg::toUppercase (const string &s)
 
void vg::write_fasta_sequence (const std::string &name, const std::string &sequence, ostream &os, size_t width)
 
template<typename T , typename V >
set< T > vg::map_keys_to_set (const map< T, V > &m)
 
template<typename T >
vector< T > vg::pmax (const std::vector< T > &a, const std::vector< T > &b)
 
template<typename T >
vector< T > vg::vpmax (const std::vector< std::vector< T >> &vv)
 
template<typename Collection >
Collection::value_type vg::sum (const Collection &collection)
 
string vg::temp_file::create (const string &base)
 Create a temporary file starting with the given base name. More...
 
string vg::temp_file::create ()
 Create a temporary file. More...
 
void vg::temp_file::remove (const string &filename)
 Remove a temporary file. More...
 
void vg::temp_file::set_dir (const string &new_temp_dir)
 Set a temp dir, overriding system defaults and environment variables. More...
 
string vg::temp_file::get_dir ()
 Get the current temp dir. More...
 
string vg::get_or_make_variant_id (const vcflib::Variant &variant)
 
string vg::make_variant_id (const vcflib::Variant &variant)
 
void vg::create_ref_allele (vcflib::Variant &variant, const std::string &allele)
 
int vg::add_alt_allele (vcflib::Variant &variant, const std::string &allele)
 
template<template< class T, class A=std::allocator< T >> class Container, typename Input , typename Output >
Container< Output > vg::map_over (const Container< Input > &in, const std::function< Output(const Input &)> &lambda)
 
template<template< class T, class A=std::allocator< T >> class Container, typename Item >
Container< const Item * > vg::pointerfy (const Container< Item > &in)
 
vector< size_t > vg::range_vector (size_t begin, size_t end)
 
vector< size_t > vg::range_vector (size_t end)
 
size_t vg::integer_power (size_t x, size_t power)
 
size_t vg::integer_power (uint64_t base, uint64_t exponent)
 Computes base^exponent in log(exponent) time. More...
 
size_t vg::modular_exponent (uint64_t base, uint64_t exponent, uint64_t modulus)
 
string vg::random_sequence (size_t length)
 Returns a uniformly random DNA sequence of the given length. More...
 
string vg::pseudo_random_sequence (size_t length, uint64_t seed)
 Returns a uniformly random DNA sequence sequence deterministically from a seed. More...
 
string vg::percent_url_encode (const string &seq)
 Escape "%" to "%25". More...
 
string vg::replace_in_string (string subject, const string &search, const string &replace)
 
template<class RandomIt >
void vg::deterministic_shuffle (RandomIt begin, RandomIt end, const uint32_t &seed)
 
template<class RandomIt >
void vg::deterministic_shuffle (RandomIt begin, RandomIt end, const string &seed)
 
string vg::make_shuffle_seed (const Alignment &aln)
 Make seeds for Alignments based on their sequences. More...
 
string vg::make_shuffle_seed (const Alignment *aln)
 Make seeds for Alignments based on their sequences. More...
 
string vg::make_shuffle_seed (const pair< Alignment, Alignment > *alns)
 Make seeds for pairs of Alignments based on their concatenated sequences. More...
 
template<class RandomIt >
void vg::deterministic_shuffle (RandomIt begin, RandomIt end)
 Do a deterministic shuffle with automatic seed determination. More...
 
template<class RandomIt , class Compare , class MakeSeed >
void vg::sort_shuffling_ties (RandomIt begin, RandomIt end, Compare comp, MakeSeed seed)
 
template<class RandomIt , class Compare >
void vg::sort_shuffling_ties (RandomIt begin, RandomIt end, Compare comp)
 
unordered_map< id_t, pair< id_t, bool > > vg::overlay_node_translations (const unordered_map< id_t, pair< id_t, bool >> &over, const unordered_map< id_t, pair< id_t, bool >> &under)
 Compose the translations from two graph operations, both of which involved oriented transformations. More...
 
unordered_map< id_t, pair< id_t, bool > > vg::overlay_node_translations (const unordered_map< id_t, id_t > &over, const unordered_map< id_t, pair< id_t, bool >> &under)
 Compose the translations from two graph operations, the first of which involved oriented transformations. More...
 
unordered_map< id_t, pair< id_t, bool > > vg::overlay_node_translations (const unordered_map< id_t, pair< id_t, bool >> &over, const unordered_map< id_t, id_t > &under)
 Compose the translations from two graph operations, the second of which involved oriented transformations. More...
 
unordered_map< id_t, id_t > vg::overlay_node_translations (const unordered_map< id_t, id_t > &over, const unordered_map< id_t, id_t > &under)
 Compose the translations from two graph operations, neither of which involved oriented transformations. More...
 
bool vg::have_input_file (int &optind, int argc, char **argv)
 Return true if there's a command line argument (i.e. input file name) waiting to be processed. More...
 
void vg::get_input_file (int &optind, int argc, char **argv, function< void(istream &)> callback)
 
string vg::get_input_file_name (int &optind, int argc, char **argv)
 
string vg::get_output_file_name (int &optind, int argc, char **argv)
 
void vg::get_input_file (const string &file_name, function< void(istream &)> callback)
 
pair< string, string > vg::split_ext (const string &filename)
 Split off the extension from a filename and return both parts. More...
 
bool vg::file_exists (const string &filename)
 
template<typename Result >
Result vg::parse (const string &arg)
 
template<typename Result >
Result vg::parse (const char *arg)
 
template<typename Result >
bool vg::parse (const string &arg, Result &dest)
 
template<typename Result >
bool vg::parse (const string &arg, typename enable_if< sizeof(Result)<=sizeof(long long) &&is_integral< Result >::value &&is_signed< Result >::value, Result >::type &dest)
 
template<>
bool vg::parse (const string &arg, double &dest)
 
template<>
bool vg::parse (const string &arg, std::regex &dest)