| 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.AlignmentView; |
| 26 |
|
import jalview.datamodel.BinaryNode; |
| 27 |
|
import jalview.datamodel.CigarArray; |
| 28 |
|
import jalview.datamodel.SeqCigar; |
| 29 |
|
import jalview.datamodel.SequenceI; |
| 30 |
|
import jalview.datamodel.SequenceNode; |
| 31 |
|
import jalview.viewmodel.AlignmentViewport; |
| 32 |
|
|
| 33 |
|
import java.util.BitSet; |
| 34 |
|
import java.util.Vector; |
| 35 |
|
|
| |
|
| 0% |
Uncovered Elements: 63 (63) |
Complexity: 14 |
Complexity Density: 0.32 |
|
| 36 |
|
public abstract class TreeBuilder extends TreeEngine |
| 37 |
|
{ |
| 38 |
|
public static final String AVERAGE_DISTANCE = "AV"; |
| 39 |
|
|
| 40 |
|
public static final String NEIGHBOUR_JOINING = "NJ"; |
| 41 |
|
|
| 42 |
|
protected SequenceI[] sequences; |
| 43 |
|
|
| 44 |
|
public AlignmentView seqData; |
| 45 |
|
|
| 46 |
|
private AlignmentView seqStrings; |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
@param |
| 52 |
|
@param |
| 53 |
|
@param |
| 54 |
|
|
| |
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 2 |
Complexity Density: 0.17 |
|
| 55 |
0 |
public TreeBuilder(AlignmentViewport av, ScoreModelI sm,... |
| 56 |
|
SimilarityParamsI scoreParameters) |
| 57 |
|
{ |
| 58 |
0 |
int start, end; |
| 59 |
0 |
boolean selview = av.getSelectionGroup() != null |
| 60 |
|
&& av.getSelectionGroup().getSize() > 1; |
| 61 |
0 |
seqStrings = av.getAlignmentView(selview); |
| 62 |
0 |
if (!selview) |
| 63 |
|
{ |
| 64 |
0 |
start = 0; |
| 65 |
0 |
end = av.getAlignment().getWidth(); |
| 66 |
0 |
this.sequences = av.getAlignment().getSequencesArray(); |
| 67 |
|
} |
| 68 |
|
else |
| 69 |
|
{ |
| 70 |
0 |
start = av.getSelectionGroup().getStartRes(); |
| 71 |
0 |
end = av.getSelectionGroup().getEndRes() + 1; |
| 72 |
0 |
this.sequences = av.getSelectionGroup() |
| 73 |
|
.getSequencesInOrder(av.getAlignment()); |
| 74 |
|
} |
| 75 |
|
|
| 76 |
0 |
init(seqStrings, start, end); |
| 77 |
|
|
| 78 |
0 |
computeTree(sm, scoreParameters); |
| 79 |
|
} |
| 80 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 81 |
0 |
public SequenceI[] getSequences()... |
| 82 |
|
{ |
| 83 |
0 |
return sequences; |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
@return |
| 89 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 90 |
0 |
public boolean hasDistances()... |
| 91 |
|
{ |
| 92 |
0 |
return true; |
| 93 |
|
} |
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 97 |
|
@return |
| 98 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 99 |
0 |
public boolean hasBootstrap()... |
| 100 |
|
{ |
| 101 |
0 |
return false; |
| 102 |
|
} |
| 103 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 104 |
0 |
public boolean hasRootDistance()... |
| 105 |
|
{ |
| 106 |
0 |
return true; |
| 107 |
|
} |
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
|
@param |
| 120 |
|
@param |
| 121 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 122 |
0 |
protected void computeTree(ScoreModelI sm, SimilarityParamsI scoreOptions)... |
| 123 |
|
{ |
| 124 |
0 |
distances = sm.findDistances(seqData, scoreOptions); |
| 125 |
|
|
| 126 |
0 |
makeLeaves(); |
| 127 |
|
|
| 128 |
0 |
noClus = clusters.size(); |
| 129 |
|
|
| 130 |
0 |
cluster(); |
| 131 |
|
} |
| 132 |
|
|
| |
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 4 |
Complexity Density: 0.29 |
|
| 133 |
0 |
protected void init(AlignmentView seqView, int start, int end)... |
| 134 |
|
{ |
| 135 |
0 |
this.node = new Vector<BinaryNode>(); |
| 136 |
0 |
if (seqView != null) |
| 137 |
|
{ |
| 138 |
0 |
this.seqData = seqView; |
| 139 |
|
} |
| 140 |
|
else |
| 141 |
|
{ |
| 142 |
0 |
SeqCigar[] seqs = new SeqCigar[sequences.length]; |
| 143 |
0 |
for (int i = 0; i < sequences.length; i++) |
| 144 |
|
{ |
| 145 |
0 |
seqs[i] = new SeqCigar(sequences[i], start, end); |
| 146 |
|
} |
| 147 |
0 |
CigarArray sdata = new CigarArray(seqs); |
| 148 |
0 |
sdata.addOperation(CigarArray.M, end - start + 1); |
| 149 |
0 |
this.seqData = new AlignmentView(sdata, start); |
| 150 |
|
} |
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 154 |
|
|
| 155 |
0 |
noseqs = 0; |
| 156 |
|
|
| 157 |
0 |
done = new BitSet(); |
| 158 |
|
|
| 159 |
0 |
for (SequenceI seq : sequences) |
| 160 |
|
{ |
| 161 |
0 |
if (seq != null) |
| 162 |
|
{ |
| 163 |
0 |
noseqs++; |
| 164 |
|
} |
| 165 |
|
} |
| 166 |
|
} |
| 167 |
|
|
| 168 |
|
|
| 169 |
|
|
| 170 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
| 171 |
0 |
void makeLeaves()... |
| 172 |
|
{ |
| 173 |
0 |
clusters = new Vector<BitSet>(); |
| 174 |
|
|
| 175 |
0 |
for (int i = 0; i < noseqs; i++) |
| 176 |
|
{ |
| 177 |
0 |
SequenceNode sn = new SequenceNode(); |
| 178 |
|
|
| 179 |
0 |
sn.setElement(sequences[i]); |
| 180 |
0 |
sn.setName(sequences[i].getName()); |
| 181 |
0 |
node.addElement(sn); |
| 182 |
0 |
BitSet bs = new BitSet(); |
| 183 |
0 |
bs.set(i); |
| 184 |
0 |
clusters.addElement(bs); |
| 185 |
|
} |
| 186 |
|
} |
| 187 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 188 |
0 |
public AlignmentView getOriginalData()... |
| 189 |
|
{ |
| 190 |
0 |
return seqStrings; |
| 191 |
|
} |
| 192 |
|
|
| 193 |
|
} |