A library for working with phylogenetic and population genetic data.
v0.27.0
Pquery Class Reference

#include <genesis/placement/pquery.hpp>

Detailed Description

A pquery holds a set of PqueryPlacements and a set of PqueryNames.

According to the jplace standard, a pquery is a container object that represents the possible phylogenetic placement positions of a sequence (or set of sequences). Each such position is stored as a PqueryPlacement and can be accessed via the functions of this class.

Furthermore, it might be useful to combine the placement positions of several sequences into one object. This is for example the case if there are replicate sequences. Thus, a Pquery supports to store multiple PqueryNames, each of them containing an identifying name string and a so called multiplicity, which can be used as e.g., an abundance count for the associated name, and is used as a factor for the weights of the placements in some calculations.

Definition at line 82 of file pquery.hpp.

Public Member Functions

 Pquery ()=default
 
 Pquery (Pquery &&)=default
 
 Pquery (Pquery const &)=default
 
 ~Pquery ()=default
 
PqueryNameadd_name (PqueryName const &other)
 Create a new PqueryName as a copy of the provided one, add it to the Pquery and return it. More...
 
PqueryNameadd_name (std::string name="", double multiplicity=1.0)
 Create a new PqueryName using the provided parameters, add it to the Pquery and return it. More...
 
PqueryPlacementadd_placement (PlacementTreeEdge &edge)
 Create a new PqueryPlacement at a given PlacementTreeEdge, add it to the Pquery and return it. More...
 
PqueryPlacementadd_placement (PlacementTreeEdge &edge, PqueryPlacement const &val)
 Create a new PqueryPlacement at a given PlacementTreeEdge, add it to the Pquery and return it. The property values of the provided PqueryPlacement are copied. More...
 
PqueryPlacementadd_placement (PqueryPlacement const &val)
 Create a new PqueryPlacement as a copy of the provided one, add it to the Pquery and return it. More...
 
iterator_names begin_names ()
 
const_iterator_names begin_names () const
 
iterator_placements begin_placements ()
 
const_iterator_placements begin_placements () const
 
void clear ()
 Clear all data stored in this Pquery, i.e., clear all PqueryNames and all PqueryPlacements. More...
 
void clear_names ()
 Delete all PqueryNames of this Pquery. More...
 
void clear_placements ()
 Delete all PqueryPlacements of this Pquery. More...
 
iterator_names end_names ()
 
const_iterator_names end_names () const
 
iterator_placements end_placements ()
 
const_iterator_placements end_placements () const
 
std::vector< PqueryName > & expose_names ()
 
std::vector< PqueryPlacement > & expose_placements ()
 
PqueryNamename_at (size_t index)
 Return the PqueryName at a certain index. More...
 
PqueryName const & name_at (size_t index) const
 Return the PqueryName at a certain index. More...
 
size_t name_size () const
 Return the number of PqueryNames stored in this Pquery. More...
 
utils::Range< iterator_namesnames ()
 Return a Range iterator to the PqueryNames. More...
 
utils::Range< const_iterator_namesnames () const
 Return a const Range iterator to the PqueryNames. More...
 
Pqueryoperator= (Pquery &&)=default
 
Pqueryoperator= (Pquery const &)=default
 
PqueryPlacementplacement_at (size_t index)
 Return the PqueryPlacement at a certain index. More...
 
PqueryPlacement const & placement_at (size_t index) const
 Return the PqueryPlacement at a certain index. More...
 
size_t placement_size () const
 Return the number of PqueryPlacements stored in this Pquery. More...
 
utils::Range< iterator_placementsplacements ()
 Return a Range iterator to the PqueryPlacements. More...
 
utils::Range< const_iterator_placementsplacements () const
 Return a const Range iterator to the PqueryPlacements. More...
 
void remove_name_at (size_t index)
 Remove the PqueryName at a certain index position within this Pquery. More...
 
void remove_placement_at (size_t index)
 Remove the PqueryPlacement at a certain index position within this Pquery. More...
 

