vg
tools for working with variation graphs
Classes | Namespaces | Functions
utility.cpp File Reference
#include "utility.hpp"
#include "statistics.hpp"
#include <set>
#include <mutex>
#include <dirent.h>
#include <thread>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <iostream>
#include <cctype>
#include <gcsa/utils.h>
#include <gbwt/utils.h>
#include <xg.hpp>

Classes

struct  vg::temp_file::Handler
 

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 ()
 
std::vector< std::string > & vg::split_delims (const std::string &s, const std::string &delims, std::vector< std::string > &elems, size_t max_cuts)
 
std::vector< std::string > vg::split_delims (const std::string &s, const std::string &delims, size_t max_cuts)
 
bool vg::starts_with (const std::string &value, const std::string &prefix)
 Check if a string starts with another string. More...
 
const std::string vg::sha1sum (const std::string &data)
 
const std::string vg::sha1head (const std::string &data, size_t head)
 
string vg::wrap_text (const string &str, size_t width)
 
bool vg::is_number (const std::string &s)
 
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::toUppercaseInPlace (string &s)
 
void vg::write_fasta_sequence (const std::string &name, const std::string &sequence, ostream &os, size_t width)
 
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...
 
string vg::temp_file::create_directory ()
 Create a temporary directory. More...
 
void vg::temp_file::remove (const string &filename)
 
void vg::temp_file::forget ()
 Forget about all current temporary files and directories without deleting them. More...
 
void vg::temp_file::set_system_dir ()
 
void vg::temp_file::set_dir (const string &new_temp_dir)
 
string vg::temp_file::get_dir ()
 Get the current location for temporary files and directories. More...
 
string vg::get_or_make_variant_id (const vcflib::Variant &variant)
 
string vg::make_variant_id (const vcflib::Variant &variant)
 
vector< size_t > vg::range_vector (size_t begin, size_t end)
 Vector containing positive integer values in [begin, end) More...
 
std::vector< size_t > vg::stack_permutations (const std::vector< size_t > &bottom, const std::vector< size_t > &top)
 Apply one permutation on top of another. Retutn the combined permutation. 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, bool test_open)
 
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...
 
string vg::file_base_name (const string &filename)
 Get the base name of a filename (without the directory and the extension). More...
 
bool vg::file_exists (const string &filename)
 
void vg::create_ref_allele (vcflib::Variant &variant, const std::string &allele)
 
int vg::add_alt_allele (vcflib::Variant &variant, const std::string &allele)
 
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)
 
default_random_engine vg::random_sequence_gen (102)
 
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::replace_in_string (string subject, const string &search, const string &replace)
 
string vg::percent_url_encode (const string &seq)
 Escape "%" to "%25". More...
 
bool vg::deterministic_flip (LazyRNG &rng)
 Flip a coin with 50% probability against the given RNG. 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, 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...
 
template<>
bool vg::parse (const string &arg, double &dest)
 
template<>
bool vg::parse (const string &arg, std::regex &dest)
 
template<>
bool vg::parse (const string &arg, pos_t &dest)