parser.add_option("--snapshots", dest="snapshots",default=None,help="A comma separated list of generations at which the frequency of the SNPs should be recorded")
(options, args) = parser.parse_args()
repsim  = int(options.repsim)
twone   = int(options.ne)*2
r       = float(options.r)
p1      = float(options.p1)
p2      = float(options.p2)
rsquared    = float(options.rsquared)
snapshots=set(map(int, options.snapshots.split(",")))
maxgen = max(snapshots)

selectiondictionary=FitnessFunctionParser.get_fitnessFunctionDictionary(options.selection)
print  "# snp_id\tgeneration\tfrequency\treplicate"

for i in range(0,repsim):
        pop=PopGenerator.ini_ld(twone,p1,p2,rsquared)
        print "{0}\t{1}\t{2}\t{3}".format("A",0,pop.get_frequencyA() ,i+1)
        print "{0}\t{1}\t{2}\t{3}".format("B",0,pop.get_frequencyB() ,i+1)
        counter=0
        ff=None
        while(True):
                if (counter+1) in selectiondictionary:
                        ff=selectiondictionary[(counter+1)]
                pop=pop.getNextGeneration(twone,ff,r)       
                counter+=1
                if counter in snapshots:
                        print "{0}\t{1}\t{2}\t{3}".format("A",counter,pop.get_frequencyA() ,i+1)
                        print "{0}\t{1}\t{2}\t{3}".format("B",counter,pop.get_frequencyB() ,i+1)
                if counter>=maxgen:
                        break   
 
p2 = float(options.p2)
maxgen = float(options.maxgen)

assert p1 + p2 <= 1.0

ff = FitnessFunctionNormal(s1, h1, s2, h2)


for i in range(0, repsim):
    sA = "S"
    sB = "S"
    sab = "S"
    genA = int(maxgen)
    genB = int(maxgen)
    genab = int(maxgen)
    pop = PopGenerator.ini_competition(twone, p1, p2)
    counter = 0
    while not pop.is_fixed():
        pop = pop.getNextGeneration(twone, ff, r)
        counter += 1

        if sA == "S" and pop.is_fixedA():
            sA = pop.status(pop.countA())
            genA = counter
        if sB == "S" and pop.is_fixedB():
            sB = pop.status(pop.countB())
            genB = counter
        if sab == "S" and pop.is_fixedab():
            sab = pop.status(pop.countab())
            genab = counter
        if counter >= maxgen:
예제 #3
0
p1 = float(options.p1)
p2 = float(options.p2)
maxgen = float(options.maxgen)

assert (p1 + p2 <= 1.0)

ff = FitnessFunctionNormal(s1, h1, s2, h2)

for i in range(0, repsim):
    sA = "S"
    sB = "S"
    sab = "S"
    genA = int(maxgen)
    genB = int(maxgen)
    genab = int(maxgen)
    pop = PopGenerator.ini_competition(twone, p1, p2)
    counter = 0
    while (not pop.is_fixed()):
        pop = pop.getNextGeneration(twone, ff, r)
        counter += 1

        if (sA == "S" and pop.is_fixedA()):
            sA = pop.status(pop.countA())
            genA = counter
        if (sB == "S" and pop.is_fixedB()):
            sB = pop.status(pop.countB())
            genB = counter
        if (sab == "S" and pop.is_fixedab()):
            sab = pop.status(pop.countab())
            genab = counter
        if counter >= maxgen:
r      = float(options.r)
h1      = float(options.het1)
h2      = float(options.het2)
p     = float(options.p)
maxgen = float(options.maxgen)
output = options.output

ff=FitnessFunctionNormal(s1,h1,s2,h2)

trajectories_selected1=[]
trajectories_selected2=[]
trajectories_AB=[]
ld_decay=[]

