annotate sequencingdepthconversion_G.py @ 0:70f8259b0b30 draft

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