ʻOhana
Population structure, admixture history, and selection using learning methods.
Public Types | Static Public Member Functions
jade::basic_genotype_matrix_factory< TValue > Class Template Reference

A template for a class that creates genotype matrices based on files and their file extensions. More...

#include <jade.genotype_matrix_factory.hpp>

+ Collaboration diagram for jade::basic_genotype_matrix_factory< TValue >:

Public Types

typedef TValue value_type
 The value type. More...
 
typedef basic_genotype_matrix< value_typegenotype_matrix_type
 The genotype matrix type. More...
 
typedef basic_discrete_genotype_matrix< value_typediscrete_genotype_matrix_type
 The discrete genotype matrix type. More...
 
typedef basic_likelihood_genotype_matrix< value_typelikelihood_genotype_matrix_type
 The likelihood genotype matrix type. More...
 

Static Public Member Functions

static genotype_matrix_typecreate (const std::string &path)
 Creates a genotype matrix based on values from a file. This function determines what kind of genotype matrix to create based on the file extension of the specified path. More...
 
static genotype_matrix_typecreate (char const *const path)
 Creates a genotype matrix based on values from a file. This function determines what kind of genotype matrix to create based on the file extension of the specified path. More...
 

Detailed Description

template<typename TValue>
class jade::basic_genotype_matrix_factory< TValue >

A template for a class that creates genotype matrices based on files and their file extensions.

Definition at line 20 of file jade.genotype_matrix_factory.hpp.

Member Typedef Documentation

◆ discrete_genotype_matrix_type

The discrete genotype matrix type.

Definition at line 32 of file jade.genotype_matrix_factory.hpp.

◆ genotype_matrix_type

The genotype matrix type.

Definition at line 28 of file jade.genotype_matrix_factory.hpp.

◆ likelihood_genotype_matrix_type

The likelihood genotype matrix type.

Definition at line 36 of file jade.genotype_matrix_factory.hpp.

◆ value_type

template<typename TValue >
typedef TValue jade::basic_genotype_matrix_factory< TValue >::value_type

The value type.

Definition at line 24 of file jade.genotype_matrix_factory.hpp.

Member Function Documentation

◆ create() [1/2]

template<typename TValue >
static genotype_matrix_type* jade::basic_genotype_matrix_factory< TValue >::create ( char const *const  path)
inlinestatic

Creates a genotype matrix based on values from a file. This function determines what kind of genotype matrix to create based on the file extension of the specified path.

Returns
A pointer to a new genotype matrix.
Exceptions
Anexception if the path has no file extension or if the file cannot be parsed successfully.
Parameters
pathThe path to the file.

Definition at line 77 of file jade.genotype_matrix_factory.hpp.

79  {
80  assert(path != nullptr);
81  return create(std::string(path));
82  }
+ Here is the call graph for this function:

◆ create() [2/2]

template<typename TValue >
static genotype_matrix_type* jade::basic_genotype_matrix_factory< TValue >::create ( const std::string &  path)
inlinestatic

Creates a genotype matrix based on values from a file. This function determines what kind of genotype matrix to create based on the file extension of the specified path.

Returns
A pointer to a new genotype matrix.
Exceptions
Anexception if the path has no file extension or if the file cannot be parsed successfully.
Parameters
pathThe path to the file.

Definition at line 48 of file jade.genotype_matrix_factory.hpp.

50  {
51  const auto period = path.find_last_of('.');
52  if (period == std::string::npos)
53  throw error() << "missing file extension for G matrix '"
54  << path << "'.";
55 
56  const auto extension = path.substr(period);
57  if (extension == ".dgm")
58  return new discrete_genotype_matrix_type(path);
59 
60  if (extension == ".lgm")
61  return new likelihood_genotype_matrix_type(path);
62 
63  throw error() << "unsupported file extension for G matrix '"
64  << path << "'.";
65  }
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file:
jade::basic_genotype_matrix_factory::create
static genotype_matrix_type * create(const std::string &path)
Creates a genotype matrix based on values from a file. This function determines what kind of genotype...
Definition: jade.genotype_matrix_factory.hpp:48
jade::basic_genotype_matrix_factory::discrete_genotype_matrix_type
basic_discrete_genotype_matrix< value_type > discrete_genotype_matrix_type
The discrete genotype matrix type.
Definition: jade.genotype_matrix_factory.hpp:32
jade::basic_genotype_matrix_factory::likelihood_genotype_matrix_type
basic_likelihood_genotype_matrix< value_type > likelihood_genotype_matrix_type
The likelihood genotype matrix type.
Definition: jade.genotype_matrix_factory.hpp:36