vg
tools for working with variation graphs
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
vg::IndexManager Class Reference

#include <index_manager.hpp>

Inheritance diagram for vg::IndexManager:
vg::Progressive

Public Member Functions

 IndexManager (const string &fasta_filename="", const string &vcf_filename="")
 
void set_fasta_filename (const string &filename)
 Set the FASTA filename (and thus the basename for looking for other indexes, if not already set). More...
 
void set_vcf_filename (const string &filename)
 Set the VCF filename. More...
 
void set_minimizer_override (const string &filename)
 Override the file to load the minimizer index from. More...
 
shared_ptr< gbwtgraph::DefaultMinimizerIndex > get_minimizer ()
 Get the minimizer index. More...
 
bool can_get_minimizer () const
 Returns true if the minimizer index is available or can be generated/loaded, and false otherwise. More...
 
void set_gbwtgraph_override (const string &filename)
 Override the file to load the gbwtgraph index from. More...
 
shared_ptr< gbwtgraph::GBWTGraph > get_gbwtgraph ()
 Get the gbwtgraph index. More...
 
bool can_get_gbwtgraph () const
 Returns true if the GBWTGraph is available or can be generated/loaded, and false otherwise. More...
 
void set_gbwt_override (const string &filename)
 Override the file to load the gbwt index from. More...
 
shared_ptr< gbwt::GBWT > get_gbwt ()
 Get the gbwt index. More...
 
bool can_get_gbwt () const
 Returns true if the GBWT is available or can be generated/loaded, and false otherwise. More...
 
void set_distance_override (const string &filename)
 Override the file to load the distance index from. More...
 
shared_ptr< vg::MinimumDistanceIndexget_distance ()
 Get the gbwt index. More...
 
bool can_get_distance () const
 Returns true if the distance index is available or can be generated/loaded, and false otherwise. More...
 
void set_snarls_override (const string &filename)
 Override the file to load the snarls from. More...
 
shared_ptr< vg::SnarlManagerget_snarls ()
 Get the snarls. More...
 
bool can_get_snarls () const
 Returns true if the snarls are available or can be generated/loaded, and false otherwise. More...
 
void set_graph_override (const string &filename)
 
shared_ptr< PathHandleGraphget_graph ()
 Get the graph. More...
 
bool can_get_graph () const
 Returns true if the graph is available or can be generated/loaded, and false otherwise. More...
 
- Public Member Functions inherited from vg::Progressive
void preload_progress (const string &message)
 
void create_progress (const string &message, long count)
 
void create_progress (long count)
 
void update_progress (long i)
 
void increment_progress ()
 
void destroy_progress (void)
 

Static Public Attributes

constexpr static size_t minimizer_k = 29
 Minimizer kmer length to use when minimizer indexing. More...
 
constexpr static size_t minimizer_w = 11
 Minimizer window size to use when minimizer indexing. More...
 

Protected Member Functions

void ensure_graph ()
 Load the graph, or make it from the FASTA and VCF file names, and save it to disk. More...
 
void ensure_snarls ()
 Load the snarls (including trivial snarls), or make them from the graph and save them to disk. More...
 
void ensure_distance ()
 Load the distance index, or make it from the graph and the snarls and save it to disk. More...
 
void ensure_gbwt ()
 Load the GBWT, or make it from the graph and the VCF filename and save it to disk. More...
 
void ensure_gbwtgraph ()
 Load the GBWTGraph, or make it from the GBWT and the base graph, and save it to disk. More...
 
void ensure_minimizer ()
 Load the minimizer index, or make it from the GBWTGraph and the GBWT and save it to disk. More...
 
template<typename IndexHolderType >
void ensure (IndexHolderType &member, const string &filename_override, const string &extension, const function< void(ifstream &)> &load, const function< void(ofstream &)> &make_and_save)
 
template<typename IndexHolderType >
bool can_get (IndexHolderType &member, const string &filename_override, const string &extension, const function< bool(void)> &poll_dependencies) const
 
string get_filename (const string &extension) const
 

Protected Attributes

string fasta_filename
 
string vcf_filename
 
string basename
 
string minimizer_override
 
string gbwtgraph_override
 
string gbwt_override
 
string distance_override
 
string snarls_override
 
string graph_override
 
shared_ptr< gbwtgraph::DefaultMinimizerIndex > minimizer
 
