basic VamsasSession gui bits.
authorjprocter <Jim Procter>
Sat, 25 Mar 2006 16:33:09 +0000 (16:33 +0000)
committerjprocter <Jim Procter>
Sat, 25 Mar 2006 16:33:09 +0000 (16:33 +0000)
build.xml
src/jalview/gui/Desktop.java
src/jalview/io/VamsasClient.java [new file with mode: 0755]
src/jalview/io/VamsasDatastore.java [new file with mode: 0755]
src/jalview/jbgui/GDesktop.java

index ae21307..189260f 100755 (executable)
--- a/build.xml
+++ b/build.xml
           <include name="*.jar"/>
           <include name="**/*.jar"/>
         </fileset>
+               <fileset dir="../VamsasClient/packages">
+                       <include name="*.jar"/>
+                               <include name="**/*.jar"/>
+               </fileset>
 <!--        <fileset dir="old_lib_signed">
 <include name="lib_axis.jar"/>
 
         <fileset dir="${resourceDir}">
           <include name="**/*.*"/>
         </fileset>
+       <fileset dir="../VamsasClient/packages/">
+         <include name="**/*.jar"/>
+       </fileset>
       </copy>
     </target>
 
index 9085b1e..3bc2613 100755 (executable)
@@ -27,6 +27,8 @@ import java.awt.event.*;
 \r
 import javax.swing.*;\r
 \r
+import org.vamsas.test.simpleclient.ArchiveClient;\r
+\r
 \r
 /**\r
  * DOCUMENT ME!\r
@@ -576,32 +578,47 @@ public class Desktop extends jalview.jbgui.GDesktop
             Jalview2XML.LoadJalviewAlign(choice);\r
         }\r
     }\r
-\r
-  /*  public void vamsasLoad_actionPerformed(ActionEvent e)\r
+    jalview.io.VamsasClient v_client=null;\r
+    public void vamsasLoad_actionPerformed(ActionEvent e)\r
     {\r
-      JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.\r
-          getProperty("LAST_DIRECTORY"));\r
+      if (v_client==null) {\r
+        // Start a session.\r
+        JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.\r
+            getProperty("LAST_DIRECTORY"));\r
 \r
-      chooser.setFileView(new JalviewFileView());\r
-      chooser.setDialogTitle("Load Vamsas file");\r
-      chooser.setToolTipText("Import");\r
+        chooser.setFileView(new JalviewFileView());\r
+        chooser.setDialogTitle("Load Vamsas file");\r
+        chooser.setToolTipText("Import");\r
 \r
-      int value = chooser.showOpenDialog(this);\r
+        int value = chooser.showOpenDialog(this);\r
 \r
-      if (value == JalviewFileChooser.APPROVE_OPTION)\r
-      {\r
-        jalview.io.VamsasDatastore vs = new jalview.io.VamsasDatastore(null);\r
-        vs.load(\r
-            chooser.getSelectedFile().getAbsolutePath()\r
-            );\r
+        if (value == JalviewFileChooser.APPROVE_OPTION)\r
+        {\r
+          v_client = new jalview.io.VamsasClient(this,\r
+              chooser.getSelectedFile().getAbsolutePath()\r
+              );\r
+          this.vamsasLoad.setText("Session Update");\r
+          this.vamsasStop.setVisible(true);\r
+          v_client.initial_update();\r
+        }\r
+      } else {\r
+        // store current data in session.\r
+         v_client.push_update();\r
       }\r
-\r
-    }*/\r
-\r
-\r
+    }\r
+    public void vamsasStop_actionPerformed(ActionEvent e) {\r
+       if (v_client!=null) {\r
+               v_client.end_session();\r
+               v_client=null;\r
+               this.vamsasStop.setVisible(false);\r
+               this.vamsasLoad.setText("Start Vamsas Session...");\r
+       }\r
+    }\r
+    \r
     public void inputSequence_actionPerformed(ActionEvent e)\r
     {\r
       SequenceFetcher sf = new SequenceFetcher(null);\r
     }\r
