3533{
3534
3537 Patch* current_patch;
3539
3540
3541 double **genes;
3542 int total_size = 0;
3543
3544 double *snp_tab;
3545
3546
3548
3549
3550 unsigned int loc, rec;
3553
3554
3555 snp_tab = new double [ (nb_trait * nb_locus) ];
3556
3557
3558
3559
3560 ostringstream REC;
3561 string current;
3562
3563
3564
3567
3569
3570
3572
3573 rec = 1;
3574 for(int i = 0; i < patchNbr; i++)
3575 for(unsigned int k = 0; k < nb_trait; k++) {
3576 for(unsigned int l = 0; l < nb_locus; l++) {
3577
3578 REC<<i+1<<" "<<k+1<<" "<<l+1<<" "<<snp_allele[l][0];
3579
3581
3582 REC.str("");
3583
3584 }
3585 }
3586
3587 } else {
3588
3590
3592 }
3593
3594
3595
3596
3597 rec = 1;
3598 for(int i = 0; i < patchNbr; i++) {
3599
3600
3602
3603
3604
3605
3606
3607 for(unsigned int k = 0; k < nb_trait; k++) {
3608 for(unsigned int l = 0; l < nb_locus; l++) {
3609 loc = l * nb_trait + k;
3610 snp_tab [loc] = 0;
3611 }
3612 }
3613
3615
3616
3617 for(
unsigned int j = 0, size = current_patch->
size(
FEM,
ADLTx); j < size; j++) {
3618
3620
3622
3623
3624 for(unsigned int k = 0; k < nb_trait; k++) {
3625 for(unsigned int l = 0; l < nb_locus; l++) {
3626 loc = l * nb_trait + k;
3627
3628 if (genes[0][loc] == snp_allele[l][0]){
3629 snp_tab [loc] += 1;
3630 }
3631
3632 if (genes[1][loc] == snp_allele[l][0]){
3633 snp_tab [loc] += 1;
3634 }
3635
3636 }
3637 }
3638
3639
3640 }
3641
3642
3643 for(
unsigned int j = 0, size = current_patch->
size(
MAL,
ADLTx); j < size; j++) {
3644
3646
3648
3649 for(unsigned int k = 0; k < nb_trait; k++) {
3650 for(unsigned int l = 0; l < nb_locus; l++) {
3651 loc = l * nb_trait + k;
3652
3653 if (genes[0][loc] == snp_allele[l][0]){
3654 snp_tab [loc] += 1;
3655 }
3656 if (genes[1][loc] == snp_allele[l][0]){
3657 snp_tab [loc] += 1;
3658 }
3659 }
3660 }
3661
3662
3663 }
3664
3665
3666 for(unsigned int k = 0; k < nb_trait; k++) {
3667 for(unsigned int l = 0; l < nb_locus; l++) {
3668
3669 loc = l * nb_trait + k;
3670
3671
3673
3675
3677
3678 rec++;
3679 }
3680 }
3681 }
3682
3683
3684 delete [] snp_tab;
3685
3687
3689 std::ofstream FILE ;
3690
3691
3692 FILE.open(filename.c_str(), ios::out);
3693
3694 if(!FILE)
fatal(
"Trait quanti could not open output file: \"%s\"\n",filename.c_str());
3695
3696 for(
unsigned int i = 0; i <
_records.size(); ++i)
3698
3699 FILE.close();
3700 }
3701}
std::string & get_extension()
Definition: filehandler.h:143
std::string & get_path()
Definition: filehandler.h:139
unsigned int get_GenerationOccurrence()
Definition: filehandler.h:162
FileServices * get_service()
Returns pointer to the FileServices.
Definition: filehandler.h:135
string & getReplicateFileName()
Accessor to the current replicate file name.
Definition: fileservices.cc:381
virtual Metapop * get_pop_ptr()
Accessor to the pointer to the main population.
Definition: fileservices.h:111
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:49
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:277
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:430
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:496
Individual * get(sex_t SEX, age_idx AGE, unsigned int at)
Returns a pointer to the individual sitting at the index passed.
Definition: metapop.h:532
unsigned int get_nb_locus()
Definition: ttquanti.h:122
unsigned int get_nb_traits()
Definition: ttquanti.h:121
double ** get_allele_values() const
Definition: ttquanti.h:131
virtual void ** get_sequence() const =0
sequence accessor.
int _FHLinkedTraitIndex
Definition: filehandler.h:220
TProtoQuanti * _FHLinkedTrait
Definition: filehandler.h:219
static string int2str(const int i)
Writes an integer value into a string.
Definition: tstring.h:95
static string dble2str(const double d)
Writes a floating-point value into a string.
Definition: tstring.h:115
void fatal(const char *str,...)
Definition: output.cc:96
@ FEM
Definition: types.h:37
@ MAL
Definition: types.h:37
@ ADLTx
Definition: types.h:42