This file shows several main file demos for different mating structures.

Scenario 2 : random mating for 10 generations within 2 populations, then cross these 2 populations and random mating for 10 generations

In []:
%%file main.cpp


#include <iostream>
#include <fstream>
#include "cohort.h"
#include "tools.h"
#include "simPop.h"
#include "global.h"
#include "parmMap.h"

int main(int argc, const char * argv[])
{   
    ///user-defined parameters and map positions
    unsigned popSize =  10;
    unsigned nGen    =  10;
  
    string genomeFile="/Users/erxingfangshui/Dropbox/GenSim/GenSim1.3_xcode/genomeInfo.txt";
    string mapFile="/Users/erxingfangshui/Dropbox/GenSim/GenSim1.3_xcode/mapPos.txt";
    string haplotype="/Users/erxingfangshui/Dropbox/GenSim/GenSim1.3_xcode/haplotype.txt";
    
    SimPop osim1(genomeFile,mapFile);
    SimPop osim2(genomeFile,mapFile);
    SimPop osim3(genomeFile,mapFile);

    osim1.popFounders(popSize,haplotype);
    osim2.popFounders(popSize,haplotype);

    osim3.cross(osim1,osim2,popSize);
    osim3.popSample(popSize/2,nGen);
    

    MatrixXf out;
    out=osim3.getGenotypes();
    ofstream outFile("/Users/erxingfangshui/genotype.example");
    outFile << out;
    
    return 0;

}
In []:
%%file main.cpp

#include <iostream>
#include <fstream>
#include "cohort.h"
#include "tools.h"
#include "simPop.h"
#include "global.h"
#include "parmMap.h"

int main(int argc, const char * argv[])
{   

    ///constant nLoci, chrLength and random map positions
    unsigned nLoci   =  100;
    unsigned nChrm   =  1;
    double chrLength =  0.01;
    unsigned popSize =  100;
    unsigned nGen    =  10;
    double   mutRate =  1e-5;
    
    SimPop osim1(nChrm,nLoci,chrLength,mutRate);
    SimPop osim2(nChrm,nLoci,chrLength,mutRate);
    SimPop osim3(nChrm,nLoci,chrLength,mutRate);

    osim1.popFounders(popSize);
    osim2.popFounders(popSize);

    osim3.cross(osim1,osim2,popSize);
    osim3.popSample(popSize/2,nGen);
    
    MatrixXf out;
    out=osim3.getGenotypes();
    ofstream outFile("/Users/erxingfangshui/genotype.example");
    outFile << out;

    return 0;

}
In []:
%%file  makeGenSim
#############################################################################
# Makefile for building: OSim

INCPATH = -I/Users/erxingfangshui/Dropbox/CODE/eigen3 -I/Users/erxingfangshui/Dropbox/CODE/boost

GenSim:	main.o libGenSim.a
	g++ -o GenSim main.o libGenSim.a 

main.o: main.cpp 
	g++ $(INCPATH) -c -o main.o main.cpp

clean:
	\rm main.o GenSim
In []:
%%bash
mv makeGenSim ../
mv main.cpp ../
cd ..
make -f makeGenSim
In []:
%%bash
cd ..
./GenSim