Mercurial > repos > artbio > lumpy_sv
annotate pairend_distro.py @ 6:48e97429a749 draft default tip
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy_sv commit 37c0f0938a5cad74c954a89827a6a08bbbb81cb0
author | artbio |
---|---|
date | Mon, 08 Jul 2024 22:23:10 +0000 |
parents | 6ae3a402b9af |
children |
rev | line source |
---|---|
0
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
1 #!/usr/bin/env python |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
2 # (c) 2012 - Ryan M. Layer |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
3 # Hall Laboratory |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
4 # Quinlan Laboratory |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
5 # Department of Computer Science |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
6 # Department of Biochemistry and Molecular Genetics |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
7 # Department of Public Health Sciences and Center for Public Health Genomics, |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
8 # University of Virginia |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
9 # rl6sf@virginia.edu |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
10 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
11 import sys |
1
1ed8619a5611
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents:
0
diff
changeset
|
12 from optparse import OptionParser |
1ed8619a5611
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents:
0
diff
changeset
|
13 |
0
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
14 import numpy as np |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
15 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
16 # some constants for sam/bam field ids |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
17 SAM_FLAG = 1 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
18 SAM_REFNAME = 2 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
19 SAM_MATE_REFNAME = 6 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
20 SAM_ISIZE = 8 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
21 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
22 parser = OptionParser() |
1
1ed8619a5611
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents:
0
diff
changeset
|
23 parser.add_option("-r", "--read_length", type="int", dest="read_length", |
1ed8619a5611
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents:
0
diff
changeset
|
24 help="Read length") |
1ed8619a5611
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents:
0
diff
changeset
|
25 parser.add_option("-X", dest="X", type="int", |
1ed8619a5611
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents:
0
diff
changeset
|
26 help="Number of stdevs from mean to extend") |
1ed8619a5611
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents:
0
diff
changeset
|
27 parser.add_option("-N", dest="N", type="int", help="Number to sample") |
1ed8619a5611
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents:
0
diff
changeset
|
28 parser.add_option("-o", dest="output_file", help="Output file") |
1ed8619a5611
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents:
0
diff
changeset
|
29 parser.add_option("-m", dest="mads", type="int", default=10, |
1ed8619a5611
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents:
0
diff
changeset
|
30 help='''Outlier cutoff in # of median absolute deviations |
1ed8619a5611
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents:
0
diff
changeset
|
31 (unscaled, upper only)''') |
0
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
32 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
33 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
34 def unscaled_upper_mad(xs): |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
35 """Return a tuple consisting of the median of xs followed by the |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
36 unscaled median absolute deviation of the values in xs that lie |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
37 above the median. |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
38 """ |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
39 med = np.median(xs) |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
40 return med, np.median(xs[xs > med] - med) |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
41 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
42 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
43 (options, args) = parser.parse_args() |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
44 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
45 if not options.read_length: |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
46 parser.error('Read length not given') |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
47 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
48 if not options.X: |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
49 parser.error('X not given') |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
50 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
51 if not options.N: |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
52 parser.error('N not given') |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
53 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
54 if not options.output_file: |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
55 parser.error('Output file not given') |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
56 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
57 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
58 required = 97 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
59 restricted = 3484 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
60 flag_mask = required | restricted |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
61 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
62 L = [] |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
63 c = 0 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
64 |
4
093bb151a0a8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 07c73df696d6d80e03f03232603d713882131625"
artbio
parents:
1
diff
changeset
|
65 for length in sys.stdin: |
0
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
66 if c >= options.N: |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
67 break |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
68 |
4
093bb151a0a8
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 07c73df696d6d80e03f03232603d713882131625"
artbio
parents:
1
diff
changeset
|
69 A = length.rstrip().split('\t') |
0
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
70 flag = int(A[SAM_FLAG]) |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
71 refname = A[SAM_REFNAME] |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
72 mate_refname = A[SAM_MATE_REFNAME] |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
73 isize = int(A[SAM_ISIZE]) |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
74 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
75 want = mate_refname == "=" and flag & flag_mask == required and isize >= 0 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
76 if want: |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
77 c += 1 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
78 L.append(isize) |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
79 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
80 # warn if very few elements in distribution |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
81 min_elements = 1000 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
82 if len(L) < min_elements: |
1
1ed8619a5611
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents:
0
diff
changeset
|
83 sys.stderr.write("Warning: only %s elements in distribution (min: %s)\n" % |
5
6ae3a402b9af
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy_sv commit e1bfc70a74f12ef8182d9afa0b3ab69d620fb3a8"
artbio
parents:
4
diff
changeset
|
84 (str(len(L)), str(min_elements))) |
0
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
85 mean = "NA" |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
86 stdev = "NA" |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
87 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
88 else: |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
89 # Remove outliers |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
90 L = np.array(L) |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
91 L.sort() |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
92 med, umad = unscaled_upper_mad(L) |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
93 upper_cutoff = med + options.mads * umad |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
94 L = L[L < upper_cutoff] |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
95 new_len = len(L) |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
96 removed = c - new_len |
5
6ae3a402b9af
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy_sv commit e1bfc70a74f12ef8182d9afa0b3ab69d620fb3a8"
artbio
parents:
4
diff
changeset
|
97 sys.stderr.write("Removed %s outliers with isize >= %s\n" % |
6ae3a402b9af
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy_sv commit e1bfc70a74f12ef8182d9afa0b3ab69d620fb3a8"
artbio
parents:
4
diff
changeset
|
98 (str(removed), str(upper_cutoff))) |
0
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
99 c = new_len |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
100 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
101 mean = np.mean(L) |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
102 stdev = np.std(L) |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
103 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
104 start = options.read_length |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
105 end = int(mean + options.X*stdev) |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
106 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
107 H = [0] * (end - start + 1) |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
108 s = 0 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
109 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
110 for x in L: |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
111 if (x >= start) and (x <= end): |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
112 j = int(x - start) |
1
1ed8619a5611
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit 0b55a106b1f76e3cc3d89932fef2cc8d3eb24e4f
artbio
parents:
0
diff
changeset
|
113 H[j] = H[int(x - start)] + 1 |
0
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
114 s += 1 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
115 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
116 f = open(options.output_file, 'w') |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
117 |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
118 for i in range(end - start): |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
119 o = str(i) + "\t" + str(float(H[i])/float(s)) + "\n" |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
120 f.write(o) |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
121 f.close() |
796552c157de
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/lumpy-sv commit d06124e8a097f3f665b4955281f40fe811eaee64
artbio
parents:
diff
changeset
|
122 print('mean:' + str(mean) + '\tstdev:' + str(stdev)) |