annotate test-data/sequencingdepthconversion_G.py @ 5:b27006b0a953

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