Clover icon

Coverage Report

  1. Project Clover database Wed Jan 7 2026 02:49:01 GMT
  2. Package jalview.workers

File AlignmentComparisonThread.java

 

Coverage histogram

../../img/srcFileCovDistChart0.png
60% of files have more coverage

Code metrics

14
36
5
1
140
97
21
0.58
7.2
5
4.2

Classes

Class Line # Actions
AlignmentComparisonThread 48 36 21
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
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    * A thread to compute the columnwise correspondence between aligned positions
43    * and their positions in a linked alignment
44    *
45    * @author jprocter
46    *
47    */
 
48    public class AlignmentComparisonThread extends AlignCalcWorker
49    {
50   
 
51  0 toggle 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   
 
62  0 toggle @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   
 
94  0 toggle 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   
 
122  0 toggle 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   
 
133  0 toggle @Override
134    public void updateAnnotation()
135    {
136  0 updateResultAnnotation(false);
137   
138    }
139   
140    }