Public Types

typedef std::vector< PqueryName >::const_iterator const_iterator_names
 
typedef std::vector< PqueryPlacement >::const_iterator const_iterator_placements
 
typedef std::vector< PqueryName >::iterator iterator_names
 
typedef std::vector< PqueryPlacement >::iterator iterator_placements
 
typedef std::vector< PqueryNamePqueryNames
 
typedef std::vector< PqueryPlacementPqueryPlacements
 

Constructor & Destructor Documentation

◆ Pquery() [1/3]

Pquery ( )
default

◆ ~Pquery()

~Pquery ( )
default

◆ Pquery() [2/3]

Pquery ( Pquery const &  )
default

◆ Pquery() [3/3]

Pquery ( Pquery &&  )
default

Member Function Documentation

◆ add_name() [1/2]

PqueryName & add_name ( PqueryName const &  other)

Create a new PqueryName as a copy of the provided one, add it to the Pquery and return it.

As this function might reallocate the memory where names are stored, all iterators and pointer to PqueryNamess are considered to be invalidated.

Definition at line 187 of file pquery.cpp.

◆ add_name() [2/2]

PqueryName & add_name ( std::string  name = "",
double  multiplicity = 1.0 
)

Create a new PqueryName using the provided parameters, add it to the Pquery and return it.

As this function might reallocate the memory where names are stored, all iterators and pointer to PqueryNamess are considered to be invalidated.

Definition at line 181 of file pquery.cpp.

◆ add_placement() [1/3]

PqueryPlacement & add_placement ( PlacementTreeEdge edge)

Create a new PqueryPlacement at a given PlacementTreeEdge, add it to the Pquery and return it.

The values of the placement can then be adjusted using the returned object reference.

It is important that the provided edge belongs to the same PlacementTree as the Pquery and its containing Sample do. This is up to the user and not checked.

As this function might reallocate the memory where placements are stored, all iterators and pointer to PqueryPlacements are invalidated.

Definition at line 92 of file pquery.cpp.

◆ add_placement() [2/3]

PqueryPlacement & add_placement ( PlacementTreeEdge edge,
PqueryPlacement const &  val 
)

Create a new PqueryPlacement at a given PlacementTreeEdge, add it to the Pquery and return it. The property values of the provided PqueryPlacement are copied.

It is important that the provided edge belongs to the same PlacementTree as the Pquery and its containing Sample do. This is up to the user and not checked.

As this function might reallocate the memory where placements are stored, all iterators and pointer to PqueryPlacements are considered to be invalidated.

Definition at line 104 of file pquery.cpp.

◆ add_placement() [3/3]

PqueryPlacement & add_placement ( PqueryPlacement const &  val)

Create a new PqueryPlacement as a copy of the provided one, add it to the Pquery and return it.

As this function might reallocate the memory where placements are stored, all iterators and pointer to PqueryPlacements are considered to be invalidated.

Definition at line 98 of file pquery.cpp.

◆ begin_names() [1/2]

Definition at line 142 of file pquery.cpp.

◆ begin_names() [2/2]

const_iterator_names begin_names ( ) const

◆ begin_placements() [1/2]

Pquery::const_iterator_placements begin_placements ( )

Definition at line 53 of file pquery.cpp.

◆ begin_placements() [2/2]

const_iterator_placements begin_placements ( ) const

◆ clear()

void clear ( )

Clear all data stored in this Pquery, i.e., clear all PqueryNames and all PqueryPlacements.

Definition at line 43 of file pquery.cpp.

◆ clear_names()

void clear_names ( )

Delete all PqueryNames of this Pquery.

Definition at line 213 of file pquery.cpp.

◆ clear_placements()

void clear_placements ( )

Delete all PqueryPlacements of this Pquery.

Definition at line 133 of file pquery.cpp.

◆ end_names() [1/2]

Definition at line 147 of file pquery.cpp.

◆ end_names() [2/2]

const_iterator_names end_names ( ) const