+\r
 }\r
 \r
diff --git a/src/jalview/io/VamsasClient.java b/src/jalview/io/VamsasClient.java
new file mode 100755 (executable)
index 0000000..ca62b09
--- /dev/null
@@ -0,0 +1,67 @@
+/**
+ * 
+ */
+package jalview.io;
+
+import jalview.bin.Cache;
+import jalview.gui.Desktop;
+
+import org.vamsas.client.UserHandle;
+import org.vamsas.client.simpleclient.FileWatcher;
+import org.vamsas.client.simpleclient.VamsasArchive;
+import org.vamsas.client.simpleclient.VamsasFile;
+import org.vamsas.test.simpleclient.ArchiveClient;
+
+/**
+ * @author jimp
+ *
+ */
+public class VamsasClient extends ArchiveClient {
+       Desktop us;
+       public VamsasClient(Desktop jdesktop,
+                       String sessionPath) {
+               super("Jalview User", "Dundee", // new org.vamsas.client.ClientHandle("jalview","2.7"),
+                               sessionPath);
+               us=jdesktop;
+       }
+       public void initial_update() {
+               Cache.log.info("Jalview loading the Vamsas Session.");
+               // load in the vamsas archive for the first time
+               
+               // VamsasArchive doc = new VamsasArchive();
+       }
+       public void get_update(VamsasArchive doc) {
+               Cache.log.info("Jalview updating from Vamsas Session.");
+       }
+       public void push_update() {
+               // collect all uncached alignments and put them into the vamsas dataset.
+               // store them.
+               Cache.log.info("Jalview updating the Vamsas Session.");
+       }
+       public void end_session() {
+               // stop any update/watcher thread.
+               Cache.log.info("Jalview disconnecting from the Vamsas Session.");
+       }
+       protected class VamsasClientWatcher extends Thread implements Runnable {
+               /* (non-Javadoc)
+                * @see java.lang.Thread#run()
+                */
+               VamsasClient client=null;
+               VamsasClientWatcher(VamsasClient client) {
+                       this.client = client;
+               }
+               public void run() {
+                       VamsasArchive docio = client.watch(0);
+                       client.get_update(docio);
+               }
+               
+       }
+       /**
+        * @param args
+        */
+       public static void main(String[] args) {
+               // TODO Auto-generated method stub
+
+       }
+
+}
diff --git a/src/jalview/io/VamsasDatastore.java b/src/jalview/io/VamsasDatastore.java
new file mode 100755 (executable)
index 0000000..6b793c6
--- /dev/null
@@ -0,0 +1,578 @@
+/*\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
+ */\r
+\r
+package jalview.io;\r
+\r
+import org.vamsas.objects.core.*;\r
+\r
+import jalview.gui.*;\r
+import java.io.*;\r
+import java.util.jar.*;\r
+import org.exolab.castor.xml.*;\r
+import org.exolab.castor.mapping.Mapping;\r
+\r
+/*\r
+\r
+ static {\r
+ org.exolab.castor.util.LocalConfiguration.getInstance().getProperties().setProperty(\r
+ "org.exolab.castor.serializer", "org.apache.xml.serialize.XMLSerilazizer");\r
+ }\r
+\r
+*/\r
+\r
+public class VamsasDatastore\r
+{\r
+       AlignViewport av;\r
+        org.exolab.castor.types.Date date\r
+              = new org.exolab.castor.types.Date(new java.util.Date());\r
+\r
+       public VamsasDatastore(AlignViewport av)\r
+       {\r
+               this.av = av;\r
+       }\r
+\r
+        public void store(String file)\r
+        {\r
+          storeVAMSAS(file);\r
+        }\r
+\r
+        public void storeJalview(String file, AlignFrame af)\r
+        {\r
+          try\r
+          {\r
+            // 1. Load the mapping information from the file\r
+            Mapping map = new Mapping(getClass().getClassLoader());\r
+            java.net.URL url = getClass().getResource("/jalview_mapping.xml");\r
+            map.loadMapping(url);\r
+\r
+            // 2. Unmarshal the data\r
+            // Unmarshaller unmar = new Unmarshaller();\r
+            //unmar.setIgnoreExtraElements(true);\r
+            //unmar.setMapping(map);\r
+            // uni = (UniprotFile) unmar.unmarshal(new FileReader(file));\r
+\r
+            // 3. marshal the data with the total price back and print the XML in the console\r
+              Marshaller marshaller = new Marshaller( new FileWriter(file) );\r
+\r
+             marshaller.setMapping(map);\r
+             marshaller.marshal(af);\r
+          }\r
+          catch (Exception e)\r
+          {\r
+            e.printStackTrace();\r
+          }\r
+        }\r
+\r
+\r
+\r
+        public VAMSAS storeVAMSAS(String file)\r
+        {\r
+          long time = System.currentTimeMillis();\r
+          VAMSAS vamsas = new VAMSAS();\r
+\r
+          try\r
+          {\r
+            FileOutputStream fos = new FileOutputStream(file);\r
+            JarOutputStream jout = new JarOutputStream(fos);\r
+\r
+\r
+            ////////////////////////////////////////////////////\r
+            //NOTE UTF-8 MUST BE USED FOR WRITING UNICODE CHARS\r
+            PrintWriter out = new PrintWriter(new OutputStreamWriter(jout,\r
+                "UTF-8"));\r
+\r
+            jalview.datamodel.AlignmentI jal = av.getAlignment();\r
+\r
+\r
+            ///////////////////////////////////////////\r
+            // SAVE THE DATASET\r
+            DataSet dataset = new DataSet();\r
+            vamsas.addDataSet(dataset);\r
+\r
+            Sequence sequence;\r
+            DbRef dbref;\r
+            for (int i = 0; i < jal.getHeight(); i++)\r
+            {\r
+              sequence = new Sequence();\r
+              sequence.setSequence(jal.getDataset().getSequenceAt(i).getSequence());\r
+              sequence.setName(jal.getDataset().getSequenceAt(i).getName());\r
+              sequence.setStart(jal.getDataset().getSequenceAt(i).getStart());\r
+              sequence.setEnd(jal.getDataset().getSequenceAt(i).getEnd());\r
+\r
+\r
+              if(jal.getDataset().getSequenceAt(i).getSequenceFeatures()!=null)\r
+              {\r
+                int sfSize = jal.getDataset().getSequenceAt(i).getSequenceFeatures().length;\r
+\r
+                for (int sf = 0; sf < sfSize; sf++)\r
+                {\r
+                  jalview.datamodel.SequenceFeature feature =\r
+                      (jalview.datamodel.SequenceFeature)\r
+                      jal.getDataset().getSequenceAt(i).getSequenceFeatures()[sf];\r
+\r
+                  DataSetAnnotations dsa = new DataSetAnnotations();\r
+                  dsa.setType(feature.getType());\r
+                  dsa.setBegin(feature.getBegin());\r
+                  dsa.setEnd(feature.getEnd());\r
+                  dsa.setDescription(feature.getDescription());\r
+                  dsa.setStatus(feature.getStatus());\r
+                  dsa.addProvenance(dummyProvenance());\r
+                  dsa.setSeqRef(sequence);\r
+                  dsa.setId("sf"+(time++));\r
+                  dataset.addDataSetAnnotations(dsa);\r
+                }\r
+              }\r
+\r
+              if(jal.getDataset().getSequenceAt(i).getDBRef()!=null)\r
+              {\r
+                java.util.Vector entries = jal.getDataset().getSequenceAt(i).getDBRef();\r
+                jalview.datamodel.DBRefEntry dbentry;\r
+                for(int db=0; db<entries.size(); db++)\r
+                {\r
+                  dbentry = (jalview.datamodel.DBRefEntry)entries.elementAt(db);\r
+                  dbref = new DbRef();\r
+                  dbref.setAccessionId( dbentry.getAccessionId() );\r
+                  dbref.setSource( dbentry.getSource() );\r
+                  dbref.setVersion( dbentry.getVersion() );\r
+                  dbref.setId("db"+(time++));\r
+                  sequence.addDbRef(dbref);\r
+                }\r
+\r
+              }\r
+\r
+\r
+              if(jal.getDataset().getSequenceAt(i).getVamsasId()==null)\r
+                sequence.setId("ds" + (time++));\r
+              else\r
+                sequence.setId(jal.getDataset().getSequenceAt(i).getVamsasId());\r
+\r
+              dataset.addSequence(sequence);\r
+            }\r
+            // dataset.setProvenance(getVamsasProvenance(jal.getDataset().getProvenance()));\r
+            //////////////////////////////////////////////\r
+\r
+\r
+            //////////////////////////////////////////////\r
+            //Save the Alignments\r
+            Alignment alignment = new Alignment();\r
+            alignment.setGapChar(av.getGapCharacter() + "");\r
+            AlignmentSequence alseq = null;\r
+            for (int i = 0; i < jal.getHeight(); i++)\r
+            {\r
+              alseq = new AlignmentSequence();\r
+              alseq.setSequence(\r
+                  jal.getSequenceAt(i).getSequence()\r
+                  );\r
+              alseq.setName(jal.getSequenceAt(i).getName());\r
+              alseq.setStart(jal.getSequenceAt(i).getStart());\r
+              alseq.setEnd(jal.getSequenceAt(i).getEnd());\r
+              alseq.setRefid(dataset.getSequence(i));\r
+              alseq.setId("as" + (time++));\r
+              alignment.addAlignmentSequence(alseq);\r
+            }\r
+            // alignment.setProvenance(getVamsasProvenance(jal.getProvenance()));\r
+            dataset.addAlignment(alignment);\r
+            //////////////////////////////////////////////\r
+\r
+\r
+\r
+            //////////////////////////////////////////////\r
+            //SAVE ANNOTATIONS\r
+            if (jal.getAlignmentAnnotation() != null)\r
+            {\r
+                jalview.datamodel.AlignmentAnnotation[] aa = jal.getAlignmentAnnotation();\r
+\r
+                for (int i = 0; i < aa.length; i++)\r
+                {\r
+                    if (aa[i].label.equals("Quality") ||\r
+                            aa[i].label.equals("Conservation") ||\r
+                            aa[i].label.equals("Consensus"))\r
+                    {\r
+                        continue;\r
+                    }\r
+\r
+                    AlignmentAnnotations an = new AlignmentAnnotations();\r
+\r
+                    an.setDescription(aa[i].description);\r
+                    // JBPNote - have to deal with the many lines for one graph thing\r
+                    if (aa[i].graph>0)\r
+                       an.setGraph(true); //aa[i].graph);\r
+                    // JBPNote - store graphGroup in the Jalview specific bits.\r
+                    an.setLabel(aa[i].label);\r
+                    an.setProvenance(dummyProvenance());\r
+\r
+                    AnnotationElement ae;\r
+\r
+                    for (int a = 0; a < aa[i].annotations.length; a++)\r
+                    {\r
+                        if ((aa[i] == null) || (aa[i].annotations[a] == null))\r
+                        {\r
+                            continue;\r
+                        }\r
+\r
+                        ae = new AnnotationElement();\r
+                        ae.setDescription(aa[i].annotations[a].description);\r
+                        ae.setDisplayCharacter(aa[i].annotations[a].displayCharacter);\r
+                        ae.setValue(aa[i].annotations[a].value);\r
+                        ae.setPosition(a);\r
+                        ae.setSecondaryStructure(aa[i].annotations[a].secondaryStructure +\r
+                            "");\r
+                        an.addAnnotationElement(ae);\r
+                    }\r
+\r
+                    alignment.addAlignmentAnnotations(an);\r
+                }\r
+            }\r
+            ///////////////////////////////////////////////////////\r
+\r
+\r
+          ////////////////////////////////////////////////\r
+          ///SAVE THE TREES\r
+          ///////////////////////////////////\r
+          // FIND ANY ASSOCIATED TREES\r
+          if (Desktop.desktop != null)\r
+          {\r
+            javax.swing.JInternalFrame[] frames = Desktop.desktop.getAllFrames();\r
+\r
+            for (int t = 0; t < frames.length; t++)\r
+            {\r
+              if (frames[t] instanceof TreePanel)\r
+              {\r
+                TreePanel tp = (TreePanel) frames[t];\r
+\r
+                if (tp.getAlignment() == jal)\r
+                {\r
+                  Tree tree = new Tree();\r
+                  tree.setTitle(tp.getTitle());\r
+                  Newick newick = new Newick();\r
+                  newick.setContent( tp.getTree().toString() );\r
+                  newick.setTitle( tp.getTitle() );\r
+                  newick.setId("t"+(time++));\r
+                  tree.addNewick( newick );\r
+                  tree.setProvenance(dummyProvenance());\r
+                  alignment.addTree(tree);\r
+                }\r
+              }\r
+            }\r
+          }\r
+\r
+\r
+            JarEntry entry = new JarEntry("vamsas.xml");\r
+            jout.putNextEntry(entry);\r
+\r
+            vamsas.marshal(out);\r
+\r
+            out.close();\r
+            jout.close();\r
+\r
+\r
+          }\r
+          catch (Exception ex)\r
+          {\r
+            ex.printStackTrace();\r
+          }\r
+\r
+          return vamsas;\r
+       }\r
+\r
+        Tree jalview2VamsasTree()\r
+        {\r
+          Tree tree = new Tree();\r
+\r
+          return tree;\r
+        }\r
+\r
+\r
+       public void load(String file)\r
+       {\r
+          VAMSAS vamsas = new VAMSAS() ;\r
+\r
+          try\r
+          {\r
+            FileInputStream fis = new FileInputStream(file);\r
+            JarInputStream jin = new JarInputStream(fis);\r
+\r
+\r
+            ////////////////////////////////////////////////////\r
+            //NOTE UTF-8 MUST BE USED FOR WRITING UNICODE CHARS\r
+            InputStreamReader in = new InputStreamReader(jin, "UTF-8");\r
+            JarEntry jarentry = jin.getNextJarEntry();\r
+            System.out.println("reading: "+jarentry.getName());\r
+            vamsas = (VAMSAS) vamsas.unmarshal(in);\r
+\r
+\r
+            /////////////////////////////////////\r
+            /////LOAD DATASET\r
+            DataSet dataset = vamsas.getDataSet(0);\r
+\r
+            int i, iSize = dataset.getSequenceCount();\r
+            jalview.datamodel.Sequence [] seqs = new jalview.datamodel.Sequence[iSize];\r
+            DbRef [] dbref;\r
+\r
+            for (i = 0; i < iSize ; i++)\r
+            {\r
+              seqs[i] = new jalview.datamodel.Sequence(\r
+                  dataset.getSequence(i).getName(),\r
+                  dataset.getSequence(i).getSequence(),\r
+                   dataset.getSequence(i).getStart(),\r
+                     dataset.getSequence(i).getEnd()  );\r
+              seqs[i].setVamsasId(dataset.getSequence(i).getId());\r
+\r
+              if (dataset.getDataSetAnnotations() != null)\r
+              {\r
+                for (int dsa = 0; dsa < dataset.getDataSetAnnotationsCount(); dsa++)\r
+                {\r
+                  if (dataset.getDataSetAnnotations(dsa).getSeqRef() ==\r
+                      dataset.getSequence(i))\r
+                  {\r
+                    seqs[i].addSequenceFeature(new jalview.datamodel.\r
+                                               SequenceFeature(\r
+                        dataset.getDataSetAnnotations(dsa).getType(),\r
+                        dataset.getDataSetAnnotations(dsa).getDescription(),\r
+                        dataset.getDataSetAnnotations(dsa).getStatus(),\r
+                        dataset.getDataSetAnnotations(dsa).getBegin(),\r
+                        dataset.getDataSetAnnotations(dsa).getEnd(),\r
+                        "vamsas"));\r
+                  }\r
+                }\r
+              }\r
+              dbref = dataset.getSequence(i).getDbRef();\r
+\r
+              if(dbref.length>0)\r
+              {\r
+                for(int db=0; db<dbref.length; db++)\r
+                {\r
+                  seqs[i].addDBRef( new jalview.datamodel.DBRefEntry\r
+                      (\r
+                           dbref[db].getSource().toString(),\r
+                           dbref[db].getVersion().toString(),\r
+                           dbref[db].getAccessionId().toString()));\r
+                }\r
+              }\r
+            }\r
+            jalview.datamodel.Alignment jdataset = new jalview.datamodel.Alignment(seqs);\r
+            ////////////////////////////////////////////////\r
+\r
+\r
+            //////////////////////////////////////\r
+            ////LOAD ALIGNMENT\r
+            Alignment alignment = dataset.getAlignment(0);\r
+            iSize = alignment.getAlignmentSequenceCount();\r
+            seqs = new jalview.datamodel.Sequence[iSize];\r
+            String id;\r
+            int j, jSize = jdataset.getHeight();\r
+            for (i = 0; i < iSize; i++)\r
+            {\r
+              seqs[i] = new jalview.datamodel.Sequence(\r
+                  alignment.getAlignmentSequence(i).getName(),\r
+                  alignment.getAlignmentSequence(i).getSequence(),\r
+                  alignment.getAlignmentSequence(i).getStart(),\r
+                  alignment.getAlignmentSequence(i).getEnd());\r
+\r
+              id = ( (Sequence) alignment.getAlignmentSequence(i).getRefid()).getId();\r
+\r
+             for(j=0; j<jSize; j++)\r
+             {\r
+               if(jdataset.getSequenceAt(j).getVamsasId().equals(id))\r
+               {\r
+                 seqs[i].setDatasetSequence( jdataset.getSequenceAt(j) );\r
+                 break;\r
+               }\r
+             }\r
+            }\r
+            jalview.datamodel.Alignment jal = new jalview.datamodel.Alignment(seqs);\r
+            jal.setDataset(jdataset);\r
+            /*jal.getDataset().setProvenance(\r
+                getJalviewProvenance(dataset.getProvenance()));\r
+            jal.setProvenance(\r
+                getJalviewProvenance(alignment.getProvenance()));\r
+            */\r
+             //////////////////////////////////////////////\r
+\r
+\r
+            ////////////////////////////////////////////\r
+            ////LOAD ANNOTATIONS\r
+            ////////////////////\r
+            if (alignment.getAlignmentAnnotationsCount()>0)\r
+            {\r
+              AlignmentAnnotations[] an = alignment.getAlignmentAnnotations();\r
+\r
+              for (j = 0; j < an.length; j++)\r
+              {\r
+                boolean topaliBreakpoint = false;\r
+\r
+                AnnotationElement[] ae = an[j].getAnnotationElement();\r
+                jalview.datamodel.Annotation[] anot = new jalview.datamodel.Annotation[jal.\r
+                    getWidth()];\r
+\r
+                try{\r
+\r
+                  for (int aa = 0; aa < ae.length; aa++)\r
+                  {\r
+                    String dc = ae[aa].getDisplayCharacter()==null ? "dc" : ae[aa].getDisplayCharacter();\r
+                    String desc = ae[aa].getDescription()==null ? "desc" : ae[aa].getDescription();\r
+                    String ss = ae[aa].getSecondaryStructure()==null ? "ss" : ae[aa].getSecondaryStructure();\r
+                    float value = ae[aa].getValue();\r
+\r
+                    if(an[j].getGraph())\r
+                    {\r
+                      dc = value+"";\r
+                      desc = value + "";\r
+                    }\r
+                    anot[ae[aa].getPosition()-1] = new jalview.datamodel.\r
+                        Annotation(dc,desc,ss.charAt(0),value);\r
+\r
+                    if(desc.equals("TOPALi Partition Breakpoint"))\r
+                      topaliBreakpoint = true;\r
+\r
+                  }\r
+                }catch(Exception ex)\r
+                {\r
+                  ex.printStackTrace();\r
+                  System.out.println("problem parsing annotations\n"+ex);}\r
+\r
+                jalview.datamodel.AlignmentAnnotation jaa = null;\r
+\r
+                if (an[j].getGraph())\r
+                {\r
+                  jaa = new jalview.datamodel.AlignmentAnnotation(an[j].getLabel(),\r
+                      an[j].getDescription(), anot, 0, 0, 1);\r
+                }\r
+                else\r
+                {\r
+                  String label = an[j].getLabel();\r
+                  if(topaliBreakpoint)\r
+                    label = "TOPALi Partition Breakpoint";\r
+                  jaa = new jalview.datamodel.AlignmentAnnotation(label,\r
+                      an[j].getDescription(), anot);\r
+                }\r
+\r
+                jal.addAnnotation(jaa);\r
+              }\r
+            }\r
+            /////////////////////////////////\r
+\r
+            AlignFrame alignFrame = new AlignFrame(jal);\r
+            jalview.gui.Desktop.addInternalFrame(alignFrame, "VAMSAS LOAD",\r
+                                                 AlignFrame.NEW_WINDOW_WIDTH,\r
+                                                 AlignFrame.NEW_WINDOW_HEIGHT);\r
+\r
+            //LOAD TREES\r
+            ///////////////////////////////////////\r
+            if (alignment.getTreeCount() > 0)\r
+            {\r
+                for (int t = 0; t < alignment.getTreeCount(); t++)\r
+                {\r
+                  Tree tree = alignment.getTree(t);\r
+\r
+                  alignFrame.ShowNewickTree(\r
+                      new jalview.io.NewickFile(tree.getNewick(0).getContent()),\r
+                      tree.getNewick(0).getTitle(),\r
+                      600, 500,\r
+                      t * 20 + 50, t * 20 + 50);\r
+                }\r
+            }\r
+\r
+\r
+            in.close();\r
+            jin.close();\r
+          }\r
+          catch (Exception ex)\r
+          {\r
+            ex.printStackTrace();\r
+          }\r
+\r
+\r
+       }\r
+\r
+\r
+\r
+        Provenance getVamsasProvenance(jalview.datamodel.Provenance jprov)\r
+        {\r
+          jalview.datamodel.ProvenanceEntry [] entries = null;\r
+\r
+\r
+          Provenance prov = new Provenance();\r
+          org.exolab.castor.types.Date date = new org.exolab.castor.types.Date(\r
+      new java.util.Date());\r
+          Entry provEntry;\r
+\r
+          if(jprov!=null)\r
+          {\r
+            entries = jprov.getEntries();\r
+            for (int i = 0; i < entries.length; i++)\r
+            {\r
+              provEntry = new Entry();\r
+              try\r
+              {\r
+                date = new org.exolab.castor.types.Date(entries[i].getDate());\r
+              }\r
+              catch (Exception ex)\r
+              {\r
+                ex.printStackTrace();\r
+\r
+                date = new org.exolab.castor.types.Date(entries[i].getDate());\r
+              }\r
+              provEntry.setDate(date);\r
+              provEntry.setUser(entries[i].getUser());\r
+              provEntry.setAction(entries[i].getAction());\r
+              prov.addEntry(provEntry);\r
+            }\r
+          }\r
+          else\r
+          {\r
+            provEntry = new Entry();\r
+            provEntry.setDate(date);\r
+            provEntry.setUser(System.getProperty("user.name"));\r
+            provEntry.setAction("Jalview");\r
+            prov.addEntry(provEntry);\r
+          }\r
+\r
+          return prov;\r
+        }\r
+\r
+        jalview.datamodel.Provenance getJalviewProvenance(Provenance prov)\r
+        {\r
+\r
+          jalview.datamodel.Provenance jprov = new jalview.datamodel.Provenance();\r
+          for (int i = 0; i < prov.getEntryCount(); i++)\r
+          {\r
+            jprov.addEntry(\r
+                prov.getEntry(i).getUser(),\r
+                prov.getEntry(i).getAction(),\r
+                prov.getEntry(i).getDate().toDate(),\r
+                prov.getEntry(i).getId()\r
+                );\r
+          }\r
+\r
+          return jprov;\r
+        }\r
+\r
+        Provenance dummyProvenance()\r
+        {\r
+          Provenance prov = new Provenance();\r
+          Entry entry = new Entry();\r
+          entry.setAction("Jalview");\r
+          entry.setDate(new org.exolab.castor.types.Date(new java.util.Date()));\r
+          entry.setUser(System.getProperty("user.name"));\r
+          prov.addEntry(entry);\r
+          return prov;\r
+        }\r
+\r
+}\r
index 63f1836..4ecf779 100755 (executable)
@@ -48,8 +48,9 @@ public class GDesktop extends JFrame
     JMenuItem saveState = new JMenuItem();\r
     JMenuItem loadState = new JMenuItem();\r
     JMenu jMenu1 = new JMenu();\r
