32 int sample_length(
const std::vector< std::pair<int,int> > & fragments )
40 for( std::vector< std::pair<int,int> >::const_iterator i = fragments.begin() ;
41 i < fragments.end() ; ++i )
48 int total_length(
const std::vector< std::pair<int,int> > & fragments )
56 for( std::vector< std::pair<int,int> >::const_iterator i = fragments.begin() ;
57 i < fragments.end() ; ++i )
59 sum += (i->first+i->second);
65 std::vector< std::pair<double,double> > * sample_scale,
66 std::vector< std::pair<double,double> > * mutation_scale )
83 sample_scale->resize(fragments.size());
84 mutation_scale->resize(fragments.size());
93 std::vector< std::pair<double,double> >::iterator si = sample_scale->begin(),
94 mi = mutation_scale->begin();
95 for( std::vector<std::pair<int,int> >::const_iterator i = fragments.begin() ;
96 i < fragments.end() ; ++i,++si,++mi )
99 si->second = double(i->second)/double(ttl_sample_len);
100 dummy += double(i->second)/double(ttl_sample_len);
101 mi->first = double(ttl)/double(ttl_len) + double(i->first)/double(ttl_len);
102 mi->second = double(i->second)/double(ttl_len);
103 ttl += i->first + i->second;
108 const std::vector< std::pair<double,double> > & sample_scale,
109 const std::vector< std::pair<double,double> > & mutation_scale )
117 assert(mutation_scale.size()==sample_scale.size());
118 typedef std::vector<std::pair<double,double> >::const_iterator ci;
119 for(Sequence::SimData::pos_iterator p = d->pbegin() ; p < d->pend() ; ++p)
121 for( ci ss=sample_scale.begin(),ms=mutation_scale.begin() ;
122 ss < sample_scale.end() && ms < mutation_scale.end() ; ++ss,++ms )
124 if( *p >= ss->first &&
125 *p < (ss->first+ss->second) )
128 double delta = (*p-ss->first)/(ss->second);
129 *p = ms->first + delta*ms->second;
137 const std::vector< std::pair<int,int> > & fragments )
144 for(arg::iterator ai = sample_history->begin() ; ai != sample_history->end() ; ++ai)
147 int ttl_sample_len=0;
148 for( std::vector< std::pair<int,int> >::const_iterator f = fragments.
begin() ;
149 f < fragments.
end() ; ++f )
152 if( ai->beg >= ttl_sample_len && ai->beg < (ttl_sample_len+f->second) )
155 double delta = double(ai->beg-ttl_sample_len)/double(f->second);
156 ai->beg = ttl_len + int(delta*
double(f->second));
161 ttl_sample_len += f->second;
169 const int & current_nsam,
170 const std::vector<double> & genetic_map,
171 std::vector<double> * reclens)
190 assert(current_nsam > 0);
191 assert(!genetic_map.empty());
192 reclens->resize(std::vector<double>::size_type(current_nsam));
193 std::vector<double>::iterator ri = reclens->begin();
195 for(std::vector<chromosome>::const_iterator chrom = sample.begin() ;
196 chrom < (sample.begin()+current_nsam) ; ++chrom,++ri)
198 int beg = chrom->first(), end = chrom->last();
200 double rho_chrom = std::accumulate(genetic_map.begin()+beg,genetic_map.begin()+end,0.);
void calculate_scales(const std::vector< std::pair< int, int > > &fragments, std::vector< std::pair< double, double > > *sample_scale, std::vector< std::pair< double, double > > *mutation_scale)
This is a helper function that rescales physical distance in base pairs to continuous distance on the...
int total_length(const std::vector< std::pair< int, int > > &fragments)
When simulating partially linked regions, return the total length of the region.
std::list< marginal > arg
Ancestral Recombination Graph.
The namespace in which this library resides.
Helper functions for simulating partially linked fragments One often wants to simulate partially link...
void rescale_mutation_positions(Sequence::SimData *d, const std::vector< std::pair< double, double > > &sample_scale, const std::vector< std::pair< double, double > > &mutation_scale) __attribute__((deprecated))
Rescales the positions of the mutations in d from the scale given in sample_scale to that given in mu...
double integrate_genetic_map(const std::vector< chromosome > &sample, const int ¤t_nsam, const std::vector< double > &genetic_map, std::vector< double > *reclens)
When simulating non-uniform recombination rates, the probability of recombination at each point in th...
Declaration of Sequence::SimData, a class representing polymorphism data from coalescent simulations ...
Data from coalescent simulations.
int sample_length(const std::vector< std::pair< int, int > > &fragments)
When simulating partially linked regions, return the total length of sample material that we are simu...
void rescale_arg(arg *sample_history, const std::vector< std::pair< int, int > > &fragments)
Rescales the beginnings of marginal trees in an ancestral recombination graph from a genetic scale to...