From: jprocter Date: Mon, 27 Mar 2006 17:42:19 +0000 (+0000) Subject: part finished (still finishing the updateJalview method of VamsasDatastore) X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=072fc418c393cbd2a40dfa1d3e46f90178b79572;p=jalview.git part finished (still finishing the updateJalview method of VamsasDatastore) --- diff --git a/src/jalview/gui/VamsasClient.java b/src/jalview/gui/VamsasClient.java index 8d635a3..76e9599 100755 --- a/src/jalview/gui/VamsasClient.java +++ b/src/jalview/gui/VamsasClient.java @@ -8,6 +8,7 @@ import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Hashtable; +import java.util.IdentityHashMap; import java.util.Vector; import java.util.jar.JarOutputStream; @@ -42,9 +43,33 @@ public class VamsasClient extends ArchiveClient { Cache.log.info("Jalview loading the Vamsas Session."); // load in the vamsas archive for the first time ClientDoc cdoc = this.getUpdateable(); + updateJalview(cdoc); + + } + /** + * this will close all windows currently in Jalview. + * + */ + protected void closeWindows() { + JInternalFrame[] frames = Desktop.desktop.getAllFrames(); + + if (frames == null) + { + return; + } + + try + { + for (int i = frames.length - 1; i > -1; i--) { + frames[i].dispose(); + } + } catch (Exception e) { + Cache.log.error("Whilst closing windows",e); + } } public void get_update(VamsasArchive doc) { + // Close windows - load update. Cache.log.info("Jalview updating from Vamsas Session."); } public void push_update() { @@ -56,10 +81,22 @@ public class VamsasClient extends ArchiveClient { // stop any update/watcher thread. Cache.log.info("Jalview disconnecting from the Vamsas Session."); } - java.util.Hashtable jv2vobj = null; + public void updateJalview(ClientDoc cdoc) { + + } + protected void _updateAlignFrame(ClientDoc cdoc, AlignFrame av) { + + } + /** + * jalview object binding to VorbaIds + */ + IdentityHashMap jv2vobj = null; + Hashtable vobj2jv = null; public void updateVamsasDocument(ClientDoc doc) { - if (jv2vobj==null) - jv2vobj = new Hashtable(); + if (jv2vobj==null) { + jv2vobj = new IdentityHashMap(); + vobj2jv = new Hashtable(); + } // wander through frames JInternalFrame[] frames = Desktop.desktop.getAllFrames(); @@ -83,7 +120,9 @@ public class VamsasClient extends ArchiveClient { if (frames[i] instanceof AlignFrame) { AlignFrame af = (AlignFrame) frames[i]; + // check if this frame has an associated alignment object ? + // update alignment and root from frame. } diff --git a/src/jalview/io/VamsasDatastore.java b/src/jalview/io/VamsasDatastore.java index 6b793c6..3915446 100755 --- a/src/jalview/io/VamsasDatastore.java +++ b/src/jalview/io/VamsasDatastore.java @@ -19,10 +19,20 @@ package jalview.io; +import org.vamsas.client.Vobject; +import org.vamsas.client.VorbaId; import org.vamsas.objects.core.*; +import org.vamsas.objects.utils.DocumentStuff; +import org.vamsas.test.simpleclient.ClientDoc; +import jalview.bin.Cache; +import jalview.datamodel.SequenceI; import jalview.gui.*; import java.io.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.IdentityHashMap; import java.util.jar.*; import org.exolab.castor.xml.*; import org.exolab.castor.mapping.Mapping; @@ -34,25 +44,26 @@ import org.exolab.castor.mapping.Mapping; "org.exolab.castor.serializer", "org.apache.xml.serialize.XMLSerilazizer"); } -*/ + */ public class VamsasDatastore { + Entry provEntry=null; AlignViewport av; - org.exolab.castor.types.Date date - = new org.exolab.castor.types.Date(new java.util.Date()); - - public VamsasDatastore(AlignViewport av) - { - this.av = av; + org.exolab.castor.types.Date date + = new org.exolab.castor.types.Date(new java.util.Date()); + ClientDoc cdoc; + Hashtable vobj2jv; + IdentityHashMap jv2vobj; + public VamsasDatastore(ClientDoc cdoc, Hashtable vobj2jv, IdentityHashMap jv2vobj, Entry provEntry) { + + this.cdoc = cdoc; + this.vobj2jv = vobj2jv; + this.jv2vobj = jv2vobj; + this.provEntry = provEntry; } - - public void store(String file) - { - storeVAMSAS(file); - } - - public void storeJalview(String file, AlignFrame af) + + /* public void storeJalview(String file, AlignFrame af) { try { @@ -80,499 +91,569 @@ public class VamsasDatastore } - - public VAMSAS storeVAMSAS(String file) - { - long time = System.currentTimeMillis(); - VAMSAS vamsas = new VAMSAS(); - - try - { - FileOutputStream fos = new FileOutputStream(file); - JarOutputStream jout = new JarOutputStream(fos); - - - //////////////////////////////////////////////////// - //NOTE UTF-8 MUST BE USED FOR WRITING UNICODE CHARS - PrintWriter out = new PrintWriter(new OutputStreamWriter(jout, - "UTF-8")); - - jalview.datamodel.AlignmentI jal = av.getAlignment(); - - - /////////////////////////////////////////// - // SAVE THE DATASET - DataSet dataset = new DataSet(); - vamsas.addDataSet(dataset); - - Sequence sequence; - DbRef dbref; - for (int i = 0; i < jal.getHeight(); i++) - { - sequence = new Sequence(); - sequence.setSequence(jal.getDataset().getSequenceAt(i).getSequence()); - sequence.setName(jal.getDataset().getSequenceAt(i).getName()); - sequence.setStart(jal.getDataset().getSequenceAt(i).getStart()); - sequence.setEnd(jal.getDataset().getSequenceAt(i).getEnd()); - - - if(jal.getDataset().getSequenceAt(i).getSequenceFeatures()!=null) - { - int sfSize = jal.getDataset().getSequenceAt(i).getSequenceFeatures().length; - - for (int sf = 0; sf < sfSize; sf++) - { - jalview.datamodel.SequenceFeature feature = - (jalview.datamodel.SequenceFeature) - jal.getDataset().getSequenceAt(i).getSequenceFeatures()[sf]; - - DataSetAnnotations dsa = new DataSetAnnotations(); - dsa.setType(feature.getType()); - dsa.setBegin(feature.getBegin()); - dsa.setEnd(feature.getEnd()); - dsa.setDescription(feature.getDescription()); - dsa.setStatus(feature.getStatus()); - dsa.addProvenance(dummyProvenance()); - dsa.setSeqRef(sequence); - dsa.setId("sf"+(time++)); - dataset.addDataSetAnnotations(dsa); - } - } - - if(jal.getDataset().getSequenceAt(i).getDBRef()!=null) - { - java.util.Vector entries = jal.getDataset().getSequenceAt(i).getDBRef(); - jalview.datamodel.DBRefEntry dbentry; - for(int db=0; db0) - an.setGraph(true); //aa[i].graph); - // JBPNote - store graphGroup in the Jalview specific bits. - an.setLabel(aa[i].label); - an.setProvenance(dummyProvenance()); - - AnnotationElement ae; - - for (int a = 0; a < aa[i].annotations.length; a++) - { - if ((aa[i] == null) || (aa[i].annotations[a] == null)) - { - continue; - } - - ae = new AnnotationElement(); - ae.setDescription(aa[i].annotations[a].description); - ae.setDisplayCharacter(aa[i].annotations[a].displayCharacter); - ae.setValue(aa[i].annotations[a].value); - ae.setPosition(a); - ae.setSecondaryStructure(aa[i].annotations[a].secondaryStructure + - ""); - an.addAnnotationElement(ae); - } - - alignment.addAlignmentAnnotations(an); - } - } - /////////////////////////////////////////////////////// - - - //////////////////////////////////////////////// - ///SAVE THE TREES - /////////////////////////////////// - // FIND ANY ASSOCIATED TREES - if (Desktop.desktop != null) - { - javax.swing.JInternalFrame[] frames = Desktop.desktop.getAllFrames(); - - for (int t = 0; t < frames.length; t++) - { - if (frames[t] instanceof TreePanel) - { - TreePanel tp = (TreePanel) frames[t]; - - if (tp.getAlignment() == jal) - { - Tree tree = new Tree(); - tree.setTitle(tp.getTitle()); - Newick newick = new Newick(); - newick.setContent( tp.getTree().toString() ); - newick.setTitle( tp.getTitle() ); - newick.setId("t"+(time++)); - tree.addNewick( newick ); - tree.setProvenance(dummyProvenance()); - alignment.addTree(tree); - } - } - } - } - - - JarEntry entry = new JarEntry("vamsas.xml"); - jout.putNextEntry(entry); - - vamsas.marshal(out); - - out.close(); - jout.close(); - - - } - catch (Exception ex) - { - ex.printStackTrace(); - } - - return vamsas; + */ + + protected Vobject getjv2vObj(Object jvobj) { + if (jv2vobj.containsKey(jvobj)) + return cdoc.getObject(((VorbaId)jv2vobj.get(jvobj))); + return null; } - - Tree jalview2VamsasTree() - { - Tree tree = new Tree(); - - return tree; - } - - - public void load(String file) + + protected Object getvObj2jv(org.vamsas.client.Vobject vobj) { + VorbaId id = vobj.getVorbaId(); + if (id==null) { + id = cdoc.registerObject(vobj); + Cache.log.debug("Registering new object and returning null for getvObj2jv"); + return null; + } + if (vobj2jv.containsKey(vobj.getVorbaId())) + return vobj2jv.get(id); + return null; + } + protected void bindjvvobj(Object jvobj, org.vamsas.client.Vobject vobj) { + VorbaId id = vobj.getVorbaId(); + if (id==null) { + id = cdoc.registerObject(vobj); + } + if (vobj2jv.containsKey(vobj.getVorbaId())||jv2vobj.containsKey(jvobj)) { + Cache.log.error("Duplicate object binding!"); + } else { + vobj2jv.put(vobj.getVorbaId(),jvobj);// JBPNote - better implementing a hybrid invertible hash. + jv2vobj.put(jvobj,vobj.getVorbaId()); + } + } + + public void storeVAMSAS(AlignViewport av) { - VAMSAS vamsas = new VAMSAS() ; - - try - { - FileInputStream fis = new FileInputStream(file); - JarInputStream jin = new JarInputStream(fis); - - - //////////////////////////////////////////////////// - //NOTE UTF-8 MUST BE USED FOR WRITING UNICODE CHARS - InputStreamReader in = new InputStreamReader(jin, "UTF-8"); - JarEntry jarentry = jin.getNextJarEntry(); - System.out.println("reading: "+jarentry.getName()); - vamsas = (VAMSAS) vamsas.unmarshal(in); - - - ///////////////////////////////////// - /////LOAD DATASET - DataSet dataset = vamsas.getDataSet(0); - - int i, iSize = dataset.getSequenceCount(); - jalview.datamodel.Sequence [] seqs = new jalview.datamodel.Sequence[iSize]; - DbRef [] dbref; - - for (i = 0; i < iSize ; i++) - { - seqs[i] = new jalview.datamodel.Sequence( - dataset.getSequence(i).getName(), - dataset.getSequence(i).getSequence(), - dataset.getSequence(i).getStart(), - dataset.getSequence(i).getEnd() ); - seqs[i].setVamsasId(dataset.getSequence(i).getId()); - - if (dataset.getDataSetAnnotations() != null) - { - for (int dsa = 0; dsa < dataset.getDataSetAnnotationsCount(); dsa++) - { - if (dataset.getDataSetAnnotations(dsa).getSeqRef() == - dataset.getSequence(i)) - { - seqs[i].addSequenceFeature(new jalview.datamodel. - SequenceFeature( - dataset.getDataSetAnnotations(dsa).getType(), - dataset.getDataSetAnnotations(dsa).getDescription(), - dataset.getDataSetAnnotations(dsa).getStatus(), - dataset.getDataSetAnnotations(dsa).getBegin(), - dataset.getDataSetAnnotations(dsa).getEnd(), - "vamsas")); - } - } - } - dbref = dataset.getSequence(i).getDbRef(); - - if(dbref.length>0) - { - for(int db=0; db0) - { - AlignmentAnnotations[] an = alignment.getAlignmentAnnotations(); - - for (j = 0; j < an.length; j++) - { - boolean topaliBreakpoint = false; - - AnnotationElement[] ae = an[j].getAnnotationElement(); - jalview.datamodel.Annotation[] anot = new jalview.datamodel.Annotation[jal. - getWidth()]; - - try{ - - for (int aa = 0; aa < ae.length; aa++) - { - String dc = ae[aa].getDisplayCharacter()==null ? "dc" : ae[aa].getDisplayCharacter(); - String desc = ae[aa].getDescription()==null ? "desc" : ae[aa].getDescription(); - String ss = ae[aa].getSecondaryStructure()==null ? "ss" : ae[aa].getSecondaryStructure(); - float value = ae[aa].getValue(); - - if(an[j].getGraph()) - { - dc = value+""; - desc = value + ""; - } - anot[ae[aa].getPosition()-1] = new jalview.datamodel. - Annotation(dc,desc,ss.charAt(0),value); - - if(desc.equals("TOPALi Partition Breakpoint")) - topaliBreakpoint = true; - - } - }catch(Exception ex) - { - ex.printStackTrace(); - System.out.println("problem parsing annotations\n"+ex);} - - jalview.datamodel.AlignmentAnnotation jaa = null; - - if (an[j].getGraph()) - { - jaa = new jalview.datamodel.AlignmentAnnotation(an[j].getLabel(), - an[j].getDescription(), anot, 0, 0, 1); - } - else - { - String label = an[j].getLabel(); - if(topaliBreakpoint) - label = "TOPALi Partition Breakpoint"; - jaa = new jalview.datamodel.AlignmentAnnotation(label, - an[j].getDescription(), anot); - } - - jal.addAnnotation(jaa); - } - } - ///////////////////////////////// - - AlignFrame alignFrame = new AlignFrame(jal); - jalview.gui.Desktop.addInternalFrame(alignFrame, "VAMSAS LOAD", - AlignFrame.NEW_WINDOW_WIDTH, - AlignFrame.NEW_WINDOW_HEIGHT); - - //LOAD TREES - /////////////////////////////////////// - if (alignment.getTreeCount() > 0) - { - for (int t = 0; t < alignment.getTreeCount(); t++) - { - Tree tree = alignment.getTree(t); - - alignFrame.ShowNewickTree( - new jalview.io.NewickFile(tree.getNewick(0).getContent()), - tree.getNewick(0).getTitle(), - 600, 500, - t * 20 + 50, t * 20 + 50); - } - } - - - in.close(); - jin.close(); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - - + long time = System.currentTimeMillis(); + + try + { + + jalview.datamodel.AlignmentI jal = av.getAlignment(); + + + /////////////////////////////////////////// + // SAVE THE DATASET + VAMSAS root = cdoc.getVamsasRoots()[0]; + if (jal.getDataset()==null) { + Cache.log.warn("Creating new dataset for an alignment."); + jal.setDataset(null); // + } + boolean nw=false; + DataSet dataset = (DataSet) getjv2vObj(jal.getDataset()); + if (dataset==null) { + dataset = new DataSet(); + root.addDataSet(dataset); + bindjvvobj(jal.getDataset(),dataset); + nw=true; + } //else { + // should really check root corresponds to dataset. + // } + // update dataset + Sequence sequence; + DbRef dbref; + for (int i = 0; i < jal.getHeight(); i++) + { + SequenceI sq = jal.getDataset().getSequenceAt(i); + sequence = (Sequence) getjv2vObj(sq); + if (sequence==null) { + sequence=new Sequence(); + bindjvvobj(sq, sequence); + sq.setVamsasId(sequence.getVorbaId().getId()); + sequence.setSequence(sq.getSequence()); + sequence.setName(jal.getDataset().getSequenceAt(i).getName()); + sequence.setStart(jal.getDataset().getSequenceAt(i).getStart()); + sequence.setEnd(jal.getDataset().getSequenceAt(i).getEnd()); + dataset.addSequence(sequence); + } else { + // verify principal attributes. + + } + + if(jal.getDataset().getSequenceAt(i).getSequenceFeatures()!=null) + { + int sfSize = jal.getDataset().getSequenceAt(i).getSequenceFeatures().length; + + for (int sf = 0; sf < sfSize; sf++) + { + jalview.datamodel.SequenceFeature feature = + (jalview.datamodel.SequenceFeature) + jal.getDataset().getSequenceAt(i).getSequenceFeatures()[sf]; + + DataSetAnnotations dsa = (DataSetAnnotations) getjv2vObj(feature); + if (dsa==null) { + dsa = new DataSetAnnotations(); + bindjvvobj(feature, dsa); + dsa.setType(feature.getType()); + dsa.setBegin(feature.getBegin()); + dsa.setEnd(feature.getEnd()); + dsa.setDescription(feature.getDescription()); + dsa.setStatus(feature.getStatus()); + if (dsa.getProvenance()==null) { + dsa.setProvenance(new Provenance()); + } + + dsa.getProvenance().addEntry(provEntry); // JBPNote - need to update jalview datamodel. + dsa.setSeqRef(sequence); + dataset.addDataSetAnnotations(dsa); + } else { + // todo: verify + } + } + } + + if(jal.getDataset().getSequenceAt(i).getDBRef()!=null) + { + java.util.Vector entries = jal.getDataset().getSequenceAt(i).getDBRef(); + jalview.datamodel.DBRefEntry dbentry; + for(int db=0; db0) + an.setGraph(true); //aa[i].graph); + // JBPNote - store graphGroup in the Jalview specific bits. + an.setLabel(aa[i].label); + an.setProvenance(dummyProvenance()); + + AnnotationElement ae; + + for (int a = 0; a < aa[i].annotations.length; a++) + { + if ((aa[i] == null) || (aa[i].annotations[a] == null)) + { + continue; + } + + ae = new AnnotationElement(); + ae.setDescription(aa[i].annotations[a].description); + ae.setDisplayCharacter(aa[i].annotations[a].displayCharacter); + ae.setValue(aa[i].annotations[a].value); + ae.setPosition(a); + ae.setSecondaryStructure(aa[i].annotations[a].secondaryStructure + + ""); + an.addAnnotationElement(ae); + } + + alignment.addAlignmentAnnotations(an); + } else { + // verify annotation - update (perhaps) + } + } + } + /////////////////////////////////////////////////////// + + //////////////////////////////////////////////// + ///SAVE THE TREES + /////////////////////////////////// + // FIND ANY ASSOCIATED TREES + if (Desktop.desktop != null) + { + javax.swing.JInternalFrame[] frames = Desktop.desktop.getAllFrames(); + + for (int t = 0; t < frames.length; t++) + { + if (frames[t] instanceof TreePanel) + { + TreePanel tp = (TreePanel) frames[t]; + + if (tp.getAlignment() == jal) + { + // JBPNote - can recover alignment and Vamsas Alignment for an associated tree using the getjv2vObj() + + Tree tree = (Tree) getjv2vObj(tp); + if (tree==null) { + tree = new Tree(); + bindjvvobj(tp,tree); + tree.setTitle(tp.getTitle()); + Newick newick = new Newick(); + newick.setContent( tp.getTree().toString() ); + newick.setTitle( tp.getTitle() ); + tree.addNewick( newick ); + tree.setProvenance(dummyProvenance()); + alignment.addTree(tree); + } else { + // verify any changes. + } + } + } + } + } + } + + catch (Exception ex) + { + ex.printStackTrace(); + } + } - - - - Provenance getVamsasProvenance(jalview.datamodel.Provenance jprov) - { - jalview.datamodel.ProvenanceEntry [] entries = null; - - - Provenance prov = new Provenance(); - org.exolab.castor.types.Date date = new org.exolab.castor.types.Date( - new java.util.Date()); - Entry provEntry; - - if(jprov!=null) - { - entries = jprov.getEntries(); - for (int i = 0; i < entries.length; i++) - { - provEntry = new Entry(); - try - { - date = new org.exolab.castor.types.Date(entries[i].getDate()); - } - catch (Exception ex) - { - ex.printStackTrace(); - - date = new org.exolab.castor.types.Date(entries[i].getDate()); - } - provEntry.setDate(date); - provEntry.setUser(entries[i].getUser()); - provEntry.setAction(entries[i].getAction()); - prov.addEntry(provEntry); - } - } - else - { - provEntry = new Entry(); - provEntry.setDate(date); - provEntry.setUser(System.getProperty("user.name")); - provEntry.setAction("Jalview"); - prov.addEntry(provEntry); - } - - return prov; - } - - jalview.datamodel.Provenance getJalviewProvenance(Provenance prov) - { - - jalview.datamodel.Provenance jprov = new jalview.datamodel.Provenance(); - for (int i = 0; i < prov.getEntryCount(); i++) - { - jprov.addEntry( - prov.getEntry(i).getUser(), - prov.getEntry(i).getAction(), - prov.getEntry(i).getDate().toDate(), - prov.getEntry(i).getId() - ); - } - - return jprov; - } - - Provenance dummyProvenance() - { - Provenance prov = new Provenance(); - Entry entry = new Entry(); - entry.setAction("Jalview"); - entry.setDate(new org.exolab.castor.types.Date(new java.util.Date())); - entry.setUser(System.getProperty("user.name")); - prov.addEntry(entry); - return prov; - } - -} + + + + public void updateJalview() + { + VAMSAS root = cdoc.getVamsasRoots()[0]; + try + { + boolean newds=false; + for (int _ds=0,_nds=root.getDataSetCount(); _ds<_nds; _ds++) { + ///////////////////////////////////// + /////LOAD DATASET + DataSet dataset = vamsas.getDataSet(_ds); + int i, iSize = dataset.getSequenceCount(); + jalview.datamodel.Alignment jdataset = (jalview.datamodel.Alignment) vobj2jv(dataset); + if (jdataset!=null) { + // recover + } else { + newds=true; + // construct new dataset + jalview.datamodel.Sequence [] seqs = new jalview.datamodel.Sequence[iSize]; + DbRef [] dbref; + for (i = 0; i < iSize ; i++) + { + seqs[i] = new jalview.datamodel.Sequence( + dataset.getSequence(i).getName(), + dataset.getSequence(i).getSequence(), + dataset.getSequence(i).getStart(), + dataset.getSequence(i).getEnd() ); + bindjvvobj(seqs[i], dataset.getSequence(i)); + seqs[i].setVamsasId(dataset.getSequence(i).getVorbaId().getId()); + + if (dataset.getDataSetAnnotations() != null) + { + for (int dsa = 0; dsa < dataset.getDataSetAnnotationsCount(); dsa++) + { + // could be optimised + if (dataset.getDataSetAnnotations(dsa).getSeqRef() == + dataset.getSequence(i)) + { + jalview.datamodel.SequenceFeature sf; + seqs[i].addSequenceFeature(sf=new jalview.datamodel. + SequenceFeature( + dataset.getDataSetAnnotations(dsa).getType(), + dataset.getDataSetAnnotations(dsa).getDescription(), + dataset.getDataSetAnnotations(dsa).getStatus(), + dataset.getDataSetAnnotations(dsa).getBegin(), + dataset.getDataSetAnnotations(dsa).getEnd(), + "vamsas")); + bindjvvobj(sf, dataset.getDataSetAnnotations(dsa)); + } + } + } + dbref = dataset.getSequence(i).getDbRef(); + + if(dbref.length>0) + { + for(int db=0; db0) + { + AlignmentAnnotations[] an = alignment.getAlignmentAnnotations(); + + for (j = 0; j < an.length; j++) + { + boolean topaliBreakpoint = false; + + AnnotationElement[] ae = an[j].getAnnotationElement(); + jalview.datamodel.Annotation[] anot = getvObj2jv(ae); + if (anot!=null) { + // update or stay the same. + } else { + // new one + anot=new jalview.datamodel.Annotation[jal. + getWidth()]; + bindjvvobj(anot, ae); + try{ + for (int aa = 0; aa < ae.length; aa++) + { + String dc = ae[aa].getDisplayCharacter()==null ? "dc" : ae[aa].getDisplayCharacter(); + String desc = ae[aa].getDescription()==null ? "desc" : ae[aa].getDescription(); + String ss = ae[aa].getSecondaryStructure()==null ? "ss" : ae[aa].getSecondaryStructure(); + float value = ae[aa].getValue(); + if(an[j].getGraph()) + { + dc = value+""; + desc = value + ""; + } + anot[ae[aa].getPosition()-1] = new jalview.datamodel. + Annotation(dc,desc,ss.charAt(0),value); + + if(desc.equals("TOPALi Partition Breakpoint")) + topaliBreakpoint = true; + + } + }catch(Exception ex) + { + ex.printStackTrace(); + System.out.println("problem parsing annotations\n"+ex);} + } + jalview.datamodel.AlignmentAnnotation jaa = null; + if (an[j].getGraph()) + { + jaa = new jalview.datamodel.AlignmentAnnotation(an[j].getLabel(), + an[j].getDescription(), anot, 0, 0, 1); + } + else + { + String label = an[j].getLabel(); + if(topaliBreakpoint) + label = "TOPALi Partition Breakpoint"; + jaa = new jalview.datamodel.AlignmentAnnotation(label, + an[j].getDescription(), anot); + } + + jal.addAnnotation(jaa); + } + } + ///////////////////////////////// + + AlignFrame alignFrame = new AlignFrame(jal); + jalview.gui.Desktop.addInternalFrame(alignFrame, "VAMSAS LOAD", + AlignFrame.NEW_WINDOW_WIDTH, + AlignFrame.NEW_WINDOW_HEIGHT); + + //LOAD TREES + /////////////////////////////////////// + if (alignment.getTreeCount() > 0) + { + for (int t = 0; t < alignment.getTreeCount(); t++) + { + Tree tree = alignment.getTree(t); + + alignFrame.ShowNewickTree( + new jalview.io.NewickFile(tree.getNewick(0).getContent()), + tree.getNewick(0).getTitle(), + 600, 500, + t * 20 + 50, t * 20 + 50); + } + } + + + in.close(); + jin.close(); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + + } + + + + Provenance getVamsasProvenance(jalview.datamodel.Provenance jprov) + { + jalview.datamodel.ProvenanceEntry [] entries = null; + + + Provenance prov = new Provenance(); + org.exolab.castor.types.Date date = new org.exolab.castor.types.Date( + new java.util.Date()); + Entry provEntry; + + if(jprov!=null) + { + entries = jprov.getEntries(); + for (int i = 0; i < entries.length; i++) + { + provEntry = new Entry(); + try + { + date = new org.exolab.castor.types.Date(entries[i].getDate()); + } + catch (Exception ex) + { + ex.printStackTrace(); + + date = new org.exolab.castor.types.Date(entries[i].getDate()); + } + provEntry.setDate(date); + provEntry.setUser(entries[i].getUser()); + provEntry.setAction(entries[i].getAction()); + prov.addEntry(provEntry); + } + } + else + { + provEntry = new Entry(); + provEntry.setDate(date); + provEntry.setUser(System.getProperty("user.name")); + provEntry.setAction("Jalview"); + prov.addEntry(provEntry); + } + + return prov; + } + + jalview.datamodel.Provenance getJalviewProvenance(Provenance prov) + { + + jalview.datamodel.Provenance jprov = new jalview.datamodel.Provenance(); + for (int i = 0; i < prov.getEntryCount(); i++) + { + jprov.addEntry( + prov.getEntry(i).getUser(), + prov.getEntry(i).getAction(), + prov.getEntry(i).getDate().toDate(), + prov.getEntry(i).getId() + ); + } + + return jprov; + } + + Provenance dummyProvenance() + { + Provenance prov = new Provenance(); + Entry entry = new Entry(); + entry.setAction("Jalview"); + entry.setDate(new org.exolab.castor.types.Date(new java.util.Date())); + entry.setUser(System.getProperty("user.name")); + prov.addEntry(entry); + return prov; + } + + }