import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.gui.AlignmentPanel;
import jalview.gui.QuitHandler;
import jalview.project.Jalview2XML;
import jalview.renderer.ResidueShader;
if (calculator.getRegisteredWorkersOfClass(
AlignmentComparisonThread.class) == null)
{
- calculator
- .registerWorker(new AlignmentComparisonThread(this, ap));
+ initAlignmentComparison(ap);
+ ap.adjustAnnotationHeight();
}
}
}
*/
private boolean followHighlight = true;
+ private AlignmentAnnotation aligComparison;
+
+ private boolean showComparison = true;
+
/**
* Property change listener for changes in alignment
*
}
}
+ private void initAlignmentComparison(final AlignmentViewPanel ap)
+ {
+ if (getCodingComplement() == null
+ || getCodingComplement().isNucleotide() != isNucleotide())
+ {
+ return;
+ }
+
+ if (aligComparison == null)
+ {
+ aligComparison = new AlignmentAnnotation("Comparision",
+ MessageManager.getString("label.alignment_comparison_descr"),
+ new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
+ aligComparison.hasText = true;
+ aligComparison.autoCalculated = true;
+
+ if (showComparison)
+ {
+ alignment.addAnnotation(aligComparison);
+ }
+ }
+
+ if (calculator.getRegisteredWorkersOfClass(
+ AlignmentComparisonThread.class) == null)
+ {
+ calculator.registerWorker(new AlignmentComparisonThread(this, ap));
+ }
+ }
+ @Override
+ public AlignmentAnnotation getComparisonAnnotation()
+ {
+ return aligComparison;
+ }
+
/*
* (non-Javadoc)
*
import jalview.analysis.scoremodels.ScoreModels;
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
+import jalview.bin.Console;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
AlignmentViewPanel alignPanel)
{
super(alignViewport, alignPanel);
+ comparisonAnnot = alignViewport.getComparisonAnnotation();
}
- Annotation[] correspondence = new Annotation[] {};
+ Annotation[] correspondence = new Annotation[1];
AlignmentAnnotation comparisonAnnot=null;
int alWidth;
+ private int maxCor=1;
@Override
public void run()
return;
}
- comparisonAnnot = alignViewport.getAlignment().findOrCreateAnnotation("Comparison", "CORRESPONDENCE", true, null, null);
+
comparisonAnnot.annotations=correspondence;
ourAnnot.add(comparisonAnnot);
ourAnnots = ourAnnot;
try
{
computeColumnCorrespondence(alignViewport, codingComplement);
- } catch (IndexOutOfBoundsException x)
+ } catch (Throwable x)
{
+ Console.error("Unexpected error computing similarity of alignments",x);
// probable race condition. just finish and return without any fuss.
calcMan.workerComplete(this);
return;
int colEnd = alignViewport.getAlignment().getWidth();
Annotation[] colCorrsp = new Annotation[colEnd];
+ maxCor=0;
for (int col = 0; col < colEnd; col++)
{
int[] theirWidth = MappingUtils.findMappedColumns(col, ourMappings,
us, them, alignViewport.getGapCharacter());
+ int wid =theirWidth != null ? Math.abs(theirWidth[1] - theirWidth[0])
+ : 0;
colCorrsp[col] = new Annotation(
- theirWidth != null ? Math.abs(theirWidth[1] - theirWidth[0])
- : 0);
+ wid);
+ maxCor = Math.max(maxCor, wid);
}
correspondence=colCorrsp;
}
if (b || !calcMan.isWorking(this) && correspondence!=null)
{
comparisonAnnot.annotations = correspondence;
+ comparisonAnnot.graphMax=(float)maxCor;
comparisonAnnot.validateRangeAndDisplay();
+ ap.paintAlignment(false, false);
}
}