1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.analysis.scoremodels; |
22 |
|
|
23 |
|
import jalview.api.AlignmentViewPanel; |
24 |
|
import jalview.api.analysis.ScoreModelI; |
25 |
|
import jalview.io.DataSourceType; |
26 |
|
import jalview.io.FileParse; |
27 |
|
import jalview.io.ScoreMatrixFile; |
28 |
|
|
29 |
|
import java.io.IOException; |
30 |
|
import java.util.LinkedHashMap; |
31 |
|
import java.util.Map; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
|
|
| 0% |
Uncovered Elements: 52 (52) |
Complexity: 17 |
Complexity Density: 0.55 |
|
36 |
|
public class ScoreModels |
37 |
|
{ |
38 |
|
private final ScoreMatrix BLOSUM62; |
39 |
|
|
40 |
|
private final ScoreMatrix PAM250; |
41 |
|
|
42 |
|
private final ScoreMatrix DNA; |
43 |
|
|
44 |
|
private final ScoreMatrix SECONDARYSTRUCTURE; |
45 |
|
|
46 |
|
private static ScoreModels instance; |
47 |
|
|
48 |
|
private Map<String, ScoreModelI> models; |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
@return |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
56 |
0 |
public static ScoreModels getInstance()... |
57 |
|
{ |
58 |
0 |
if (instance == null) |
59 |
|
{ |
60 |
0 |
instance = new ScoreModels(); |
61 |
|
} |
62 |
0 |
return instance; |
63 |
|
} |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
77 |
0 |
private ScoreModels()... |
78 |
|
{ |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
0 |
models = new LinkedHashMap<>(); |
83 |
0 |
BLOSUM62 = loadScoreMatrix("scoreModel/blosum62.scm",true); |
84 |
0 |
PAM250 = loadScoreMatrix("scoreModel/pam250.scm",true); |
85 |
0 |
DNA = loadScoreMatrix("scoreModel/dna.scm",true); |
86 |
0 |
registerScoreModel(new PIDModel()); |
87 |
0 |
registerScoreModel(new FeatureDistanceModel()); |
88 |
0 |
SECONDARYSTRUCTURE = loadScoreMatrix( |
89 |
|
"scoreModel/secondarystructure.scm",false); |
90 |
0 |
registerScoreModel(new SecondaryStructureDistanceModel()); |
91 |
|
|
92 |
|
} |
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
@param |
99 |
|
@param |
100 |
|
@return |
101 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
102 |
0 |
ScoreMatrix loadScoreMatrix(String resourcePath, boolean register)... |
103 |
|
{ |
104 |
0 |
try |
105 |
|
{ |
106 |
|
|
107 |
|
|
108 |
|
|
109 |
0 |
FileParse fp = new FileParse(resourcePath, |
110 |
|
DataSourceType.CLASSLOADER); |
111 |
0 |
ScoreMatrix sm = new ScoreMatrixFile(fp).parseMatrix(); |
112 |
0 |
if (register) { |
113 |
0 |
registerScoreModel(sm); |
114 |
|
} |
115 |
0 |
return sm; |
116 |
|
} catch (IOException e) |
117 |
|
{ |
118 |
0 |
jalview.bin.Console.errPrintln( |
119 |
|
"Error reading " + resourcePath + ": " + e.getMessage()); |
120 |
|
} |
121 |
0 |
return null; |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
@return |
129 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
130 |
0 |
public Iterable<ScoreModelI> getModels()... |
131 |
|
{ |
132 |
0 |
return models.values(); |
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
@param |
142 |
|
@param |
143 |
|
@return |
144 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
145 |
0 |
public ScoreModelI getScoreModel(String name, AlignmentViewPanel avp)... |
146 |
|
{ |
147 |
0 |
ScoreModelI model = models.get(name); |
148 |
0 |
return model == null ? null : model.getInstance(avp); |
149 |
|
} |
150 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
151 |
0 |
public void registerScoreModel(ScoreModelI sm)... |
152 |
|
{ |
153 |
0 |
ScoreModelI sm2 = models.get(sm.getName()); |
154 |
0 |
if (sm2 != null) |
155 |
|
{ |
156 |
0 |
jalview.bin.Console.errPrintln( |
157 |
|
"Warning: replacing score model " + sm2.getName()); |
158 |
|
} |
159 |
0 |
models.put(sm.getName(), sm); |
160 |
|
} |
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
165 |
0 |
public void reset()... |
166 |
|
{ |
167 |
0 |
instance = new ScoreModels(); |
168 |
|
} |
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
@param |
175 |
|
@return |
176 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
177 |
0 |
public ScoreMatrix getDefaultModel(boolean forPeptide)... |
178 |
|
{ |
179 |
0 |
return forPeptide ? BLOSUM62 : DNA; |
180 |
|
} |
181 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
182 |
0 |
public ScoreMatrix getBlosum62()... |
183 |
|
{ |
184 |
0 |
return BLOSUM62; |
185 |
|
} |
186 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
187 |
0 |
public ScoreMatrix getPam250()... |
188 |
|
{ |
189 |
0 |
return PAM250; |
190 |
|
} |
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
@return |
195 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
196 |
0 |
public ScoreMatrix getSecondaryStructureMatrix()... |
197 |
|
{ |
198 |
0 |
return SECONDARYSTRUCTURE; |
199 |
|
} |
200 |
|
} |