forked from justinbois/bootcamp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathb_test_seq_features.py
More file actions
126 lines (99 loc) · 5.03 KB
/
b_test_seq_features.py
File metadata and controls
126 lines (99 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import pytest
import seq_features
def test_number_negatives_single_E_or_D():
"""Perform unit tests on number_negative for single AA"""
assert seq_features.number_negatives('E') == 1
assert seq_features.number_negatives('D') == 1
def test_number_negatives_for_empty():
"""Perform unit tests on number_negative for empty entry"""
assert seq_features.number_negatives('') == 0
def test_number_negatives_for_short_sequences():
"""Perform unit tests on number_negative for short sequence"""
assert seq_features.number_negatives('ACKLWTTAE') == 1
assert seq_features.number_negatives('DDDDEEEE') == 8
# TESTS NEGATIVES FOR PH DEPENDENCE
def test_low_pH():
assert seq_features.number_negatives('ACDDEK', pH = 3) == 0
assert seq_features.number_negatives('ACDDEK', pH = 5) == 3
def test_number_negatives_for_lowercase():
"""Perform unit tests on number_negative for lowercase"""
assert seq_features.number_negatives('acklwttae') == 1
def test_number_negatives_for_invalid_amino_acid():
with pytest.raises(RuntimeError) as excinfo:
seq_features.number_negatives('Z')
excinfo.match("Z is not a valid amino acid")
def test_number_positives_single_R_K_or_H():
"""Perform unit tests on number_positives for single AA"""
assert seq_features.number_positives('R') == 1
assert seq_features.number_positives('K') == 1
assert seq_features.number_positives('H') == 1
def test_number_positives_for_empty():
"""Perform unit tests on number_positives for empty entry"""
assert seq_features.number_positives('') == 0
def test_number_positives_for_short_sequences():
"""Perform unit tests on number_positives for short sequence"""
assert seq_features.number_positives('RCKLWTTRE') == 3
assert seq_features.number_positives('DDDDEEEE') == 0
# TESTS POSITIVES FOR PH DEPENDENCE
def test_low_pH():
assert seq_features.number_positives('ACKLHGR', pH = 7.7) == 3
assert seq_features.number_positives('ACKLHGA', pH = 9) == 1
assert seq_features.number_positives('ACKLHGR', pH = 11) == 0
def test_number_positives_for_lowercase():
"""Perform unit tests on number_positives for lowercase"""
assert seq_features.number_positives('rcklwttre') == 3
def test_number_positives_for_invalid_amino_acid():
with pytest.raises(RuntimeError) as excinfo:
seq_features.number_positives('Z')
excinfo.match("Z is not a valid amino acid")
def test_number_negatives_for_invalid_amino_acid_anywhere():
with pytest.raises(RuntimeError) as excinfo:
seq_features.number_negatives('AZK')
excinfo.match("Z is not a valid amino acid")
def test_number_positives_for_invalid_amino_acid_anywhere():
with pytest.raises(RuntimeError) as excinfo:
seq_features.number_positives('AZK')
excinfo.match("Z is not a valid amino acid")
def test_is_valid_sequence_for_invalid_amino_acid():
with pytest.raises(RuntimeError) as excinfo:
seq_features.is_valid_sequence('Z')
excinfo.match("Z is not a valid amino acid")
def test_is_valid_sequence_for_invalid_amino_acid_anywhere():
with pytest.raises(RuntimeError) as excinfo:
seq_features.is_valid_sequence('AZK')
excinfo.match("Z is not a valid amino acid")
def test_is_valid_sequence_for_other_invalid_amino_acid_anywhere():
assert seq_features.is_valid_sequence('ALKSAYGS') is None
with pytest.raises(RuntimeError) as excinfo:
seq_features.is_valid_sequence('AZLL')
excinfo.match("Z is not a valid amino acid")
with pytest.raises(RuntimeError) as excinfo:
seq_features.is_valid_sequence('ALLBJ')
excinfo.match("B is not a valid amino acid")
with pytest.raises(RuntimeError) as excinfo:
seq_features.is_valid_sequence('AL%J')
excinfo.match("% is not a valid amino acid")
#tests net_charge
def test_net_charge():
assert seq_features.net_charge('ACCAVDDKL') == -1
assert seq_features.net_charge('ACAHHDKLH', pH = 9) == 0
assert seq_features.net_charge('ACAHHDKLH', pH = 11) == -1
assert seq_features.net_charge('ACAHHDKLH', pH = 2) == 4
#fractional tests
def test_fraction_negatives():
assert seq_features.fraction_negatives('AAAAAA') == 0
assert seq_features.fraction_negatives('AAAAAE', pH = 0.1) < 0.0001
assert seq_features.fraction_negatives('AAAAAE', pH = 10) > 0.9800
assert seq_features.fraction_negatives('AAAADE', pH = 10) > 1.5
def test_fraction_positives():
assert seq_features.fraction_positives('AAAAAA') == 0
assert seq_features.fraction_positives('AAAAKK', pH = 1) > 0.999
assert seq_features.fraction_positives('AAAAKA', pH = 0.1) > 0.999
assert seq_features.fraction_positives('AAARKA', pH = 14) < 1.5
s
def test_fractional_net_charge():
assert seq_features.fractional_net_charge('AAAAAA') == 0
assert seq_features.fractional_net_charge('AAAADR', pH = 7) > 0
assert seq_features.fractional_net_charge('AAAADR', pH = 12) < 1
assert seq_features.fractional_net_charge('AARKDR', pH = 7) > 1
#test_for_dictionary