-
Notifications
You must be signed in to change notification settings - Fork 1
/
Teste.jl
177 lines (130 loc) · 5.1 KB
/
Teste.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
using ProgressMeter
using PmapProgressMeter
using Parameters
using DataArrays,DataFrames
using QuadGK
using Distributions
using StatsBase
using ParallelDataTransfer
using Match
using Lumberjack
using FileIO
include("parameters.jl")
include("PopStruc.jl")
include("mutation.jl")
include("functions.jl")
P = InfluenzaParameters(
mutation_rate = 0.00416,
matrix_strain_lines = 10,
grid_size_human = 7100
)
#Here I am creating a random strain with sequence_size sites and 1 to 20 states per site
Original_Strain = rand(1:P.number_of_states,P.sequence_size)
p = 1 - exp(-P.mutation_rate/365)
Vector_Prob = zeros(Float64,365)
for i = 1:365
Vector_Prob[i] = p*((1-p)^(i-1))
end
CumProb = cumsum(Vector_Prob)
humans = Array{Human}(P.grid_size_human)
setup_human(humans)
###### Let's test the functions and how the mutations is going
Vaccine_Strain = Original_Strain
TransmitingStrain = Original_Strain
t = 7
for i = 1:P.grid_size_human
humans[i].strains_matrix,humans[i].Vector_time,humans[i].NumberStrains = mutation(TransmitingStrain,P,t,CumProb,1) ### t must be changed by humans[i].infectious period
available_strains = 1:humans[i].NumberStrains
VaccineEfVector = Calculating_Efficacy(humans[i].strains_matrix[available_strains,:],length(available_strains),Vaccine_Strain,0.0,P)
transm = Which_One_Will_Transmit(VaccineEfVector,humans[i].Vector_time[available_strains],8,2)#rand(1:humans[i].NumberStrains)
TransmitingStrain = humans[i].strains_matrix[transm,:]
end
DistMatrix = Calculating_Distance(humans,P)
DistMatrix/P.sequence_size
B = DistMatrix[1,:]/P.sequence_size
find(x-> x.NumberStrains>2,humans)
########################################################3
Matrix = zeros(Int64,P.matrix_strain_lines,P.sequence_size)
Matrix[1,:] = rand(1:P.number_of_states,P.sequence_size)
Matrix[2,:] = Matrix[1,:]
for i = 1:30
aux = rand(1:P.sequence_size)
Matrix[2,aux] = rand(1:P.number_of_states)
end
Matrix[3,:] = Matrix[2,:]
for i = 1:15
aux = rand(1:P.sequence_size)
Matrix[3,aux] = rand(1:P.number_of_states)
end
Calculating_Distance_Two_Strains(Matrix[1,:],Matrix[3,:])
VaccineEfVector = Calculating_Efficacy(Matrix,3,Matrix[1,:],0.8,P)
Vector_time = [0; 5; 8]
A = Vector{Int64}(100000)
for i = 1:100000
A[i] = Which_One_Will_Transmit(VaccineEfVector,Vector_time,9,2)
end
find(x-> x == 2,A)
r = rand()
retorno = findfirst(x->x>r,probs)
function main(simulationNumber::Int64,P::InfluenzaParameters)
humans = Array{Human}(P.grid_size_human)
# srand(100*simulationNumber)
setup_human(humans)
setup_demographic(humans,P)
Vaccine_Strain = Vector{Int8}(P.sequence_size)
Creating_Vaccine_Vector(Vaccine_Strain,P)
if P.GeneralCoverage == 1
vaccination(humans,P)
end
latent_ctr = zeros(Int64,P.sim_time)##vector of results latent
symp_ctr = zeros(Int64,P.sim_time) #vector for results symp
asymp_ctr = zeros(Int64,P.sim_time) #vector for results asymp
gd_ctr = zeros(Float64,P.sim_time) #vector for results genetic distance
initial = setup_rand_initial_latent(humans,P,Vaccine_Strain)### for now, we are using only 1
Number_in_age_group = zeros(Int64,15)
Age_group_Matrix = Matrix{Int64}(15,P.grid_size_human)
for i = 1:P.grid_size_human
Age_group_Matrix[humans[i].contact_group,(Number_in_age_group[humans[i].contact_group]+1)] = humans[i].index
Number_in_age_group[humans[i].contact_group] += 1
end
for t=1:P.sim_time
contact_dynamic2(humans,P,Age_group_Matrix,Number_in_age_group,Vaccine_Strain)
for i=1:P.grid_size_human
increase_timestate(humans[i],P)
end
latent_ctr[t],symp_ctr[t],asymp_ctr[t],gd_ctr[t]=update_human(humans,P,Vaccine_Strain)
end
first_inf = find(x-> x.WhoInf == initial && x.WentTo == SYMP,humans)
numb_first_inf = length(first_inf)
## Calculating the proportion of infected people in function of hamming distance
#number_of_infected = sum(latent_ctr)
p = zeros(Int64,P.matrix_strain_lines)
Ef = zeros(Float64,P.grid_size_human)
count::Int64 = 0
for i = 1:P.grid_size_human
if humans[i].WhoInf > 0
count += 1
p[Int64(Calculating_Distance_Two_Strains(Vaccine_Strain,humans[i].strains_matrix[1,:]))+1]+=1
auxMatrix = Matrix{Int8}(1,P.sequence_size)
auxMatrix[1,:] = humans[i].strains_matrix[1,:]
Ef[count] = Calculating_Efficacy(auxMatrix,1,Vaccine_Strain,humans[i].vaccineEfficacy,P)[1]
end
end
#return latent_ctr,symp_ctr,asymp_ctr,numb_first_inf,numb_symp_inf,numb_asymp_inf
return latent_ctr,symp_ctr,asymp_ctr,numb_first_inf,p,gd_ctr,Ef
end
Mod_Strain = Vector{Int8}(P.sequence_size)
for i = 1:P.sequence_size
Mod_Strain[i] = Vaccine_Strain[i]
end
for i = 1:1:(round(0.0*566))
aux = rand(1:P.sequence_size)
println("$i $aux")
end
change = Mod_Strain[aux]
while change == Mod_Strain[aux]
change = rand(1:P.number_of_states)
end
Mod_Strain[aux] = change
end
Mod = setup_rand_initial_latent(humans,P,Mod_Strain,0)