annotate sequencingdepthconversion_G.py @ 13:35aedbe548b9 draft

Uploaded
author arkarachai-fungtammasan
date Sun, 24 Jul 2016 17:56:49 -0400
parents 07588b899c13
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
1 def stop_err(msg):
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
2 sys.stderr.write(msg)
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
3 sys.exit()
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
4
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
5 def info2require(X,L,F,r):
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
6 '''infodepth,readlength,flanksize,repeatlength
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
7 '''
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
8 return int(math.ceil((X*L*1.0)/(L-(1*((2*F)+r-1)))))
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
9
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
10 def poissondef(meancov,specificcov):
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
11 nominator=1.0*(meancov**specificcov)*(math.e**(-1*meancov))
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
12 denominator=math.factorial(specificcov)
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
13 return nominator/denominator
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
14
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
15 def require2recommend(needprob,mindepth):
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
16 i=mindepth
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
17 reverseneedprob=1-needprob
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
18 sumprob=1
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
19 while sumprob>reverseneedprob: #mean cov
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
20 sumprob=0
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
21 for j in range(0,mindepth): #specific cov
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
22 sumprob+=poissondef(i,j)
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
23 i+=1
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
24
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
25 return i-1
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
26
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
27 import sys,math
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
28
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
29 repeatlength=int(sys.argv[1])
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
30 flanksize=int(sys.argv[2])#20
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
31 readlength=int(sys.argv[3])#100
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
32 infodepth=int(sys.argv[4])#5
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
33 probdetection=float(sys.argv[5])#0.90
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
34
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
35 if probdetection >1:
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
36 try:
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
37 probvalue=int('probvalue')
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
38 except Exception, eee:
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
39 print eee
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
40 stop_err("Proportion of genome to have certain locus specific must be between 0 and 1")
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
41
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
42 print 'repeat_length'+'\t'+'read_length'+'\t'+'informative_read_depth''\t'+'=locus_specific_sequencing_depth'+'\t'+'=genome_wide_sequencing_depth'
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
43 t_requiredepth=info2require(infodepth,readlength,flanksize,repeatlength)
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
44 t_recomendseq=require2recommend(probdetection,t_requiredepth)
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
45 preplotlist=[repeatlength,readlength,infodepth,t_requiredepth,t_recomendseq]
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
46 plotlist=map(str,preplotlist)
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
47 print '\t'.join(plotlist)
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
48
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
49 #print info2require(infodepth,readlength,flanksize,repeatlength)
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
50 #print poissondef(10,3)
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
51 #print require2recommend(0.90,80)
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
52 #informative_read_depth
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
53 #required_seq_depth
07588b899c13 Uploaded
arkarachai-fungtammasan
parents:
diff changeset
54 #recommend_seq_depth