42 const int & d = 0) : beg(b),end(e),desc(d)
50 assert ( end >= beg );
64 const int & population ) :
68 nsegs(unsigned(initial_segs.size()))
76 std::copy(initial_segs.begin(),initial_segs.end(),
segs);
104 if(
this == &ch)
return *
this;
105 if(ch.
nsegs>this->nsegs)
130 std::swap(this->
pop,ch.
pop);
134 const unsigned & new_nsegs )
189 const int & a) : time(t),abv(a)
199 const std::vector<node> & t) :
200 beg(b),nsam(ns),nnodes(nn),tree(t)
248 assert(
int(i) <= 2*
nsam-2 );
258 assert(
int(i) <= 2*
nsam-2 );
267 return this->
beg < rhs.beg;
279 for( ; seg < c.
end() ;
282 s << seg->beg <<
':' << seg->end <<
',';
284 s <<
' ' << c.
nsegs <<
' ' << c.
links() <<
')';
294 s <<
"marginal tree begins at: " << m.
beg <<
'\n';
296 for( ;seg < m.
nnodes ; ++seg)
299 << (m.
begin()+seg)->time <<
' ' 300 << (m.
begin()+seg)->abv <<
'\n';
303 << (m.
begin()+seg)->time <<
' ' 304 << (m.
begin()+seg)->abv;
314 marginal::const_iterator mi;
316 std::vector<int> left,right;
317 std::vector<node>
tree;
319 std::ostream & parens(
const int & noden,
320 std::ostream & o)
const;
327 newick_stream_marginal_tree_impl::newick_stream_marginal_tree_impl(
const marginal & m) :
329 left(std::vector<int>::size_type(2*
nsam-1),-1),right(left),
330 tree(std::vector<node>())
335 newick_stream_marginal_tree_impl::newick_stream_marginal_tree_impl(
const marginal * m) :
337 left(std::vector<int>::size_type(2*
nsam-1),-1),right(left),
338 tree(std::vector<node>())
343 newick_stream_marginal_tree_impl::newick_stream_marginal_tree_impl(arg::const_iterator m) :
344 mi(m->begin()),
nsam(m->nsam),
345 left(std::vector<int>::size_type(2*
nsam-1),-1),right(left),
346 tree(std::vector<node>())
351 newick_stream_marginal_tree_impl::newick_stream_marginal_tree_impl(arg::iterator m) :
352 mi(m->begin()),
nsam(m->nsam),
353 left(std::vector<int>::size_type(2*
nsam-1),-1),right(left),
354 tree(std::vector<node>())
361 std::ostream & o)
const 366 if( left[std::vector<int>::size_type(noden)] == -1 )
368 assert( (mi+((mi+noden)->abv))->time >= 0. );
369 o << noden+1 <<
':' <<(mi+((mi+noden)->abv))->time;
374 parens( left[std::vector<int>::size_type(noden)], o ) ;
376 parens( right[std::vector<int>::size_type(noden)], o ) ;
377 if( (mi+noden)->abv == -1 )
383 double time = (mi + (mi+noden)->abv )->time - (mi+noden)->time ;
396 for(
int i=0;i<2*
nsam-2;++i)
398 if( left[ std::vector<int>::size_type( (mi+i)->abv ) ] == -1 )
400 left[std::vector<int>::size_type( (mi+i)->abv ) ] = i;
404 right[ std::vector<int>::size_type( (mi+i)->abv ) ] = i;
410 newick_stream_marginal_tree::newick_stream_marginal_tree(
const marginal & m ) :
415 newick_stream_marginal_tree::newick_stream_marginal_tree(
const marginal * m ) :
420 newick_stream_marginal_tree::newick_stream_marginal_tree( arg::const_iterator m ) :
425 newick_stream_marginal_tree::newick_stream_marginal_tree( arg::iterator m ) :
430 newick_stream_marginal_tree::~newick_stream_marginal_tree( )
448 impl->parens( 2*(impl->nsam)-2,o);
std::ostream & parens(const int &noden, std::ostream &o) const
void swap_with(chromosome &ch)
chromosome()
constructor sets segs to NULL, pop to 0, and nsegs to 0
void assign_allocated_segs(segment *newsegs, const unsigned &new_nsegs)
reference operator[](const std::vector< node >::size_type &i)
Class that provides a typecast-on-output of a marginal tree to a newick tree Example use: ...
std::ostream & operator<<(std::ostream &s, const chromosome &c)
output operator for chromosome types in coalescent simulation Outputs the segments contained by the c...
The namespace in which this library resides.
declaration of types for coalescent simulation
std::vector< node > get_tree() const
segment()
default constructor initializes all members to 0
std::istream & read(std::istream &i)
std::istream & operator>>(std::istream &i, newick_stream_marginal_tree &n)
marginal(const int &b, const int &ns, const int &nn, const std::vector< node > &tree)
A chromosome is a container of segments.
chromosome & operator=(const chromosome &ch)
assignment operator
bool operator<(const marginal &rhs) const
node(const double &t=0., const int &a=-1)
A portion of a recombining chromosome.
std::ostream & print(std::ostream &o) const
The genealogy of a portion of a chromosome on which no recombination has occurred.