JAL-845 start cDNA consensus on 'add alignment' (as well as translate or
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 11 Mar 2015 11:45:56 +0000 (11:45 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 11 Mar 2015 11:45:56 +0000 (11:45 +0000)
show cross-ref)

src/jalview/gui/AlignViewport.java
src/jalview/viewmodel/AlignmentViewport.java

index 6c34479..289a0ea 100644 (file)
@@ -39,7 +39,6 @@
 package jalview.gui;
 
 import jalview.analysis.AlignmentUtils;
-import jalview.analysis.AlignmentUtils.MappingResult;
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.analysis.NJTree;
 import jalview.api.AlignViewportI;
@@ -1036,21 +1035,11 @@ public class AlignViewport extends AlignmentViewport implements
     }
 
     /*
-     * Try to find mappings for at least one sequence. Any mappings made will be
-     * added to the protein alignment.
+     * Map sequences. At least one should get mapped as we have already passed
+     * the test for 'mappability'. Any mappings made will be added to the
+     * protein alignment.
      */
-    MappingResult mapped = AlignmentUtils.mapProteinToCdna(protein, cdna);
-    if (mapped != MappingResult.Mapped)
-    {
-      /*
-       * No mapping possible - warn the user, but leave window open.
-       */
-      final String msg = JvSwingUtils.wrapTooltip(true,
-              MessageManager.getString("label.mapping_failed"));
-      JOptionPane.showInternalMessageDialog(Desktop.desktop, msg,
-              MessageManager.getString("label.no_mappings"),
-              JOptionPane.WARNING_MESSAGE);
-    }
+    AlignmentUtils.mapProteinToCdna(protein, cdna);
 
     try
     {
@@ -1106,6 +1095,7 @@ public class AlignViewport extends AlignmentViewport implements
             : copyMe;
     AlignmentI protein = proteinFrame.viewport.getAlignment();
     protein.setCodonFrames(mappings);
+    proteinFrame.viewport.initComplementConsensus();
 
     cdnaFrame.setVisible(true);
     proteinFrame.setVisible(true);
index 140d141..2cfc1e6 100644 (file)
@@ -1718,17 +1718,26 @@ public abstract class AlignmentViewport implements AlignViewportI,
               new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
       initConsensus(consensus);
 
-      if (!alignment.isNucleotide())
+      initComplementConsensus();
+    }
+  }
+
+  /**
+   * If this is a protein alignment and there are mappings to cDNA, add the cDNA
+   * consensus annotation.
+   */
+  protected void initComplementConsensus()
+  {
+    if (!alignment.isNucleotide())
+    {
+      final Set<AlignedCodonFrame> codonMappings = alignment
+              .getCodonFrames();
+      if (codonMappings != null && !codonMappings.isEmpty())
       {
-        final Set<AlignedCodonFrame> 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);
-        }
+        complementConsensus = new AlignmentAnnotation("cDNA Consensus",
+                "PID for cDNA", new Annotation[1], 0f, 100f,
+                AlignmentAnnotation.BAR_GRAPH);
+        initConsensus(complementConsensus);
       }
     }
   }