for i in range(0,repsim):
        pop=PopGenerator.ini_complete_linkage(twone,p)
        freqsA=[]
        freqsB=[]
        freqsAB=[]
        ld=[]
        freqsA.append(pop.get_frequencyA())
        freqsB.append(pop.get_frequencyB())
        freqsAB.append(pop.get_frequencyAB())
        ld.append(pop.get_rsquared())
        counter=0
        while(not pop.is_fixed()):
                pop=pop.getNextGeneration(twone,ff,r)
                freqsA.append(pop.get_frequencyA())
                freqsB.append(pop.get_frequencyB())
                freqsAB.append(pop.get_frequencyAB())
                ld.append(pop.get_rsquared())
r = float(options.r)
h1 = float(options.het1)
h2 = float(options.het2)
p = float(options.p)
maxgen = float(options.maxgen)
output = options.output

ff = FitnessFunctionNormal(s1, h1, s2, h2)

trajectories_selected1 = []
trajectories_selected2 = []
trajectories_AB = []
ld_decay = []

for i in range(0, repsim):
    pop = PopGenerator.ini_complete_linkage(twone, p)
    freqsA = []
    freqsB = []
    freqsAB = []
    ld = []
    freqsA.append(pop.get_frequencyA())
    freqsB.append(pop.get_frequencyB())
    freqsAB.append(pop.get_frequencyAB())
    ld.append(pop.get_rsquared())
    counter = 0
    while (not pop.is_fixed()):
        pop = pop.getNextGeneration(twone, ff, r)
        freqsA.append(pop.get_frequencyA())
        freqsB.append(pop.get_frequencyB())
        freqsAB.append(pop.get_frequencyAB())
        ld.append(pop.get_rsquared())
r      = float(options.r)
h1      = float(options.het1)
h2      = float(options.het2)
p1     = float(options.p1)
p2     = float(options.p2)
snapshots=set(map(int, options.snapshots.split(",")))
maxgen = max(snapshots)


assert(p1+p2<=1.0)

ff=FitnessFunctionNormal(s1,h1,s2,h2)

print  "# snp_id\tgeneration\tfrequency\treplicate"
for i in range(0,repsim):
        pop=PopGenerator.ini_subfrequency(twone,p1,p2)
        print "{0}\t{1}\t{2}\t{3}".format("A",0,pop.get_frequencyA() ,i+1)
        print "{0}\t{1}\t{2}\t{3}".format("B",0,pop.get_frequencyB() ,i+1)
        counter=0
        while(True):
                pop=pop.getNextGeneration(twone,ff,r)  
                counter+=1
                if counter in snapshots:
                        print "{0}\t{1}\t{2}\t{3}".format("A",counter,pop.get_frequencyA() ,i+1)
                        print "{0}\t{1}\t{2}\t{3}".format("B",counter,pop.get_frequencyB() ,i+1)
                if counter>=maxgen:
                        break



        
예제 #7
0
s1 = float(options.s1)
s2 = float(options.s2)
r = float(options.r)
h1 = float(options.het1)
h2 = float(options.het2)
p1 = float(options.p1)
p2 = float(options.p2)
snapshots = set(map(int, options.snapshots.split(",")))
maxgen = max(snapshots)

assert (p1 + p2 <= 1.0)

ff = FitnessFunctionNormal(s1, h1, s2, h2)

print "# snp_id\tgeneration\tfrequency\treplicate"
for i in range(0, repsim):
    pop = PopGenerator.ini_subfrequency(twone, p1, p2)
    print "{0}\t{1}\t{2}\t{3}".format("A", 0, pop.get_frequencyA(), i + 1)
    print "{0}\t{1}\t{2}\t{3}".format("B", 0, pop.get_frequencyB(), i + 1)
    counter = 0
    while (True):
        pop = pop.getNextGeneration(twone, ff, r)
        counter += 1
        if counter in snapshots:
            print "{0}\t{1}\t{2}\t{3}".format("A", counter,
                                              pop.get_frequencyA(), i + 1)
            print "{0}\t{1}\t{2}\t{3}".format("B", counter,
                                              pop.get_frequencyB(), i + 1)
        if counter >= maxgen:
            break