| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.workers; |
| 22 |
|
|
| 23 |
|
import jalview.analysis.AAFrequency; |
| 24 |
|
import jalview.analysis.Conservation; |
| 25 |
|
import jalview.analysis.scoremodels.ScoreModels; |
| 26 |
|
import jalview.api.AlignViewportI; |
| 27 |
|
import jalview.api.AlignmentViewPanel; |
| 28 |
|
import jalview.bin.Console; |
| 29 |
|
import jalview.datamodel.AlignedCodonFrame; |
| 30 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 31 |
|
import jalview.datamodel.AlignmentI; |
| 32 |
|
import jalview.datamodel.Annotation; |
| 33 |
|
import jalview.datamodel.SequenceI; |
| 34 |
|
import jalview.util.MappingUtils; |
| 35 |
|
|
| 36 |
|
import java.util.ArrayList; |
| 37 |
|
import java.util.ConcurrentModificationException; |
| 38 |
|
import java.util.Hashtable; |
| 39 |
|
import java.util.List; |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
@author |
| 46 |
|
|
| 47 |
|
|
| |
|
| 0% |
Uncovered Elements: 55 (55) |
Complexity: 21 |
Complexity Density: 0.58 |
|
| 48 |
|
public class AlignmentComparisonThread extends AlignCalcWorker |
| 49 |
|
{ |
| 50 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 51 |
0 |
public AlignmentComparisonThread(AlignViewportI alignViewport,... |
| 52 |
|
AlignmentViewPanel alignPanel) |
| 53 |
|
{ |
| 54 |
0 |
super(alignViewport, alignPanel); |
| 55 |
|
} |
| 56 |
|
|
| 57 |
|
Annotation[] correspondence = new Annotation[1]; |
| 58 |
|
AlignmentAnnotation comparisonAnnot=null; |
| 59 |
|
int alWidth; |
| 60 |
|
private int maxCor=1; |
| 61 |
|
|
| |
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 8 |
Complexity Density: 0.53 |
|
| 62 |
0 |
@Override... |
| 63 |
|
public void run() |
| 64 |
|
{ |
| 65 |
0 |
comparisonAnnot = alignViewport.getComparisonAnnotation(); |
| 66 |
0 |
if ((alignViewport == null) || (calcMan == null) |
| 67 |
|
|| (alignViewport.isClosed())) |
| 68 |
|
{ |
| 69 |
0 |
return; |
| 70 |
|
} |
| 71 |
0 |
List<AlignmentAnnotation> ourAnnot = new ArrayList<>(); |
| 72 |
|
|
| 73 |
0 |
AlignmentI alignment = alignViewport.getAlignment(); |
| 74 |
0 |
AlignViewportI codingComplement = alignViewport.getCodingComplement(); |
| 75 |
0 |
if (alignment == null || (alWidth = alignment.getWidth()) < 0 |
| 76 |
|
|| (codingComplement == null)) |
| 77 |
|
{ |
| 78 |
0 |
return; |
| 79 |
|
} |
| 80 |
|
|
| 81 |
0 |
comparisonAnnot.annotations=correspondence; |
| 82 |
0 |
ourAnnot.add(comparisonAnnot); |
| 83 |
0 |
ourAnnots = ourAnnot; |
| 84 |
0 |
computeColumnCorrespondence(alignViewport, codingComplement); |
| 85 |
0 |
updateResultAnnotation(true); |
| 86 |
|
|
| 87 |
0 |
if (ap != null) |
| 88 |
|
{ |
| 89 |
0 |
ap.paintAlignment(true, true); |
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
} |
| 93 |
|
|
| |
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 7 |
Complexity Density: 0.5 |
|
| 94 |
0 |
private void computeColumnCorrespondence(AlignViewportI alignViewport,... |
| 95 |
|
AlignViewportI codingComplement) |
| 96 |
|
{ |
| 97 |
0 |
List<SequenceI> us = alignViewport.getAlignment().getSequences(); |
| 98 |
0 |
List<AlignedCodonFrame> ourMappings = alignViewport.getAlignment() |
| 99 |
|
.getCodonFrames(); |
| 100 |
0 |
List<SequenceI> them = codingComplement.getAlignment().getSequences(); |
| 101 |
0 |
if (us == null || them == null || us.isEmpty() || them.isEmpty()) |
| 102 |
|
{ |
| 103 |
0 |
return; |
| 104 |
|
} |
| 105 |
|
|
| 106 |
0 |
int colEnd = alignViewport.getAlignment().getWidth(); |
| 107 |
0 |
Annotation[] colCorrsp = new Annotation[colEnd]; |
| 108 |
0 |
maxCor=0; |
| 109 |
0 |
for (int col = 0; col < colEnd; col++) |
| 110 |
|
{ |
| 111 |
0 |
int[] theirWidth = MappingUtils.findMappedColumns(col, ourMappings, |
| 112 |
|
us, them, alignViewport.getGapCharacter()); |
| 113 |
0 |
int wid =theirWidth != null ? Math.abs(theirWidth[1] - theirWidth[0]) |
| 114 |
|
: 0; |
| 115 |
0 |
colCorrsp[col] = new Annotation( |
| 116 |
|
wid); |
| 117 |
0 |
maxCor = Math.max(maxCor, wid); |
| 118 |
|
} |
| 119 |
0 |
correspondence=colCorrsp; |
| 120 |
|
} |
| 121 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 122 |
0 |
private void updateResultAnnotation(boolean b)... |
| 123 |
|
{ |
| 124 |
0 |
if (b || !calcMan.isWorking(this) && correspondence!=null) |
| 125 |
|
{ |
| 126 |
0 |
comparisonAnnot.annotations = correspondence; |
| 127 |
0 |
comparisonAnnot.graphMax=(float)maxCor; |
| 128 |
0 |
comparisonAnnot.validateRangeAndDisplay(); |
| 129 |
0 |
ap.paintAlignment(false, false); |
| 130 |
|
} |
| 131 |
|
} |
| 132 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 133 |
0 |
@Override... |
| 134 |
|
public void updateAnnotation() |
| 135 |
|
{ |
| 136 |
0 |
updateResultAnnotation(false); |
| 137 |
|
|
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
} |