| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.analysis; |
| 22 |
|
|
| 23 |
|
import jalview.api.analysis.ScoreModelI; |
| 24 |
|
import jalview.api.analysis.SimilarityParamsI; |
| 25 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 26 |
|
import jalview.datamodel.AlignmentView; |
| 27 |
|
import jalview.datamodel.BinaryNode; |
| 28 |
|
import jalview.datamodel.CigarArray; |
| 29 |
|
import jalview.datamodel.SeqCigar; |
| 30 |
|
import jalview.datamodel.SequenceI; |
| 31 |
|
import jalview.datamodel.SequenceNode; |
| 32 |
|
import jalview.util.Constants; |
| 33 |
|
import jalview.viewmodel.AlignmentViewport; |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
import java.util.ArrayList; |
| 37 |
|
import java.util.BitSet; |
| 38 |
|
import java.util.HashMap; |
| 39 |
|
import java.util.List; |
| 40 |
|
import java.util.Vector; |
| 41 |
|
|
| |
|
| 79.5% |
Uncovered Elements: 17 (83) |
Complexity: 21 |
Complexity Density: 0.37 |
|
| 42 |
|
public abstract class TreeBuilder extends TreeEngine |
| 43 |
|
{ |
| 44 |
|
public static final String AVERAGE_DISTANCE = "AV"; |
| 45 |
|
|
| 46 |
|
public static final String NEIGHBOUR_JOINING = "NJ"; |
| 47 |
|
|
| 48 |
|
protected SequenceI[] sequences; |
| 49 |
|
|
| 50 |
|
protected List<String> labels; |
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
protected HashMap<Integer, String> annotationDetails; |
| 55 |
|
|
| 56 |
|
public AlignmentView seqData; |
| 57 |
|
|
| 58 |
|
private AlignmentView seqStrings; |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
|
@param |
| 64 |
|
@param |
| 65 |
|
@param |
| 66 |
|
|
| |
|
| 71.4% |
Uncovered Elements: 4 (14) |
Complexity: 2 |
Complexity Density: 0.17 |
|
| 67 |
1 |
public TreeBuilder(AlignmentViewport av, ScoreModelI sm,... |
| 68 |
|
SimilarityParamsI scoreParameters) |
| 69 |
|
{ |
| 70 |
1 |
int start, end; |
| 71 |
1 |
boolean selview = av.getSelectionGroup() != null |
| 72 |
|
&& av.getSelectionGroup().getSize() >= 1; |
| 73 |
1 |
seqStrings = av.getAlignmentView(selview); |
| 74 |
|
|
| 75 |
|
|
| 76 |
1 |
if (!selview) |
| 77 |
|
{ |
| 78 |
0 |
start = 0; |
| 79 |
0 |
end = av.getAlignment().getWidth(); |
| 80 |
0 |
this.sequences = av.getAlignment().getSequencesArray(); |
| 81 |
|
} |
| 82 |
|
else |
| 83 |
|
{ |
| 84 |
1 |
start = av.getSelectionGroup().getStartRes(); |
| 85 |
1 |
end = av.getSelectionGroup().getEndRes() + 1; |
| 86 |
1 |
this.sequences = av.getSelectionGroup() |
| 87 |
|
.getSequencesInOrder(av.getAlignment()); |
| 88 |
|
} |
| 89 |
|
|
| 90 |
1 |
init(seqStrings, start, end); |
| 91 |
|
|
| 92 |
1 |
computeTree(sm, scoreParameters); |
| 93 |
|
} |
| 94 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 95 |
1 |
public SequenceI[] getSequences()... |
| 96 |
|
{ |
| 97 |
1 |
return sequences; |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
@return |
| 103 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 104 |
1 |
public boolean hasDistances()... |
| 105 |
|
{ |
| 106 |
1 |
return true; |
| 107 |
|
} |
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
@return |
| 112 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 113 |
1 |
public boolean hasBootstrap()... |
| 114 |
|
{ |
| 115 |
1 |
return false; |
| 116 |
|
} |
| 117 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 118 |
1 |
public boolean hasRootDistance()... |
| 119 |
|
{ |
| 120 |
1 |
return true; |
| 121 |
|
} |
| 122 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 123 |
1 |
public List<String> getLabels(){... |
| 124 |
1 |
return this.labels; |
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
ArrayList<AlignmentAnnotation> ssAnnotationForSeqs; |
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| 139 |
|
@param |
| 140 |
|
@param |
| 141 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
| 142 |
1 |
protected void computeTree(ScoreModelI sm, SimilarityParamsI scoreOptions)... |
| 143 |
|
{ |
| 144 |
1 |
labels = new ArrayList<String>(); |
| 145 |
1 |
annotationDetails = new HashMap<Integer, String>(); |
| 146 |
1 |
ssAnnotationForSeqs = new ArrayList<AlignmentAnnotation>(); |
| 147 |
1 |
sequences = sm.expandSeqData(sequences, seqData, scoreOptions, |
| 148 |
|
labels, ssAnnotationForSeqs, annotationDetails); |
| 149 |
1 |
noseqs = sequences.length; |
| 150 |
|
|
| 151 |
1 |
distances = sm.findDistances(seqData, scoreOptions); |
| 152 |
|
|
| 153 |
1 |
makeLeaves(); |
| 154 |
|
|
| 155 |
1 |
noClus = clusters.size(); |
| 156 |
|
|
| 157 |
1 |
cluster(); |
| 158 |
|
} |
| 159 |
|
|
| |
|
| 50% |
Uncovered Elements: 10 (20) |
Complexity: 4 |
Complexity Density: 0.29 |
|
| 160 |
1 |
protected void init(AlignmentView seqView, int start, int end)... |
| 161 |
|
{ |
| 162 |
1 |
this.node = new Vector<BinaryNode>(); |
| 163 |
1 |
if (seqView != null) |
| 164 |
|
{ |
| 165 |
1 |
this.seqData = seqView; |
| 166 |
|
} |
| 167 |
|
else |
| 168 |
|
{ |
| 169 |
0 |
SeqCigar[] seqs = new SeqCigar[sequences.length]; |
| 170 |
0 |
for (int i = 0; i < sequences.length; i++) |
| 171 |
|
{ |
| 172 |
0 |
seqs[i] = new SeqCigar(sequences[i], start, end); |
| 173 |
|
} |
| 174 |
0 |
CigarArray sdata = new CigarArray(seqs); |
| 175 |
0 |
sdata.addOperation(CigarArray.M, end - start + 1); |
| 176 |
0 |
this.seqData = new AlignmentView(sdata, start); |
| 177 |
|
} |
| 178 |
|
|
| 179 |
|
|
| 180 |
|
|
| 181 |
|
|
| 182 |
1 |
noseqs = 0; |
| 183 |
|
|
| 184 |
1 |
done = new BitSet(); |
| 185 |
|
|
| 186 |
1 |
for (SequenceI seq : sequences) |
| 187 |
|
{ |
| 188 |
15 |
if (seq != null) |
| 189 |
|
{ |
| 190 |
15 |
noseqs++; |
| 191 |
|
} |
| 192 |
|
} |
| 193 |
|
} |
| 194 |
|
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
| |
|
| 87.5% |
Uncovered Elements: 3 (24) |
Complexity: 8 |
Complexity Density: 0.5 |
|
| 198 |
1 |
void makeLeaves()... |
| 199 |
|
{ |
| 200 |
1 |
clusters = new Vector<BitSet>(); |
| 201 |
|
|
| 202 |
19 |
for (int i = 0; i < noseqs; i++) |
| 203 |
|
{ |
| 204 |
18 |
SequenceNode sn = new SequenceNode(); |
| 205 |
|
|
| 206 |
18 |
sn.setElement(sequences[i]); |
| 207 |
|
|
| 208 |
18 |
if (labels.size() == noseqs) |
| 209 |
|
{ |
| 210 |
18 |
sn.setLabel(labels.get(i)); |
| 211 |
|
} |
| 212 |
|
|
| 213 |
18 |
if (ssAnnotationForSeqs != null && !ssAnnotationForSeqs.isEmpty() && ssAnnotationForSeqs.get(i) != null) |
| 214 |
|
{ |
| 215 |
|
|
| 216 |
4 |
sn.setAlignmentAnnotation(ssAnnotationForSeqs.get(i)); |
| 217 |
|
|
| 218 |
|
|
| 219 |
4 |
String annotationData = annotationDetails.get(i); |
| 220 |
4 |
if(annotationData != null && annotationData.length() > 0) |
| 221 |
|
{ |
| 222 |
0 |
sn.setAnnotationDetails(annotationData); |
| 223 |
|
} |
| 224 |
|
|
| 225 |
|
} |
| 226 |
|
|
| 227 |
18 |
sn.setName(sequences[i].getName()); |
| 228 |
|
|
| 229 |
18 |
node.addElement(sn); |
| 230 |
18 |
BitSet bs = new BitSet(); |
| 231 |
18 |
bs.set(i); |
| 232 |
18 |
clusters.addElement(bs); |
| 233 |
|
} |
| 234 |
|
} |
| 235 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 236 |
1 |
public AlignmentView getOriginalData()... |
| 237 |
|
{ |
| 238 |
1 |
return seqStrings; |
| 239 |
|
} |
| 240 |
|
|
| 241 |
|
} |