◆ end_placements() [1/2]

Definition at line 58 of file pquery.cpp.

◆ end_placements() [2/2]

const_iterator_placements end_placements ( ) const

◆ expose_names()

std::vector< PqueryName > & expose_names ( )

Definition at line 172 of file pquery.cpp.

◆ expose_placements()

std::vector< PqueryPlacement > & expose_placements ( )

Definition at line 83 of file pquery.cpp.

◆ name_at() [1/2]

PqueryName & name_at ( size_t  index)

Return the PqueryName at a certain index.

The index must be smaller than name_size(), otherwise this functions throws an exception.

Definition at line 198 of file pquery.cpp.

◆ name_at() [2/2]

PqueryName const & name_at ( size_t  index) const

Return the PqueryName at a certain index.

The index must be smaller than name_size(), otherwise this functions throws an exception.

Definition at line 203 of file pquery.cpp.

◆ name_size()

size_t name_size ( ) const

Return the number of PqueryNames stored in this Pquery.

Definition at line 193 of file pquery.cpp.

◆ names() [1/2]

Return a Range iterator to the PqueryNames.

This makes iterating placements via a range based for loop easy.

Definition at line 162 of file pquery.cpp.

◆ names() [2/2]

Return a const Range iterator to the PqueryNames.

This makes iterating placements via a range based for loop easy.

◆ operator=() [1/2]

Pquery& operator= ( Pquery &&  )
default

◆ operator=() [2/2]

Pquery& operator= ( Pquery const &  )
default

◆ placement_at() [1/2]

PqueryPlacement & placement_at ( size_t  index)

Return the PqueryPlacement at a certain index.

The index must be smaller than placement_size(), otherwise this functions throws an exception.

Definition at line 118 of file pquery.cpp.

◆ placement_at() [2/2]

PqueryPlacement const & placement_at ( size_t  index) const

Return the PqueryPlacement at a certain index.

The index must be smaller than placement_size(), otherwise this functions throws an exception.

Definition at line 123 of file pquery.cpp.

◆ placement_size()

size_t placement_size ( ) const

Return the number of PqueryPlacements stored in this Pquery.

Definition at line 113 of file pquery.cpp.

◆ placements() [1/2]

Return a Range iterator to the PqueryPlacements.

This makes iterating placements via a range based for loop easy.

Definition at line 73 of file pquery.cpp.

◆ placements() [2/2]

utils::Range<const_iterator_placements> placements ( ) const

Return a const Range iterator to the PqueryPlacements.

This makes iterating placements via a range based for loop easy.

◆ remove_name_at()

void remove_name_at ( size_t  index)

Remove the PqueryName at a certain index position within this Pquery.

As this function moves names in the container, all iterators and pointer to PqueryNamess are considered to be invalidated.

Definition at line 208 of file pquery.cpp.

◆ remove_placement_at()

void remove_placement_at ( size_t  index)

Remove the PqueryPlacement at a certain index position within this Pquery.

As this function moves placements in the container, all iterators and pointer to PqueryPlacements are considered to be invalidated.

Definition at line 128 of file pquery.cpp.

Member Typedef Documentation

◆ const_iterator_names

typedef std::vector<PqueryName>::const_iterator const_iterator_names

Definition at line 97 of file pquery.hpp.

◆ const_iterator_placements

typedef std::vector<PqueryPlacement>::const_iterator const_iterator_placements

Definition at line 94 of file pquery.hpp.

◆ iterator_names

typedef std::vector<PqueryName>::iterator iterator_names

Definition at line 96 of file pquery.hpp.

◆ iterator_placements

typedef std::vector<PqueryPlacement>::iterator iterator_placements

Definition at line 93 of file pquery.hpp.

◆ PqueryNames

typedef std::vector<PqueryName> PqueryNames

Definition at line 91 of file pquery.hpp.

◆ PqueryPlacements

typedef std::vector<PqueryPlacement> PqueryPlacements

Definition at line 90 of file pquery.hpp.


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