2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.workers;
20 import java.util.ArrayList;
21 import java.util.List;
23 import jalview.analysis.Conservation;
24 import jalview.api.AlignCalcWorkerI;
25 import jalview.api.AlignmentViewPanel;
26 import jalview.api.AlignViewportI;
27 import jalview.datamodel.AlignmentAnnotation;
28 import jalview.datamodel.AlignmentI;
30 public class ConservationThread extends AlignCalcWorker implements AlignCalcWorkerI
33 private int ConsPercGaps = 25; // JBPNote : This should be a configurable property!
35 public ConservationThread(AlignViewportI alignViewport, AlignmentViewPanel alignPanel)
37 super(alignViewport, alignPanel);
38 ConsPercGaps = alignViewport.getConsPercGaps();
41 private Conservation cons;
42 AlignmentAnnotation conservation,quality;
48 calcMan.notifyStart(this); // updatingConservation = true;
50 while (!calcMan.notifyWorking(this))
56 ap.paintAlignment(false);
59 } catch (Exception ex)
64 if (alignViewport.isClosed()) {
67 List<AlignmentAnnotation>ourAnnot = new ArrayList<AlignmentAnnotation>();
68 AlignmentI alignment=alignViewport.getAlignment();
69 conservation=alignViewport.getAlignmentConservationAnnotation();
70 quality=alignViewport.getAlignmentQualityAnnot();
71 ourAnnot.add(conservation);
72 ourAnnot.add(quality);
75 // AlignViewport.UPDATING_CONSERVATION = true;
77 if (alignment==null || (alWidth=alignment.getWidth())< 0)
79 calcMan.workerComplete(this);
80 //.updatingConservation = false;
81 //AlignViewport.UPDATING_CONSERVATION = false;
86 cons = Conservation.calculateConservation("All",
87 jalview.schemes.ResidueProperties.propHash, 3,
88 alignment.getSequences(), 0, alWidth - 1, false, ConsPercGaps, quality!=null);
89 updateResultAnnotation(true);
90 } catch (OutOfMemoryError error)
92 ap.raiseOOMWarning("calculating conservation", error);
93 calcMan.workerCannotRun(this);
94 // alignViewport.conservation = null;
95 // this.alignViewport.quality = null;
98 calcMan.workerComplete(this);
102 ap.paintAlignment(true);
107 private void updateResultAnnotation(boolean b)
109 if (b || !calcMan.isWorking(this) && cons!=null && conservation!=null && quality!=null)
110 cons.completeAnnotations(conservation,
111 quality, 0, alWidth);
114 public void updateAnnotation()
116 updateResultAnnotation(false);