annotate sequencingdepthconversion_G.py @ 6:dccd7a3ee717

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