merge
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Wed, 2 Sep 2015 15:50:52 +0000 (16:50 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Wed, 2 Sep 2015 15:50:52 +0000 (16:50 +0100)
13 files changed:
help/html/calculations/consensus.html
help/html/features/splitView.html
help/html/menus/alwcalculate.html
resources/lang/Messages.properties
src/jalview/gui/AlignFrame.java
src/jalview/gui/Desktop.java
src/jalview/gui/Preferences.java
src/jalview/jbgui/GDesktop.java
src/jalview/ws/jws2/Jws2Discoverer.java
test/jalview/gui/PopupMenuTest.java
test/jalview/io/AnnotatedPDBFileInputTest.java
test/jalview/structure/StructureSelectionManagerTest.java
test/jalview/ws/seqfetcher/DbRefFetcherTest.java

index df8bdac..ef3e33a 100644 (file)
@@ -44,6 +44,9 @@ clipboard.
        click on the annotation row label and select
        <strong>Normalise Consensus Logo</strong> to scale all columns of the
        logo to the same height.
-       </p>
+
+<p><strong>cDNA Consensus</strong></p>
+A <a href="../features/splitView.html">Split Frame View</a> of cDNA and Protein alignments will show the consensus for cDNA below the protein alignment.<br/>
+This may provide additional information on  mutations in DNA that is not visible in the peptide alignment. 
 </body>
 </html>
index 16d6c10..5b48ec3 100644 (file)
 <p/></p>Coding DNA (cDNA) and its protein product can be displayed in a split view, with cDNA above and protein below. The two alignments are
 linked, with these features supported:
 <ul>
-<li>mouseover or scrolling of either alignment is followed by the other (unless you turn off <strong><a href="../menus/alwview.html">"View | Automatic Scrolling"</a></strong>)</li>
+<li>mouseover or scrolling of either alignment is followed by the other (unless you turn off <strong><a href="../menus/alwview.html">"View&#8594;Automatic Scrolling"</a></strong>)</li>
 <li>on selecting rows, columns or regions in one alignment, the corresponding selection is made in the other</li>
-<li>sequence ordering in one alignment (using the cursor, or <strong><a href="../calculate/sorting.html">"Calculate | Sort")</a></strong> is also applied to the other</li>
+<li>sequence ordering in one alignment (using the cursor, or <strong><a href="../calculate/sorting.html">"Calculate&#8594;Sort")</a></strong> is also applied to the other</li>
 <li>editing (gap insertion / deletion) in the protein alignment is reflected in the cDNA (but not vice versa)</li>
 <li>on <strong><a href="../calculations/tree.html">"Calculate Tree"</a></strong> in either alignment, grouping, colouring and sorting by tree are applied to both</li>
-<li>the <strong><a href="../menus/alwformat.html">"Format | Font"</a></strong> menu option has an option 'Scale protein residues to codons'; select this option to make each protein residue
+<li>the <strong><a href="../menus/alwformat.html">"Format&#8594;Font"</a></strong> menu option has an option 'Scale protein residues to codons'; select this option to make each protein residue
 the same width as a DNA codon (so the alignments 'line up' vertically)</li>
+<li>menu option <strong>"View&#8594;Protein"</strong> (in the cDNA panel) or <strong>"View&#8594;Nucleotide"</strong> (in the protein panel) allows you to show or hide the complementary alignment</li>
+<li>you can adjust panel heights by dragging the divider between them using the mouse</li>
+<li>menu options <a href="menus/alwview.html"><strong>"View&#8594;New View / Expand Views / Gather Views"</strong></a> behave as for a normal alignment window, but always create new views
+as split frames</li> 
 </ul>
 <p>An alignment annotation row on the protein alignment shows the <strong><a href="../calculations/consensus.html">cDNA consensus</a></strong> for each peptide column.<br/>
 This consensus may reveal variation in nucleotides coding for conserved protein residues.</p>
@@ -50,11 +54,11 @@ If more than one cDNA variant is present in the alignment, Jalview will first tr
 The additional options below apply to Jalview Desktop only.</p>
 
 <p><strong><em>Translate as cDNA</em></strong></p>
-<p>Menu option <strong><a href="../menus/alwcalculate.html">"Calculate | Translate as cDNA"</a></strong> is available for a nucleotide alignment. Selecting this option shows the DNA and its 
+<p>Menu option <strong><a href="../menus/alwcalculate.html">"Calculate&#8594;Translate as cDNA"</a></strong> is available for a nucleotide alignment. Selecting this option shows the DNA and its 
 calculated protein product in a Split Frame view.</p>
 
 <p><strong><em>Get Cross-References</em></strong></p>
-<p>Menu option <strong><a href="../menus/alwcalculate.html">"Calculate | Get Cross-References"</a></strong> is available for fetched sequences which have cross-references to other databases.
+<p>Menu option <strong><a href="../menus/alwcalculate.html">"Calculate&#8594;Get Cross-References"</a></strong> is available for fetched sequences which have cross-references to other databases.
 On selecting protein cross-references (for a cDNA alignment), or DNA xrefs (for peptide), a Split Frame view is opened showing cDNA and peptide.</p>
 
 <p><strong><em>Realign a Split View</em></strong></p>
@@ -68,7 +72,17 @@ Split Frame.</p>
     </ul>
 </li>
 </ul> 
-  
+
+<p><strong><em>Applet</em></strong></p>
+<p>To see a split frame view in the Jalview applet, provide these applet parameters:
+<table border="1">
+<tr><th>Parameter</th><th>Value</th><th>Description</th>
+<tr><td>file</td><td>path to an alignment file</td><td>a cDNA (or protein) alignment</td>
+<tr><td>file</td><td>path to an alignment file</td><td>a protein (or cDNA) alignment</td>
+<tr><td>enableSplitFrame</td><td>true</td><td>to enable the Split Frame feature</td>
+</table>
+<p/>If compatible sequences are present in the input alignments, Jalview will open a Split Frame view.<br/>
+If not, only the first alignment will be opened (an error message is written to the Java console).
 
 <p><em>Split Frame Views were introduced in Jalview 2.9</em></p>
 </body>
index 50bb37b..10b5611 100755 (executable)
                                annotation which can then be used to sort the alignment via the Sort
                                by&#8594;Score menu.</em> <br></li>
                <li><strong>Translate as cDNA</strong> (not applet)<br><em>This option is visible for nucleotide alignments. 
-                       Selecting this option shows the DNA's calculated protein product in a new window. Note that the 
+                       Selecting this option shows the DNA's calculated protein product in a new <a href="../features/splitView.html">split frame</a> window. Note that the 
                        translation is not frame- or intron-aware; it simply translates all codons in each sequence, using the
                        standard <a href="../misc/geneticCode.html">genetic code</a> (any incomplete final codon is discarded). 
                        You can perform this action on the whole alignment, 
                        or selected rows, columns, or regions.</em> <br></li>
                <li><strong>Get Cross-References</strong> (not applet)<br><em>This option is visible where sequences have cross-references to
                        other standard databases; for example, an EMBL entry may have cross-references to one or more UNIPROT entries.
-                       Select the database to view all cross-referenced sequences in a new window.</em> <br></li>
+                       Select the database to view all cross-referenced sequences in a new <a href="../features/splitView.html">split frame</a> window.</em> <br></li>
                <li><strong>Autocalculate Consensus</strong><br> <em>For
                                large alignments it can be useful to deselect &quot;Autocalculate
                                Consensus&quot; when editing. This prevents the sometimes lengthy
index 55d7a90..a4f6497 100644 (file)
@@ -1166,6 +1166,8 @@ label.couldnt_create_sequence_fetcher = Couldn't create SequenceFetcher
 warn.couldnt_create_sequence_fetcher_client = Could not create the sequence fetcher client. Check error logs for details.
 warn.server_didnt_pass_validation = Service did not pass validation.\nCheck the Jalview Console for more details.
 warn.url_must_contain = Sequence URL must contain $SEQUENCE_ID$ or a regex $SEQUENCE_ID=/<regex>/=$
+warn.urls_not_contacted = URLs that could not be contacted
+warn.urls_no_jaba = URLs without any JABA Services
 info.validate_jabaws_server = Validate JabaWS Server ?\n(Look in console output for results)
 label.test_server = Test Server?
 info.you_want_jalview_to_find_uniprot_accessions = Do you want Jalview to find\nUniprot Accession ids for given sequence names?
index 8e4030d..bdcf8a4 100644 (file)
@@ -1030,7 +1030,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   @Override
   public void addFromText_actionPerformed(ActionEvent e)
   {
-    Desktop.instance.inputTextboxMenuItem_actionPerformed(viewport);
+    Desktop.instance.inputTextboxMenuItem_actionPerformed(viewport
+            .getAlignPanel());
   }
 
   @Override
index 8e579b2..39aa257 100644 (file)
@@ -167,8 +167,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
   static final int yOffset = 30;
 
-  private static final int THREE = 3;
-
   private static AlignFrame currentAlignFrame;
 
   public static jalview.ws.jws1.Discoverer discoverer;
@@ -407,7 +405,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       public void run()
       {
         Cache.log.debug("Filechooser init thread started.");
-        JalviewFileChooser chooser = new JalviewFileChooser(
+        new JalviewFileChooser(
                 jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
                 jalview.io.AppletFormatAdapter.READABLE_EXTENSIONS,
                 jalview.io.AppletFormatAdapter.READABLE_FNAMES,
@@ -471,6 +469,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     });
   }
 
+  @Override
   protected void showNews_actionPerformed(ActionEvent e)
   {
     showNews(showNews.isSelected());
@@ -488,12 +487,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements
           @Override
           public void run()
           {
-            long instance = System.currentTimeMillis();
+            long now = System.currentTimeMillis();
             Desktop.instance.setProgressBar(
-                    MessageManager.getString("status.refreshing_news"),
-                    instance);
+                    MessageManager.getString("status.refreshing_news"), now);
             jvnews.refreshNews();
-            Desktop.instance.setProgressBar(null, instance);
+            Desktop.instance.setProgressBar(null, now);
             jvnews.showNews();
           }
         }).start();
