Sequence::chromosome Struct Reference
[Classes and functions related to simulating data under coalescent models]

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

#include <Sequence/Coalescent/SimTypes.hpp>

List of all members.

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
 ~chromosome ()
chromosomeoperator= (const chromosome &ch)
 assignment operator
void swap_with (chromosome &ch)
void assign_allocated_segs (segment *newsegs, const int &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 90 of file SimTypes.hpp.


Constructor & Destructor Documentation

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

constructor

Parameters:
initial_segs a vector of segments
population used to set pop
Note:
nsegs is set to initial_segs.size()

Definition at line 62 of file CoalescentSimTypes.cc.

Sequence::chromosome::~chromosome (  ) 

frees pointer to segments

Definition at line 78 of file CoalescentSimTypes.cc.


Member Function Documentation

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

Replaces the current segs with those pointed to by newsegs

Parameters:
newsegs an array of segments allocated with malloc
new_nsegs the number of segs stored in newsegs

Definition at line 130 of file CoalescentSimTypes.cc.

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

Definition at line 159 of file CoalescentSimTypes.cc.

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

Definition at line 143 of file CoalescentSimTypes.cc.

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

Definition at line 167 of file CoalescentSimTypes.cc.

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

Definition at line 151 of file CoalescentSimTypes.cc.

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

Definition at line 123 of file SimTypes.hpp.

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

Definition at line 132 of file SimTypes.hpp.

int Sequence::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 175 of file CoalescentSimTypes.cc.

void Sequence::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 114 of file CoalescentSimTypes.cc.


Member Data Documentation

The number of segments contained in the pointer segs

Definition at line 113 of file SimTypes.hpp.

the population in which the chromosome is currently found

Definition at line 109 of file SimTypes.hpp.

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 103 of file SimTypes.hpp.


The documentation for this struct was generated from the following files:
Generated on Thu Aug 11 13:22:05 2011 for libsequence by  doxygen 1.6.3