Merge branch 'patchJAL-674_offset' into Release_2_8_2_Branch
authorJim Procter <jprocter@dundee.ac.uk>
Thu, 27 Nov 2014 14:39:32 +0000 (14:39 +0000)
committerJim Procter <jprocter@dundee.ac.uk>
Thu, 27 Nov 2014 14:39:32 +0000 (14:39 +0000)
src/MCview/PDBChain.java
src/jalview/api/AlignmentViewPanel.java
src/jalview/appletgui/AlignmentPanel.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignmentPanel.java
src/jalview/structure/StructureSelectionManager.java
test/jalview/io/Jalview2xmlTests.java
test/jalview/io/testProps.jvprops [new file with mode: 0644]

index 408108b..49d7d4a 100755 (executable)
@@ -522,6 +522,7 @@ public class PDBChain
                   ana.getCalcId(), ana.label);
           if (transfer == null || transfer.size() == 0)
           {
+            ana = new AlignmentAnnotation(ana);
             ana.liftOver(sequence, shadowMap);
             ana.liftOver(dsq, sqmpping);
             dsq.addAlignmentAnnotation(ana);
@@ -534,24 +535,25 @@ public class PDBChain
       }
       else
       {
-      if (sequence != null && sequence.getAnnotation() != null)
-      {
-        for (AlignmentAnnotation ana : sequence.getAnnotation())
+        if (sequence != null && sequence.getAnnotation() != null)
         {
-          List<AlignmentAnnotation> transfer = sq.getAlignmentAnnotations(
-                  ana.getCalcId(), ana.label);
-          if (transfer == null || transfer.size() == 0)
-          {
-            ana.liftOver(dsq, sqmpping);
-            // mapping.transfer(ana);
-          }
-          else
+          for (AlignmentAnnotation ana : sequence.getAnnotation())
           {
-            continue;
+            List<AlignmentAnnotation> transfer = sq
+                    .getAlignmentAnnotations(ana.getCalcId(), ana.label);
+            if (transfer == null || transfer.size() == 0)
+            {
+              ana = new AlignmentAnnotation(ana);
+              ana.liftOver(dsq, sqmpping);
+              // mapping.transfer(ana);
+            }
+            else
+            {
+              continue;
+            }
           }
         }
       }
-      }
       if (false)
       {
         // Useful for debugging mappings - adds annotation for mapped position
index 7ff3a6a..0955cb4 100644 (file)
@@ -50,4 +50,10 @@ public interface AlignmentViewPanel extends OOMHandlerI
    * ensuring the alignment is still visible.
    */
   void adjustAnnotationHeight();
+
+  /**
+   * 
+   * @return displayed name for the view
+   */
+  String getViewName();
 }
index 02ad0cd..a90425f 100644 (file)
  */
 package jalview.appletgui;
 
-import java.awt.*;
-import java.awt.event.*;
-
 import jalview.api.AlignmentViewPanel;
-import jalview.datamodel.*;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SearchResults;
+import jalview.datamodel.SequenceI;
 import jalview.structure.StructureSelectionManager;
 
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.FontMetrics;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Panel;
+import java.awt.Scrollbar;
+import java.awt.event.AdjustmentEvent;
+import java.awt.event.AdjustmentListener;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+
 public class AlignmentPanel extends Panel implements AdjustmentListener,
         AlignmentViewPanel
 {
@@ -965,6 +977,12 @@ public class AlignmentPanel extends Panel implements AdjustmentListener,
   }
 
   @Override
+  public String getViewName()
+  {
+    return getName();
+  }
+
+  @Override
   public StructureSelectionManager getStructureSelectionManager()
   {
     return StructureSelectionManager
index 2a804ad..31652c1 100644 (file)
@@ -30,6 +30,7 @@ import jalview.analysis.ParseProperties;
 import jalview.analysis.SequenceIdMatcher;
 import jalview.api.AlignViewControllerGuiI;
 import jalview.api.AlignViewControllerI;
+import jalview.api.AlignmentViewPanel;
 import jalview.api.analysis.ScoreModelI;
 import jalview.bin.Cache;
 import jalview.commands.CommandI;
@@ -115,6 +116,7 @@ import java.beans.PropertyChangeEvent;
 import java.io.File;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.List;
@@ -5831,6 +5833,15 @@ this,
             .setShowAutocalculatedAbove(isShowAutoCalculatedAbove());
     alignPanel.paintAlignment(true);
   }
+
+  /**
+   * 
+   * @return alignment panels in this alignemnt frame
+   */
+  public List<AlignmentViewPanel> getAlignPanels()
+  {
+    return alignPanels == null ? Arrays.asList(alignPanel) : alignPanels;
+  }
 }
 
 class PrintThread extends Thread
