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

Scenario 1 : random mating for 10 generations for one population

reading real genotypes from files

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 path="/Users/erxingfangshui/Dropbox/GenSim/GenSim1.3/data/";
    string genomeFile=path+"genomeInfo.txt";
    string mapFile=path+"mapPos.txt";
    string haplotype=path+"haplotype.txt";
    
    SimPop osim(genomeFile,mapFile);
    osim.popFounders(popSize,haplotype);
    
    osim.popSample(popSize,nGen);
    MatrixXf out;
    out=osim.getGenotypes();
    ofstream outFile(path+"genotype.txt");
    outFile << out;
    
    return 0;

}

randomly generate genotypes

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 osim(nChrm,nLoci,chrLength,mutRate);
    osim.popFounders(popSize);
    osim.popSample(popSize,nGen);
    MatrixXf out;
    out=osim.getGenotypes();
    ofstream outFile("genotype.example");
    outFile << out;
    cout<<"DONE"<<endl;
    
    return 0;

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

myPath = /Users/erxingfangshui/Dropbox/CODE
INCPATH = -I $(myPath)/eigen3 -I $(myPath)/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
path=/Users/erxingfangshui/Dropbox/GenSim/GenSim1.3
mv makeGenSim $path
mv main.cpp $path

cd $path
make -f makeGenSim
In []:
%%bash
path=/Users/erxingfangshui/Dropbox/GenSim/GenSim1.3
cd $path
./GenSim