libsequence  1.9.5

A chromosome is a container of segments. More...

#include <Sequence/Coalescent/SimTypes.hpp>

Public Types

typedef segmentiterator
 
typedef const segmentconst_iterator
 

Public Member Functions

 chromosome ()
 constructor sets segs to NULL, pop to 0, and nsegs to 0
 
 chromosome (const chromosome &ch)
 copy constructor
 
 chromosome (const std::vector< segment > &initial_segs, const int &population=0)
 constructor More...
 
 ~chromosome ()
 
chromosomeoperator= (const chromosome &ch)
 assignment operator
 
void swap_with (chromosome &ch)
 
void assign_allocated_segs (segment *newsegs, const unsigned &new_nsegs)
 
int first () const
 
int last () const
 
int links () const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 

Public Attributes

segmentsegs
 
int pop
 
unsigned nsegs
 

Detailed Description

A chromosome is a container of segments.

Note
this is a malloc-based container

Definition at line 92 of file SimTypes.hpp.

Constructor & Destructor Documentation

◆ chromosome()

Sequence::coalsim::chromosome::chromosome ( const std::vector< segment > &  initial_segs,
const int &  population = 0 
)

constructor

Parameters
initial_segsa vector of segments
populationused to set pop
Note
nsegs is set to initial_segs.size()

Definition at line 63 of file CoalescentSimTypes.cc.

◆ ~chromosome()

Sequence::coalsim::chromosome::~chromosome ( )

frees pointer to segments

Definition at line 79 of file CoalescentSimTypes.cc.

Member Function Documentation

◆ assign_allocated_segs()

void Sequence::coalsim::chromosome::assign_allocated_segs ( segment newsegs,
const unsigned &  new_nsegs 
)

Replaces the current segs with those pointed to by newsegs

Parameters
newsegsan array of segments allocated with malloc
new_nsegsthe number of segs stored in newsegs

Definition at line 133 of file CoalescentSimTypes.cc.

◆ begin() [1/2]

chromosome::iterator Sequence::coalsim::chromosome::begin ( )
Returns
segs

Definition at line 146 of file CoalescentSimTypes.cc.

◆ begin() [2/2]

chromosome::const_iterator Sequence::coalsim::chromosome::begin ( ) const
Returns
segs

Definition at line 162 of file CoalescentSimTypes.cc.

◆ end() [1/2]

chromosome::iterator Sequence::coalsim::chromosome::end ( )
Returns
segs+nsegs

Definition at line 154 of file CoalescentSimTypes.cc.

◆ end() [2/2]

chromosome::const_iterator Sequence::coalsim::chromosome::end ( ) const
Returns
segs+nsegs

Definition at line 170 of file CoalescentSimTypes.cc.

◆ first()

int Sequence::coalsim::chromosome::first ( ) const
inline
Returns
the first position in the chromosome

Definition at line 125 of file SimTypes.hpp.

◆ last()

int Sequence::coalsim::chromosome::last ( ) const
inline
Returns
the last position in the chromosome

Definition at line 134 of file SimTypes.hpp.

◆ links()

int Sequence::coalsim::chromosome::links ( ) const

Computes and returns the number of positions at which recombination can occur in the chromosome

Returns
(segs+nsegs-1)->end - segs->beg

Definition at line 178 of file CoalescentSimTypes.cc.

◆ swap_with()

void Sequence::coalsim::chromosome::swap_with ( chromosome ch)

Swaps the data members of the current chromosome with chromosome ch. Called by the coalesce routine, and is necessary to prevent nastiness such as multiple calls to free when vectors of chromosomes go out of scope. Implemented as: std::swap(this->segs,ch.segs); std::swap(this->nsegs,ch.nsegs); std::swap(this->pop,ch.pop);

Definition at line 117 of file CoalescentSimTypes.cc.

Member Data Documentation

◆ nsegs

unsigned Sequence::coalsim::chromosome::nsegs

The number of segments contained in the pointer segs

Definition at line 115 of file SimTypes.hpp.

◆ pop

int Sequence::coalsim::chromosome::pop

the population in which the chromosome is currently found

Definition at line 111 of file SimTypes.hpp.

◆ segs

segment* Sequence::coalsim::chromosome::segs

The list of segments making up the ancestral material of a chromosome at the current point in the simulation.

Note
Please be aware that allocation of this array is done via malloc, rather than operator new. As coalescent simulations are all about copying segments, the use of malloc is more efficient for simulation purposes, as it results in many fewer calls to the default constructor. But this means you cannot assign to this pointer something allocated with operator new, else bad things will happen.

Definition at line 105 of file SimTypes.hpp.


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