Mercurial > repos > padge > clipkit
annotate clipkit_repo/tests/unit/test_smart_gap_helper.py @ 0:49b058e85902 draft
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
author | padge |
---|---|
date | Fri, 25 Mar 2022 13:04:31 +0000 |
parents | |
children |
rev | line source |
---|---|
0
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
1 import pytest |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
2 import pytest_mock |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
3 from pathlib import Path |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
4 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
5 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
6 import numpy as np |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
7 from Bio import AlignIO |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
8 from Bio import SeqIO |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
9 from Bio.Seq import Seq |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
10 from Bio.SeqRecord import SeqRecord |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
11 from Bio.Align import MultipleSeqAlignment |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
12 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
13 from clipkit.smart_gap_helper import ( |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
14 smart_gap_threshold_determination, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
15 greatest_diff_in_slopes, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
16 gap_to_gap_slope, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
17 get_gaps_distribution, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
18 count_and_sort_gaps |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
19 ) |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
20 from clipkit.files import FileFormat |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
21 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
22 here = Path(__file__) |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
23 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
24 class TestSmartGapsHelper(object): |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
25 def test_smart_gap_threshold_simple_case(self): |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
26 ## set up |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
27 alignment = AlignIO.read(f"{here.parent}/examples/simple.fa", "fasta") |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
28 expected_gaps = 0.8 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
29 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
30 ## execution |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
31 gaps = smart_gap_threshold_determination(alignment) |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
32 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
33 ## check results |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
34 assert expected_gaps == gaps |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
35 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
36 def test_smart_gap_threshold_standard_case(self): |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
37 ## set up |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
38 alignment = AlignIO.read(f"{here.parent}/examples/EOG091N44M8_aa.fa", "fasta") |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
39 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
40 ## execution |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
41 gaps = smart_gap_threshold_determination(alignment) |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
42 expected_gaps = 0.8803 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
43 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
44 ## check results |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
45 assert expected_gaps == gaps |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
46 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
47 def test_greatest_diff_in_slopes_simple_case(self): |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
48 ## set up |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
49 slopes = [0.833333333333333] |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
50 gaps_arr = [[0.8, 1.0], [0.6, 1.0], [0.2, 1.0], [0.0, 3.0]] |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
51 expected_return = 0.8 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
52 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
53 ## execution |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
54 greatest_diff = greatest_diff_in_slopes(slopes, gaps_arr) |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
55 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
56 ## check results |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
57 assert greatest_diff == expected_return |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
58 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
59 def test_greatest_diff_in_slopes_standard_case(self): |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
60 ## set up |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
61 slopes = [ |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
62 0.453329706695677, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
63 0.1903630604288502, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
64 2.153316106804466, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
65 0.11466574934067258, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
66 2.4933133868262236, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
67 0.6879944960440355, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
68 0.037924469626292194, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
69 2.1786492374727793, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
70 2.4933133868262236, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
71 4.12796697626421, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
72 1.6999864001087854, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
73 1.0319917440660464, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
74 0.7933269867174482, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
75 0.11399518940300717, |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
76 0.8026602453847114 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
77 ] |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
78 gaps_arr = [ |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
79 [0.9915, 136.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
80 [0.9829, 4.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
81 [0.9573, 5.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
82 [0.9487, 19.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
83 [0.9402, 1.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
84 [0.9316, 22.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
85 [0.9231, 6.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
86 [0.8974, 1.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
87 [0.8889, 19.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
88 [0.8803, 22.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
89 [0.8718, 36.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
90 [0.8632, 15.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
91 [0.8462, 18.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
92 [0.8376, 7.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
93 [0.8205, 2.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
94 [0.812, 7.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
95 [0.8034, 19.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
96 [0.7949, 1.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
97 [0.7692, 288.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
98 [0.7607, 279.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
99 [0.7521, 6.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
100 [0.6667, 5.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
101 [0.1197, 1.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
102 [0.1026, 2.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
103 [0.0855, 1.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
104 [0.0769, 1.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
105 [0.0598, 2.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
106 [0.0342, 1.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
107 [0.0256, 3.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
108 [0.0171, 1.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
109 [0.0085, 1.0], |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
110 [0.0, 95.0] |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
111 ] |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
112 expected_return = 0.8803 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
113 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
114 ## execution |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
115 greatest_diff = greatest_diff_in_slopes(slopes, gaps_arr) |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
116 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
117 ## check results |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
118 assert greatest_diff == expected_return |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
119 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
120 def test_gap_to_gap_slope_simple_case(self): |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
121 ## set up |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
122 gaps_arr = [[0.8, 1.0], [0.6, 1.0], [0.2, 1.0], [0.0, 3.0]] |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
123 alignment_length = 6 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
124 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
125 ## execution |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
126 slopes = gap_to_gap_slope(gaps_arr, alignment_length) |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
127 expected_slopes = [0.833333333333333] |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
128 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
129 ## check results |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
130 assert expected_slopes == slopes |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
131 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
132 def test_get_gaps_distribution(self): |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
133 ## set up |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
134 alignment = AlignIO.read(f"{here.parent}/examples/simple.fa", "fasta") |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
135 alignment_length = 6 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
136 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
137 ## execution |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
138 gaps_arr = get_gaps_distribution(alignment, alignment_length) |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
139 expected_gaps_arr = [0.0, 0.6, 0.0, 0.8, 0.0, 0.2] |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
140 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
141 ## check results |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
142 assert expected_gaps_arr == gaps_arr |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
143 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
144 def test_count_and_sort_gaps(self): |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
145 ## set up |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
146 gaps_dist = [0.0, 0.6, 0.0, 0.8, 0.0, 0.2] |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
147 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
148 ## execution |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
149 gaps_arr = count_and_sort_gaps(gaps_dist) |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
150 expected_gaps_arr = [[0.8, 1.0], [0.6, 1.0], [0.2, 1.0], [0.0, 3.0]] |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
151 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
152 ## check results |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
153 assert expected_gaps_arr == gaps_arr |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
154 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
155 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
156 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
157 |
49b058e85902
"planemo upload for repository https://github.com/jlsteenwyk/clipkit commit cbe1e8577ecb1a46709034a40dff36052e876e7a-dirty"
padge
parents:
diff
changeset
|
158 |