@@ -885,6 +883,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   {
   }
 
+  @Override
   public void dropActionChanged(DropTargetDragEvent evt)
   {
   }
@@ -988,6 +987,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   public void inputLocalFileMenuItem_actionPerformed(AlignViewport viewport)
   {
     JalviewFileChooser chooser = new JalviewFileChooser(
@@ -1045,6 +1045,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   public void inputURLMenuItem_actionPerformed(AlignViewport viewport)
   {
     // This construct allows us to have a wider textfield
@@ -1125,16 +1126,18 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   }
 
   /**
-   * DOCUMENT ME!
+   * Opens the CutAndPaste window for the user to paste an alignment in to
    * 
-   * @param e
-   *          DOCUMENT ME!
+   * @param viewPanel
+   *          - if not null, the pasted alignment is added to the current
+   *          alignment; if null, to a new alignment window
    */
-  public void inputTextboxMenuItem_actionPerformed(AlignViewport viewport)
+  @Override
+  public void inputTextboxMenuItem_actionPerformed(
+          AlignmentViewPanel viewPanel)
   {
     CutAndPasteTransfer cap = new CutAndPasteTransfer();
-//    cap.setForInput(viewport.getAlignPanel());
-    cap.setForInput(null);
+    cap.setForInput(viewPanel);
     Desktop.addInternalFrame(cap,
             MessageManager.getString("label.cut_paste_alignmen_file"),
             true, 600, 500);
@@ -1143,6 +1146,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   /*
    * Exit the program
    */
+  @Override
   public void quit()
   {
     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
@@ -1189,6 +1193,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   public void aboutMenuItem_actionPerformed(ActionEvent e)
   {
     // StringBuffer message = getAboutMessage(false);
@@ -1275,6 +1280,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   public void documentationMenuItem_actionPerformed(ActionEvent e)
   {
     try
@@ -1285,6 +1291,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     }
   }
 
+  @Override
   public void closeAll_actionPerformed(ActionEvent e)
   {
     JInternalFrame[] frames = desktop.getAllFrames();
@@ -1315,11 +1322,13 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     }
   }
 
+  @Override
   public void raiseRelated_actionPerformed(ActionEvent e)
   {
     reorderAssociatedWindows(false, false);
   }
 
+  @Override
   public void minimizeAssociated_actionPerformed(ActionEvent e)
   {
     reorderAssociatedWindows(true, false);
@@ -1336,6 +1345,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
    * @seejalview.jbgui.GDesktop#garbageCollect_actionPerformed(java.awt.event.
    * ActionEvent)
    */
+  @Override
   protected void garbageCollect_actionPerformed(ActionEvent e)
   {
     // We simply collect the garbage
@@ -1351,6 +1361,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
    * jalview.jbgui.GDesktop#showMemusage_actionPerformed(java.awt.event.ActionEvent
    * )
    */
+  @Override
   protected void showMemusage_actionPerformed(ActionEvent e)
   {
     desktop.showMemoryUsage(showMemusage.isSelected());
@@ -1363,6 +1374,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
    * jalview.jbgui.GDesktop#showConsole_actionPerformed(java.awt.event.ActionEvent
    * )
    */
+  @Override
   protected void showConsole_actionPerformed(ActionEvent e)
   {
     showConsole(showConsole.isSelected());
@@ -1467,6 +1479,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   protected void preferences_actionPerformed(ActionEvent e)
   {
     new Preferences();
@@ -1478,6 +1491,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   public void saveState_actionPerformed(ActionEvent e)
   {
     JalviewFileChooser chooser = new JalviewFileChooser(
@@ -1549,6 +1563,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
    * @param e
    *          DOCUMENT ME!
    */
+  @Override
   public void loadState_actionPerformed(ActionEvent e)
   {
     JalviewFileChooser chooser = new JalviewFileChooser(
@@ -1599,6 +1614,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     }
   }
 
+  @Override
   public void inputSequence_actionPerformed(ActionEvent e)
   {
     new SequenceFetcher(this);
@@ -1851,6 +1867,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
   jalview.gui.VamsasApplication v_client = null;
 
+  @Override
   public void vamsasImport_actionPerformed(ActionEvent e)
   {
     if (v_client == null)
@@ -1996,6 +2013,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     return (v_client.inSession());
   }
 
+  @Override
   public void vamsasStart_actionPerformed(ActionEvent e)
   {
     if (v_client == null)
@@ -2044,6 +2062,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
             .getString("label.new_vamsas_session"));
   }
 
+  @Override
   public void vamsasStop_actionPerformed(ActionEvent e)
   {
     if (v_client != null)
@@ -2124,6 +2143,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
     }
   }
 
+  @Override
   public void vamsasSave_actionPerformed(ActionEvent e)
   {
     if (v_client != null)
@@ -2249,10 +2269,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       showMemoryUsage(showMemoryUsage);
     }
 
-    public void showMemoryUsage(boolean showMemoryUsage)
+    public void showMemoryUsage(boolean showMemory)
     {
-      this.showMemoryUsage = showMemoryUsage;
-      if (showMemoryUsage)
+      this.showMemoryUsage = showMemory;
+      if (showMemory)
       {
         Thread worker = new Thread(this);
         worker.start();
@@ -2341,7 +2361,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
       {
         public void actionPerformed(ActionEvent e)
         {
-          groovyShell_actionPerformed(e);
+          groovyShell_actionPerformed();
         }
       });
       toolsMenu.add(groovyShell);
@@ -2428,7 +2448,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   /**
    * Add Groovy Support to Jalview
    */
-  public void groovyShell_actionPerformed(ActionEvent e)
+  public void groovyShell_actionPerformed()
   {
     // use reflection to avoid creating compilation dependency.
     if (!jalview.bin.Cache.groovyJarsPresent())
@@ -2483,12 +2503,12 @@ public class Desktop extends jalview.jbgui.GDesktop implements
 
     if (progressBars.get(new Long(id)) != null)
     {
-      JPanel progressPanel = progressBars.remove(new Long(id));
+      JPanel panel = progressBars.remove(new Long(id));
       if (progressBarHandlers.contains(new Long(id)))
       {
         progressBarHandlers.remove(new Long(id));
       }
-      removeProgressPanel(progressPanel);
+      removeProgressPanel(panel);
     }
     else
     {
index 1b274a8..88f5df3 100755 (executable)
@@ -353,8 +353,8 @@ public class Preferences extends GPreferences
     epsRendering.setSelectedItem(Cache.getDefault("EPS_RENDERING",
             "Prompt each time"));
     autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false));
-    userIdWidth.setEnabled(autoIdWidth.isSelected());
-    userIdWidthlabel.setEnabled(autoIdWidth.isSelected());
+    userIdWidth.setEnabled(!autoIdWidth.isSelected());
+    userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
     Integer wi = Cache.getIntegerProperty("FIGURE_USERIDWIDTH");
     userIdWidth.setText(wi == null ? "" : wi.toString());
     blcjv.setSelected(Cache.getDefault("BLC_JVSUFFIX", true));
index 7bb688c..7a55444 100755 (executable)
@@ -20,6 +20,7 @@
  */
 package jalview.jbgui;
 
+import jalview.api.AlignmentViewPanel;
 import jalview.util.MessageManager;
 
 import java.awt.FlowLayout;
@@ -457,8 +458,7 @@ public class GDesktop extends JFrame
    * @param e
    *          DOCUMENT ME!
    */
-  protected void inputTextboxMenuItem_actionPerformed(
-          jalview.gui.AlignViewport av)
+  protected void inputTextboxMenuItem_actionPerformed(AlignmentViewPanel avp)
   {
   }
 
index f2b1145..792e93f 100644 (file)
@@ -853,7 +853,8 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
       if (getInvalidServiceUrls() != null
               && getInvalidServiceUrls().size() > 0)
       {
-        ermsg.append("URLs that could not be contacted: \n");
+        ermsg.append(MessageManager.getString("warn.urls_not_contacted")
+                + ": \n");
         for (String svcurl : getInvalidServiceUrls())
         {
           if (list)
@@ -869,7 +870,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
       if (getUrlsWithoutServices() != null
               && getUrlsWithoutServices().size() > 0)
       {
-        ermsg.append("URLs without any JABA Services : \n");
+        ermsg.append(MessageManager.getString("warn.urls_no_jaba") + ": \n");
         for (String svcurl : getUrlsWithoutServices())
         {
           if (list)
index daeb83f..82fcbc8 100644 (file)
@@ -10,6 +10,7 @@ import jalview.datamodel.Annotation;
 import jalview.datamodel.SequenceI;
 import jalview.io.AppletFormatAdapter;
 import jalview.io.FormatAdapter;
+import jalview.util.MessageManager;
 
 import java.awt.Component;
 import java.io.IOException;
@@ -130,7 +131,9 @@ public class PopupMenuTest
 
     testee.configureReferenceAnnotationsMenu(menu, seqs);
     assertTrue(menu.isEnabled());
-    String expected = "<html><style> p.ttip {width: 350; text-align: justify; word-wrap: break-word;}</style><p class=\"ttip\">Add annotations for<br/>JMOL/secondary structure<br/>PBD/Temp</p></html>";
+    String s = MessageManager.getString("label.add_annotations_for");
+    String expected = "<html><style> p.ttip {width: 350; text-align: justify; word-wrap: break-word;}</style><p class=\"ttip\">"
+            + s + "<br/>Jmol/secondary structure<br/>PDB/Temp</p></html>";
     assertEquals(expected, menu.getToolTipText());
   }
 
@@ -151,7 +154,9 @@ public class PopupMenuTest
 
     testee.configureReferenceAnnotationsMenu(menu, seqs);
     assertTrue(menu.isEnabled());
-    String expected = "<html><style> p.ttip {width: 350; text-align: justify; word-wrap: break-word;}</style><p class=\"ttip\">Add annotations for<br/>JMOL/secondary structure<br/>PBD/Temp</p></html>";
+    String s = MessageManager.getString("label.add_annotations_for");
+    String expected = "<html><style> p.ttip {width: 350; text-align: justify; word-wrap: break-word;}</style><p class=\"ttip\">"
+            + s + "<br/>Jmol/secondary structure<br/>PDB/Temp</p></html>";
     assertEquals(expected, menu.getToolTipText());
   }
 
@@ -169,7 +174,7 @@ public class PopupMenuTest
     // PDB.secondary structure on Sequence0
     AlignmentAnnotation annotation = new AlignmentAnnotation(
             "secondary structure", "", 0);
-    annotation.setCalcId("PBD");
+    annotation.setCalcId("PDB");
     seqs.get(0).getDatasetSequence().addAlignmentAnnotation(annotation);
     if (addToSequence)
     {
@@ -182,7 +187,7 @@ public class PopupMenuTest
 
     // PDB.Temp on Sequence1
     annotation = new AlignmentAnnotation("Temp", "", 0);
-    annotation.setCalcId("PBD");
+    annotation.setCalcId("PDB");
     seqs.get(1).getDatasetSequence().addAlignmentAnnotation(annotation);
     if (addToSequence)
     {
@@ -195,7 +200,7 @@ public class PopupMenuTest
 
     // JMOL.secondary structure on Sequence0
     annotation = new AlignmentAnnotation("secondary structure", "", 0);
-    annotation.setCalcId("JMOL");
+    annotation.setCalcId("Jmol");
     seqs.get(0).getDatasetSequence().addAlignmentAnnotation(annotation);
     if (addToSequence)
     {
index b4a8bf6..91e816a 100644 (file)
@@ -11,9 +11,6 @@ import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
-import jalview.gui.Desktop;
-import jalview.structure.StructureMapping;
-import jalview.structure.StructureSelectionManager;
 
 import java.io.File;
 
@@ -28,10 +25,14 @@ public class AnnotatedPDBFileInputTest
 
   AlignmentI al;
 
-  String pdbStr = "examples/1gaq.txt";
-
   String pdbId;
 
+  /**
+   * Ensure 'process secondary structure from PDB and add annotations' are set
+   * in preferences, and load PDB example file 1gaq
+   * 
+   * @throws Exception
+   */
  @BeforeMethod(alwaysRun = true)
   public void setup() throws Exception
   {
@@ -40,7 +41,7 @@ public class AnnotatedPDBFileInputTest
     Cache.applicationProperties.setProperty("ADD_SS_ANN",
             Boolean.TRUE.toString());
     FileLoader loader = new FileLoader(false);
-    AlignFrame af = loader.LoadFileWaitTillLoaded(pdbStr,
+    AlignFrame af = loader.LoadFileWaitTillLoaded("examples/1gaq.txt",
             FormatAdapter.FILE);
     al = af.getViewport().getAlignment();
     pdbId = al.getSequenceAt(0).getDatasetSequence().getAllPDBEntries()
@@ -88,11 +89,6 @@ public class AnnotatedPDBFileInputTest
   @Test(groups ={ "Functional" })
   public void checkPDBSequenceFeatures()
   {
-    StructureSelectionManager ssm = StructureSelectionManager
-            .getStructureSelectionManager(Desktop.instance);
-    StructureMapping[] mappings = ssm.getMapping("1gaq");
-    // suspect we really want to make assertions on sequence features
-    // in these mappings' sequencess
     /*
      * 1GAQ/A
      */
@@ -159,8 +155,7 @@ public class AnnotatedPDBFileInputTest
   @BeforeClass(alwaysRun = true)
   public static void setUpBeforeClass() throws Exception
   {
-    jalview.bin.Jalview.main(new String[]
- { "-props",
+    jalview.bin.Jalview.main(new String[] { "-props",
         "test/jalview/io/testProps.jvprops" });
   }
 
index e4cc336..8e3e086 100644 (file)
@@ -4,6 +4,10 @@ import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertTrue;
 
 import jalview.datamodel.AlignedCodonFrame;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceI;
+import jalview.io.FormatAdapter;
 
 import java.util.HashSet;
 import java.util.Set;
@@ -11,6 +15,8 @@ import java.util.Set;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import MCview.PDBfile;
+
 public class StructureSelectionManagerTest
 {
   private StructureSelectionManager ssm;
@@ -72,4 +78,46 @@ public class StructureSelectionManagerTest
     assertTrue(ssm.seqmappings.contains(acf2));
     assertTrue(ssm.seqmappings.contains(acf3));
   }
+
+  /**
+   * Verify that RESNUM sequence features are present after creating a PDB
+   * mapping
+   */
+  @Test(groups = { "Functional" })
+  public void testSetMapping_seqFeatures()
+  {
+    SequenceI seq = new Sequence(
+            "1GAQ|B",
+            "ATYNVKLITPEGEVELQVPDDVYILDQAEEDGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSYLDDGQIADGWVLTCHAYPTSDVVIETHKEEELTGA");
+    StructureSelectionManager sm = new StructureSelectionManager();
+    sm.setProcessSecondaryStructure(true);
+    sm.setAddTempFacAnnot(true);
+    PDBfile pmap = sm.setMapping(true, new SequenceI[] { seq },
+            new String[] { null }, "examples/1gaq.txt",
+            FormatAdapter.FILE);
+    assertTrue(pmap != null);
+
+    assertEquals(3, pmap.getSeqs().size());
+    assertEquals("1GAQ|A", pmap.getSeqs().get(0).getName());
+    assertEquals("1GAQ|B", pmap.getSeqs().get(1).getName());
+    assertEquals("1GAQ|C", pmap.getSeqs().get(2).getName());
+
+    /*
+     * Verify a RESNUM sequence feature in the PDBfile sequence
+     */
+    SequenceFeature sf = pmap.getSeqs().get(0).getSequenceFeatures()[0];
+    assertEquals("RESNUM", sf.getType());
+    assertEquals("1gaq", sf.getFeatureGroup());
+    assertEquals("GLU:  19  1gaqA", sf.getDescription());
+
+    /*
+     * Verify a RESNUM sequence feature in the StructureSelectionManager mapped
+     * sequence
+     */
+    StructureMapping map = sm.getMapping("examples/1gaq.txt")[0];
+    sf = map.sequence.getSequenceFeatures()[0];
+    assertEquals("RESNUM", sf.getType());
+    assertEquals("1gaq", sf.getFeatureGroup());
+    assertEquals("ALA:   1  1gaqB", sf.getDescription());
+  }
 }
index d9b1d90..1171bfd 100644 (file)
@@ -28,6 +28,9 @@ import jalview.analysis.CrossRef;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.DBRefSource;
+import jalview.datamodel.FeatureProperties;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceI;
 import jalview.util.DBRefUtils;
 import jalview.ws.SequenceFetcher;
 
@@ -62,6 +65,11 @@ public class DbRefFetcherTest
   {
   }
 
+  /**
+   * Tests that standard protein database sources include Uniprot (as the first)
+   * and also PDB. (Additional sources are dependent on available of DAS
+   * services.)
+   */
   @Test(groups ={ "Functional" })
   public void testStandardProtDbs()
   {
@@ -77,38 +85,53 @@ public class DbRefFetcherTest
         srces.addAll(srcesfordb);
       }
     }
-    DbSourceProxy uniprot = null;
+
     int i = 0;
+    int uniprotPos = -1;
+    int pdbPos = -1;
     // append the selected sequence sources to the default dbs
     for (DbSourceProxy s : srces)
     {
-      if (s.getDbSource().equalsIgnoreCase(DBRefSource.UNIPROT))
+      if (s instanceof jalview.ws.dbsources.Uniprot)
       {
-        i++;
+        uniprotPos = i;
       }
-
-      if (s instanceof jalview.ws.dbsources.Uniprot)
+      if (s instanceof jalview.ws.dbsources.Pdb)
       {
-        uniprot = s;
-        break;
+        pdbPos = i;
       }
+      i++;
     }
 
     assertTrue("Failed to find Uniprot source as first source amongst "
-            + srces.size() + " sources (source was at position " + i + ")",
-            uniprot != null && i < 2);
+            + srces.size() + " sources (source was at position "
+            + uniprotPos + ")", uniprotPos == 0);
+    assertTrue("Failed to find PDB source amongst " + srces.size()
+            + " sources", pdbPos >= 0);
   }
 
+  /**
+   * Tests retrieval of one entry from EMBL. Test is dependent on availability
+   * of network and the EMBL service.
+   * 
+   * @throws Exception
+   */
   @Test(groups =
   { "External" })
   public void testEmblUniprotProductRecovery() throws Exception
   {
-    String retrievalId = "CAA23748"; // "V00488";
+    String retrievalId = "V00488";
     DbSourceProxy embl = new SequenceFetcher().getSourceProxy(DBRefSource.EMBL).get(0);
     assertNotNull("Couldn't find the EMBL retrieval client", embl);
     verifyProteinNucleotideXref(retrievalId, embl);
   }
 
+  /**
+   * Tests retrieval of one entry from EMBLCDS. Test is dependent on
+   * availability of network and the EMBLCDS service.
+   * 
+   * @throws Exception
+   */
   @Test(groups =
   { "External" })
   public void testEmblCDSUniprotProductRecovery() throws Exception
@@ -120,24 +143,46 @@ public class DbRefFetcherTest
     verifyProteinNucleotideXref(retrievalId, embl);
   }
 
+  /**
+   * Helper method to perform database retrieval and verification of results.
+   * 
+   * @param retrievalId
+   * @param embl
+   * @throws Exception
+   */
   private void verifyProteinNucleotideXref(String retrievalId,
           DbSourceProxy embl) throws Exception
   {
     AlignmentI alsq = embl.getSequenceRecords(retrievalId);
     assertNotNull("Couldn't find the EMBL record " + retrievalId, alsq);
     assertEquals("Didn't retrieve right number of records", 1, alsq.getHeight());
-    DBRefEntry[] dr = DBRefUtils.selectRefs(alsq.getSequenceAt(0).getDBRef(), DBRefSource.PROTEINSEQ);
+    SequenceI seq = alsq.getSequenceAt(0);
+    assertEquals("Wrong sequence name", embl.getDbSource() + "|"
+            + retrievalId, seq.getName());
+    SequenceFeature[] sfs = seq.getSequenceFeatures();
+    assertNotNull("Sequence features missing", sfs);
+    assertTrue(
+            "Feature not CDS",
+            FeatureProperties.isCodingFeature(embl.getDbSource(),
+                    sfs[0].getType()));
+    assertEquals(embl.getDbSource(), sfs[0].getFeatureGroup());
+    DBRefEntry[] dr = DBRefUtils.selectRefs(seq.getDBRef(), DBRefSource.PROTEINSEQ);
     assertNotNull(dr);
     assertEquals("Expected a single Uniprot cross reference", 1, dr.length);
-    assertEquals("Expected cross refernce map to be one amino acid", dr[0]
+    assertEquals("Expected cross reference map to be one amino acid", dr[0]
             .getMap().getMappedWidth(), 1);
-    assertEquals("Expected local refernce map to be 3 nucleotides", dr[0]
+    assertEquals("Expected local reference map to be 3 nucleotides", dr[0]
             .getMap().getWidth(), 3);
     AlignmentI sprods = CrossRef.findXrefSequences(alsq.getSequencesArray(), true, dr[0].getSource(), alsq.getDataset());
     assertNotNull(
             "Couldn't recover cross reference sequence from dataset. Was it ever added ?",
             sprods);
-    
-    
+    assertEquals("Didn't xref right number of records", 1,
+            sprods.getHeight());
+    SequenceI proteinSeq = sprods.getSequenceAt(0);
+    assertEquals(proteinSeq.getSequenceAsString(), dr[0].getMap().getTo()
+            .getSequenceAsString());
+    assertEquals(dr[0].getSource() + "|" + dr[0].getAccessionId(),
+            proteinSeq.getName());
   }
 }