upgrade vamsas client to 0.1 (selections)
authorjprocter <Jim Procter>
Tue, 2 Jun 2009 09:25:51 +0000 (09:25 +0000)
committerjprocter <Jim Procter>
Tue, 2 Jun 2009 09:25:51 +0000 (09:25 +0000)
lib/vamsas-client.jar
src/jalview/gui/VamsasApplication.java
src/jalview/io/vamsas/Sequencemapping.java

index f34a1fc..c9edbcb 100644 (file)
Binary files a/lib/vamsas-client.jar and b/lib/vamsas-client.jar differ
index 5988bb8..c52ca9f 100644 (file)
@@ -45,6 +45,7 @@ import uk.ac.vamsas.client.picking.IMessageHandler;
 import uk.ac.vamsas.client.picking.IPickManager;
 import uk.ac.vamsas.client.picking.Message;
 import uk.ac.vamsas.client.picking.MouseOverMessage;
+import uk.ac.vamsas.client.picking.SelectionMessage;
 import uk.ac.vamsas.objects.core.Entry;
 
 /**
@@ -569,7 +570,12 @@ public class VamsasApplication
 
           public void handleMessage(Message message)
           {
-            if (message instanceof MouseOverMessage && vobj2jv != null)
+            if (vobj2jv==null)
+            {
+              // we are not in a session yet.
+              return;
+            }
+            if (message instanceof MouseOverMessage)
             {
               MouseOverMessage mm = (MouseOverMessage) message;
               String mstring = mm.getVorbaID() + " " + mm.getPosition();
@@ -593,6 +599,63 @@ public class VamsasApplication
                         .getPosition());
               }
             }
+            if (message instanceof uk.ac.vamsas.client.picking.SelectionMessage)
+            {
+              // we only care about AlignmentSequence selections
+              SelectionMessage sm = (SelectionMessage) message;
+              
+              Object[] jvobjs = new Object[sm.getVorbaIDs().length];
+              Class type = null;
+              for (int o=0;o<jvobjs.length; o++)
+              {
+                jvobjs[o] = vobj2jv.get(sm.getVorbaIDs()[o]);
+                if (jvobjs[o]==null)
+                {
+                  // can't cope with selections for unmapped objects
+                  continue;
+                }
+                if (type==null){ type = jvobjs[o].getClass(); };
+                if (type != jvobjs[o].getClass())
+                {
+                  // discard - can't cope with selections over mixed objects
+                  continue;
+                }
+              }
+              if (type == jalview.datamodel.Alignment.class)
+              {
+                if (jvobjs.length==1) {
+                  // othewise discard - can't cope with multiple alignment selections (at the moment) ?
+                  ;
+                }
+                // send a message to select the specified columns over the given alignment
+              }
+              if (type == jalview.datamodel.Sequence.class)
+              {
+                boolean aligned = ((jalview.datamodel.Sequence)jvobjs[0]).getDatasetSequence()==null;
+                for (int c=0; jvobjs.length>1 && c<jvobjs.length; c++)
+                {
+                  if (((jalview.datamodel.Sequence) jvobjs[c]).getDatasetSequence()==null)
+                  {
+                    aligned=false;
+                    continue;
+                  }
+                }
+                if (!aligned)
+                {
+                  // if cardinality is greater than one then verify all sequences are alignment sequences.
+                  if (jvobjs.length==1)
+                  {
+                    // find all instances of this dataset sequence in the displayed alignments containing the associated range and select them. 
+                  } 
+                } else {
+                  // locate the alignment containing the given sequences and select the associated ranges on them. 
+                }
+              }
+              // discard message.
+              for (int c=0;c<jvobjs.length;c++) { jvobjs[c] = null;};
+              jvobjs=null;
+              return;
+            }
           }
         });
         picker = new VamsasListener()
@@ -610,8 +673,8 @@ public class VamsasApplication
               VorbaId v = (VorbaId) jv2vobj.get(seq);
               if (v != null)
               {
-                Cache.log.debug("Mouse over " + v.getId() + " bound to "
-                        + seq + " at " + index);
+                //Cache.log.debug("Mouse over " + v.getId() + " bound to "
+                //        + seq + " at " + index);
                 last = seq;
                 i = index;
                 MouseOverMessage message = new MouseOverMessage(v.getId(),
index de4a01e..08bb669 100644 (file)
@@ -186,7 +186,7 @@ public class Sequencemapping extends Rangetype
     // source
     // of
     // mapping
-    bindjvvobj(mjvmapping, sequenceMapping);
+    bindjvvobj(mjvmapping.getMap(), sequenceMapping);
 
     jalview.bin.Cache.log.debug("Successfully created mapping "
             + sequenceMapping.getVorbaId());