-  JMenuItem vamsasLoad = new JMenuItem();\r
+  protected JMenuItem vamsasLoad = new JMenuItem();\r
   JMenuItem inputSequence = new JMenuItem();\r
+  protected JMenuItem vamsasStop = new JMenuItem();\r
 \r
   /**\r
      * Creates a new GDesktop object.\r
@@ -160,8 +161,8 @@ public class GDesktop extends JFrame
             });\r
         jMenu1.setMnemonic('I');\r
         jMenu1.setText("Input Alignment");\r
-    vamsasLoad.setText("Vamsas");\r
-    vamsasLoad.setVisible(false);\r
+    vamsasLoad.setText("Start Vamsas Session...");\r
+    vamsasLoad.setVisible(true);\r
     vamsasLoad.addActionListener(new ActionListener()\r
     {\r
       public void actionPerformed(ActionEvent e)\r
@@ -177,7 +178,15 @@ public class GDesktop extends JFrame
         inputSequence_actionPerformed(e);\r
       }\r
     });\r
-    DesktopMenubar.add(FileMenu);\r
+    vamsasStop.setText("Stop Vamsas Session");\r
+    vamsasStop.setVisible(false);\r
+    vamsasStop.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        vamsasStop_actionPerformed(e);\r
+      }\r
+    });    DesktopMenubar.add(FileMenu);\r
         DesktopMenubar.add(toolsMenu);\r
         DesktopMenubar.add(HelpMenu);\r
         DesktopMenubar.add(windowMenu);\r
@@ -188,15 +197,17 @@ public class GDesktop extends JFrame
         FileMenu.add(saveState);\r
         FileMenu.add(loadState);\r
         FileMenu.addSeparator();\r
-        FileMenu.add(quit);\r
+        FileMenu.add(vamsasLoad);\r
+        FileMenu.add(vamsasStop);\r
+    FileMenu.addSeparator();\r
+    FileMenu.add(quit);\r
         HelpMenu.add(aboutMenuItem);\r
         HelpMenu.add(documentationMenuItem);\r
         toolsMenu.add(preferences);\r
         jMenu1.add(inputLocalFileMenuItem);\r
         jMenu1.add(inputURLMenuItem);\r
         jMenu1.add(inputTextboxMenuItem);\r
-    jMenu1.add(vamsasLoad);\r
-  }\r
+      }\r
 \r
     /**\r
      * DOCUMENT ME!\r
@@ -304,4 +315,8 @@ public class GDesktop extends JFrame
   {\r
 \r
   }\r
+  public void vamsasStop_actionPerformed(ActionEvent e)\r
+  {\r
+\r
+  }\r
 }\r