pair< shared_ptr< gbwtgraph::GBWTGraph >, shared_ptr< gbwt::GBWT > > gbwtgraph
 
shared_ptr< gbwt::GBWT > gbwt
 
shared_ptr< vg::MinimumDistanceIndexdistance
 
shared_ptr< SnarlManagersnarls
 
shared_ptr< PathHandleGraphgraph
 

Additional Inherited Members

- Public Attributes inherited from vg::Progressive
bool show_progress = false
 

Detailed Description

Represents a set of indexes (including the actual graph) organized around a base name. The base name is the name of the indexed FASTA file.

We have an internal collection of shared_ptrs, one for each final or intermediate index.

We also have a bunch of internal ensure_whatever() methods that make sure that the corresponding index is populated, either from disk if available, or from the indexes it depends on, first calling the ensure method for each.

For each index type (foo), we need:

  1. A protected member "foo" which is a shared_ptr to the index.
  2. A protected member "foo_override" which is a filename to load the index from, to override the basename-based logic.
  3. A protected method "ensure_foo()" which uses "ensure()" to load or create the index.
  4. A public method "set_foo_override()" to set the override filename.
  5. A public method "get_foo()" to fill it in (via "ensure_foo()") and return it.
  6. A public method "can_get_foo()" which returns true if it thinks get_foo() will be successful, and false (and prints a warning) if e.g. necessary files are missing.

Note that the IndexManager may exit the process, instead of throwing an exception, if something goes wrong during a "get_foo()" method, so you should check "can_get_foo()" first.

Constructor & Destructor Documentation

◆ IndexManager()

vg::IndexManager::IndexManager ( const string &  fasta_filename = "",
const string &  vcf_filename = "" 
)

Member Function Documentation

◆ can_get()

template<typename IndexHolderType >
bool vg::IndexManager::can_get ( IndexHolderType &  member,
const string &  filename_override,
const string &  extension,
const function< bool(void)> &  poll_dependencies 
) const
protected

We have a template for helping write the can_get functions. Defined in the CPP since only we use it.

◆ can_get_distance()

bool vg::IndexManager::can_get_distance ( ) const

Returns true if the distance index is available or can be generated/loaded, and false otherwise.

◆ can_get_gbwt()

bool vg::IndexManager::can_get_gbwt ( ) const

Returns true if the GBWT is available or can be generated/loaded, and false otherwise.

◆ can_get_gbwtgraph()

bool vg::IndexManager::can_get_gbwtgraph ( ) const

Returns true if the GBWTGraph is available or can be generated/loaded, and false otherwise.

◆ can_get_graph()

bool vg::IndexManager::can_get_graph ( ) const

Returns true if the graph is available or can be generated/loaded, and false otherwise.

◆ can_get_minimizer()

bool vg::IndexManager::can_get_minimizer ( ) const

Returns true if the minimizer index is available or can be generated/loaded, and false otherwise.

◆ can_get_snarls()

bool vg::IndexManager::can_get_snarls ( ) const

Returns true if the snarls are available or can be generated/loaded, and false otherwise.

◆ ensure()

template<typename IndexHolderType >
void vg::IndexManager::ensure ( IndexHolderType &  member,
const string &  filename_override,
const string &  extension,
const function< void(ifstream &)> &  load,
const function< void(ofstream &)> &  make_and_save 
)
protected

We have a template to help us stamp out these ensure functions. We define it in the CPP since only we ever use it. Note that the ostream to make_and_save is only open if there is a basename and a file to write to.

◆ ensure_distance()

void vg::IndexManager::ensure_distance ( )
protected

Load the distance index, or make it from the graph and the snarls and save it to disk.

◆ ensure_gbwt()

void vg::IndexManager::ensure_gbwt ( )
protected

Load the GBWT, or make it from the graph and the VCF filename and save it to disk.

◆ ensure_gbwtgraph()

void vg::IndexManager::ensure_gbwtgraph ( )
protected

Load the GBWTGraph, or make it from the GBWT and the base graph, and save it to disk.

◆ ensure_graph()

void vg::IndexManager::ensure_graph ( )
protected

Load the graph, or make it from the FASTA and VCF file names, and save it to disk.

◆ ensure_minimizer()

void vg::IndexManager::ensure_minimizer ( )
protected

