# 各位大佬，怎么使用并行计算呢？

``````using CSV,DataFrames
......
chromosome=chr[number]
start=chromosome[1,3];final=chromosome[end,3]
chromosomename=chromosome[1,1]
println('[',Dates.format(now(), "YYYY-m-d HH:MM:SS"),']'," Start calculating ",chromosomename,"'s pdrs")
chdf=lastchdf(chdf)
pdrs=repeat([(NaN,0,0,0)],nrow(chromosome))
pdrspos=calculatepospdrs(chdf,chromosome)#这个函数是自己写的
pdrsneg=calculatenegpdrs(chdf,chromosome)#这个函数是自己写的
pdrs[findall(==("C"),chromosome.Column2)]=pdrspos
pdrs[findall(==("G"),chromosome.Column2)]=pdrsneg
pd=vcat(pd,rename!(DataFrame(pdrs),[:pdr,:discordant,:sum,:allsum]))#这一步vcat相当于拼接染色体结果
println('[',Dates.format(now(), "YYYY-m-d HH:MM:SS"),']'," Finish calculating ",chromosomename,"'s pdrs")
end

[2022-10-18 14:40:23] Start calculating chr16's pdrs
[2022-10-18 14:40:23] Start calculating chr21's pdrs
[2022-10-18 14:40:23] Start calculating chr7's pdrs
[2022-10-18 14:40:23] Start calculating chr1's pdrs
Stacktrace:
[1] wait
[3] top-level scope

nested task error: BGZFStreams.BGZFDataError("invalid gzip identifier")
Stacktrace:

``````

``````Threads.@threads for number in 1:chr.ngroups
chromosome=chr[number]
start=chromosome[1,3];final=chromosome[end,3]
chromosomename=chromosome[1,1]
println('[',Dates.format(now(), "YYYY-m-d HH:MM:SS"),']'," Start calculating ",chromosomename,"'s pdrs")
chdf=lastchdf(chdf)
pdrs=repeat([(NaN,0,0,0)],nrow(chromosome))
pdrspos=calculatepospdrs(chdf,chromosome)
pdrsneg=calculatenegpdrs(chdf,chromosome)
pdrs[findall(==("C"),chromosome.Column2)]=pdrspos
pdrs[findall(==("G"),chromosome.Column2)]=pdrsneg
#pd=vcat(pd,rename!(DataFrame(pdrs),[:pdr,:discordant,:sum,:allsum]))
println('[',Dates.format(now(), "YYYY-m-d HH:MM:SS"),']'," Finish calculating ",chromosomename,"'s pdrs")
end
[2022-10-18 20:17:49] Start calculating chr21's pdrs
[2022-10-18 20:17:49] Start calculating chr1's pdrs
[2022-10-18 20:17:49] Start calculating chr7's pdrs
[2022-10-18 20:17:49] Start calculating chr16's pdrs
Stacktrace:
[1] wait
[3] top-level scope

nested task error: BGZFStreams.BGZFDataError("invalid gzip identifier")
Stacktrace:
[1] bgzferror(message::String)
@ BGZFStreams ~/anaconda3/envs/julia/share/julia/packages/BGZFStreams/bsx6S/src/bgzfstream.jl:350