index 5527f1e..2398bda 100644 (file)
@@ -1503,11 +1503,8 @@ public class AlignmentPanel extends GAlignmentPanel implements
     return av.getAlignment();
   }
 
-  /**
-   * get the name for this view
-   * 
-   * @return
-   */
+
+  @Override
   public String getViewName()
   {
     return av.viewName;
index 4359879..af00798 100644 (file)
@@ -522,7 +522,6 @@ public class StructureSelectionManager
     {
       return;
     }
-    boolean removeMapping = true;
     String[] handlepdbs;
     Vector pdbs = new Vector();
     for (int i = 0; i < pdbfiles.length; pdbs.addElement(pdbfiles[i++]))
index 6dfa729..75626e9 100644 (file)
@@ -20,7 +20,9 @@
  */
 package jalview.io;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import jalview.api.AlignmentViewPanel;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
@@ -45,7 +47,7 @@ public class Jalview2xmlTests
   public static void setUpBeforeClass() throws Exception
   {
     jalview.bin.Jalview.main(new String[]
-    { "-props", "test/src/jalview/io/testProps.jvprops" });
+    { "-props", "test/jalview/io/testProps.jvprops" });
   }
 
   /**
@@ -237,7 +239,8 @@ public class Jalview2xmlTests
   @Test
   public void gatherViewsHere() throws Exception
   {
-    int origCount = Desktop.getAlignframes().length;
+    int origCount = Desktop.getAlignframes() == null ? 0 : Desktop
+            .getAlignframes().length;
     AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
             "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
     assertTrue("Didn't read in the example file correctly.", af != null);
@@ -245,4 +248,62 @@ public class Jalview2xmlTests
             Desktop.getAlignframes().length == 1 + origCount);
 
   }
+
+  @Test
+  public void viewRefPdbAnnotation() throws Exception
+  {
+    AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
+            "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
+    assertTrue("Didn't read in the example file correctly.", af != null);
+    AlignmentViewPanel sps = null;
+    for (AlignmentViewPanel ap : af.alignPanel.alignFrame.getAlignPanels())
+    {
+      if ("Spinach Feredoxin Structure".equals(ap.getViewName()))
+      {
+        sps = ap;
+        break;
+      }
+    }
+    assertTrue("Couldn't find the structure view", sps != null);
+    SequenceI sq = sps.getAlignment().findName("1A70|");
+    AlignmentAnnotation refan = null;
+    for (AlignmentAnnotation ra:sps.getAlignment().getAlignmentAnnotation())
+    {
+      if (ra.graph != 0)
+      {
+        refan = ra;
+        break;
+      }
+    }
+    assertTrue("Annotation secondary structure not found.",refan!=null);
+    assertTrue("Couldn't find 1a70 null chain", sq != null);
+    // compare the manually added temperature factor annotation
+    // to the track automatically transferred from the pdb structure on load
+    for (AlignmentAnnotation ala : sq.getDatasetSequence().getAnnotation())
+    {
+      AlignmentAnnotation alaa;
+      sq.addAlignmentAnnotation(alaa = new AlignmentAnnotation(ala));
+      alaa.adjustForAlignment();
+      if (ala.graph == refan.graph)
+      {
+        for (int p = 0; p < ala.annotations.length; p++)
+        {
+          sq.findPosition(p);
+          try {
+            assertTrue(
+                    "Mismatch at alignment position " + p,
+                  (alaa.annotations[p] == null && refan.annotations[p] == null)
+                            || alaa.annotations[p].value == refan.annotations[p].value);
+          }
+          catch (NullPointerException q)
+          {
+            fail("Mismatch of alignment annotations at position " + p
+                    + " Ref seq ann: " + refan.annotations[p]
+                    + " alignment " + alaa.annotations[p]);
+          }
+          }
+      }
+    }
+    
+  }
 }
diff --git a/test/jalview/io/testProps.jvprops b/test/jalview/io/testProps.jvprops
new file mode 100644 (file)
index 0000000..d5a6c4c
--- /dev/null
@@ -0,0 +1,84 @@
+#---JalviewX Properties File---
+#Fri Apr 25 09:54:25 BST 2014
+SCREEN_Y=768
+SCREEN_X=936
+SHOW_WSDISCOVERY_ERRORS=true
+LATEST_VERSION=2.8.0b1
+SHOW_CONSERVATION=true
+JALVIEW_RSS_WINDOW_SCREEN_WIDTH=550
+JAVA_CONSOLE_SCREEN_WIDTH=450
+LAST_DIRECTORY=/Volumes/Data/Users/jimp/Documents/testing/Jalview/examples
+ID_ITALICS=true
+SORT_ALIGNMENT=No sort
+SHOW_IDENTITY=true
+WSMENU_BYHOST=false
+SEQUENCE_LINKS=EMBL-EBI Search|http\://www.ebi.ac.uk/ebisearch/search.ebi?db\=allebi&query\=$SEQUENCE_ID$
+SHOW_FULLSCREEN=false
+RECENT_URL=http\://www.jalview.org/examples/exampleFile_2_7.jar
+FONT_NAME=SansSerif
+BLC_JVSUFFIX=true
+VERSION_CHECK=false
+YEAR=2011
+SHOW_DBREFS_TOOLTIP=true
+MSF_JVSUFFIX=true
+SCREENGEOMETRY_HEIGHT=1600
+JAVA_CONSOLE_SCREEN_Y=475
+JAVA_CONSOLE_SCREEN_X=830
+PFAM_JVSUFFIX=true
+PIR_JVSUFFIX=true
+STARTUP_FILE=http\://www.jalview.org/examples/exampleFile_2_3.jar
+JAVA_CONSOLE_SCREEN_HEIGHT=162
+PIR_MODELLER=false
+GAP_SYMBOL=-
+SHOW_QUALITY=true
+SHOW_GROUP_CONSERVATION=false
+SHOW_JWS2_SERVICES=true
+SHOW_NPFEATS_TOOLTIP=true
+FONT_STYLE=plain
+ANTI_ALIAS=false
+SORT_BY_TREE=false
+RSBS_SERVICES=|Multi-Harmony|Analysis|Sequence Harmony and Multi-Relief (Brandt et al. 2010)|hseparable,gapCharacter\='-',returns\='ANNOTATION'|?tool\=jalview|http\://zeus.few.vu.nl/programs/shmrwww/index.php?tool\=jalview&groups\=$PARTITION\:min\='2',minsize\='2',sep\=' '$&ali_file\=$ALIGNMENT\:format\='FASTA',writeasfile$
+AUTHORFNAMES=Jim Procter, Andrew Waterhouse, Jan Engelhardt, Lauren Lui, Michele Clamp, James Cuff, Steve Searle, David Martin & Geoff Barton
+JALVIEW_RSS_WINDOW_SCREEN_HEIGHT=328
+SHOW_GROUP_CONSENSUS=false
+SHOW_CONSENSUS_HISTOGRAM=true
+SHOW_OVERVIEW=false
+AUTHORS=J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+FIGURE_AUTOIDWIDTH=false
+SCREEN_WIDTH=900
+ANNOTATIONCOLOUR_MIN=ffc800
+SHOW_STARTUP_FILE=false
+RECENT_FILE=examples/uniref50.fa\t/Volumes/Data/Users/jimp/Documents/testing/Jalview/examples/RF00031_folded.stk\t/Volumes/Data/Users/jimp/bs_ig_mult.out
+DEFAULT_FILE_FORMAT=FASTA
+SHOW_JAVA_CONSOLE=false
+VERSION=2.8b1
+FIGURE_USERIDWIDTH=
+WSMENU_BYTYPE=false
+DEFAULT_COLOUR=None
+NOQUESTIONNAIRES=true
+JALVIEW_NEWS_RSS_LASTMODIFIED=Apr 23, 2014 2\:53\:26 PM
+BUILD_DATE=01 November 2013
+PILEUP_JVSUFFIX=true
+SHOW_CONSENSUS_LOGO=false
+SCREENGEOMETRY_WIDTH=2560
+SHOW_ANNOTATIONS=true
+JALVIEW_RSS_WINDOW_SCREEN_Y=0
+USAGESTATS=false
+JALVIEW_RSS_WINDOW_SCREEN_X=0
+SHOW_UNCONSERVED=false
+SHOW_JVSUFFIX=true
+DAS_LOCAL_SOURCE=
+SCREEN_HEIGHT=650
+ANNOTATIONCOLOUR_MAX=ff0000
+AUTO_CALC_CONSENSUS=true
+FASTA_JVSUFFIX=true
+DAS_ACTIVE_SOURCE=uniprot\t
+JWS2HOSTURLS=http\://www.compbio.dundee.ac.uk/jabaws
+PAD_GAPS=false
+CLUSTAL_JVSUFFIX=true
+SHOW_ENFIN_SERVICES=true
+FONT_SIZE=10
+RIGHT_ALIGN_IDS=false
+USE_PROXY=false
+WRAP_ALIGNMENT=false
+DAS_REGISTRY_URL=http\://www.dasregistry.org/das/