Load the minimizer index, or make it from the GBWTGraph and the GBWT and save it to disk.

◆ ensure_snarls()

void vg::IndexManager::ensure_snarls ( )
protected

Load the snarls (including trivial snarls), or make them from the graph and save them to disk.

◆ get_distance()

shared_ptr< vg::MinimumDistanceIndex > vg::IndexManager::get_distance ( )

Get the gbwt index.

◆ get_filename()

string vg::IndexManager::get_filename ( const string &  extension) const
protected

Get the filename for the index file having the given extension. Extension should not include the dot. May or may not exist yet. Returns "" if there is no basename.

◆ get_gbwt()

shared_ptr< gbwt::GBWT > vg::IndexManager::get_gbwt ( )

Get the gbwt index.

◆ get_gbwtgraph()

shared_ptr< gbwtgraph::GBWTGraph > vg::IndexManager::get_gbwtgraph ( )

Get the gbwtgraph index.

◆ get_graph()

shared_ptr< PathHandleGraph > vg::IndexManager::get_graph ( )

Get the graph.

◆ get_minimizer()

shared_ptr< gbwtgraph::DefaultMinimizerIndex > vg::IndexManager::get_minimizer ( )

Get the minimizer index.

◆ get_snarls()

shared_ptr< vg::SnarlManager > vg::IndexManager::get_snarls ( )

Get the snarls.

◆ set_distance_override()

void vg::IndexManager::set_distance_override ( const string &  filename)

Override the file to load the distance index from.

◆ set_fasta_filename()

void vg::IndexManager::set_fasta_filename ( const string &  filename)

Set the FASTA filename (and thus the basename for looking for other indexes, if not already set).

◆ set_gbwt_override()

void vg::IndexManager::set_gbwt_override ( const string &  filename)

Override the file to load the gbwt index from.

◆ set_gbwtgraph_override()

void vg::IndexManager::set_gbwtgraph_override ( const string &  filename)

Override the file to load the gbwtgraph index from.

◆ set_graph_override()

void vg::IndexManager::set_graph_override ( const string &  filename)

Override the file to load the graph from. Also sets index basename to be based on this graph file.

◆ set_minimizer_override()

void vg::IndexManager::set_minimizer_override ( const string &  filename)

Override the file to load the minimizer index from.

◆ set_snarls_override()

void vg::IndexManager::set_snarls_override ( const string &  filename)

Override the file to load the snarls from.

◆ set_vcf_filename()

void vg::IndexManager::set_vcf_filename ( const string &  filename)

Set the VCF filename.

Member Data Documentation

◆ basename

string vg::IndexManager::basename
protected

◆ distance

shared_ptr<vg::MinimumDistanceIndex> vg::IndexManager::distance
protected

◆ distance_override

string vg::IndexManager::distance_override
protected

◆ fasta_filename

string vg::IndexManager::fasta_filename
protected

◆ gbwt

shared_ptr<gbwt::GBWT> vg::IndexManager::gbwt
protected

◆ gbwt_override

string vg::IndexManager::gbwt_override
protected

◆ gbwtgraph

pair<shared_ptr<gbwtgraph::GBWTGraph>, shared_ptr<gbwt::GBWT> > vg::IndexManager::gbwtgraph
protected

◆ gbwtgraph_override

string vg::IndexManager::gbwtgraph_override
protected

◆ graph

shared_ptr<PathHandleGraph> vg::IndexManager::graph
protected

◆ graph_override

string vg::IndexManager::graph_override
protected

◆ minimizer

shared_ptr<gbwtgraph::DefaultMinimizerIndex> vg::IndexManager::minimizer
protected

◆ minimizer_k

constexpr size_t vg::IndexManager::minimizer_k = 29
staticconstexpr

Minimizer kmer length to use when minimizer indexing.

◆ minimizer_override

string vg::IndexManager::minimizer_override
protected

◆ minimizer_w

constexpr size_t vg::IndexManager::minimizer_w = 11
staticconstexpr

Minimizer window size to use when minimizer indexing.

◆ snarls

shared_ptr<SnarlManager> vg::IndexManager::snarls
protected

◆ snarls_override

string vg::IndexManager::snarls_override
protected

◆ vcf_filename

string vg::IndexManager::vcf_filename
protected

The documentation for this class was generated from the following files: