X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fviewmodel%2FAlignmentViewport.java;h=6322243d9dede0ce4f3abd3156ccf0252e2d686a;hb=4d7fb8a093a3151363b0782dddb9598567de66e0;hp=eb686a4f3d361c71f1ecbafc50eb6f3c1e6d7129;hpb=0f5255080bd41820b3dcd934c499f68007fc5544;p=jalview.git diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index eb686a4..6322243 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -49,6 +49,7 @@ import jalview.structure.CommandListener; import jalview.structure.StructureSelectionManager; import jalview.structure.VamsasSource; import jalview.util.Comparison; +import jalview.util.MapList; import jalview.util.MappingUtils; import jalview.viewmodel.styles.ViewStyle; import jalview.workers.AlignCalcManager; @@ -65,7 +66,6 @@ import java.util.HashMap; import java.util.Hashtable; import java.util.List; import java.util.Map; -import java.util.Set; /** * base class holding visualization and analysis attributes and common logic for @@ -837,15 +837,28 @@ public abstract class AlignmentViewport implements AlignViewportI, /* * A separate thread to compute cDNA consensus for a protein alignment + * which has mapping to cDNA */ final AlignmentI al = this.getAlignment(); if (!al.isNucleotide() && al.getCodonFrames() != null && !al.getCodonFrames().isEmpty()) { - if (calculator - .getRegisteredWorkersOfClass(ComplementConsensusThread.class) == null) + /* + * fudge - check first mapping is protein-to-nucleotide + * (we don't want to do this for protein-to-protein) + */ + AlignedCodonFrame mapping = al.getCodonFrames().iterator().next(); + // TODO hold mapping type e.g. dna-to-protein in AlignedCodonFrame? + MapList[] mapLists = mapping.getdnaToProt(); + // mapLists can be empty if project load has not finished resolving seqs + if (mapLists.length > 0 && mapLists[0].getFromRatio() == 3) { - calculator.registerWorker(new ComplementConsensusThread(this, ap)); + if (calculator + .getRegisteredWorkersOfClass(ComplementConsensusThread.class) == null) + { + calculator + .registerWorker(new ComplementConsensusThread(this, ap)); + } } } } @@ -1424,7 +1437,7 @@ public abstract class AlignmentViewport implements AlignViewportI, if (hiddenRepSequences == null) { - hiddenRepSequences = new Hashtable(); + hiddenRepSequences = new Hashtable(); } hiddenRepSequences.put(repSequence, sg); @@ -1780,14 +1793,22 @@ public abstract class AlignmentViewport implements AlignViewportI, { if (!alignment.isNucleotide()) { - final Set codonMappings = alignment + final List codonMappings = alignment .getCodonFrames(); if (codonMappings != null && !codonMappings.isEmpty()) { - complementConsensus = new AlignmentAnnotation("cDNA Consensus", - "PID for cDNA", new Annotation[1], 0f, 100f, - AlignmentAnnotation.BAR_GRAPH); - initConsensus(complementConsensus); + // fudge: check mappings are not protein-to-protein + // TODO: nicer + AlignedCodonFrame mapping = codonMappings.iterator().next(); + MapList[] mapLists = mapping.getdnaToProt(); + // mapLists can be empty if project load has not finished resolving seqs + if (mapLists.length > 0 && mapLists[0].getFromRatio() == 3) + { + complementConsensus = new AlignmentAnnotation("cDNA Consensus", + "PID for cDNA", new Annotation[1], 0f, 100f, + AlignmentAnnotation.BAR_GRAPH); + initConsensus(complementConsensus); + } } } } @@ -2099,7 +2120,7 @@ public abstract class AlignmentViewport implements AlignViewportI, public boolean areFeaturesDisplayed() { return featuresDisplayed != null - && featuresDisplayed.getRegisterdFeaturesCount() > 0; + && featuresDisplayed.getRegisteredFeaturesCount() > 0; } /** @@ -2580,7 +2601,7 @@ public abstract class AlignmentViewport implements AlignViewportI, { return 0; } - final Set mappings = proteinAlignment + final List mappings = proteinAlignment .getCodonFrames(); /*