vamsasDemo new branch
authoramwaterhouse <Andrew Waterhouse>
Wed, 26 Oct 2005 14:31:45 +0000 (14:31 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 26 Oct 2005 14:31:45 +0000 (14:31 +0000)
53 files changed:
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/CutAndPasteTransfer.java
src/jalview/appletgui/FeatureRenderer.java
src/jalview/appletgui/SeqPanel.java
src/jalview/bin/JalviewLite.java
src/jalview/datamodel/Alignment.java
src/jalview/datamodel/AlignmentI.java
src/jalview/datamodel/DBRefEntry.java [new file with mode: 0755]
src/jalview/datamodel/Provenance.java [new file with mode: 0755]
src/jalview/datamodel/ProvenanceEntry.java [new file with mode: 0755]
src/jalview/datamodel/Sequence.java
src/jalview/datamodel/SequenceFeature.java
src/jalview/datamodel/SequenceI.java
src/jalview/datamodel/UniprotEntry.java [new file with mode: 0755]
src/jalview/datamodel/UniprotFile.java [new file with mode: 0755]
src/jalview/datamodel/UniprotSequence.java [new file with mode: 0755]
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/CutAndPasteTransfer.java
src/jalview/gui/Desktop.java
src/jalview/gui/FeatureRenderer.java
src/jalview/gui/FeatureSettings.java [new file with mode: 0755]
src/jalview/gui/FontChooser.java
src/jalview/gui/GFeatureSelector.java [new file with mode: 0755]
src/jalview/gui/OverviewPanel.java
src/jalview/gui/Preferences.java
src/jalview/gui/SeqCanvas.java
src/jalview/gui/SeqPanel.java
src/jalview/gui/SequenceRenderer.java
src/jalview/gui/SplashScreen.java
src/jalview/io/AlignFile.java
src/jalview/io/AppletFormatAdapter.java [new file with mode: 0755]
src/jalview/io/BLCFile.java
src/jalview/io/ClustalFile.java
src/jalview/io/EBIFetchClient.java
src/jalview/io/FastaFile.java
src/jalview/io/FormatAdapter.java
src/jalview/io/MSFfile.java
src/jalview/io/PIRFile.java
src/jalview/io/PfamFile.java
src/jalview/io/PileUpfile.java
src/jalview/io/SequenceFeatureFetcher.java
src/jalview/io/VamsasDatastore.java [new file with mode: 0755]
src/jalview/io/WSWUBlastClient.java
src/jalview/jbappletgui/GAlignFrame.java
src/jalview/jbgui/GAlignFrame.java
src/jalview/jbgui/GDesktop.java
src/jalview/jbgui/GPreferences.java
src/jalview/schemes/ResidueProperties.java
src/jalview/util/Comparison.java
src/jalview/ws/JPredClient.java
src/vamsas/objects/simple/Object.java

index e303500..b632442 100755 (executable)
@@ -29,6 +29,7 @@ import java.awt.event.*;
 import java.util.*;\r
 import java.io.InputStreamReader;\r
 import java.io.BufferedReader;\r
+import java.io.FileReader;\r
 \r
 public class AlignFrame\r
     extends GAlignFrame\r
@@ -139,6 +140,78 @@ public class AlignFrame
 \r
   }\r
 \r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param String DOCUMENT ME!\r
+   */\r
+\r
+  public void parseGroupsFile(String file)\r
+  {\r
+    try\r
+    {\r
+      BufferedReader in = new BufferedReader(new FileReader(file));\r
+      SequenceI seq = null;\r
+      String line, text, token;\r
+      UserColourScheme ucs;\r
+      int index, start, end;\r
+      StringTokenizer st;\r
+      SequenceGroup sg;\r
+      int lineNo = 0;\r
+      while ( (line = in.readLine()) != null)\r
+      {\r
+        lineNo++;\r
+        st = new StringTokenizer(line, "\t");\r
+        if (st.countTokens() != 6)\r
+        {\r
+          System.out.println("Groups file " + file +\r
+                             " is invalid. Read help file.\nLine: \n"\r
+              +lineNo +": "+line);\r
+          break;\r
+        }\r
+\r
+        while (st.hasMoreElements())\r
+        {\r
+          text = st.nextToken();\r
+          token = st.nextToken();\r
+          if (!token.equals("ID_NOT_SPECIFIED"))\r
+          {\r
+            index = viewport.alignment.findIndex(viewport.alignment.findName(\r
+                token));\r
+            st.nextToken();\r
+          }\r
+          else\r
+          {\r
+            index = Integer.parseInt(st.nextToken());\r
+          }\r
+\r
+          start = Integer.parseInt(st.nextToken());\r
+          end = Integer.parseInt(st.nextToken());\r
+          ucs = new UserColourScheme(st.nextToken());\r
+\r
+          seq = viewport.alignment.getSequenceAt(index);\r
+          start = seq.findIndex(start) - 1;\r
+          end = seq.findIndex(end) - 1;\r
+\r
+          sg = new SequenceGroup(text, ucs, true, true, false, start, end);\r
+          sg.addSequence(seq, false);\r
+\r
+          viewport.alignment.addGroup(sg);\r
+\r
+        }\r
+      }\r
+\r
+      alignPanel.repaint();\r
+\r
+    }\r
+    catch (Exception ex)\r
+    {\r
+      System.out.println("Error parsing groups file: " + ex);\r
+    }\r
+  }\r
+\r
+\r
   public void inputText_actionPerformed(ActionEvent e)\r
   {\r
     CutAndPasteTransfer cap = new CutAndPasteTransfer(true, applet);\r
@@ -155,7 +228,7 @@ public class AlignFrame
     jalview.bin.JalviewLite.addFrame(frame,\r
                                      "Alignment output - " + e.getActionCommand(),\r
                                      600, 500);\r
-    cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),\r
+    cap.setText(new AppletFormatAdapter().formatSequences(e.getActionCommand(),\r
                                               viewport.getAlignment().\r
                                               getSequences()));\r
   }\r
index 4c0d3de..6627e88 100755 (executable)
@@ -74,7 +74,7 @@ public class CutAndPasteTransfer
     SequenceI[] sequences = null;\r
 \r
     String format = IdentifyFile.Identify(text, "Paste");\r
-    sequences = new FormatAdapter().readFile(text, "Paste", format);\r
+    sequences = new AppletFormatAdapter().readFile(text, "Paste", format);\r
 \r
     if (sequences != null)\r
     {\r
index 291ce5f..9d6503d 100755 (executable)
@@ -48,12 +48,12 @@ public class FeatureRenderer
     while (e.hasMoreElements())\r
     {\r
       SequenceFeature sf = (SequenceFeature) e.nextElement();\r
-      if (sf.getStart() > seq.getEnd())\r
+      if (sf.getBegin() > seq.getEnd())\r
       {\r
         continue;\r
       }\r
 \r
-      int fstart = seq.findIndex(sf.getStart()) - 1;\r
+      int fstart = seq.findIndex(sf.getBegin()) - 1;\r
       int fend = seq.findIndex(sf.getEnd()) - 1;\r
 \r
       if ( (fstart <= end && fend >= start))\r
index 9ed48b2..dec2b0a 100755 (executable)
@@ -302,7 +302,7 @@ public class SeqPanel
       while (e.hasMoreElements())\r
       {\r
         SequenceFeature sf = (SequenceFeature) e.nextElement();\r
-        if (sf.getStart() <= sequence.findPosition(res) &&\r
+        if (sf.getBegin() <= sequence.findPosition(res) &&\r
             sf.getEnd() >= sequence.findPosition(res))\r
         {\r
           if (sbuffer.length() > 0)\r
index 1e94a0d..a263ed4 100755 (executable)
@@ -80,7 +80,9 @@ public class JalviewLite extends Applet
         if (file != null)\r
         {\r
             add(launcher);\r
-            file = applet.getCodeBase() + file;\r
+            if(!file.startsWith("http://") && !file.startsWith("file://"))\r
+               file = applet.getCodeBase() + file;\r
+\r
             launcher.addActionListener(new java.awt.event.ActionListener()\r
                 {\r
                     public void actionPerformed(ActionEvent e)\r
@@ -108,7 +110,7 @@ public class JalviewLite extends Applet
 \r
 \r
       String format = jalview.io.IdentifyFile.Identify(args[0],"File");\r
-      SequenceI[] sequences = new FormatAdapter().readFile(args[0], "File", format);\r
+      SequenceI[] sequences = new AppletFormatAdapter().readFile(args[0], "File", format);\r
 \r
       if ( (sequences != null) && (sequences.length > 0))\r
       {\r
@@ -227,7 +229,7 @@ public class JalviewLite extends Applet
         public void run()\r
         {\r
             SequenceI[] sequences = null;\r
-            sequences = new FormatAdapter().readFile(file, protocol, format);\r
+            sequences = new AppletFormatAdapter().readFile(file, protocol, format);\r
 \r
             if ((sequences != null) && (sequences.length > 0))\r
             {\r
index ac8f47a..309fdae 100755 (executable)
@@ -29,12 +29,15 @@ import java.util.*;
  */\r
 public class Alignment implements AlignmentI\r
 {\r
+    protected Alignment dataset;\r
     protected Vector sequences;\r
     protected Vector groups = new Vector();\r
     protected Vector superGroup = new Vector();\r
     protected char gapCharacter = '-';\r
-    protected boolean isNucleotide = true;\r
-\r
+    protected Provenance provenance;\r
+    protected int type = NUCLEOTIDE;\r
+    public static final int PROTEIN = 0;\r
+    public static final int NUCLEOTIDE = 1;\r
 \r
     /** DOCUMENT ME!! */\r
     public AlignmentAnnotation[] annotations;\r
@@ -48,21 +51,12 @@ public class Alignment implements AlignmentI
      */\r
     public Alignment(SequenceI[] seqs)\r
     {\r
-        int i=0, iSize = seqs.length, j, jSize;\r
-        while(isNucleotide && i<iSize)\r
-        {\r
-            jSize = seqs[i].getLength();\r
-            for(j=0; j<jSize; j++)\r
-            {\r
-              if(!jalview.schemes.ResidueProperties.nucleotideHash.containsKey(seqs[i].getSequence(j, j+1))\r
-              && !jalview.util.Comparison.isGap(seqs[i].getSequence().charAt(j)))\r
-              {\r
-                isNucleotide = false;\r
-                break;\r
-              }\r
-            }\r
-            i++;\r
-        }\r
+        int i=0;\r
+\r
+        if( jalview.util.Comparison.isNucleotide(seqs))\r
+          type = NUCLEOTIDE;\r
+        else\r
+          type = PROTEIN;\r
 \r
         sequences = new Vector();\r
 \r
@@ -676,6 +670,7 @@ public class Alignment implements AlignmentI
             aSize = annotations.length + 1;\r
         }\r
 \r
+\r
         AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize];\r
         int i = 0;\r
 \r
@@ -704,11 +699,59 @@ public class Alignment implements AlignmentI
 \r
     public void setNucleotide(boolean b)\r
     {\r
-      isNucleotide = b;\r
+      if(b)\r
+        type = NUCLEOTIDE;\r
+      else\r
+        type = PROTEIN;\r
     }\r
 \r
     public boolean isNucleotide()\r
     {\r
-      return isNucleotide;\r
+      if(type==NUCLEOTIDE)\r
+        return true;\r
+      else\r
+        return false;\r
+    }\r
+\r
+    public void setDataset(Alignment data)\r
+    {\r
+      if(dataset==null && data==null)\r
+      {\r
+        // Create a new dataset for this alignment.\r
+        // Can only be done once, if dataset is not null\r
+        // This will not be performed\r
+        Sequence[] seqs = new Sequence[getHeight()];\r
+        for (int i = 0; i < getHeight(); i++)\r
+        {\r
+\r
+          seqs[i] = new Sequence(getSequenceAt(i).getName(),\r
+                                 AlignSeq.extractGaps(\r
+                                     jalview.util.Comparison.GapChars,\r
+                                     getSequenceAt(i).getSequence()\r
+                                 ),\r
+                                 getSequenceAt(i).getStart(),\r
+                                 getSequenceAt(i).getEnd());\r
+        }\r
+\r
+        dataset = new Alignment(seqs);\r
+      }\r
+      else if(dataset==null && data!=null)\r
+      {\r
+        dataset = data;\r
+      }\r
+    }\r
+\r
+    public Alignment getDataset()\r
+    {\r
+      return dataset;\r
+    }\r
+\r
+    public void setProvenance(Provenance prov)\r
+    {\r
+      provenance = prov;\r
+    }\r
+    public Provenance getProvenance()\r
+    {\r
+      return provenance;\r
     }\r
 }\r
index 4399b39..9ee51e9 100755 (executable)
@@ -304,4 +304,13 @@ public interface AlignmentI
      */\r
     public void setNucleotide(boolean b);\r
 \r
+\r
+    public Alignment getDataset();\r
+\r
+    public void setDataset(Alignment dataset);\r
+\r
+    public Provenance getProvenance();\r
+\r
+    public void setProvenance(Provenance prov);\r
+\r
 }\r
diff --git a/src/jalview/datamodel/DBRefEntry.java b/src/jalview/datamodel/DBRefEntry.java
new file mode 100755 (executable)
index 0000000..75e0cc8
--- /dev/null
@@ -0,0 +1,23 @@
+package jalview.datamodel;\r
+\r
+public class DBRefEntry\r
+{\r
+  String source, version, accessionId;\r
+\r
+  public DBRefEntry(String source, String version, String accessionId)\r
+  {\r
+    this.source = source;\r
+    this.version = version;\r
+    this.accessionId = accessionId;\r
+  }\r
+\r
+  public String getSource()\r
+  {    return source; }\r
+\r
+  public String getVersion()\r
+  { return version; }\r
+\r
+  public String getAccessionId()\r
+  { return accessionId; }\r
+\r
+}\r
diff --git a/src/jalview/datamodel/Provenance.java b/src/jalview/datamodel/Provenance.java
new file mode 100755 (executable)
index 0000000..e52c855
--- /dev/null
@@ -0,0 +1,26 @@
+package jalview.datamodel;\r
+import java.util.*;\r
+\r
+public class Provenance\r
+{\r
+  Vector entries = new Vector();\r
+  public Provenance()\r
+  {\r
+\r
+  }\r
+\r
+  public ProvenanceEntry[] getEntries()\r
+  {\r
+    ProvenanceEntry [] ret = new ProvenanceEntry[entries.size()];\r
+    for(int i=0; i<entries.size(); i++)\r
+       ret[i] = (ProvenanceEntry)entries.elementAt(i);\r
+    return ret;\r
+  }\r
+\r
+  public void addEntry(String user, String action, java.util.Date date, String id)\r
+  {\r
+    entries.addElement( new ProvenanceEntry(user,action,date,id));\r
+  }\r
+\r
+}\r
+\r
diff --git a/src/jalview/datamodel/ProvenanceEntry.java b/src/jalview/datamodel/ProvenanceEntry.java
new file mode 100755 (executable)
index 0000000..df8e8e9
--- /dev/null
@@ -0,0 +1,23 @@
+package jalview.datamodel;\r
+\r
+public class ProvenanceEntry\r
+{\r
+    String user, action, id;\r
+    java.util.Date date;\r
+    public ProvenanceEntry(String u, String a, java.util.Date d, String i)\r
+    {\r
+      user = u; action = a; date = d; id = i;\r
+    }\r
+\r
+    public String getUser()\r
+    {return user;}\r
+\r
+    public String getAction()\r
+    {return action;}\r
+\r
+    public java.util.Date getDate()\r
+    {return date;}\r
+\r
+    public String getID()\r
+    {return id;}\r
+}\r
index d30003d..586280b 100755 (executable)
@@ -39,6 +39,9 @@ public class Sequence implements SequenceI
     protected String displayId;\r
     protected Color color = Color.white;\r
     String pdbId;\r
+    String vamsasId;\r
+    Vector dbrefs;\r
+\r
 \r
     /** DOCUMENT ME!! */\r
     public Vector sequenceFeatures = new Vector();\r
@@ -58,6 +61,13 @@ public class Sequence implements SequenceI
       this.start = start;\r
       this.end = end;\r
 \r
+      checkValidRange();\r
+\r
+      setDisplayId();\r
+    }\r
+\r
+    void checkValidRange()\r
+    {\r
       if (end < 1)\r
       {\r
         int endRes = 0;\r
@@ -78,7 +88,7 @@ public class Sequence implements SequenceI
         this.end = endRes;\r
       }\r
 \r
-        setDisplayId();\r
+      setDisplayId();\r
     }\r
 \r
     /**\r
@@ -112,6 +122,14 @@ public class Sequence implements SequenceI
         sequenceFeatures = v;\r
     }\r
 \r
+    public void addSequenceFeature(SequenceFeature sf)\r
+    {\r
+      if(sequenceFeatures==null)\r
+        sequenceFeatures = new Vector();\r
+\r
+      sequenceFeatures.addElement(sf);\r
+    }\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -241,6 +259,7 @@ public class Sequence implements SequenceI
     public void setSequence(String seq)\r
     {\r
         this.sequence = seq;\r
+        checkValidRange();\r
     }\r
 \r
     /**\r
@@ -501,4 +520,28 @@ public class Sequence implements SequenceI
     {\r
         return color;\r
     }\r
+\r
+    public String getVamsasId()\r
+    {\r
+      return vamsasId;\r
+    }\r
+\r
+    public void setVamsasId(String id)\r
+    {\r
+      vamsasId = id;\r
+    }\r
+\r
+    public Vector getDBRef()\r
+    {\r
+      return dbrefs;\r
+    }\r
+\r
+    public void addDBRef(DBRefEntry entry)\r
+    {\r
+      if(dbrefs == null)\r
+        dbrefs = new Vector();\r
+\r
+      dbrefs.addElement(entry);\r
+    }\r
+\r
 }\r
index 5bf4e88..1adff25 100755 (executable)
@@ -26,48 +26,54 @@ package jalview.datamodel;
  */\r
 public class SequenceFeature\r
 {\r
+    int position;\r
     int begin;\r
     int end;\r
     String type;\r
     String description;\r
     String status;\r
 \r
-    /**\r
-     * Creates a new SequenceFeature object.\r
-     */\r
     public SequenceFeature()\r
+    {}\r
+\r
+    public SequenceFeature(String type, String desc, String status, int begin, int end)\r
     {\r
+      this.type = type;\r
+      this.description = desc;\r
+      this.status = status;\r
+      this.position = begin;\r
+      this.begin = begin;\r
+      this.end = end;\r
     }\r
 \r
-    /**\r
-     * Creates a new SequenceFeature object.\r
-     *\r
-     * @param type DOCUMENT ME!\r
-     * @param start DOCUMENT ME!\r
-     * @param end DOCUMENT ME!\r
-     * @param description DOCUMENT ME!\r
-     * @param status DOCUMENT ME!\r
-     */\r
-    public SequenceFeature(String type, int start, int end, String description,\r
-        String status)\r
+    public int getPosition()\r
     {\r
-        this.type = type;\r
-        this.begin = start;\r
-        this.end = end;\r
-        this.description = description;\r
-        this.status = status;\r
+      return position;\r
     }\r
 \r
+    public void setPosition(int pos)\r
+    {\r
+      position = pos;\r
+      begin = pos;\r
+      end = pos;\r
+    }\r
+\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
      * @return DOCUMENT ME!\r
      */\r
-    public int getStart()\r
+    public int getBegin()\r
     {\r
         return begin;\r
     }\r
 \r
+    public void setBegin(int start)\r
+    {\r
+      this.begin = start;\r
+    }\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -78,6 +84,11 @@ public class SequenceFeature
         return end;\r
     }\r
 \r
+    public void setEnd(int end)\r
+    {\r
+      this.end = end;\r
+    }\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -88,6 +99,11 @@ public class SequenceFeature
         return type;\r
     }\r
 \r
+    public void setType(String type)\r
+    {\r
+      this.type = type;\r
+    }\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -98,6 +114,11 @@ public class SequenceFeature
         return description;\r
     }\r
 \r
+    public void setDescription(String desc)\r
+    {\r
+      description = desc;\r
+    }\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -108,42 +129,9 @@ public class SequenceFeature
         return status;\r
     }\r
 \r
-    /*\r
-          <xs:enumeration value="active site" />\r
-         <xs:enumeration value="binding site" />\r
-         <xs:enumeration value="calcium-binding region" />\r
-         <xs:enumeration value="chain" />\r
-         <xs:enumeration value="cross-link" />\r
-         <xs:enumeration value="disulfide bond" />\r
-         <xs:enumeration value="DNA-binding region" />\r
-         <xs:enumeration value="domain" />\r
-         <xs:enumeration value="glycosylation site" />\r
-         <xs:enumeration value="helix" />\r
-         <xs:enumeration value="initiator methionine" />\r
-         <xs:enumeration value="lipid moiety-binding region" />\r
-         <xs:enumeration value="metal ion-binding site" />\r
-         <xs:enumeration value="modified residue" />\r
-         <xs:enumeration value="mutagenesis site" />\r
-         <xs:enumeration value="non-consecutive residues" />\r
-         <xs:enumeration value="non-terminal residue" />\r
-         <xs:enumeration value="nucleotide phosphate-binding region" />\r
-         <xs:enumeration value="peptide" />\r
-         <xs:enumeration value="propeptide" />\r
-         <xs:enumeration value="repeat" />\r
-         <xs:enumeration value="selenocysteine" />\r
-         <xs:enumeration value="sequence conflict" />\r
-         <xs:enumeration value="sequence variant" />\r
-         <xs:enumeration value="signal peptide" />\r
-         <xs:enumeration value="similar" />\r
-         <xs:enumeration value="site" />\r
-         <xs:enumeration value="splice variant" />\r
-         <xs:enumeration value="strand" />\r
-         <xs:enumeration value="thioether bond" />\r
-         <xs:enumeration value="thiolester bond" />\r
-         <xs:enumeration value="transit peptide" />\r
-         <xs:enumeration value="transmembrane region" />\r
-         <xs:enumeration value="turn" />\r
-         <xs:enumeration value="unsure residue" />\r
-         <xs:enumeration value="zinc finger region" />\r
-     */\r
+    public void setStatus(String status)\r
+    {\r
+      this.status = status;\r
+    }\r
+\r
 }\r
index b7c9197..186179b 100755 (executable)
@@ -232,4 +232,14 @@ public interface SequenceI
      * @return DOCUMENT ME!\r
      */\r
     public String getPDBId();\r
+\r
+    public String getVamsasId();\r
+\r
+    public void setVamsasId(String id);\r
+\r
+    public Vector getDBRef();\r
+\r
+    public void addDBRef(DBRefEntry entry);\r
+\r
+    public void addSequenceFeature(SequenceFeature sf);\r
 }\r
diff --git a/src/jalview/datamodel/UniprotEntry.java b/src/jalview/datamodel/UniprotEntry.java
new file mode 100755 (executable)
index 0000000..0bc0f0b
--- /dev/null
@@ -0,0 +1,52 @@
+package jalview.datamodel;\r
+\r
+import java.util.Vector;\r
+\r
+public class UniprotEntry\r
+{\r
+\r
+  UniprotSequence sequence;\r
+  String name;\r
+  String accession;\r
+  Vector features;\r
+\r
+  public void setFeatures(Vector items)\r
+  {\r
+       features = items;\r
+   }\r
+\r
+   public Vector getFeatures() {\r
+       return features;\r
+   }\r
+\r
+   public void setAccession(String acc)\r
+   {\r
+     accession = acc;\r
+   }\r
+\r
+   public String getAccession()\r
+   {\r
+     return accession;\r
+   }\r
+\r
+\r
+  public void setName(String na)\r
+  {\r
+    name = na;\r
+  }\r
+  public String getName()\r
+  {\r
+    return name;\r
+  }\r
+\r
+  public UniprotSequence getUniprotSequence()\r
+  {\r
+    return sequence;\r
+  }\r
+\r
+  public void setUniprotSequence(UniprotSequence seq)\r
+  {\r
+    sequence = seq;\r
+  }\r
+\r
+}\r
diff --git a/src/jalview/datamodel/UniprotFile.java b/src/jalview/datamodel/UniprotFile.java
new file mode 100755 (executable)
index 0000000..c668c4b
--- /dev/null
@@ -0,0 +1,16 @@
+package jalview.datamodel;\r
+import java.util.Vector;\r
+\r
+public class UniprotFile\r
+{\r
+  Vector _items;\r
+\r
+  public void setUniprotEntries(Vector items) {\r
+       _items = items;\r
+   }\r
+\r
+   public Vector getUniprotEntries() {\r
+       return _items;\r
+   }\r
+\r
+}\r
diff --git a/src/jalview/datamodel/UniprotSequence.java b/src/jalview/datamodel/UniprotSequence.java
new file mode 100755 (executable)
index 0000000..9233889
--- /dev/null
@@ -0,0 +1,24 @@
+package jalview.datamodel;\r
+\r
+public class UniprotSequence\r
+{\r
+    /**\r
+   * internal content storage\r
+   */\r
+  private java.lang.String _content = "";\r
+\r
+  public void setContent(String seq)\r
+  {\r
+    StringBuffer sb = new StringBuffer();\r
+    for(int i=0; i<seq.length(); i++)\r
+      if(seq.charAt(i)!=' ')\r
+      {\r
+        sb.append(seq.charAt(i));\r
+      }\r
+    _content = sb.toString();\r
+  }\r
+\r
+  public String getContent()\r
+  { return _content; }\r
+\r
+}\r
index d6be387..7fbd14f 100755 (executable)
@@ -49,8 +49,11 @@ public class AlignFrame
 \r
   /** DOCUMENT ME!! */\r
   public static final int NEW_WINDOW_HEIGHT = 500;\r
-  final AlignmentPanel alignPanel;\r
-  final AlignViewport viewport;\r
+  AlignmentPanel alignPanel;\r
+  AlignViewport viewport;\r
+\r
+  Vector viewports = new Vector();\r
+  Vector alignPanels = new Vector();\r
 \r
   /** DOCUMENT ME!! */\r
   public String currentFileFormat = null;\r
@@ -66,10 +69,12 @@ public class AlignFrame
   public AlignFrame(AlignmentI al)\r
   {\r
     viewport = new AlignViewport(al);\r
+    viewports.add(viewport);\r
+\r
 \r
     if(viewport.vconsensus==null)\r
     {\r
-      //Out of memory caluclating consensus.\r
+      //Out of memory calculating consensus.\r
       BLOSUM62Colour.setEnabled(false);\r
       PIDColour.setEnabled(false);\r
       conservationMenuItem.setEnabled(false);\r
@@ -79,12 +84,7 @@ public class AlignFrame
     }\r
 \r
     alignPanel = new AlignmentPanel(this, viewport);\r
-    alignPanel.annotationPanel.adjustPanelHeight();\r
-    alignPanel.annotationSpaceFillerHolder.setPreferredSize(alignPanel.\r
-        annotationPanel.getPreferredSize());\r
-    alignPanel.annotationScroller.setPreferredSize(alignPanel.annotationPanel.\r
-        getPreferredSize());\r
-    alignPanel.setAnnotationVisible(viewport.getShowAnnotation());\r
+    alignPanels.add(alignPanel);\r
 \r
     String sortby = jalview.bin.Cache.getDefault("SORT_ALIGNMENT", "No sort");\r
 \r
@@ -93,7 +93,24 @@ public class AlignFrame
     else if(sortby.equals("Pairwise Identity"))\r
       sortPairwiseMenuItem_actionPerformed(null);\r
 \r
-    getContentPane().add(alignPanel, java.awt.BorderLayout.CENTER);\r
+    tabbedPane.add(al.isNucleotide() ? "DNA":"Protein", alignPanel);\r
+\r
+    ///Dataset tab\r
+    /////////////////////////\r
+\r
+    if(al.getDataset()==null)\r
+    {\r
+      al.setDataset(null);\r
+    }\r
+\r
+    AlignViewport ds = new AlignViewport(al.getDataset());\r
+    ds.setDataset(true);\r
+    AlignmentPanel dap = new AlignmentPanel(this, ds);\r
+    tabbedPane.add("Dataset", dap);\r
+    viewports.add(ds);\r
+    alignPanels.add(dap);\r
+    /////////////////////////\r
+\r
 \r
     viewport.addPropertyChangeListener(new PropertyChangeListener()\r
     {\r
@@ -106,6 +123,7 @@ public class AlignFrame
      }\r
    });\r
 \r
+\r
        if(Desktop.desktop!=null)\r
     addServiceListeners();\r
   }\r
@@ -156,24 +174,29 @@ public class AlignFrame
     {\r
       BufferedReader in = new BufferedReader(new FileReader(file));\r
       SequenceI seq = null;\r
-      String line, text, token;\r
+      String line, type, desc, token;\r
       UserColourScheme ucs;\r
       int index, start, end;\r
       StringTokenizer st;\r
-      SequenceGroup sg;\r
+      SequenceFeature sf;\r
+      FeatureRenderer fr = alignPanel.seqPanel.seqCanvas.getFeatureRenderer();\r
+      int lineNo = 0;\r
       while ( (line = in.readLine()) != null)\r
       {\r
+        lineNo++;\r
         st = new StringTokenizer(line, "\t");\r
-        if (st.countTokens() != 6)\r
+        if (st.countTokens() != 7)\r
         {\r
           System.out.println("Groups file " + file +\r
-                             " is invalid. Read help file.");\r
-          System.exit(1);\r
+                             " is invalid. Read help file.\nLine: \n"\r
+              +lineNo +": "+line);\r
+          break;\r
         }\r
 \r
         while (st.hasMoreElements())\r
         {\r
-          text = st.nextToken();\r
+          type = st.nextToken();\r
+          desc = st.nextToken();\r
           token = st.nextToken();\r
           if (!token.equals("ID_NOT_SPECIFIED"))\r
           {\r
@@ -194,13 +217,26 @@ public class AlignFrame
           start = seq.findIndex(start) - 1;\r
           end = seq.findIndex(end) - 1;\r
 \r
-          sg = new SequenceGroup(text, ucs, true, true, false, start, end);\r
-          sg.addSequence(seq, true);\r
+          sf = new SequenceFeature(type, desc, "", start, end);\r
+          fr.setColour(type, ucs.findColour("A"));\r
+\r
+          seq.addSequenceFeature(sf);\r
+\r
+          System.out.println(sf.getType()+" "+sf.getBegin());\r
+\r
+         // sg = new SequenceGroup(text, ucs, true, true, false, start, end);\r
+         // sg.addSequence(seq, false);\r
+\r
+         // viewport.alignment.addGroup(sg);\r
 \r
-          viewport.alignment.addGroup(sg);\r
         }\r
       }\r
 \r
+      viewport.showSequenceFeatures = true;\r
+      ((Alignment)viewport.alignment).featuresAdded = true;\r
+\r
+      alignPanel.repaint();\r
+\r
     }\r
     catch (Exception ex)\r
     {\r
@@ -639,7 +675,7 @@ public class AlignFrame
                              endRes);\r
     }\r
 \r
-    c.setContents(new StringSelection(FastaFile.print(seqs)), null);\r
+    c.setContents(new StringSelection(new FastaFile().print(seqs)), null);\r
   }\r
 \r
   /**\r
@@ -682,6 +718,8 @@ public class AlignFrame
       }\r
 \r
       String str = (String) contents.getTransferData(DataFlavor.stringFlavor);\r
+      if(str.length()<1)\r
+        return;\r
 \r
       String format = IdentifyFile.Identify(str, "Paste");\r
       SequenceI[] sequences = new FormatAdapter().readFile(str, "Paste", format);\r
@@ -689,7 +727,9 @@ public class AlignFrame
 \r
       if (newAlignment)\r
       {\r
-        AlignFrame af = new AlignFrame(new Alignment(sequences));\r
+        Alignment alignment = new Alignment(sequences);\r
+        alignment.setDataset( viewport.alignment.getDataset() );\r
+        AlignFrame af = new AlignFrame(alignment);\r
         String newtitle = new String("Copied sequences");\r
 \r
         if (title.startsWith("Copied sequences"))\r
@@ -1069,6 +1109,16 @@ public class AlignFrame
    if(alignPanel.overviewPanel!=null)\r
      alignPanel.overviewPanel.updateOverviewImage();\r
 \r
+  Provenance prov = viewport.alignment.getProvenance();\r
+  if(prov == null)\r
+   {\r
+     prov = new Provenance();\r
+     viewport.alignment.setProvenance(prov);\r
+   }\r
+\r
+   prov.addEntry("Me",\r
+       "Edited in Jalview", new java.util.Date(), "myID");\r
+\r
    alignPanel.repaint();\r
  }\r
 \r
@@ -1282,9 +1332,10 @@ public class AlignFrame
       new SequenceFeatureFetcher(viewport.\r
           alignment,\r
           alignPanel);\r
-      ( (Alignment) viewport.alignment).featuresAdded = true;\r
     }\r
 \r
+    featureSettings.setEnabled(true);\r
+\r
     alignPanel.repaint();\r
   }\r
 \r
@@ -2338,4 +2389,144 @@ public class AlignFrame
     // TODO: group services by location as well as function.\r
   }\r
 \r
+  public void vamsasStore_actionPerformed(ActionEvent e)\r
+  {\r
+    JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.\r
+        getProperty("LAST_DIRECTORY"));\r
+\r
+    chooser.setFileView(new JalviewFileView());\r
+    chooser.setDialogTitle("Export to Vamsas file");\r
+    chooser.setToolTipText("Export");\r
+\r
+    int value = chooser.showSaveDialog(this);\r
+\r
+    if (value == JalviewFileChooser.APPROVE_OPTION)\r
+    {\r
+      jalview.io.VamsasDatastore vs = new jalview.io.VamsasDatastore(viewport);\r
+      vs.store(chooser.getSelectedFile().getAbsolutePath()\r
+          );\r
+    }\r
+  }\r
+\r
+  public void featureSettings_actionPerformed(ActionEvent e)\r
+  {\r
+    new FeatureSettings(viewport, alignPanel);\r
+  }\r
+\r
+\r
+\r
+public void showTranslation_actionPerformed(ActionEvent e)\r
+{\r
+\r
+  if(!viewport.alignment.isNucleotide())\r
+    return;\r
+\r
+  viewport.showTranslation(showTranslation.isSelected());\r
+\r
+  if(!viewport.alignment.isNucleotide())\r
+    return;\r
+\r
+  int s, sSize = viewport.alignment.getHeight();\r
+  SequenceI [] newSeq = new SequenceI[sSize];\r
+\r
+  int res, resSize;\r
+  StringBuffer protein;\r
+  SequenceI seq;\r
+  for(s=0; s<sSize; s++)\r
+  {\r
+    protein = new StringBuffer();\r
+    seq = (SequenceI)viewport.alignment.getSequenceAt(s);\r
+    resSize = seq.getLength();\r
+    for(res = 0; res < resSize; res+=3)\r
+    {\r
+      String codon = seq.getSequence(res, res+3);\r
+      codon = codon.replace('U', 'T');\r
+      String aa = ResidueProperties.codonTranslate(codon);\r
+      if(aa==null)\r
+        protein.append(viewport.getGapCharacter());\r
+      else if(aa.equals("STOP"))\r
+        protein.append("X");\r
+      else\r
+        protein.append( aa );\r
+    }\r
+    newSeq[s] = new Sequence(seq.getName(), protein.toString());\r
+  }\r
+\r
+\r
+  AlignmentI al = new Alignment(newSeq);\r
+  al.setDataset(null);\r
+\r
+\r
+  ////////////////////////////////\r
+  // Copy annotations across\r
+  jalview.datamodel.AlignmentAnnotation[] annotations\r
+      = viewport.alignment.getAlignmentAnnotation();\r
+  int a, aSize;\r
+  for (int i = 0; i < annotations.length; i++)\r
+  {\r
+\r
+    if (annotations[i].label.equals("Quality") ||\r
+        annotations[i].label.equals("Conservation") ||\r
+        annotations[i].label.equals("Consensus"))\r
+    {\r
+      continue;\r
+    }\r
+\r
+\r
+    aSize = viewport.alignment.getWidth()/3;\r
+    jalview.datamodel.Annotation [] anots =\r
+        new jalview.datamodel.Annotation[aSize];\r
+\r
+    for(a=0; a<viewport.alignment.getWidth(); a++)\r
+    {\r
+     if( annotations[i].annotations[a]==null\r
+      || annotations[i].annotations[a]==null)\r
+       continue;\r
+\r
+      anots[a/3] = new Annotation(\r
+     annotations[i].annotations[a].displayCharacter,\r
+     annotations[i].annotations[a].description,\r
+     annotations[i].annotations[a].secondaryStructure,\r
+     annotations[i].annotations[a].value,\r
+     annotations[i].annotations[a].colour);\r
+    }\r
+\r
+    jalview.datamodel.AlignmentAnnotation aa\r
+          = new jalview.datamodel.AlignmentAnnotation(annotations[i].label,\r
+       annotations[i].description, anots );\r
+     al.addAnnotation(aa);\r
+  }\r
+\r
+\r
+   // Desktop.addInternalFrame(af, "Translation of "+this.getTitle(),\r
+    //                         NEW_WINDOW_WIDTH,\r
+     //                        NEW_WINDOW_HEIGHT);\r
+\r
+    AlignViewport newViewport = new AlignViewport(al);\r
+    AlignmentPanel ap = new AlignmentPanel(this, newViewport);\r
+    tabbedPane.add("Protein", ap);\r
+    viewports.add(newViewport);\r
+    alignPanels.add(ap);\r
+\r
+    ///Dataset tab\r
+  /////////////////////////\r
+\r
+    AlignViewport ds = new AlignViewport(al.getDataset());\r
+    ds.setDataset(true);\r
+    AlignmentPanel dap = new AlignmentPanel(this, ds);\r
+    tabbedPane.add("Dataset", dap);\r
+    viewports.add(ds);\r
+    alignPanels.add(dap);\r
+  /////////////////////////\r
+\r
+\r
+}\r
+\r
+public void tabSelected()\r
+{\r
+  int index = tabbedPane.getSelectedIndex();\r
+  viewport = (AlignViewport)viewports.elementAt(index);\r
+  alignPanel = (AlignmentPanel)alignPanels.elementAt(index);\r
+}\r
+\r
 }\r
index 2922f09..f57e993 100755 (executable)
@@ -86,6 +86,10 @@ public class AlignViewport
 \r
     boolean ignoreGapsInConsensusCalculation = false;\r
 \r
+    boolean showTranslation = false;\r
+\r
+    boolean isDataset = false;\r
+\r
     /**\r
      * Creates a new AlignViewport object.\r
      *\r
@@ -99,14 +103,7 @@ public class AlignViewport
         this.startSeq = 0;\r
         this.endSeq = al.getHeight() - 1;\r
 \r
-        updateFromPreferences();\r
-    }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     */\r
-    public void updateFromPreferences()\r
-    {\r
       showFullId = Cache.getDefault("SHOW_FULL_ID", true);\r
       showAnnotation = Cache.getDefault("SHOW_ANNOTATIONS", true);\r
       showConservation = Cache.getDefault("SHOW_CONSERVATION", true);\r
@@ -137,9 +134,11 @@ public class AlignViewport
 \r
         // We must set conservation and consensus before setting colour,\r
         // as Blosum and Clustal require this to be done\r
-        updateConservation();\r
-\r
-        updateConsensus();\r
+        if(vconsensus==null)\r
+        {\r
+          updateConservation();\r
+          updateConsensus();\r
+        }\r
 \r
         if (jalview.bin.Cache.getProperty("DEFAULT_COLOUR") != null)\r
         {\r
@@ -1058,4 +1057,24 @@ public class AlignViewport
     {\r
      return ignoreGapsInConsensusCalculation;\r
     }\r
+\r
+    public void showTranslation(boolean b)\r
+    {\r
+      this.showTranslation = b;\r
+    }\r
+\r
+    public boolean getShowTranslation()\r
+    {\r
+      return showTranslation;\r
+    }\r
+\r
+    public void setDataset(boolean b)\r
+    {\r
+      isDataset = b;\r
+    }\r
+\r
+    public boolean isDataset()\r
+    {\r
+      return isDataset;\r
+    }\r
 }\r
index e31134b..66bc999 100755 (executable)
@@ -98,6 +98,13 @@ public class AlignmentPanel extends GAlignmentPanel
 \r
         setScrollValues(0, 0);\r
 \r
+        annotationPanel.adjustPanelHeight();\r
+        annotationSpaceFillerHolder.setPreferredSize(annotationPanel.getPreferredSize());\r
+        annotationScroller.setPreferredSize(annotationPanel.\r
+                                            getPreferredSize());\r
+        setAnnotationVisible(av.getShowAnnotation());\r
+\r
+\r
         hscroll.addAdjustmentListener(this);\r
         vscroll.addAdjustmentListener(this);\r
 \r
index a10f433..be2cf97 100755 (executable)
@@ -80,6 +80,11 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
         textarea.setText(text);\r
     }\r
 \r
+    public void appendText(String text)\r
+    {\r
+      textarea.append(text);\r
+    }\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
index 4186090..9ac5a5c 100755 (executable)
@@ -68,7 +68,7 @@ public class Desktop extends jalview.jbgui.GDesktop
         {
         }
 
-        setTitle("Jalview 2005");
+        setTitle("Jalview "+jalview.bin.Cache.getProperty("VERSION"));
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         desktop = new JDesktopPane();
         desktop.setBackground(Color.white);
@@ -544,5 +544,27 @@ public class Desktop extends jalview.jbgui.GDesktop
         }
     }
 
+    public void vamsasLoad_actionPerformed(ActionEvent e)
+    {
+      JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
+          getProperty("LAST_DIRECTORY"));
+
+      chooser.setFileView(new JalviewFileView());
+      chooser.setDialogTitle("Load Vamsas file");
+      chooser.setToolTipText("Import");
+
+      int value = chooser.showOpenDialog(this);
+
+      if (value == JalviewFileChooser.APPROVE_OPTION)
+      {
+        jalview.io.VamsasDatastore vs = new jalview.io.VamsasDatastore(null);
+        vs.load(
+            chooser.getSelectedFile().getAbsolutePath()
+            );
+      }
+
+    }
+
+
 }
 
index 8a94a89..f315df6 100755 (executable)
@@ -38,6 +38,11 @@ public class FeatureRenderer
     SequenceGroup[] allGroups = null;\r
     Color resBoxColour;\r
     Graphics graphics;\r
+    float transparency = 1.0f;\r
+\r
+    // The following vector holds the features which are\r
+    // to be added, in the correct order or rendering\r
+    Vector featuresDisplayed;\r
 \r
     /**\r
      * Creates a new FeatureRenderer object.\r
@@ -47,6 +52,7 @@ public class FeatureRenderer
     public FeatureRenderer(AlignViewport av)\r
     {\r
         this.av = av;\r
+        initColours();\r
     }\r
 \r
     /**\r
@@ -62,22 +68,57 @@ public class FeatureRenderer
      * @param width DOCUMENT ME!\r
      * @param height DOCUMENT ME!\r
      */\r
-    public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg,\r
+    public void drawSequence(Graphics g1, SequenceI seq, SequenceGroup[] sg,\r
         int start, int end, int x1, int y1, int width, int height)\r
     {\r
-        Vector features = seq.getSequenceFeatures();\r
-        Enumeration e = features.elements();\r
+\r
+        if(seq.getSequenceFeatures()==null)\r
+          return;\r
+\r
+        Enumeration e = null, e2;\r
+        String type;\r
+        if(featuresDisplayed!=null)\r
+          e = featuresDisplayed.elements();\r
+        else\r
+         e = seq.getSequenceFeatures().elements();\r
+\r
+        Graphics2D g = (Graphics2D)g1;\r
+        g.setComposite(\r
+        AlphaComposite.getInstance(\r
+               AlphaComposite.SRC_OVER,transparency));\r
 \r
         while (e.hasMoreElements())\r
         {\r
-            SequenceFeature sf = (SequenceFeature) e.nextElement();\r
+            SequenceFeature sf=null;\r
+            if(featuresDisplayed!=null)\r
+            {\r
+              e2 = seq.getSequenceFeatures().elements();\r
+              type = e.nextElement().toString();\r
+              while(e2.hasMoreElements())\r
+              {\r
+                sf = (SequenceFeature) e2.nextElement();\r
+                if(sf.getType().equals(type))\r
+                  break;\r
+                else\r
+                  sf = null;\r
+              }\r
+            }\r
+            else\r
+            {\r
+              sf = (SequenceFeature) e.nextElement();\r
+              type = sf.getType();\r
+            }\r
+\r
+            if(sf==null)\r
+              continue;\r
 \r
-            if (sf.getStart() > seq.getEnd())\r
+\r
+            if (sf.getBegin() > seq.getEnd())\r
             {\r
                 continue;\r
             }\r
 \r
-            int fstart = seq.findIndex(sf.getStart()) - 1;\r
+            int fstart = seq.findIndex(sf.getBegin()) - 1;\r
             int fend = seq.findIndex(sf.getEnd()) - 1;\r
 \r
             if (((fstart <= end) && (fend >= start)))\r
@@ -94,7 +135,7 @@ public class FeatureRenderer
 \r
                 if (fstart == fend)\r
                 {\r
-                    g.setColor(Color.red);\r
+                    g.setColor(getColour(type));\r
                     g.fillRoundRect((fstart - start) * width, y1, width,\r
                         height, 4, 4);\r
                     g.setColor(Color.white);\r
@@ -118,7 +159,7 @@ public class FeatureRenderer
                             continue;\r
                         }\r
 \r
-                        g.setColor(Color.blue);\r
+                        g.setColor(getColour(type));\r
                         g.fillRect((i - start) * width, y1, width, height);\r
 \r
                         g.setColor(Color.white);\r
@@ -133,5 +174,89 @@ public class FeatureRenderer
                 }\r
             }\r
         }\r
+        g.setComposite(\r
+        AlphaComposite.getInstance(\r
+               AlphaComposite.SRC_OVER,1.0f));\r
+\r
     }\r
+\r
+    public Color getColour(String featureType)\r
+    {\r
+      return (Color)featureColours.get(featureType);\r
+    }\r
+\r
+    public void setColour(String featureType, Color col)\r
+    {\r
+      featureColours.put(featureType, col);\r
+    }\r
+\r
+    public void setTransparency(float value)\r
+    {\r
+      transparency = value;\r
+    }\r
+\r
+    public float getTransparency()\r
+    {\r
+      return transparency;\r
+    }\r
+\r
+    public void setFeaturePriority(Object [][] data)\r
+    {\r
+      // The feature table will display high priority\r
+      // features at the top, but theses are the ones\r
+      // we need to render last, so invert the data\r
+      featuresDisplayed = new Vector();\r
+      for(int i=data.length-1; i>-1; i--)\r
+      {\r
+       String type = data[i][0].toString();\r
+       setColour(type, (Color)data[i][1]);\r
+       if( ((Boolean)data[i][2]).booleanValue() )\r
+         featuresDisplayed.addElement(type);\r
+      }\r
+    }\r
+\r
+    Hashtable featureColours = new Hashtable();\r
+    void initColours()\r
+    {\r
+      featureColours.put("active site", new Color(255, 75, 0));\r
+      featureColours.put("binding site", new Color(245, 85, 0));\r
+      featureColours.put("calcium-binding region", new Color(235, 95, 0));\r
+      featureColours.put("chain", new Color(225, 105, 0));\r
+      featureColours.put("coiled-coil region", new Color(215, 115, 0));\r
+      featureColours.put("compositionally biased region", new Color(205, 125, 0));\r
+      featureColours.put("cross-link", new Color(195, 135, 0));\r
+      featureColours.put("disulfide bond", new Color(185, 145, 0));\r
+      featureColours.put("DNA-binding region", new Color(175, 155, 0));\r
+      featureColours.put("domain", new Color(165, 165, 0));\r
+      featureColours.put("glycosylation site", new Color(155, 175, 0));\r
+      featureColours.put("helix", new Color(145, 185, 0));\r
+      featureColours.put("initiator methionine", new Color(135, 195, 5));\r
+      featureColours.put("lipid moiety-binding region", new Color(125, 205, 15));\r
+      featureColours.put("metal ion-binding site", new Color(115, 215, 25));\r
+      featureColours.put("modified residue", new Color(105, 225, 35));\r
+      featureColours.put("mutagenesis site", new Color(95, 235, 45));\r
+      featureColours.put("non-consecutive residues", new Color(85, 245, 55));\r
+      featureColours.put("non-terminal residue", new Color(75, 255, 65));\r
+      featureColours.put("nucleotide phosphate-binding region",\r
+                         new Color(65, 245, 75));\r
+      featureColours.put("peptide", new Color(55, 235, 85));\r
+      featureColours.put("propeptide", new Color(45, 225, 95));\r
+      featureColours.put("region of interest", new Color(35, 215, 105));\r
+      featureColours.put("repeat", new Color(25, 205, 115));\r
+      featureColours.put("selenocysteine", new Color(15, 195, 125));\r
+      featureColours.put("sequence conflict", new Color(5, 185, 135));\r
+      featureColours.put("sequence variant", new Color(0, 175, 145));\r
+      featureColours.put("short sequence motif", new Color(0, 165, 155));\r
+      featureColours.put("signal peptide", new Color(0, 155, 165));\r
+      featureColours.put("site", new Color(0, 145, 175));\r
+      featureColours.put("splice variant", new Color(0, 135, 185));\r
+      featureColours.put("strand", new Color(0, 125, 195));\r
+      featureColours.put("topological domain", new Color(0, 115, 205));\r
+      featureColours.put("transit peptide", new Color(0, 105, 215));\r
+      featureColours.put("transmembrane region", new Color(0, 95, 225));\r
+      featureColours.put("turn", new Color(0, 85, 235));\r
+      featureColours.put("unsure residue", new Color(0, 75, 245));\r
+      featureColours.put("zinc finger region", new Color(0, 65, 255));\r
+    }\r
+\r
 }\r
diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java
new file mode 100755 (executable)
index 0000000..aa9f827
--- /dev/null
@@ -0,0 +1,343 @@
+package jalview.gui;\r
+\r
+import jalview.datamodel.*;\r
+import javax.swing.*;\r
+import javax.swing.event.*;\r
+import java.awt.*;\r
+import java.util.*;\r
+import javax.swing.BorderFactory;\r
+import java.awt.event.*;\r
+import javax.swing.table.*;\r
+\r
+public class FeatureSettings extends JPanel\r
+{\r
+  Vector allFeatures;\r
+  final FeatureRenderer fr;\r
+  final AlignmentPanel ap;\r
+  Object [][] originalData;\r
+\r
+  public FeatureSettings(AlignViewport av, final AlignmentPanel ap)\r
+  {\r
+    this.ap = ap;\r
+    fr = ap.seqPanel.seqCanvas.getFeatureRenderer();\r
+    av.alignment.getSequences();\r
+    final JInternalFrame frame = new JInternalFrame();\r
+    frame.setContentPane(this);\r
+    Desktop.addInternalFrame(frame, "Sequence Feature Settings", 500, 300);\r
+\r
+\r
+    allFeatures = new Vector();\r
+    Vector features;\r
+    Enumeration e;\r
+    SequenceFeature sf;\r
+    for(int i=0; i< av.alignment.getHeight(); i++)\r
+    {\r
+       features = av.alignment.getSequenceAt(i).getSequenceFeatures();\r
+       if(features==null)\r
+         continue;\r
+\r
+       e = features.elements();\r
+       while(e.hasMoreElements())\r
+       {\r
+         sf = (SequenceFeature)e.nextElement();\r
+         if(!allFeatures.contains(sf.getType()))\r
+         {\r
+           allFeatures.addElement(sf.getType());\r
+         }\r
+       }\r
+    }\r
+    if(allFeatures.size()<1)\r
+     {\r
+       try{\r
+         frame.setClosed(true);\r
+       }catch(Exception ex){}\r
+       return;\r
+     }\r
+\r
+    int fSize = allFeatures.size();\r
+\r
+    String type;\r
+    Object [][] data = new Object[fSize][3];\r
+    originalData = new Object[fSize][3];\r
+    for(int i=0; i<fSize; i++)\r
+    {\r
+      type = allFeatures.elementAt(i).toString();\r
+      Color col = fr.getColour(type);\r
+      data[i][0]=type;\r
+      data[i][1]=col;\r
+      data[i][2]= new Boolean(true);\r
+      originalData[i][0]=type;\r
+      originalData[i][1]=col;\r
+      originalData[i][2]= new Boolean(true);\r
+    }\r
+\r
+    final JSlider transparency = new JSlider(0,70,0);\r
+    transparency.addChangeListener(new ChangeListener()\r
+        {\r
+          public void stateChanged(ChangeEvent evt)\r
+          {\r
+            fr.setTransparency( (float)(100-transparency.getValue())/100f);\r
+            ap.repaint();\r
+          }\r
+        });\r
+\r
+    JPanel transPanel = new JPanel(new FlowLayout());\r
+    transPanel.add(new JLabel("Transparency"));\r
+    transPanel.add(transparency);\r
+\r
+\r
+\r
+    ////////////////////////////////////\r
+    //Now build the table\r
+    final JTable table = new JTable(new FeatureTableModel(data));\r
+    JScrollPane scrollPane = new JScrollPane(table);\r
+    table.getTableHeader().setFont(new Font("Verdana", Font.PLAIN, 12));\r
+    table.setFont(new Font("Verdana", Font.PLAIN, 12));\r
+    table.setDefaultRenderer(Color.class,\r
+                         new ColorRenderer());\r
+\r
+    table.setDefaultEditor(Color.class,\r
+                      new ColorEditor());\r
+\r
+    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
+\r
+    table.addMouseListener(new MouseAdapter()\r
+        {\r
+          public void mousePressed(MouseEvent evt)\r
+          {\r
+            selectedRow = table.rowAtPoint(evt.getPoint());\r
+          }\r
+        });\r
+\r
+    table.addMouseMotionListener(new MouseMotionAdapter()\r
+        {\r
+          public void mouseDragged(MouseEvent evt)\r
+          {\r
+            int newRow = table.rowAtPoint(evt.getPoint());\r
+            if(newRow!=selectedRow\r
+               && selectedRow!=-1\r
+               && newRow!=-1)\r
+            {\r
+              Object[] temp = new Object[3];\r
+              temp[0] = table.getValueAt(selectedRow, 0);\r
+              temp[1] = table.getValueAt(selectedRow, 1);\r
+              temp[2] = table.getValueAt(selectedRow, 2);\r
+\r
+              table.setValueAt(table.getValueAt(newRow, 0), selectedRow, 0);\r
+              table.setValueAt(table.getValueAt(newRow, 1), selectedRow, 1);\r
+              table.setValueAt(table.getValueAt(newRow, 2), selectedRow, 2);\r
+\r
+              table.setValueAt(temp[0], newRow, 0);\r
+              table.setValueAt(temp[1], newRow, 1);\r
+              table.setValueAt(temp[2], newRow, 2);\r
+\r
+              selectedRow = newRow;\r
+            }\r
+          }\r
+        });\r
+\r
+      //////////////////////////////////////////////\r
+      //We're going to need those OK cancel buttons\r
+      JPanel buttonPanel = new JPanel(new FlowLayout());\r
+        JButton button = new JButton("OK");\r
+        button.addActionListener(new ActionListener()\r
+        {\r
+          public void actionPerformed(ActionEvent evt)\r
+          {\r
+            try {\r
+              frame.setClosed(true);\r
+            }\r
+            catch (Exception exe)\r
+            {}\r
+          }\r
+        });\r
+        buttonPanel.add(button);\r
+        button = new JButton("Cancel");\r
+        button.addActionListener(new ActionListener()\r
+        {\r
+          public void actionPerformed(ActionEvent evt)\r
+          {\r
+            try{\r
+              updateFeatureRenderer(originalData);\r
+              frame.setClosed(true);\r
+            }catch(Exception exe){}\r
+          }\r
+        });\r
+        buttonPanel.add(button);\r
+\r
+\r
+        this.setLayout(new BorderLayout());\r
+        JPanel bigPanel = new JPanel(new BorderLayout());\r
+        bigPanel.add(transPanel, BorderLayout.SOUTH);\r
+        bigPanel.add(scrollPane, BorderLayout.CENTER);\r
+\r
+        add(bigPanel, BorderLayout.CENTER);\r
+        add(buttonPanel, BorderLayout.SOUTH);\r
+\r
+  }\r
+\r
+  public void updateFeatureRenderer(Object [][] data)\r
+  {\r
+    fr.setFeaturePriority( data );\r
+    ap.repaint();\r
+  }\r
+\r
+  int selectedRow =-1;\r
+\r
+\r
+  /////////////////////////////////////////////////////////////////////////\r
+  // http://java.sun.com/docs/books/tutorial/uiswing/components/table.html\r
+  /////////////////////////////////////////////////////////////////////////\r
+  class FeatureTableModel\r
+      extends AbstractTableModel\r
+  {\r
+    FeatureTableModel(Object[][] data)\r
+    {\r
+      this.data = data;\r
+    }\r
+\r
+    private String[] columnNames = {"Feature Type", "Colour","Display"};\r
+          private Object[][] data;\r
+\r
+          public Object[][] getData()\r
+          {\r
+            return data;\r
+          }\r
+\r
+          public int getColumnCount() {\r
+              return columnNames.length;\r
+          }\r
+\r
+          public Object[] getRow(int row)\r
+          {\r
+            return data[row];\r
+          }\r
+\r
+          public int getRowCount() {\r
+              return data.length;\r
+          }\r
+\r
+          public String getColumnName(int col) {\r
+              return columnNames[col];\r
+          }\r
+\r
+          public Object getValueAt(int row, int col) {\r
+              return data[row][col];\r
+          }\r
+\r
+          public Class getColumnClass(int c) {\r
+              return getValueAt(0, c).getClass();\r
+          }\r
+\r
+          public boolean isCellEditable(int row, int col) {\r
+              return col==0 ? false:true;\r
+          }\r
+\r
+          public void setValueAt(Object value, int row, int col) {\r
+              data[row][col] = value;\r
+              fireTableCellUpdated(row, col);\r
+              updateFeatureRenderer(data);\r
+          }\r
+\r
+    }\r
+    class ColorRenderer extends JLabel\r
+                              implements TableCellRenderer {\r
+       javax.swing.border.Border unselectedBorder = null;\r
+       javax.swing.border.Border selectedBorder = null;\r
+\r
+       public ColorRenderer() {\r
+           setOpaque(true); //MUST do this for background to show up.\r
+       }\r
+\r
+       public Component getTableCellRendererComponent(\r
+                               JTable table, Object color,\r
+                               boolean isSelected, boolean hasFocus,\r
+                               int row, int column) {\r
+           Color newColor = (Color)color;\r
+           setBackground(newColor);\r
+               if (isSelected) {\r
+                   if (selectedBorder == null) {\r
+                       selectedBorder = BorderFactory.createMatteBorder(2,5,2,5,\r
+                                                 table.getSelectionBackground());\r
+                   }\r
+                   setBorder(selectedBorder);\r
+               } else {\r
+                   if (unselectedBorder == null) {\r
+                       unselectedBorder = BorderFactory.createMatteBorder(2,5,2,5,\r
+                                                 table.getBackground());\r
+                   }\r
+                   setBorder(unselectedBorder);\r
+               }\r
+\r
+           setToolTipText("RGB value: " + newColor.getRed() + ", "\r
+                                        + newColor.getGreen() + ", "\r
+                                        + newColor.getBlue());\r
+           return this;\r
+       }\r
+   }\r
+}\r
+\r
+ class ColorEditor extends AbstractCellEditor\r
+                          implements TableCellEditor,\r
+                                     ActionListener {\r
+     Color currentColor;\r
+     JButton button;\r
+     JColorChooser colorChooser;\r
+     JDialog dialog;\r
+     protected static final String EDIT = "edit";\r
+\r
+     public ColorEditor() {\r
+         //Set up the editor (from the table's point of view),\r
+         //which is a button.\r
+         //This button brings up the color chooser dialog,\r
+         //which is the editor from the user's point of view.\r
+         button = new JButton();\r
+         button.setActionCommand(EDIT);\r
+         button.addActionListener(this);\r
+         button.setBorderPainted(false);\r
+         //Set up the dialog that the button brings up.\r
+         colorChooser = new JColorChooser();\r
+         dialog = JColorChooser.createDialog(button,\r
+                                         "Select new Colour",\r
+                                         true,  //modal\r
+                                         colorChooser,\r
+                                         this,  //OK button handler\r
+                                         null); //no CANCEL button handler\r
+     }\r
+\r
+     /**\r
+      * Handles events from the editor button and from\r
+      * the dialog's OK button.\r
+      */\r
+     public void actionPerformed(ActionEvent e) {\r
+\r
+          if (EDIT.equals(e.getActionCommand())) {\r
+             //The user has clicked the cell, so\r
+             //bring up the dialog.\r
+             button.setBackground(currentColor);\r
+             colorChooser.setColor(currentColor);\r
+             dialog.setVisible(true);\r
+\r
+             //Make the renderer reappear.\r
+             fireEditingStopped();\r
+\r
+         } else { //User pressed dialog's "OK" button.\r
+             currentColor = colorChooser.getColor();\r
+         }\r
+     }\r
+\r
+     //Implement the one CellEditor method that AbstractCellEditor doesn't.\r
+     public Object getCellEditorValue() {\r
+         return currentColor;\r
+     }\r
+\r
+     //Implement the one method defined by TableCellEditor.\r
+     public Component getTableCellEditorComponent(JTable table,\r
+                                                  Object value,\r
+                                                  boolean isSelected,\r
+                                                  int row,\r
+                                                  int column) {\r
+         currentColor = (Color)value;\r
+         return button;\r
+     }\r
+}\r
index ddaf4aa..33bb9de 100755 (executable)
@@ -85,7 +85,7 @@ public class FontChooser extends GFontChooser
             fontName.addItem(fonts[i]);\r
         }\r
 \r
-        for (int i = 1; i < 31; i++)\r
+        for (int i = 1; i < 51; i++)\r
         {\r
             fontSize.addItem(i + "");\r
         }\r
diff --git a/src/jalview/gui/GFeatureSelector.java b/src/jalview/gui/GFeatureSelector.java
new file mode 100755 (executable)
index 0000000..af5d135
--- /dev/null
@@ -0,0 +1,28 @@
+package jalview.gui;\r
+\r
+import javax.swing.*;\r
+\r
+public class GFeatureSelector\r
+    extends JPanel\r
+{\r
+  public GFeatureSelector()\r
+  {\r
+    try\r
+    {\r
+      jbInit();\r
+    }\r
+    catch (Exception ex)\r
+    {\r
+      ex.printStackTrace();\r
+    }\r
+  }\r
+\r
+  private void jbInit()\r
+      throws Exception\r
+  {\r
+    jLabel1.setText("Feature");\r
+    this.add(jLabel1);\r
+  }\r
+\r
+  JLabel jLabel1 = new JLabel();\r
+}\r
index 635e455..534f68f 100755 (executable)
@@ -69,7 +69,7 @@ public class OverviewPanel extends JPanel implements Runnable
         // scale the initial size of overviewpanel to shape of alignment\r
         float initialScale = (float) av.alignment.getWidth() / (float) av.alignment.getHeight();\r
 \r
-        if(av.vconsensus==null)\r
+        if(av.conservation==null)\r
           graphHeight = 0;\r
 \r
 \r
index 32aad84..078eff1 100755 (executable)
@@ -140,6 +140,21 @@ public class Preferences extends GPreferences
         epsRendering.addItem("Text");\r
         epsRendering.setSelectedItem( Cache.getDefault("EPS_RENDERING", "Prompt each time"));\r
 \r
+        blcdb.setSelected( Cache.getDefault("BLC_DBPREFIX", false) );\r
+        blcjv.setSelected( Cache.getDefault("BLC_JVSUFFIX", true) );\r
+        clustaldb.setSelected( Cache.getDefault("CLUSTAL_DBPREFIX", false) );\r
+        clustaljv.setSelected( Cache.getDefault("CLUSTAL_JVSUFFIX", true) );\r
+        fastadb.setSelected( Cache.getDefault("FASTA_DBPREFIX", false) );\r
+        fastajv.setSelected( Cache.getDefault("FASTA_JVSUFFIX", true) );\r
+        msfdb.setSelected( Cache.getDefault("MSF_DBPREFIX", false) );\r
+        msfjv.setSelected( Cache.getDefault("MSF_JVSUFFIX", true) );\r
+        pfamdb.setSelected( Cache.getDefault("PFAM_DBPREFIX", false) );\r
+        pfamjv.setSelected( Cache.getDefault("PFAM_JVSUFFIX", true) );\r
+        pileupdb.setSelected( Cache.getDefault("PILEUP_DBPREFIX", false) );\r
+        pileupjv.setSelected( Cache.getDefault("PILEUP_JVSUFFIX", true) );\r
+        pirdb.setSelected( Cache.getDefault("PIR_DBPREFIX", false) );\r
+        pirjv.setSelected( Cache.getDefault("PIR_JVSUFFIX", true) );\r
+\r
   /****************************************************\r
    * Set up Connections\r
    */\r
@@ -257,6 +272,21 @@ public class Preferences extends GPreferences
         }\r
 \r
 \r
+        Cache.applicationProperties.setProperty("BLC_DBPREFIX", Boolean.toString(blcdb.isSelected()) );\r
+        Cache.applicationProperties.setProperty("BLC_JVSUFFIX", Boolean.toString(blcjv.isSelected()) );\r
+        Cache.applicationProperties.setProperty("CLUSTAL_DBPREFIX", Boolean.toString(clustaldb.isSelected()) );\r
+        Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX", Boolean.toString(clustaljv.isSelected()) );\r
+        Cache.applicationProperties.setProperty("FASTA_DBPREFIX", Boolean.toString(fastadb.isSelected()) );\r
+        Cache.applicationProperties.setProperty("FASTA_JVSUFFIX", Boolean.toString(fastajv.isSelected()) );\r
+        Cache.applicationProperties.setProperty("MSF_DBPREFIX", Boolean.toString(msfdb.isSelected()) );\r
+        Cache.applicationProperties.setProperty("MSF_JVSUFFIX", Boolean.toString(msfjv.isSelected()) );\r
+        Cache.applicationProperties.setProperty("PFAM_DBPREFIX", Boolean.toString(pfamdb.isSelected()) );\r
+        Cache.applicationProperties.setProperty("PFAM_JVSUFFIX", Boolean.toString(pfamjv.isSelected()) );\r
+        Cache.applicationProperties.setProperty("PILEUP_DBPREFIX", Boolean.toString(pileupdb.isSelected()) );\r
+        Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX", Boolean.toString(pileupjv.isSelected()) );\r
+        Cache.applicationProperties.setProperty("PIR_DBPREFIX", Boolean.toString(pirdb.isSelected()) );\r
+        Cache.applicationProperties.setProperty("PIR_JVSUFFIX", Boolean.toString(pirjv.isSelected()) );\r
+\r
 \r
         Cache.saveProperties();\r
         try\r
index 7f9ee97..fd19721 100755 (executable)
@@ -24,6 +24,7 @@ import java.awt.*;
 import java.awt.image.*;\r
 \r
 import javax.swing.*;\r
+import jalview.schemes.*;\r
 \r
 \r
 /**\r
@@ -64,6 +65,11 @@ public class SeqCanvas extends JComponent
         setBackground(Color.white);\r
     }\r
 \r
+    public FeatureRenderer getFeatureRenderer()\r
+    {\r
+      return fr;\r
+    }\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -513,28 +519,76 @@ public class SeqCanvas extends JComponent
     synchronized public void drawPanel(Graphics g1, int x1, int x2, int y1,\r
         int y2, int startx, int starty, int offset)\r
     {\r
-        Graphics2D g = (Graphics2D) g1;\r
-        g.setFont(av.getFont());\r
+      Graphics2D g = (Graphics2D) g1;\r
+      g.setFont(av.getFont());\r
 \r
+      SequenceI nextSeq, dna = null;\r
+      int aaHeight = av.charHeight, dnaHeight = av.charHeight;\r
+      Font dnafont = null, aafont = av.getFont();\r
 \r
-  SequenceI nextSeq;\r
+ /*     if (av.getShowTranslation())\r
+      {\r
+        aaHeight = (int) (av.getCharHeight() * aaRatio);\r
+        dnaHeight = (int) (av.getCharHeight() * (1 - aaRatio));\r
+        java.awt.geom.AffineTransform transform = new java.awt.geom.AffineTransform();\r
+        transform.scale(1f / 3f, 1);\r
+        dnafont = new Font(av.getFont().getName(), av.getFont().getStyle(),\r
+                                dnaHeight);\r
+        dnafont = dnafont.deriveFont(transform);\r
+\r
+        aafont = new Font(av.getFont().getName(), av.getFont().getStyle(),\r
+                               aaHeight);\r
+        transform = new java.awt.geom.AffineTransform();\r
+        transform.scale(1 / aaRatio, 1);\r
+        aafont = aafont.deriveFont(transform);\r
+      }\r
+*/\r
 \r
+      ColourSchemeI cs = av.getGlobalColourScheme();\r
 \r
         /// First draw the sequences\r
         /////////////////////////////\r
         for (int i = y1; i < y2; i++)\r
         {\r
             nextSeq = av.alignment.getSequenceAt(i);\r
-            g.setFont(av.getFont());\r
-\r
+            g.setFont(aafont);\r
+         /*   if(av.getShowTranslation())\r
+            {\r
+              dna = nextSeq;\r
+              StringBuffer sb = new StringBuffer();\r
+              for(int r = 0; r<nextSeq.getLength(); r+=3)\r
+              {\r
+                String codon = nextSeq.getSequence(r, r+3);\r
+                codon = codon.replace('U', 'T');\r
+                String res = ResidueProperties.codonTranslate(codon);\r
+                if(res !=null )\r
+                {\r
+                  if (res.equals("STOP"))\r
+                    sb.append("X");\r
+                  else\r
+                    sb.append(res);\r
+                }\r
+              }\r
+              nextSeq = new Sequence("d", sb.toString());\r
+            }*/\r
 \r
             sr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq),\r
                             x1, x2, (x1 - startx) * av.charWidth,\r
                             offset + ( (i - starty) * av.charHeight), av.charWidth,\r
-                            av.charHeight);\r
-\r
+                            aaHeight);\r
 \r
 \r
+         /*   if(av.getShowTranslation())\r
+            {\r
+              av.setGlobalColourScheme(new NucleotideColourScheme());\r
+              g.setFont(dnafont);\r
+              sr.drawSequence(g, dna, null,\r
+                              x1*3, (x2+2) * 3, ( (x1 - startx) * av.charWidth) / 3,\r
+                              offset + ( (i - starty) * av.charHeight) + aaHeight,\r
+                              av.charWidth / 3,\r
+                              dnaHeight);\r
+              av.setGlobalColourScheme(cs);\r
+            }*/\r
 \r
             if (av.showSequenceFeatures)\r
             {\r
@@ -551,20 +605,18 @@ public class SeqCanvas extends JComponent
         // Now outline any areas if necessary\r
         /////////////////////////////////////\r
         SequenceGroup group = av.getSelectionGroup();\r
-        java.util.Vector groups = av.alignment.getGroups();\r
 \r
         int sx = -1;\r
         int sy = -1;\r
         int ex = -1;\r
         int groupIndex = -1;\r
 \r
-        if ((group == null) && (groups.size() > 0))\r
+        if ((group == null) && (av.alignment.getGroups().size() > 0))\r
         {\r
-            group = (SequenceGroup) groups.elementAt(0);\r
+            group = (SequenceGroup) av.alignment.getGroups().elementAt(0);\r
             groupIndex = 0;\r
         }\r
 \r
-\r
         if (group != null && !isOverview)\r
         {\r
             do\r
@@ -701,14 +753,14 @@ public class SeqCanvas extends JComponent
 \r
                 groupIndex++;\r
 \r
-                if (groupIndex >= groups.size())\r
+                if (groupIndex >= av.alignment.getGroups().size())\r
                 {\r
                     break;\r
                 }\r
 \r
-                group = (SequenceGroup) groups.elementAt(groupIndex);\r
+                group = (SequenceGroup) av.alignment.getGroups().elementAt(groupIndex);\r
             }\r
-            while (groupIndex < groups.size());\r
+            while (groupIndex < av.alignment.getGroups().size());\r
         }\r
 \r
         /// Highlight search Results once all sequences have been drawn\r
index a68b226..53130af 100755 (executable)
@@ -89,6 +89,7 @@ public class SeqPanel extends JPanel
 \r
         ap = p;\r
 \r
+\r
         addMouseMotionListener(new MouseMotionAdapter()\r
             {\r
                 public void mouseMoved(MouseEvent evt)\r
@@ -100,10 +101,12 @@ public class SeqPanel extends JPanel
                 {\r
                     if (editingSeqs)\r
                     {\r
+                      if(!av.isDataset())\r
                         doMouseDragged(evt);\r
                     }\r
                     else\r
                     {\r
+                      if(!av.isDataset())\r
                         doMouseDraggedDefineMode(evt);\r
                     }\r
                 }\r
@@ -118,7 +121,7 @@ public class SeqPanel extends JPanel
            {\r
              Font font = av.getFont();\r
              int fontSize = font.getSize();\r
-             if (e.getWheelRotation() > 0 && fontSize < 30)\r
+             if (e.getWheelRotation() > 0 && fontSize < 51)\r
                fontSize++;\r
              else if (fontSize > 1)\r
                fontSize--;\r
@@ -138,67 +141,70 @@ public class SeqPanel extends JPanel
        });\r
 \r
 \r
-        addMouseListener(new MouseAdapter()\r
-            {\r
-                public void mouseReleased(MouseEvent evt)\r
-                {\r
-                    mouseWheelPressed = false;\r
-\r
-                    if (editingSeqs)\r
-                    {\r
-                        doMouseReleased(evt);\r
-                    }\r
-                    else\r
-                    {\r
-                        doMouseReleasedDefineMode(evt);\r
-                    }\r
-                }\r
-\r
-                public void mousePressed(MouseEvent evt)\r
-                {\r
-                  if( javax.swing.SwingUtilities.isMiddleMouseButton(evt))\r
-                  {\r
-                    mouseWheelPressed = true;\r
-                    return;\r
-                  }\r
+       if(!av.isDataset())\r
+       {\r
+         addMouseListener(new MouseAdapter()\r
+         {\r
+           public void mouseReleased(MouseEvent evt)\r
+           {\r
+             mouseWheelPressed = false;\r
 \r
-                    if (evt.isShiftDown() || evt.isAltDown() ||\r
-                            evt.isControlDown())\r
-                    {\r
-                        if (evt.isAltDown() || evt.isControlDown())\r
-                        {\r
-                            groupEditing = true;\r
-                        }\r
+             if (editingSeqs)\r
+             {\r
+               doMouseReleased(evt);\r
+             }\r
+             else\r
+             {\r
+               doMouseReleasedDefineMode(evt);\r
+             }\r
+           }\r
 \r
-                        editingSeqs = true;\r
-                        doMousePressed(evt);\r
-                    }\r
-                    else\r
-                    {\r
-                        doMousePressedDefineMode(evt);\r
-                    }\r
-                }\r
+           public void mousePressed(MouseEvent evt)\r
+           {\r
+             if (javax.swing.SwingUtilities.isMiddleMouseButton(evt))\r
+             {\r
+               mouseWheelPressed = true;\r
+               return;\r
+             }\r
+\r
+             if (evt.isShiftDown() || evt.isAltDown() ||\r
+                 evt.isControlDown())\r
+             {\r
+               if (evt.isAltDown() || evt.isControlDown())\r
+               {\r
+                 groupEditing = true;\r
+               }\r
+\r
+               editingSeqs = true;\r
+               doMousePressed(evt);\r
+             }\r
+             else\r
+             {\r
+               doMousePressedDefineMode(evt);\r
+             }\r
+           }\r
 \r
-                public void mouseExited(MouseEvent evt)\r
-                {\r
-                  if (editingSeqs)\r
-                  {\r
-                    return;\r
-                  }\r
+           public void mouseExited(MouseEvent evt)\r
+           {\r
+             if (editingSeqs)\r
+             {\r
+               return;\r
+             }\r
 \r
-                  doMouseExitedDefineMode(evt);\r
-                }\r
+             doMouseExitedDefineMode(evt);\r
+           }\r
 \r
-                public void mouseEntered(MouseEvent evt)\r
-                {\r
-                  if (editingSeqs)\r
-                  {\r
-                    return;\r
-                  }\r
+           public void mouseEntered(MouseEvent evt)\r
+           {\r
+             if (editingSeqs)\r
+             {\r
+               return;\r
+             }\r
 \r
-                    doMouseEnteredDefineMode(evt);\r
-                }\r
-            });\r
+             doMouseEnteredDefineMode(evt);\r
+           }\r
+         });\r
+       }\r
     }\r
 \r
     int startWrapBlock=-1;\r
@@ -377,31 +383,38 @@ public class SeqPanel extends JPanel
         if (av.showSequenceFeatures)\r
         {\r
             Vector features = sequence.getSequenceFeatures();\r
-            Enumeration e = features.elements();\r
-            StringBuffer sbuffer = new StringBuffer();\r
-\r
-            while (e.hasMoreElements())\r
+            if(features!=null)\r
             {\r
-                SequenceFeature sf = (SequenceFeature) e.nextElement();\r
+              StringBuffer sbuffer = new StringBuffer("<html>");\r
 \r
-                if ((sf.getStart() <= sequence.findPosition(res)) &&\r
-                        (sf.getEnd() >= sequence.findPosition(res)))\r
+              for (int i = 0; i < features.size(); i++)\r
+              {\r
+                SequenceFeature sf = (SequenceFeature) features.elementAt(i);\r
+\r
+                if ( (sf.getBegin() <= sequence.findPosition(res)) &&\r
+                    (sf.getEnd() >= sequence.findPosition(res)))\r
                 {\r
-                    if (sbuffer.length() > 0)\r
-                    {\r
-                        sbuffer.append("; ");\r
-                    }\r
+                  if (sbuffer.length() > 6)\r
+                    sbuffer.append("<br>");\r
 \r
-                    sbuffer.append(sf.getType() + " " + sf.getDescription());\r
+                  sbuffer.append(sf.getType());\r
+                  if (sf.getDescription() != null)\r
+                    sbuffer.append(" " + sf.getDescription());\r
 \r
-                    if (sf.getStatus().length() > 0)\r
-                    {\r
-                        sbuffer.append(" (" + sf.getStatus() + ")");\r
-                    }\r
+                  if (sf.getStatus() != null)\r
+                  {\r
+                    sbuffer.append(" (" + sf.getStatus() + ")");\r
+                  }\r
                 }\r
-            }\r
 \r
-            this.setToolTipText(sbuffer.toString());\r
+              }\r
+\r
+              sbuffer.append("</html>");\r
+              if(sbuffer.equals("<html></html>"))\r
+                setToolTipText("");\r
+              else\r
+               setToolTipText(sbuffer.toString());\r
+            }\r
         }\r
     }\r
 \r
index 6bf4d40..b961b2c 100755 (executable)
@@ -116,10 +116,10 @@ public class SequenceRenderer
 \r
         graphics = g;\r
 \r
-        drawBoxes(seq, start, end, x1, y1, width, height);\r
+        drawBoxes(seq, start, end, x1, y1, (int) width, height);\r
 \r
         fm = g.getFontMetrics();\r
-        drawText(seq, start, end, x1, y1,  width, height);\r
+        drawText(seq, start, end, x1, y1, (int) width, height);\r
     }\r
 \r
     /**\r
@@ -168,7 +168,14 @@ public class SequenceRenderer
             {\r
                 if (tempColour != null)\r
                 {\r
-                    graphics.fillRect(x1 + (width * (curStart - start)), y1,\r
+                  int xxx = x1 + (int) (av.charWidth * (curStart - start));\r
+                  if (width != av.charWidth)\r
+                  {\r
+                    xxx = x1 + (int) (av.charWidth * (curStart - start)) / 3;\r
+                  }\r
+\r
+\r
+                    graphics.fillRect(xxx, y1,\r
                         curWidth, height);\r
                 }\r
 \r
@@ -186,7 +193,14 @@ public class SequenceRenderer
             i++;\r
         }\r
 \r
-        graphics.fillRect(x1 + (width * (curStart - start)), y1, curWidth,\r
+        int xxx = x1 + (int) (av.charWidth * (curStart - start));\r
+        if (width != av.charWidth)\r
+        {\r
+          xxx = x1 + (int) (av.charWidth * (curStart - start)) / 3;\r
+        }\r
+\r
+\r
+        graphics.fillRect(xxx, y1, curWidth,\r
             height);\r
     }\r
 \r
@@ -208,6 +222,7 @@ public class SequenceRenderer
         int charOffset = 0;\r
         char s;\r
 \r
+\r
         // Need to find the sequence position here.\r
         String sequence = seq.getSequence();\r
 \r
@@ -261,8 +276,14 @@ public class SequenceRenderer
             }\r
 \r
             charOffset = (width - fm.charWidth(s)) / 2;\r
-            graphics.drawString(String.valueOf(s),\r
-                charOffset + x1 + (int)(width * (i - start)), (y1 + height) - pady);\r
+\r
+            int xxx = charOffset + x1 + (int)(av.charWidth * (i - start));\r
+            if(width != av.charWidth)\r
+            {\r
+              xxx = charOffset + x1 + (int)(av.charWidth * (i - start))/3;\r
+            }\r
+\r
+            graphics.drawString(String.valueOf(s),xxx, (y1 + height) - pady);\r
         }\r
     }\r
 \r
index 20624af..49730a0 100755 (executable)
@@ -127,10 +127,9 @@ public class SplashScreen extends JPanel implements Runnable
 \r
         int y = yoffset;\r
 \r
-        g.drawString("Jalview 2005 ", 50, y);\r
+        g.drawString("Jalview "+jalview.bin.Cache.getProperty("VERSION"), 50, y);\r
         g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2));\r
-        g.drawString("Version " + jalview.bin.Cache.getProperty("VERSION") +\r
-                     "; Last updated: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"),\r
+        g.drawString("Last updated: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"),\r
                      180, y);\r
 \r
         if (jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking").equals("Checking"))\r
index d22dc12..630dc6c 100755 (executable)
@@ -39,6 +39,8 @@ public abstract class AlignFile extends FileParse
     Vector headers;\r
     long start;\r
     long end;\r
+    boolean dbPrefix = false;\r
+    boolean jvSuffix = true;\r
 \r
     /**\r
      * Creates a new AlignFile object.\r
@@ -149,4 +151,99 @@ public abstract class AlignFile extends FileParse
      * Print out in alignment file format the Sequences in the seqs Vector.\r
      */\r
     public abstract String print();\r
+\r
+    public void addDBPrefix(boolean b)\r
+    {\r
+      dbPrefix = b;\r
+    }\r
+\r
+    public void addJVSuffix(boolean b)\r
+    {\r
+      jvSuffix = b;\r
+    }\r
+\r
+    /**\r
+     * A general parser for ids. Will look for dbrefs in\r
+     * Uniprot format source|id\r
+     * And also Jalview /start-end\r
+     *\r
+     * @String id Id to be parsed\r
+     */\r
+    Sequence parseId(String id)\r
+    {\r
+      Sequence seq = new Sequence("","");\r
+      int space = id.indexOf(" ");\r
+      if(space>-1)\r
+      {\r
+        seq.setDescription(id.substring(space+1));\r
+        id = id.substring(0, space);\r
+      }\r
+\r
+      // Read in any DB refs first\r
+      StringTokenizer st;\r
+      st = new StringTokenizer(id, "|");\r
+\r
+      while (st.countTokens()>2)\r
+      {\r
+        seq.addDBRef( new DBRefEntry( st.nextToken(), "0", st.nextToken()));\r
+      }\r
+\r
+      if(st.hasMoreTokens())\r
+        id = st.nextToken();\r
+\r
+\r
+      // Remove /start-end from sequence\r
+      if (id.indexOf("/") > 0)\r
+      {\r
+        st = new StringTokenizer(id, "/");\r
+\r
+        if (st.countTokens() == 2)\r
+        {\r
+          id = st.nextToken();\r
+\r
+          String tmp = st.nextToken();\r
+\r
+          st = new StringTokenizer(tmp, "-");\r
+\r
+          if (st.countTokens() == 2)\r
+          {\r
+            seq.setStart( Integer.valueOf(st.nextToken()).intValue() );\r
+            seq.setEnd( Integer.valueOf(st.nextToken()).intValue() );\r
+          }\r
+        }\r
+      }\r
+      seq.setName(id);\r
+      return seq;\r
+    }\r
+\r
+    /**\r
+     * Creates the output id.\r
+     * Adds prefix Uniprot format source|id\r
+     * And suffix Jalview /start-end\r
+     *\r
+     * @String id Id to be parsed\r
+     */\r
+    String printId(SequenceI seq)\r
+    {\r
+      StringBuffer result = new StringBuffer();\r
+      if(dbPrefix && seq.getDBRef()!=null)\r
+      {\r
+        Vector dbrefs = seq.getDBRef();\r
+        for(int i=0; i<dbrefs.size(); i++)\r
+        {\r
+          DBRefEntry entry = (DBRefEntry)dbrefs.elementAt(i);\r
+          result.append(entry.getSource()+"|"+entry.getAccessionId()+"|");\r
+        }\r
+      }\r
+\r
+      result.append(seq.getName());\r
+\r
+      if(jvSuffix)\r
+      {\r
+        result.append("/"+seq.getStart()+"-"+seq.getEnd());\r
+      }\r
+\r
+      return result.toString();\r
+    }\r
+\r
 }\r
diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java
new file mode 100755 (executable)
index 0000000..80a624d
--- /dev/null
@@ -0,0 +1,166 @@
+    /*\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
+    package jalview.io;\r
+\r
+    import jalview.datamodel.*;\r
+\r
+    import java.util.Vector;\r
+\r
+\r
+    /**\r
+     * DOCUMENT ME!\r
+     *\r
+     * @author $author$\r
+     * @version $Revision$\r
+     */\r
+    public class AppletFormatAdapter\r
+    {\r
+        /** DOCUMENT ME!! */\r
+        public static final Vector formats = new Vector();\r
+\r
+        static\r
+        {\r
+            formats.addElement("BLC");\r
+            formats.addElement("CLUSTAL");\r
+            formats.addElement("FASTA");\r
+            formats.addElement("MSF");\r
+            formats.addElement("PileUp");\r
+            formats.addElement("PIR");\r
+            formats.addElement("PFAM");\r
+        }\r
+\r
+        AlignFile afile = null;\r
+\r
+        /**\r
+         * DOCUMENT ME!\r
+         *\r
+         * @param inFile DOCUMENT ME!\r
+         * @param type DOCUMENT ME!\r
+         * @param format DOCUMENT ME!\r
+         *\r
+         * @return DOCUMENT ME!\r
+         */\r
+        public SequenceI[] readFile(String inFile, String type, String format)\r
+        {\r
+            try\r
+            {\r
+                if (format.equals("FASTA"))\r
+                {\r
+                    afile = new FastaFile(inFile, type);\r
+                }\r
+                else if (format.equals("MSF"))\r
+                {\r
+                    afile = new MSFfile(inFile, type);\r
+                }\r
+                else if (format.equals("PileUp"))\r
+                {\r
+                    afile = new PileUpfile(inFile, type);\r
+                }\r
+                else if (format.equals("CLUSTAL"))\r
+                {\r
+                    afile = new ClustalFile(inFile, type);\r
+                }\r
+                else if (format.equals("BLC"))\r
+                {\r
+                    afile = new BLCFile(inFile, type);\r
+                }\r
+                else if (format.equals("PIR"))\r
+                {\r
+                    afile = new PIRFile(inFile, type);\r
+                }\r
+                else if (format.equals("PFAM"))\r
+                {\r
+                    afile = new PfamFile(inFile, type);\r
+                }\r
+\r
+                return afile.getSeqsAsArray();\r
+            }\r
+            catch (Exception e)\r
+            {\r
+                System.err.println("Failed to read alignment using the '" + format +\r
+                    "' reader.");\r
+                e.printStackTrace();\r
+            }\r
+\r
+            return null;\r
+        }\r
+\r
+\r
+        /**\r
+         * DOCUMENT ME!\r
+         *\r
+         * @param format DOCUMENT ME!\r
+         * @param seqs DOCUMENT ME!\r
+         *\r
+         * @return DOCUMENT ME!\r
+         */\r
+        public String formatSequences(String format, Vector seqs)\r
+        {\r
+            SequenceI[] s = new SequenceI[seqs.size()];\r
+\r
+            for (int i = 0; i < seqs.size(); i++)\r
+                s[i] = (SequenceI) seqs.elementAt(i);\r
+\r
+            try\r
+            {\r
+                AlignFile afile = null;\r
+\r
+                if (format.equalsIgnoreCase("FASTA"))\r
+                {\r
+                    afile = new FastaFile();\r
+                }\r
+                else if (format.equalsIgnoreCase("MSF"))\r
+                {\r
+                    afile = new MSFfile();\r
+                }\r
+                else if (format.equalsIgnoreCase("PileUp"))\r
+                {\r
+                    afile = new PileUpfile();\r
+                }\r
+                else if (format.equalsIgnoreCase("CLUSTAL"))\r
+                {\r
+                    afile = new ClustalFile();\r
+                }\r
+                else if (format.equalsIgnoreCase("BLC"))\r
+                {\r
+                    afile = new BLCFile();\r
+                }\r
+                else if (format.equalsIgnoreCase("PIR"))\r
+                {\r
+                    afile = new PIRFile();\r
+                }\r
+                else if (format.equalsIgnoreCase("PFAM"))\r
+                {\r
+                    afile = new PfamFile();\r
+                }\r
+\r
+                afile.setSeqs(s);\r
+\r
+                return afile.print();\r
+            }\r
+            catch (Exception e)\r
+            {\r
+                System.err.println("Failed to write alignment as a '" + format +\r
+                    "' file\n");\r
+                e.printStackTrace();\r
+            }\r
+\r
+            return null;\r
+        }\r
+    }\r
index 0edcb63..ad2e48a 100755 (executable)
@@ -105,60 +105,18 @@ public class BLCFile extends AlignFile
 \r
                 if (abracket > -1)\r
                 {\r
-                    if (line.indexOf(" ") > -1) //\r
-                    {\r
-                        ///Colur it be this format?\r
-                        //>54402046         0             1   137   137:\r
-                        // or this??\r
-                        //     1   >L1H14       30539  343\r
-                        try\r
-                        {\r
-                            ids.addElement(line.substring(abracket + 1,\r
-                                    line.indexOf(" ", abracket + 1)));\r
-\r
-                            // remove p Value\r
-                            line = line.substring(abracket + 1);\r
-                            line = line.substring(line.indexOf(" ") + 1);\r
-                            line = line.trim();\r
-                            line = line.substring(line.indexOf(" ") + 1);\r
-                            line = line.trim();\r
-\r
-                            int value = Integer.parseInt(line.substring(0,\r
-                                        line.indexOf(" ")));\r
-                            starts.addElement(value + "");\r
-                            line = line.substring(line.indexOf(" ") + 1);\r
-                            line = line.trim();\r
-                            value = Integer.parseInt(line.substring(0,\r
-                                        line.indexOf(" ")));\r
-                            ends.addElement(value + "");\r
-                        }\r
-                        catch (Exception ex)\r
-                        {\r
-                            System.err.println("Error during blockfile read.");\r
-                            ex.printStackTrace();\r
-                            starts.addElement("1");\r
-                            ends.addElement("-1");\r
-                        }\r
-                    }\r
-                    else\r
-                    {\r
-                        if (line.indexOf("/") > -1)\r
-                        {\r
-                            ids.addElement(line.substring(abracket + 1,\r
-                                    line.indexOf("/")));\r
-                            line = line.substring(line.indexOf("/") + 1);\r
-                            starts.addElement(line.substring(0,\r
-                                    line.indexOf("-")));\r
-                            ends.addElement(line.substring(line.indexOf("-") +\r
-                                    1));\r
-                        }\r
-                        else\r
-                        {\r
-                            ids.addElement(line.substring(abracket + 1));\r
-                            starts.addElement("1");\r
-                            ends.addElement("-1");\r
-                        }\r
-                    }\r
+                  if (line.indexOf(" ") > -1) //\r
+                  {\r
+                    line = line.substring(abracket + 1,\r
+                                          line.indexOf(" ", abracket + 1));\r
+                  }\r
+                  else\r
+                    line = line.substring(abracket+1);\r
+\r
+                  Sequence seq = parseId(line);\r
+                  ids.addElement(seq.getName());\r
+                  starts.addElement(seq.getStart() + "");\r
+                  ends.addElement(seq.getEnd() + "");\r
                 }\r
             }\r
             while (!idsFound);\r
@@ -217,17 +175,22 @@ public class BLCFile extends AlignFile
      *\r
      * @return DOCUMENT ME!\r
      */\r
-    public static String print(SequenceI[] s)\r
+    public String print(SequenceI[] s)\r
     {\r
         StringBuffer out = new StringBuffer();\r
-\r
+        /**\r
+         * A general parser for ids. Will look for dbrefs in\r
+         * Uniprot format source|id\r
+         * And also Jalview /start-end\r
+         *\r
+         * @String id Id to be parsed\r
+     */\r
         int i = 0;\r
         int max = -1;\r
 \r
         while ((i < s.length) && (s[i] != null))\r
         {\r
-            out.append(">" + s[i].getName() + "/" + s[i].getStart() + "-" +\r
-                s[i].getEnd() + "\n");\r
+            out.append(">" + printId(s[i]) +"\n");\r
 \r
             if (s[i].getSequence().length() > max)\r
             {\r
index 71e86b3..981e3c9 100755 (executable)
@@ -27,7 +27,6 @@ import jalview.util.*;
 public class ClustalFile\r
     extends AlignFile\r
 {\r
-  Vector ids;\r
 \r
   public ClustalFile()\r
   {\r
@@ -47,7 +46,6 @@ public class ClustalFile
   public void initData()\r
   {\r
     super.initData();\r
-    ids = new Vector();\r
   }\r
 \r
   public void parse()\r
@@ -121,9 +119,6 @@ public class ClustalFile
       //Add sequences to the hash\r
       for (i = 0; i < headers.size(); i++)\r
       {\r
-        int start = 1;\r
-        int end = -1;\r
-\r
         if (seqhash.get(headers.elementAt(i)) != null)\r
         {\r
           if (maxLength < seqhash.get(headers.elementAt(i)).toString()\r
@@ -133,40 +128,8 @@ public class ClustalFile
                 .length();\r
           }\r
 \r
-          String head = headers.elementAt(i).toString();\r
-\r
-          if (head.indexOf("/") > 0)\r
-          {\r
-            StringTokenizer st = new StringTokenizer(head, "/");\r
-\r
-            if (st.countTokens() == 2)\r
-            {\r
-              ids.addElement(st.nextToken());\r
-\r
-              String tmp = st.nextToken();\r
-              st = new StringTokenizer(tmp, "-");\r
-\r
-              if (st.countTokens() == 2)\r
-              {\r
-                start = Integer.valueOf(st.nextToken())\r
-                    .intValue();\r
-                end = Integer.valueOf(st.nextToken()).intValue();\r
-              }\r
-            }\r
-            else\r
-            {\r
-              ids.addElement(headers.elementAt(i));\r
-            }\r
-          }\r
-          else\r
-          {\r
-            ids.addElement(headers.elementAt(i));\r
-          }\r
-\r
-          Sequence newSeq = new Sequence(ids.elementAt(i).toString(),\r
-                                         seqhash.get(headers.elementAt(i).\r
-              toString())\r
-                                         .toString(), start, end);\r
+          Sequence newSeq = parseId(headers.elementAt(i).toString());\r
+          newSeq.setSequence( seqhash.get(headers.elementAt(i).toString()).toString() );\r
 \r
           seqs.addElement(newSeq);\r
         }\r
@@ -185,7 +148,7 @@ public class ClustalFile
     return print(getSeqsAsArray());\r
   }\r
 \r
-  public static String print(SequenceI[] s)\r
+  public String print(SequenceI[] s)\r
   {\r
     StringBuffer out = new StringBuffer("CLUSTAL\n\n");\r
 \r
@@ -196,8 +159,7 @@ public class ClustalFile
 \r
     while ( (i < s.length) && (s[i] != null))\r
     {\r
-      String tmp = s[i].getName() + "/" + s[i].getStart() + "-" +\r
-          s[i].getEnd();\r
+      String tmp = printId(s[i]);\r
 \r
       if (s[i].getSequence().length() > max)\r
       {\r
@@ -228,8 +190,7 @@ public class ClustalFile
 \r
       while ( (j < s.length) && (s[j] != null))\r
       {\r
-        out.append(new Format("%-" + maxid + "s").form(s[j].getName() +\r
-            "/" + s[j].getStart() + "-" + s[j].getEnd()) + " ");\r
+        out.append(new Format("%-" + maxid + "s").form( printId(s[j]) + " "));\r
 \r
         int start = i * len;\r
         int end = start + len;\r
index eebbfc8..c1a0302 100755 (executable)
@@ -18,6 +18,8 @@
 */\r
 package jalview.io;\r
 \r
+import java.io.*;\r
+\r
 import org.apache.axis.AxisFault;\r
 import org.apache.axis.client.*;\r
 import org.apache.axis.encoding.XMLType;\r
@@ -118,6 +120,45 @@ public class EBIFetchClient
         }\r
     }\r
 \r
+    public static void main (String [] args)\r
+    {\r
+      EBIFetchClient ebi = new EBIFetchClient();\r
+      String[] result = ebi.fetchData("uniprot:25K89D_SARPE;G6PblobD_HUMAN",\r
+                           "xml", null);\r
+\r
+     try{\r
+       java.io.PrintWriter out = new java.io.PrintWriter(\r
+      new java.io.FileWriter("out.xml"));\r
+\r
+\r
+       for(int i=0; i<result.length; i++)\r
+       {\r
+         out.println(result[i]);\r
+       }\r
+       out.close();\r
+     }catch(Exception ex){ex.printStackTrace();}\r
+\r
+    }\r
+\r
+\r
+    public File fetchDataAsFile(String ids, String f, String s)\r
+    {\r
+      String [] data = fetchData(ids, f, s);\r
+      File outFile = null;\r
+      try{\r
+        outFile = File.createTempFile("jalview", ".xml");\r
+        PrintWriter out = new PrintWriter(new FileOutputStream(outFile));\r
+        int index=0;\r
+        while( index < data.length )\r
+        {\r
+          out.println(data[index]);\r
+          index++;\r
+        }\r
+        out.close();\r
+      }catch(Exception ex){}\r
+      return outFile;\r
+    }\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
index 757bb57..f1ce1fc 100755 (executable)
@@ -24,8 +24,6 @@ import jalview.datamodel.*;
 \r
 import java.io.*;\r
 \r
-import java.util.*;\r
-\r
 \r
 /**\r
  * DOCUMENT ME!\r
@@ -72,14 +70,11 @@ public class FastaFile extends AlignFile
      */\r
     public void parse() throws IOException\r
     {\r
-        String id = "";\r
-        StringBuffer seq = new StringBuffer();\r
+        StringBuffer sb = new StringBuffer();\r
         int count = 0;\r
 \r
-        int sstart = 0;\r
-        int send = 0;\r
-\r
         String line;\r
+        Sequence seq = null;\r
 \r
         while ((line = nextLine()) != null)\r
         {\r
@@ -88,138 +83,38 @@ public class FastaFile extends AlignFile
                 // Do we have an id line?\r
                 // JBPNote - this code needs to be standardised to EBI/whatever for the\r
                 // >dbref/dbref/dbref|refid1|refid2|refid3 'human-readable' style of naming (should it really exist)\r
-                if (line.substring(0, 1).equals(">"))\r
+                if (line.charAt(0)=='>')\r
                 {\r
+                    seq = parseId(line.substring(1));\r
+\r
                     if (count != 0)\r
                     {\r
-                        if (sstart != 0)\r
-                        {\r
-                            seqs.addElement(new Sequence(id, seq.toString(),\r
-                                    sstart, send));\r
-                        }\r
-                        else\r
-                        {\r
-                            seqs.addElement(new Sequence(id, seq.toString(), 1,\r
-                                    seq.length()));\r
-                        }\r
+                       seq.setSequence(sb.toString());\r
+                       seqs.addElement(seq);\r
                     }\r
 \r
                     count++;\r
-\r
-                    StringTokenizer str = new StringTokenizer(line, " ");\r
-\r
-                    id = str.nextToken();\r
-                    id = id.substring(1);\r
-\r
-                    com.stevesoft.pat.Regex dbId = new com.stevesoft.pat.Regex(\r
-                            "[A-Za-z-]+/?[A-Za-z-]+\\|(\\w+)\\|(.+)");\r
-\r
-                    // JBPNote At the moment - we don't get rid of the friendly names but this\r
-                    // behaviour is probably wrong in the long run.\r
-                    if (dbId.search(id))\r
-                    {\r
-                        String dbid = dbId.stringMatched(1);\r
-                        String idname = dbId.stringMatched(2);\r
-\r
-                        if ((idname.length() > 0) &&\r
-                                (idname.indexOf("_") > -1))\r
-                        {\r
-                            id = idname; // use the friendly name - apparently no dbid\r
-                        }\r
-                        else if (dbid.length() > 1)\r
-                        {\r
-                            id = dbid; // ignore the friendly name - we lose uniprot accession ID otherwise\r
-                        }\r
-                    }\r
-\r
-                    if (id.indexOf("/") > 0)\r
-                    {\r
-                        StringTokenizer st = new StringTokenizer(id, "/");\r
-\r
-                        if (st.countTokens() == 2)\r
-                        {\r
-                            id = st.nextToken();\r
-\r
-                            String tmp = st.nextToken();\r
-\r
-                            st = new StringTokenizer(tmp, "-");\r
-\r
-                            if (st.countTokens() == 2)\r
-                            {\r
-                                sstart = Integer.valueOf(st.nextToken())\r
-                                                .intValue();\r
-                                send = Integer.valueOf(st.nextToken()).intValue();\r
-                            }\r
-                        }\r
-                    }\r
-\r
-                    seq = new StringBuffer();\r
+                    sb = new StringBuffer();\r
                 }\r
                 else\r
                 {\r
-                    seq = seq.append(line);\r
+                    sb.append(line);\r
                 }\r
             }\r
         }\r
 \r
         if (count > 0)\r
         {\r
-            if (!isValidProteinSequence(seq.toString().toUpperCase()))\r
+            if (!isValidProteinSequence(sb.toString().toUpperCase()))\r
             {\r
                 throw new IOException("Invalid protein sequence");\r
             }\r
 \r
-            if (sstart != 0)\r
-            {\r
-                seqs.addElement(new Sequence(id, seq.toString().toUpperCase(),\r
-                        sstart, send));\r
-            }\r
-            else\r
-            {\r
-                seqs.addElement(new Sequence(id, seq.toString().toUpperCase(),\r
-                        1, seq.length()));\r
-            }\r
+            seq.setSequence(sb.toString());\r
+            seqs.addElement(seq);\r
         }\r
     }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param s DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public static String print(SequenceI[] s)\r
-    {\r
-        return print(s, 72);\r
-    }\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param s DOCUMENT ME!\r
-     * @param len DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public static String print(SequenceI[] s, int len)\r
-    {\r
-        return print(s, len, true);\r
-    }\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param s DOCUMENT ME!\r
-     * @param len DOCUMENT ME!\r
-     * @param gaps DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public static String print(SequenceI[] s, int len, boolean gaps)\r
-    {\r
-        return print(s, len, gaps, true);\r
-    }\r
 \r
     /**\r
      * DOCUMENT ME!\r
@@ -231,43 +126,34 @@ public class FastaFile extends AlignFile
      *\r
      * @return DOCUMENT ME!\r
      */\r
-    public static String print(SequenceI[] s, int len, boolean gaps,\r
-        boolean displayId)\r
+    public String print(SequenceI[] s)\r
     {\r
+        int len = 72;\r
         StringBuffer out = new StringBuffer();\r
         int i = 0;\r
 \r
         while ((i < s.length) && (s[i] != null))\r
         {\r
-            String seq = "";\r
-\r
-            if (gaps)\r
-            {\r
-                seq = s[i].getSequence();\r
-            }\r
-            else\r
-            {\r
-                seq = AlignSeq.extractGaps("-. ", s[i].getSequence());\r
-            }\r
+            out.append(">" + printId(s[i]));\r
+            if(s[i].getDescription()!=null)\r
+              out.append(" "+s[i].getDescription());\r
 \r
-            // used to always put this here: + "/" + s[i].getStart() + "-" + s[i].getEnd() +\r
-            out.append(">" +\r
-                ((displayId) ? s[i].getDisplayId() : s[i].getName()) + "\n");\r
+            out.append("\n");\r
 \r
-            int nochunks = (seq.length() / len) + 1;\r
+            int nochunks = (s[i].getLength() / len) + 1;\r
 \r
             for (int j = 0; j < nochunks; j++)\r
             {\r
                 int start = j * len;\r
                 int end = start + len;\r
 \r
-                if (end < seq.length())\r
+                if (end < s[i].getLength())\r
                 {\r
-                    out.append(seq.substring(start, end) + "\n");\r
+                    out.append(s[i].getSequence(start, end) + "\n");\r
                 }\r
-                else if (start < seq.length())\r
+                else if (start < s[i].getLength())\r
                 {\r
-                    out.append(seq.substring(start) + "\n");\r
+                    out.append(s[i].getSequence(start, s[i].getLength()) + "\n");\r
                 }\r
             }\r
 \r
index 61c2331..64f33cd 100755 (executable)
@@ -29,79 +29,8 @@ import java.util.Vector;
  * @author $author$\r
  * @version $Revision$\r
  */\r
-public class FormatAdapter\r
+public class FormatAdapter extends AppletFormatAdapter\r
 {\r
-    /** DOCUMENT ME!! */\r
-    public static final Vector formats = new Vector();\r
-\r
-    static\r
-    {\r
-        formats.addElement("FASTA");\r
-        formats.addElement("MSF");\r
-        formats.addElement("PileUp");\r
-        formats.addElement("CLUSTAL");\r
-        formats.addElement("BLC");\r
-        formats.addElement("PIR");\r
-        formats.addElement("PFAM");\r
-    }\r
-\r
-    AlignFile afile = null;\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param inFile DOCUMENT ME!\r
-     * @param type DOCUMENT ME!\r
-     * @param format DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public SequenceI[] readFile(String inFile, String type, String format)\r
-    {\r
-        try\r
-        {\r
-            if (format.equals("FASTA"))\r
-            {\r
-                afile = new FastaFile(inFile, type);\r
-            }\r
-            else if (format.equals("MSF"))\r
-            {\r
-                afile = new MSFfile(inFile, type);\r
-            }\r
-            else if (format.equals("PileUp"))\r
-            {\r
-                afile = new PileUpfile(inFile, type);\r
-            }\r
-            else if (format.equals("CLUSTAL"))\r
-            {\r
-                afile = new ClustalFile(inFile, type);\r
-            }\r
-            else if (format.equals("BLC"))\r
-            {\r
-                afile = new BLCFile(inFile, type);\r
-            }\r
-            else if (format.equals("PIR"))\r
-            {\r
-                afile = new PIRFile(inFile, type);\r
-            }\r
-            else if (format.equals("PFAM"))\r
-            {\r
-                afile = new PfamFile(inFile, type);\r
-            }\r
-\r
-            return afile.getSeqsAsArray();\r
-        }\r
-        catch (Exception e)\r
-        {\r
-            System.err.println("Failed to read alignment using the '" + format +\r
-                "' reader.");\r
-            e.printStackTrace();\r
-        }\r
-\r
-        return null;\r
-    }\r
-\r
-\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -124,30 +53,58 @@ public class FormatAdapter
             if (format.equalsIgnoreCase("FASTA"))\r
             {\r
                 afile = new FastaFile();\r
+                afile.addDBPrefix(\r
+                    jalview.bin.Cache.getDefault("FASTA_DBPREFIX", false));\r
+                afile.addJVSuffix(\r
+                    jalview.bin.Cache.getDefault("FASTA_JVSUFFIX", true));\r
             }\r
             else if (format.equalsIgnoreCase("MSF"))\r
             {\r
-                afile = new MSFfile();\r
+              afile = new MSFfile();\r
+              afile.addDBPrefix(\r
+                  jalview.bin.Cache.getDefault("MSF_DBPREFIX", false));\r
+              afile.addJVSuffix(\r
+                  jalview.bin.Cache.getDefault("MSF_JVSUFFIX", true));\r
             }\r
             else if (format.equalsIgnoreCase("PileUp"))\r
             {\r
                 afile = new PileUpfile();\r
+                afile.addDBPrefix(\r
+                    jalview.bin.Cache.getDefault("PILEUP_DBPREFIX", false));\r
+                afile.addJVSuffix(\r
+                    jalview.bin.Cache.getDefault("PILEUP_JVSUFFIX", true));\r
             }\r
             else if (format.equalsIgnoreCase("CLUSTAL"))\r
             {\r
                 afile = new ClustalFile();\r
+                afile.addDBPrefix(\r
+                    jalview.bin.Cache.getDefault("CLUSTAL_DBPREFIX", false));\r
+                afile.addJVSuffix(\r
+                    jalview.bin.Cache.getDefault("CLUSTAL_JVSUFFIX", true));\r
             }\r
             else if (format.equalsIgnoreCase("BLC"))\r
             {\r
                 afile = new BLCFile();\r
+                afile.addDBPrefix(\r
+                    jalview.bin.Cache.getDefault("BLC_DBPREFIX", false));\r
+                afile.addJVSuffix(\r
+                    jalview.bin.Cache.getDefault("BLC_JVSUFFIX", true));\r
             }\r
             else if (format.equalsIgnoreCase("PIR"))\r
             {\r
                 afile = new PIRFile();\r
+                afile.addDBPrefix(\r
+                    jalview.bin.Cache.getDefault("PIR_DBPREFIX", false));\r
+                afile.addJVSuffix(\r
+                    jalview.bin.Cache.getDefault("PIR_JVSUFFIX", true));\r
             }\r
             else if (format.equalsIgnoreCase("PFAM"))\r
             {\r
                 afile = new PfamFile();\r
+                afile.addDBPrefix(\r
+                    jalview.bin.Cache.getDefault("PFAM_DBPREFIX", false));\r
+                afile.addJVSuffix(\r
+                    jalview.bin.Cache.getDefault("PFAM_JVSUFFIX", true));\r
             }\r
 \r
             afile.setSeqs(s);\r
index 2cef0fe..179204e 100755 (executable)
@@ -155,30 +155,11 @@ public class MSFfile extends AlignFile
                     maxLength = head.length();\r
                 }\r
 \r
-                if (head.indexOf("/") > 0)\r
-                {\r
-                    StringTokenizer st = new StringTokenizer(head, "/");\r
-\r
-                    if (st.countTokens() == 2)\r
-                    {\r
-                        head = st.nextToken();\r
-\r
-                        String tmp = st.nextToken();\r
-                        st = new StringTokenizer(tmp, "-");\r
-\r
-                        if (st.countTokens() == 2)\r
-                        {\r
-                            start = Integer.valueOf(st.nextToken()).intValue();\r
-                            end = Integer.valueOf(st.nextToken()).intValue();\r
-                        }\r
-                    }\r
-                }\r
-\r
-\r
                 // Replace ~ with a sensible gap character\r
                 seq = seq.replace('~', '-');\r
 \r
-                Sequence newSeq = new Sequence(head, seq, start, end);\r
+                Sequence newSeq = parseId(head);\r
+                newSeq.setSequence(seq);\r
 \r
                 seqs.addElement(newSeq);\r
             }\r
@@ -197,7 +178,7 @@ public class MSFfile extends AlignFile
      *\r
      * @return DOCUMENT ME!\r
      */\r
-    public static int checkSum(String seq)\r
+    public int checkSum(String seq)\r
     {\r
         int check = 0;\r
         String sequence = seq.toUpperCase();\r
@@ -223,17 +204,6 @@ public class MSFfile extends AlignFile
         return check % 10000;\r
     }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param s DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public static String print(SequenceI[] s)\r
-    {\r
-        return print(s, false);\r
-    }\r
 \r
     /**\r
      * DOCUMENT ME!\r
@@ -243,9 +213,11 @@ public class MSFfile extends AlignFile
      *\r
      * @return DOCUMENT ME!\r
      */\r
-    public static String print(SequenceI[] seqs, boolean is_NA)\r
+    public String print(SequenceI[] seqs)\r
     {\r
 \r
+      boolean is_NA = jalview.util.Comparison.isNucleotide(seqs);\r
+\r
       SequenceI [] s = new SequenceI[seqs.length];\r
 \r
         StringBuffer out = new StringBuffer("!!" + (is_NA ? "NA" : "AA") +\r
@@ -265,7 +237,7 @@ public class MSFfile extends AlignFile
           {\r
             if (sb.charAt(ii) == '.')\r
             {\r
-              sb.replace(ii, ii + 1, "~");\r
+              sb.setCharAt(ii, '~');\r
             }\r
             else\r
               break;\r
@@ -275,7 +247,7 @@ public class MSFfile extends AlignFile
           {\r
             if (sb.charAt(ii) == '.')\r
             {\r
-              sb.replace(ii, ii + 1, "~");\r
+              sb.setCharAt(ii,'~');\r
             }\r
             else\r
               break;\r
@@ -317,9 +289,7 @@ public class MSFfile extends AlignFile
         while ((i < s.length) && (s[i] != null))\r
         {\r
 \r
-            nameBlock[i] = new String("  Name: " + s[i].getName()\r
-                                      + "/" + s[i].getStart() + "-" + s[i].getEnd()\r
-                                      +" ");\r
+            nameBlock[i] = new String("  Name: " + printId(s[i])+" ");\r
 \r
             idBlock[i] = new String("Len: " +\r
                     maxLenpad.form(s[i].getSequence().length()) + "  Check: " +\r
@@ -373,11 +343,9 @@ public class MSFfile extends AlignFile
 \r
             while ((j < s.length) && (s[j] != null))\r
             {\r
-                String name = s[j].getName();\r
-              //  out.append(new Format("%-" + maxid + "s").form(name)+ " ");\r
+                String name = printId( s[j] );\r
 \r
-                out.append(new Format("%-" + maxid + "s").form(name\r
-                   + "/" + s[j].getStart() + "-" + s[j].getEnd()) + " ");\r
+                out.append(new Format("%-" + maxid + "s").form(name+" "));\r
 \r
 \r
                 for (int k = 0; k < 5; k++)\r
index 65890a9..d4b818b 100755 (executable)
@@ -48,9 +48,6 @@ public class PIRFile
   {\r
     try\r
     {\r
-      String id;\r
-      String start;\r
-      String end;\r
       StringBuffer sequence;\r
       String line = null;\r
 \r
@@ -62,31 +59,11 @@ public class PIRFile
           continue;\r
         }\r
 \r
-        id = "No id";\r
-        start = "1";\r
-        end = "-1";\r
-\r
-        try\r
-        {\r
-          int slashIndex = line.indexOf("/");\r
-          if(slashIndex!=-1)\r
-          {\r
-            id = line.substring(line.indexOf(";") + 1, line.indexOf("/"));\r
-            line = line.substring(line.indexOf("/") + 1);\r
-            start = line.substring(0, line.indexOf("-"));\r
-            end = line.substring(line.indexOf("-") + 1);\r
-          }\r
-          else\r
-          {\r
-            id = line.substring(line.indexOf(";")+1);\r
-          }\r
-        }\r
-        catch (Exception ex)\r
-        {    }// Default id, start and end unchanged\r
+        Sequence newSeq = parseId(line.substring(line.indexOf(";") + 1));\r
 \r
         sequence = new StringBuffer();\r
 \r
-        line = nextLine(); // this is the title line\r
+        newSeq.setDescription(nextLine()); // this is the title line\r
 \r
         boolean starFound = false;\r
 \r
@@ -108,9 +85,7 @@ public class PIRFile
         {\r
           sequence.setLength(sequence.length() - 1);\r
 \r
-          Sequence newSeq = new Sequence(id, sequence.toString(),\r
-                                         Integer.parseInt(start),\r
-                                         Integer.parseInt(end));\r
+          newSeq.setSequence(sequence.toString());\r
           seqs.addElement(newSeq);\r
         }\r
       }\r
@@ -126,41 +101,27 @@ public class PIRFile
     return print(getSeqsAsArray());\r
   }\r
 \r
-  public static String print(SequenceI[] s)\r
-  {\r
-    return print(s, 72, true);\r
-  }\r
-\r
-  public static String print(SequenceI[] s, int len)\r
-  {\r
-    return print(s, len, true);\r
-  }\r
-\r
-  public static String print(SequenceI[] s, int len, boolean gaps)\r
+  public String print(SequenceI[] s)\r
   {\r
+    boolean is_NA = jalview.util.Comparison.isNucleotide(s);\r
+    int len = 72;\r
     StringBuffer out = new StringBuffer();\r
     int i = 0;\r
 \r
     while ( (i < s.length) && (s[i] != null))\r
     {\r
-      String seq = "";\r
+      String seq = s[i].getSequence();\r
+      seq = seq + "*";\r
 \r
-      if (gaps)\r
-      {\r
-        seq = s[i].getSequence() + "*";\r
-      }\r
+      out.append(">P1;" + printId(s[i]) + "\n");\r
+\r
+      if(s[i].getDescription()!=null)\r
+        out.append(s[i].getDescription()+"\n");\r
       else\r
       {\r
-        seq = AlignSeq.extractGaps(s[i].getSequence(), "-");\r
-        seq = AlignSeq.extractGaps(seq, ".");\r
-        seq = AlignSeq.extractGaps(seq, " ");\r
-        seq = seq + "*";\r
+        out.append(s[i].getName()+" "+ (s[i].getEnd() - s[i].getStart() + 1));\r
+        out.append( is_NA ? " bases\n" : " residues\n");\r
       }\r
-\r
-      out.append(">P1;" + s[i].getName() + "/" + s[i].getStart() + "-" +\r
-                 s[i].getEnd() + "\n");\r
-      out.append(" Dummy title\n");\r
-\r
       int nochunks = (seq.length() / len) + 1;\r
 \r
       for (int j = 0; j < nochunks; j++)\r
index 9a6ca54..ec52bac 100755 (executable)
@@ -27,7 +27,6 @@ import jalview.util.*;
 public class PfamFile\r
     extends AlignFile\r
 {\r
-  Vector ids;\r
 \r
   public PfamFile()\r
   {\r
@@ -47,7 +46,6 @@ public class PfamFile
   public void initData()\r
   {\r
     super.initData();\r
-    ids = new Vector();\r
   }\r
 \r
   public void parse()\r
@@ -113,45 +111,11 @@ public class PfamFile
               .length();\r
         }\r
 \r
-        String head = headers.elementAt(i).toString();\r
-        int start = 1;\r
-        int end = -1;\r
 \r
-        if (head.indexOf("/") > 0)\r
-        {\r
-          StringTokenizer st = new StringTokenizer(head, "/");\r
-\r
-          if (st.countTokens() == 2)\r
-          {\r
-            ids.addElement(st.nextToken());\r
-\r
-            String tmp = st.nextToken();\r
-            st = new StringTokenizer(tmp, "-");\r
-\r
-            if (st.countTokens() == 2)\r
-            {\r
-              start = Integer.valueOf(st.nextToken()).intValue();\r
-              end = Integer.valueOf(st.nextToken()).intValue();\r
-            }\r
-          }\r
-          else\r
-          {\r
-            ids.addElement(headers.elementAt(i));\r
-          }\r
-        }\r
-        else\r
-        {\r
-          ids.addElement(headers.elementAt(i));\r
-        }\r
-\r
-        Sequence newSeq = null;\r
-\r
-        newSeq = new Sequence(ids.elementAt(i).toString(),\r
-                              seqhash.get(headers.elementAt(i).toString())\r
-                              .toString(), start, end);\r
+        Sequence newSeq = parseId(headers.elementAt(i).toString());\r
+        newSeq.setSequence( seqhash.get(headers.elementAt(i).toString()).toString());\r
         seqs.addElement(newSeq);\r
 \r
-\r
         if (!isValidProteinSequence(newSeq.getSequence()))\r
         {\r
           throw new IOException(\r
@@ -166,7 +130,7 @@ public class PfamFile
     }\r
   }\r
 \r
-  public static String print(SequenceI[] s)\r
+  public String print(SequenceI[] s)\r
   {\r
     StringBuffer out = new StringBuffer("");\r
 \r
@@ -177,8 +141,7 @@ public class PfamFile
 \r
     while ( (i < s.length) && (s[i] != null))\r
     {\r
-      String tmp = s[i].getName() + "/" + s[i].getStart() + "-" +\r
-          s[i].getEnd();\r
+      String tmp = printId(s[i]);\r
 \r
       if (s[i].getSequence().length() > max)\r
       {\r
@@ -202,8 +165,7 @@ public class PfamFile
 \r
     while ( (j < s.length) && (s[j] != null))\r
     {\r
-      out.append(new Format("%-" + maxid + "s").form(s[j].getName() +\r
-          "/" + s[j].getStart() + "-" + s[j].getEnd()) + " ");\r
+      out.append(new Format("%-" + maxid + "s").form( printId(s[j])+" "));\r
 \r
       out.append(s[j].getSequence() + "\n");\r
       j++;\r
index 8c8a3ea..c945fd5 100755 (executable)
@@ -30,170 +30,53 @@ package jalview.io;
  *\r
  **/\r
 import java.io.*;\r
-import java.util.*;\r
 \r
 import jalview.datamodel.*;\r
 import jalview.util.*;\r
 \r
-public class PileUpfile\r
-    extends AlignFile\r
+public class PileUpfile  extends MSFfile\r
 {\r
-  public PileUpfile()\r
-  {\r
-  }\r
-\r
-  public PileUpfile(String inStr)\r
-  {\r
-    super(inStr);\r
-  }\r
 \r
-  public PileUpfile(String inFile, String type)\r
-      throws IOException\r
-  {\r
-    super(inFile, type);\r
-  }\r
-\r
-  public void parse()\r
-  {\r
-    int i = 0;\r
-    boolean seqFlag = false;\r
-    String key = new String();\r
-    Vector headers = new Vector();\r
-    Hashtable seqhash = new Hashtable();\r
-    String line;\r
-\r
-    try\r
+    /**\r
+     * Creates a new MSFfile object.\r
+     */\r
+    public PileUpfile()\r
     {\r
-      while ( (line = nextLine()) != null)\r
-      {\r
-        StringTokenizer str = new StringTokenizer(line);\r
-\r
-        while (str.hasMoreTokens())\r
-        {\r
-          String inStr = str.nextToken();\r
-\r
-          //If line has header information add to the headers vector\r
-          if (inStr.indexOf("Name:") != -1)\r
-          {\r
-            key = str.nextToken();\r
-            headers.addElement(key);\r
-          }\r
-\r
-          //if line has // set SeqFlag to 1 so we know sequences are coming\r
-          if (inStr.indexOf("//") != -1)\r
-          {\r
-            seqFlag = true;\r
-          }\r
-\r
-          //Process lines as sequence lines if seqFlag is set\r
-          if ( (inStr.indexOf("//") == -1) && (seqFlag == true))\r
-          {\r
-            //seqeunce id is the first field\r
-            key = inStr;\r
-\r
-            StringBuffer tempseq;\r
-\r
-            //Get sequence from hash if it exists\r
-            if (seqhash.containsKey(key))\r
-            {\r
-              tempseq = (StringBuffer) seqhash.get(key);\r
-            }\r
-            else\r
-            {\r
-              tempseq = new StringBuffer();\r
-              seqhash.put(key, tempseq);\r
-            }\r
-\r
-            //loop through the rest of the words\r
-            while (str.hasMoreTokens())\r
-            {\r
-              //append the word to the sequence\r
-              tempseq.append(str.nextToken());\r
-            }\r
-          }\r
-        }\r
-      }\r
     }\r
-    catch (IOException e)\r
+    /**\r
+     * Creates a new MSFfile object.\r
+     *\r
+     * @param inStr DOCUMENT ME!\r
+     */\r
+    public PileUpfile(String inStr)\r
     {\r
-      System.err.println("Exception parsing PileUpfile " + e);\r
-      e.printStackTrace();\r
+        super(inStr);\r
     }\r
 \r
-    this.noSeqs = headers.size();\r
-\r
-    //Add sequences to the hash\r
-    for (i = 0; i < headers.size(); i++)\r
+    /**\r
+     * Creates a new MSFfile object.\r
+     *\r
+     * @param inFile DOCUMENT ME!\r
+     * @param type DOCUMENT ME!\r
+     *\r
+     * @throws IOException DOCUMENT ME!\r
+     */\r
+    public PileUpfile(String inFile, String type) throws IOException\r
     {\r
-      if (seqhash.get(headers.elementAt(i)) != null)\r
-      {\r
-        String head = headers.elementAt(i).toString();\r
-        String seq = seqhash.get(head).toString();\r
-\r
-        int start = 1;\r
-        int end = -1;\r
-\r
-        if (maxLength < head.length())\r
-        {\r
-          maxLength = head.length();\r
-        }\r
-\r
-        if (head.indexOf("/") > 0)\r
-        {\r
-          StringTokenizer st = new StringTokenizer(head, "/");\r
-\r
-          if (st.countTokens() == 2)\r
-          {\r
-            head = st.nextToken();\r
-\r
-            String tmp = st.nextToken();\r
-            st = new StringTokenizer(tmp, "-");\r
-\r
-            if (st.countTokens() == 2)\r
-            {\r
-              start = Integer.valueOf(st.nextToken()).intValue();\r
-              end = Integer.valueOf(st.nextToken()).intValue();\r
-            }\r
-          }\r
-        }\r
-\r
-        Sequence newSeq = new Sequence(head, seq, start, end);\r
-\r
-        seqs.addElement(newSeq);\r
-      }\r
-      else\r
-      {\r
-        System.err.println(\r
-            "PileUpfile Parser: Can't find sequence for " +\r
-            headers.elementAt(i));\r
-      }\r
+        super(inFile, type);\r
     }\r
-  }\r
-\r
-  public static int checkSum(String seq)\r
+   /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public String print()\r
   {\r
-\r
-    int check = 0;\r
-\r
-    String sequence = seq.toUpperCase();\r
-\r
-    for (int i = 0; i < sequence.length(); i++)\r
-    {\r
-        if (i < sequence.length())\r
-        {\r
-          int value = sequence.charAt(i);\r
-          if (value != -1)\r
-          {\r
-            check += (i % 57 + 1) * value;\r
-          }\r
-        }\r
-\r
-    }\r
-\r
-    return check % 10000;\r
+      return print(getSeqsAsArray());\r
   }\r
 \r
-  public static String print(SequenceI[] s)\r
+\r
+  public  String print(SequenceI[] s)\r
   {\r
     StringBuffer out = new StringBuffer("PileUp\n\n");\r
 \r
@@ -217,8 +100,7 @@ public class PileUpfile
     while ( (i < s.length) && (s[i] != null))\r
     {\r
       String seq = s[i].getSequence();\r
-      out.append(" Name: " + s[i].getName() +\r
-                   "/" + s[i].getStart() + "-" + s[i].getEnd() +\r
+      out.append(" Name: " + printId(s[i]) +\r
                  " oo  Len:  " +\r
                  s[i].getSequence().length() + "  Check:  " + checksums[i] +\r
                  "  Weight:  1.00\n");\r
@@ -259,11 +141,9 @@ public class PileUpfile
 \r
       while ( (j < s.length) && (s[j] != null))\r
       {\r
-        String name = s[j].getName();\r
-       // out.append(new Format("%-" + maxid + "s").form(name) + " ");\r
+        String name = printId(s[j]);\r
 \r
-         out.append(new Format("%-" + maxid + "s").form(name\r
-          + "/" + s[j].getStart() + "-" + s[j].getEnd()) + " ");\r
+         out.append(new Format("%-" + maxid + "s").form(name + " "));\r
 \r
         for (int k = 0; k < 5; k++)\r
         {\r
@@ -309,9 +189,4 @@ public class PileUpfile
 \r
     return out.toString();\r
   }\r
-\r
-  public String print()\r
-  {\r
-    return print(getSeqsAsArray());\r
-  }\r
 }\r
index 94713ea..520ba03 100755 (executable)
@@ -26,6 +26,12 @@ import java.io.*;
 \r
 import java.util.*;\r
 \r
+import org.exolab.castor.mapping.Mapping;\r
+\r
+import org.exolab.castor.xml.*;\r
+import jalview.analysis.AlignSeq;\r
+\r
+\r
 \r
 /**\r
  * DOCUMENT ME!\r
@@ -35,527 +41,207 @@ import java.util.*;
  */\r
 public class SequenceFeatureFetcher implements Runnable\r
 {\r
-    AlignmentI align;\r
-    AlignmentPanel ap;\r
-    ArrayList unknownSequences;\r
-    CutAndPasteTransfer output = new CutAndPasteTransfer();\r
-    StringBuffer sbuffer = new StringBuffer();\r
-\r
-    /**\r
-     * Creates a new SequenceFeatureFetcher object.\r
-     *\r
-     * @param align DOCUMENT ME!\r
-     * @param ap DOCUMENT ME!\r
-     */\r
-    public SequenceFeatureFetcher(AlignmentI align, AlignmentPanel ap)\r
+\r
+  AlignmentI align;\r
+  AlignmentPanel ap;\r
+  ArrayList unknownSequences;\r
+  CutAndPasteTransfer output = new CutAndPasteTransfer();\r
+  StringBuffer sbuffer = new StringBuffer();\r
+\r
+  Vector localCache = new Vector();\r
+\r
+  Vector getUniprotEntries(File file)\r
+  {\r
+\r
+    UniprotFile uni = new UniprotFile();\r
+    try\r
     {\r
-        unknownSequences = new ArrayList();\r
-        this.align = align;\r
-        this.ap = ap;\r
+      // 1. Load the mapping information from the file\r
+      Mapping map = new Mapping(uni.getClass().getClassLoader());\r
+      java.net.URL url = uni.getClass().getResource("/uniprot_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
+      localCache.addAll( uni.getUniprotEntries() );\r
+\r
+      // 3. marshal the data with the total price back and print the XML in the console\r
+    //    Marshaller marshaller = new Marshaller(\r
+      //      new FileWriter(jalview.bin.Cache.getProperty("UNIPROT_CACHE"))\r
+     //       );\r
+       //  marshaller.setMapping(map);\r
+       //  marshaller.marshal(uni);\r
 \r
-        Thread thread = new Thread(this);\r
-        thread.start();\r
     }\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     */\r
-    public void run()\r
+    catch (Exception e)\r
     {\r
-        RandomAccessFile out = null;\r
+      System.out.println("Error getUniprotEntries() "+e);\r
+     // e.printStackTrace();\r
+     // if(!updateLocalCache)\r
+      //  file.delete();\r
 \r
-        try\r
-        {\r
-            String cache = System.getProperty("user.home") +\r
-                "/.jalview.uniprot.xml";\r
-\r
-            File test = new File(cache);\r
-\r
-            if (!test.exists())\r
-            {\r
-                out = new RandomAccessFile(cache, "rw");\r
-                out.writeBytes("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");\r
-                out.writeBytes("<UNIPROT_CACHE>\n");\r
-            }\r
-            else\r
-            {\r
-                out = new RandomAccessFile(cache, "rw");\r
-\r
-                // open exisiting cache and remove </UNIPROT_CACHE> from the end\r
-                long lastLine = 0;\r
-                String data;\r
-\r
-                while ((data = out.readLine()) != null)\r
-                {\r
-                    if (data.indexOf("</entry>") > -1)\r
-                    {\r
-                        lastLine = out.getFilePointer();\r
-                    }\r
-                }\r
-\r
-                out.seek(lastLine);\r
-            }\r
-\r
-            int seqIndex = 0;\r
-            Vector sequences = align.getSequences();\r
-\r
-            while (seqIndex < sequences.size())\r
-            {\r
-                ArrayList ids = new ArrayList();\r
-\r
-                for (int i = 0; (seqIndex < sequences.size()) && (i < 50);\r
-                        seqIndex++, i++)\r
-                {\r
-                    SequenceI sequence = (SequenceI) sequences.get(seqIndex);\r
-                    ids.add(sequence.getName());\r
-                }\r
-\r
-                tryLocalCacheFirst(ids, align);\r
-\r
-                if (ids.size() > 0)\r
-                {\r
-                    StringBuffer remainingIds = new StringBuffer("uniprot:");\r
-\r
-                    for (int i = 0; i < ids.size(); i++)\r
-                        remainingIds.append(ids.get(i) + ";");\r
-\r
-                    EBIFetchClient ebi = new EBIFetchClient();\r
-                    String[] result = ebi.fetchData(remainingIds.toString(),\r
-                            "xml", null);\r
-\r
-                    if (result != null)\r
-                    {\r
-                        ReadUniprotFile(result, out, align);\r
-                    }\r
-                }\r
-            }\r
-\r
-            if (out != null)\r
-            {\r
-                out.writeBytes("</UNIPROT_CACHE>\n");\r
-                out.close();\r
-            }\r
-        }\r
-        catch (Exception ex)\r
-        {\r
-            ex.printStackTrace();\r
-        }\r
+    }\r
+    return uni.getUniprotEntries();\r
+  }\r
+\r
+  /**\r
+   * Creates a new SequenceFeatureFetcher object.\r
+   *\r
+   * @param align DOCUMENT ME!\r
+   * @param ap DOCUMENT ME!\r
+   */\r
+  public SequenceFeatureFetcher(AlignmentI align, AlignmentPanel ap)\r
+  {\r
+    unknownSequences = new ArrayList();\r
+    this.align = align;\r
+    this.ap = ap;\r
+\r
+    Thread thread = new Thread(this);\r
+    thread.start();\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   */\r
+  public void run()\r
+  {\r
+    try\r
+    {\r
+      int seqIndex = 0;\r
+      Vector sequences = align.getSequences();\r
 \r
-        findMissingIds(align);\r
+      while (seqIndex < sequences.size())\r
+      {\r
+        Vector ids = new Vector();\r
 \r
-        if (sbuffer.length() > 0)\r
+        for (int i = 0; (seqIndex < sequences.size()) && (i < 50);\r
+             seqIndex++, i++)\r
         {\r
-            output.setText(\r
-                "Your sequences have been matched to Uniprot. Some of the ids have been\n" +\r
-                "altered, most likely the start/end residue will have been updated.\n" +\r
-                "Save your alignment to maintain the updated id.\n\n" +\r
-                sbuffer.toString());\r
-            Desktop.addInternalFrame(output, "Sequence names updated ", 600, 300);\r
+          SequenceI sequence = (SequenceI) sequences.get(seqIndex);\r
+          ids.add(sequence.getName());\r
+          unknownSequences.add(sequence.getName());\r
         }\r
 \r
-        if (unknownSequences.size() > 0)\r
+        ///////////////////////////////////\r
+        ///READ FROM EBI\r
+        if (ids.size() > 0)\r
         {\r
-            //ignore for now!!!!!!!!!!\r
-            //  WSWUBlastClient blastClient = new WSWUBlastClient(align, unknownSequences);\r
+          StringBuffer remainingIds = new StringBuffer("uniprot:");\r
+          for (int i = 0; i < ids.size(); i++)\r
+           {\r
+             remainingIds.append(ids.get(i) + ";");\r
+           }\r
+          EBIFetchClient ebi = new EBIFetchClient();\r
+          File file = ebi.fetchDataAsFile(remainingIds.toString(),\r
+                                          "xml", null);\r
+\r
+\r
+          if (file != null)\r
+          {\r
+            ReadUniprotFile(file, align, ids);\r
+          }\r
         }\r
-\r
-        jalview.gui.PaintRefresher.Refresh(null, align);\r
+      }\r
     }\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param result DOCUMENT ME!\r
-     * @param out DOCUMENT ME!\r
-     * @param align DOCUMENT ME!\r
-     */\r
-    void ReadUniprotFile(String[] result, RandomAccessFile out, AlignmentI align)\r
+    catch (Exception ex)\r
     {\r
-        SequenceI sequence = null;\r
-        Vector features = null;\r
-        String type;\r
-        String description;\r
-        String status;\r
-        String start;\r
-        String end;\r
-        String pdb = null;\r
-\r
-        for (int r = 0; r < result.length; r++)\r
-        {\r
-            if ((sequence == null) && (result[r].indexOf("<name>") > -1))\r
-            {\r
-                long filePointer = 0;\r
-\r
-                if (out != null)\r
-                {\r
-                    try\r
-                    {\r
-                        filePointer = out.getFilePointer();\r
-                        out.writeBytes("<entry>\n");\r
-                    }\r
-                    catch (Exception ex)\r
-                    {\r
-                    }\r
-                }\r
-\r
-                String seqName = parseElement(result[r], "<name>", out);\r
-                sequence = align.findName(seqName);\r
-\r
-                if (sequence == null)\r
-                {\r
-                    sequence = align.findName(seqName.substring(0,\r
-                                seqName.indexOf('_')));\r
-\r
-                    if (sequence != null)\r
-                    {\r
-                        sbuffer.append("changing " + sequence.getName() +\r
-                            " to " + seqName + "\n");\r
-                        sequence.setName(seqName);\r
-                    }\r
-                }\r
-\r
-                if (sequence == null)\r
-                {\r
-                    sbuffer.append("UNIPROT updated suggestion is " +\r
-                        result[r] + "\n");\r
-                    sequence = align.findName(result[r]);\r
-\r
-                    // this entry has been suggested by ebi.\r
-                    // doesn't match id in alignment file\r
-                    try\r
-                    {\r
-                        out.setLength(filePointer);\r
-                    }\r
-                    catch (Exception ex)\r
-                    {\r
-                    }\r
-\r
-                    // now skip to next entry\r
-                    while (result[r].indexOf("</entry>") == -1)\r
-                        r++;\r
-                }\r
-\r
-                features = new Vector();\r
-                type = "";\r
-                start = "0";\r
-                end = "0";\r
-                description = "";\r
-                status = "";\r
-                pdb = "";\r
-            }\r
-\r
-            if (sequence == null)\r
-            {\r
-                continue;\r
-            }\r
-\r
-            if (result[r].indexOf("<property type=\"pdb accession\"") > -1)\r
-            {\r
-                pdb = parseValue(result[r], "value=", out);\r
-                sequence.setPDBId(pdb);\r
-            }\r
-\r
-            if (result[r].indexOf("feature type") > -1)\r
-            {\r
-                type = parseValue(result[r], "type=", out);\r
-                description = parseValue(result[r], "description=", null);\r
-                status = parseValue(result[r], "status=", null);\r
-\r
-                while (result[r].indexOf("position") == -1)\r
-                {\r
-                    r++; //<location>\r
-                }\r
-\r
-                // r++;\r
-                if (result[r].indexOf("begin") > -1)\r
-                {\r
-                    start = parseValue(result[r], "position=", out);\r
-                    end = parseValue(result[++r], "position=", out);\r
-                }\r
-                else\r
-                {\r
-                    start = parseValue(result[r], "position=", out);\r
-                    end = parseValue(result[r], "position=", null);\r
-                }\r
-\r
-                int sstart = Integer.parseInt(start);\r
-                int eend = Integer.parseInt(end);\r
-\r
-                if (out != null)\r
-                {\r
-                    try\r
-                    {\r
-                        out.writeBytes("</feature>\n");\r
-                    }\r
-                    catch (Exception ex)\r
-                    {\r
-                    }\r
-                }\r
-\r
-                SequenceFeature sf = new SequenceFeature(type, sstart, eend,\r
-                        description, status);\r
-                features.add(sf);\r
-            }\r
-\r
-            if (result[r].indexOf("<sequence length=") > -1)\r
-            {\r
-                StringBuffer seqString = new StringBuffer();\r
-\r
-                if (out != null)\r
-                {\r
-                    try\r
-                    {\r
-                        out.writeBytes(result[r] + "\n");\r
-                    }\r
-                    catch (Exception ex)\r
-                    {\r
-                    }\r
-                }\r
-\r
-                while (result[++r].indexOf("</sequence>") == -1)\r
-                {\r
-                    seqString.append(result[r]);\r
-\r
-                    if (out != null)\r
-                    {\r
-                        try\r
-                        {\r
-                            out.writeBytes(result[r] + "\n");\r
-                        }\r
-                        catch (Exception ex)\r
-                        {\r
-                        }\r
-                    }\r
-                }\r
-\r
-                if (out != null)\r
-                {\r
-                    try\r
-                    {\r
-                        out.writeBytes(result[r] + "\n");\r
-                    }\r
-                    catch (Exception ex)\r
-                    {\r
-                    }\r
-                }\r
-\r
-                StringBuffer nonGapped = new StringBuffer();\r
-\r
-                for (int i = 0; i < sequence.getSequence().length(); i++)\r
-                {\r
-                    if (!jalview.util.Comparison.isGap(sequence.getCharAt(i)))\r
-                    {\r
-                        nonGapped.append(sequence.getCharAt(i));\r
-                    }\r
-                }\r
-\r
-                int absStart = seqString.toString().indexOf(nonGapped.toString());\r
-\r
-                if (absStart == -1)\r
-                {\r
-                    unknownSequences.add(sequence.getName());\r
-                    features = null;\r
-                    sbuffer.append(sequence.getName() +\r
-                        " SEQUENCE NOT %100 MATCH \n");\r
-\r
-                    continue;\r
-                }\r
-\r
-                int absEnd = absStart + nonGapped.toString().length();\r
-                absStart += 1;\r
-\r
-                if ((absStart != sequence.getStart()) ||\r
-                        (absEnd != sequence.getEnd()))\r
-                {\r
-                    sbuffer.append("Updated: " + sequence.getName() + " " +\r
-                        sequence.getStart() + "/" + sequence.getEnd() +\r
-                        "  to  " + absStart + "/" + absEnd + "\n");\r
-                }\r
-\r
-                sequence.setStart(absStart);\r
-                sequence.setEnd(absEnd);\r
-            }\r
-\r
-            if (result[r].indexOf("</entry>") > -1)\r
-            {\r
-                if (features != null)\r
-                {\r
-                    sequence.setSequenceFeatures(features);\r
-                }\r
-\r
-                features = null;\r
-                sequence = null;\r
-\r
-                if (out != null)\r
-                {\r
-                    try\r
-                    {\r
-                        out.writeBytes("</entry>\n");\r
-                    }\r
-                    catch (Exception ex)\r
-                    {\r
-                    }\r
-                }\r
-            }\r
-        }\r
+      ex.printStackTrace();\r
     }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param align DOCUMENT ME!\r
-     */\r
-    void findMissingIds(AlignmentI align)\r
+    if (sbuffer.length() > 0)\r
     {\r
-        String data;\r
-        ArrayList cachedIds = new ArrayList();\r
-\r
-        try\r
-        {\r
-            if(jalview.bin.Cache.getProperty("UNIPROT_CACHE")==null)\r
-              return;\r
-\r
-            BufferedReader in = new BufferedReader(new FileReader(\r
-                        jalview.bin.Cache.getProperty("UNIPROT_CACHE")));\r
-\r
-            while ((data = in.readLine()) != null)\r
-            {\r
-                if (data.indexOf("name") > -1)\r
-                {\r
-                    String name = parseElement(data, "<name>", null);\r
-                    cachedIds.add(name);\r
-                }\r
-            }\r
-        }\r
-        catch (Exception ex)\r
-        {\r
-            ex.printStackTrace();\r
-        }\r
-\r
-        for (int i = 0; i < align.getHeight(); i++)\r
-            if (!cachedIds.contains(align.getSequenceAt(i).getName()))\r
-            {\r
-                unknownSequences.add(align.getSequenceAt(i).getName());\r
-            }\r
+      output.setText(\r
+          "Your sequences have been matched to Uniprot. Some of the ids have been\n" +\r
+          "altered, most likely the start/end residue will have been updated.\n" +\r
+          "Save your alignment to maintain the updated id.\n\n" +\r
+          sbuffer.toString());\r
+      Desktop.addInternalFrame(output, "Sequence names updated ", 600, 300);\r
     }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param ids DOCUMENT ME!\r
-     * @param align DOCUMENT ME!\r
-     */\r
-    void tryLocalCacheFirst(ArrayList ids, AlignmentI align)\r
+    if (unknownSequences.size() > 0)\r
     {\r
-        ArrayList cacheData = new ArrayList();\r
-\r
-        try\r
-        {\r
-            if(jalview.bin.Cache.getProperty("UNIPROT_CACHE")==null)\r
-              return;\r
-\r
-            BufferedReader in = new BufferedReader(new FileReader(\r
-                        jalview.bin.Cache.getProperty("UNIPROT_CACHE")));\r
-\r
-            // read through cache file, if the cache has sequences we're looking for\r
-            // add the lines to a new String array, Readthis new array and\r
-            // make sure we remove the ids from the list to retrieve from EBI\r
-            String data;\r
-\r
-            while ((data = in.readLine()) != null)\r
-            {\r
-                if (data.indexOf("name") > -1)\r
-                {\r
-                    String name = parseElement(data, "<name>", null);\r
-\r
-                    if (ids.contains(name))\r
-                    {\r
-                        cacheData.add("<entry>");\r
-                        cacheData.add(data);\r
-\r
-                        while (data.indexOf("</entry>") == -1)\r
-                        {\r
-                            data = in.readLine();\r
-                            cacheData.add(data);\r
-                        }\r
-\r
-                        cacheData.add(data);\r
-\r
-                        ids.remove(name);\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        catch (Exception ex)\r
-        {\r
-            ex.printStackTrace();\r
-        }\r
-\r
-        String[] localData = new String[cacheData.size()];\r
-        cacheData.toArray(localData);\r
-\r
-        if ((localData != null) && (localData.length > 0))\r
-        {\r
-            ReadUniprotFile(localData, null, align);\r
-        }\r
+       new WSWUBlastClient(ap, align, unknownSequences);\r
     }\r
+    else\r
+       ((Alignment)align).featuresAdded = true;\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param line DOCUMENT ME!\r
-     * @param tag DOCUMENT ME!\r
-     * @param out DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    String parseValue(String line, String tag, RandomAccessFile out)\r
-    {\r
-        if (out != null)\r
-        {\r
-            try\r
-            {\r
-                out.writeBytes(line + "\n");\r
-            }\r
-            catch (Exception ex)\r
-            {\r
-            }\r
-        }\r
 \r
-        int index = line.indexOf(tag) + tag.length() + 1;\r
+    ap.repaint();\r
+  }\r
 \r
-        if (index == tag.length())\r
-        {\r
-            return "";\r
-        }\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param result DOCUMENT ME!\r
+   * @param out DOCUMENT ME!\r
+   * @param align DOCUMENT ME!\r
+   */\r
+  void ReadUniprotFile(File file, AlignmentI align, Vector ids)\r
+  {\r
+    if(!file.exists())\r
+      return;\r
 \r
-        return line.substring(index, line.indexOf("\"", index + 1));\r
-    }\r
+    SequenceI sequence = null;\r
+    //       String pdb = null;\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param line DOCUMENT ME!\r
-     * @param tag DOCUMENT ME!\r
-     * @param out DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    String parseElement(String line, String tag, RandomAccessFile out)\r
-    {\r
-        if (out != null)\r
-        {\r
-            try\r
-            {\r
-                out.writeBytes(line + "\n");\r
-            }\r
-            catch (Exception ex)\r
-            {\r
-            }\r
-        }\r
-\r
-        int index = line.indexOf(tag) + tag.length();\r
+    Vector entries = getUniprotEntries(file);\r
 \r
-        return line.substring(index, line.indexOf("</"));\r
+    int i, iSize = entries==null?0:entries.size();\r
+    UniprotEntry entry;\r
+    for (i = 0; i < iSize; i++)\r
+    {\r
+      entry = (UniprotEntry) entries.elementAt(i);\r
+      String idmatch = entry.getAccession();\r
+      sequence = align.findName(idmatch);\r
+\r
+      if (sequence == null)\r
+      {\r
+        //Sequence maybe Name, not Accession\r
+        idmatch = entry.getName();\r
+        sequence = align.findName(idmatch);\r
+      }\r
+\r
+      if (sequence == null)\r
+      {\r
+        continue;\r
+      }\r
+\r
+      ids.remove(sequence.getName());\r
+      unknownSequences.remove(sequence.getName());\r
+\r
+      String nonGapped = AlignSeq.extractGaps("-. ", sequence.getSequence());\r
+\r
+      int absStart = entry.getUniprotSequence().getContent().indexOf(\r
+          nonGapped.toString());\r
+\r
+      if (absStart == -1)\r
+      {\r
+        unknownSequences.add(sequence.getName());\r
+        sbuffer.append(sequence.getName() +\r
+                       " SEQUENCE NOT %100 MATCH \n");\r
+\r
+        continue;\r
+      }\r
+\r
+      int absEnd = absStart + nonGapped.toString().length();\r
+      absStart += 1;\r
+\r
+      if ( (absStart != sequence.getStart()) ||\r
+          (absEnd != sequence.getEnd()))\r
+      {\r
+        sbuffer.append("Updated: " + sequence.getName() + " " +\r
+                       sequence.getStart() + "/" + sequence.getEnd() +\r
+                       "  to  " + absStart + "/" + absEnd + "\n");\r
+      }\r
+\r
+      sequence.setSequenceFeatures(entry.getFeatures());\r
+      sequence.setStart(absStart);\r
+      sequence.setEnd(absEnd);\r
     }\r
+  }\r
 }\r
+\r
+\r
diff --git a/src/jalview/io/VamsasDatastore.java b/src/jalview/io/VamsasDatastore.java
new file mode 100755 (executable)
index 0000000..3c79599
--- /dev/null
@@ -0,0 +1,491 @@
+/*\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
+\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
+\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
+              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
+                    an.setGraph(aa[i].isGraph);\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
+              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
+            }\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
+            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
+            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
+            ////LOAD ANNOTATIONS\r
+            ////////////////////\r
+            if (alignment.getAlignmentAnnotationsCount()>0)\r
+            {\r
+              AlignmentAnnotations[] an = alignment.getAlignmentAnnotations();\r
+\r
+              for (int 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 c221d07..2e3ccfa 100755 (executable)
@@ -39,17 +39,22 @@ import javax.xml.namespace.QName;
  */\r
 public class WSWUBlastClient\r
 {\r
+    AlignmentPanel ap;\r
+    AlignmentI al;\r
     CutAndPasteTransfer output = new CutAndPasteTransfer();\r
     int jobsRunning = 0;\r
 \r
+    Hashtable suggestedIds = new Hashtable();\r
     /**\r
      * Creates a new WSWUBlastClient object.\r
      *\r
      * @param al DOCUMENT ME!\r
      * @param ids DOCUMENT ME!\r
      */\r
-    public WSWUBlastClient(AlignmentI al, ArrayList ids)\r
+    public WSWUBlastClient(AlignmentPanel ap, AlignmentI al, ArrayList ids)\r
     {\r
+        this.ap = ap;\r
+        this.al = al;\r
         output.setText(\r
             "To display sequence features an exact Uniprot id with 100% sequence identity match must be entered." +\r
             "\nIn order to display these features, try changing the names of your sequences to the ids suggested below.");\r
@@ -61,6 +66,7 @@ public class WSWUBlastClient
             SequenceI sequence = al.findName(ids.get(i).toString());\r
             StringBuffer nonGapped = new StringBuffer();\r
 \r
+\r
             for (int n = 0; n < sequence.getSequence().length(); n++)\r
             {\r
                 if (!jalview.util.Comparison.isGap(sequence.getCharAt(n)))\r
@@ -79,6 +85,7 @@ public class WSWUBlastClient
         thread.start();\r
     }\r
 \r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -97,32 +104,41 @@ public class WSWUBlastClient
         {\r
             data = st.nextToken();\r
 \r
-            if (data.indexOf("database=\"uniprot\" id=") > -1)\r
+            if (data.indexOf(">UNIPROT") > -1)\r
             {\r
-                int index = data.indexOf("database=\"uniprot\" id=") + 23;\r
-                id2 = data.substring(index, data.indexOf("\"", index));\r
+                int index = data.indexOf(">UNIPROT") + 9;\r
+                id2 = data.substring(index, data.indexOf(" ", index));\r
 \r
-                while (data.indexOf("</alignment>") == -1)\r
+                boolean identitiesFound = false;\r
+                while (!identitiesFound)\r
                 {\r
                     data = st.nextToken();\r
 \r
-                    if (data.indexOf("<identity>") > -1)\r
+                    if (data.indexOf("Identities") > -1)\r
                     {\r
-                        int value = Integer.parseInt(data.substring(data.indexOf(\r
-                                        "<identity>") + 10,\r
-                                    data.indexOf("</identity>")));\r
+                       identitiesFound = true;\r
+\r
+                       int value = Integer.parseInt(data.substring(data.indexOf(\r
+                           "(") + 1,\r
+                                                                   data.indexOf("%")));\r
 \r
                         if (value >= maxFound)\r
                         {\r
                             maxFound = value;\r
                             buffer.append(" " + id2 + " " + value + "%; ");\r
+                            suggestedIds.put(id1, id2);\r
                         }\r
                     }\r
                 }\r
             }\r
         }\r
 \r
-        output.setText(output.getText() + buffer.toString());\r
+        output.appendText(buffer.toString());\r
+    }\r
+\r
+    void updateIds()\r
+    {\r
+\r
     }\r
 \r
     class ImageTwirler extends Thread\r
@@ -163,6 +179,36 @@ public class WSWUBlastClient
                 {\r
                 }\r
             }\r
+\r
+            if (jobsRunning == 0)\r
+            {\r
+              int reply = JOptionPane.showConfirmDialog(\r
+                  Desktop.desktop, "Automatically update suggested ids?",\r
+                  "Auto replace sequence ids", JOptionPane.YES_NO_OPTION);\r
+\r
+              if (reply == JOptionPane.YES_OPTION)\r
+              {\r
+                Enumeration keys = suggestedIds.keys();\r
+                while(keys.hasMoreElements())\r
+                {\r
+                  String oldid = keys.nextElement().toString();\r
+                  SequenceI sequence = al.findName(oldid);\r
+                  sequence.setName( suggestedIds.get(oldid).toString() );\r
+\r
+                  sequence = al.getDataset().findName(oldid);\r
+                  Vector entries = sequence.getDBRef();\r
+                  DBRefEntry entry = (DBRefEntry) entries.elementAt(0);\r
+                  sequence.addDBRef(new jalview.datamodel.DBRefEntry("UNIPROT",\r
+                      "0",\r
+                      entry.getAccessionId()));\r
+\r
+                  sequence.setName(suggestedIds.get(oldid).toString());\r
+\r
+                  System.out.println("replace "+oldid+" with "+suggestedIds.get(oldid));\r
+                }\r
+              }\r
+              ap.repaint();\r
+            }\r
         }\r
     }\r
 \r
@@ -175,6 +221,7 @@ public class WSWUBlastClient
 \r
         BlastThread(String id, String sequence)\r
         {\r
+          System.out.println("blasting for: "+id);\r
             this.sequence = sequence;\r
             seqid = id;\r
         }\r
@@ -192,22 +239,21 @@ public class WSWUBlastClient
                             "http://www.ebi.ac.uk/cgi-bin/webservices/WSWUBlast"));\r
                     call.setOperationName(new QName("WSWUBlast", "polljob"));\r
 \r
-                    String result = (String) call.invoke(new Object[]\r
+                    Object object = (String) call.invoke(new Object[]\r
                             {\r
                                 jobid, "xml"\r
                             });\r
 \r
-                    if ((result.indexOf("JOB PENDING") == -1) &&\r
-                            (result.indexOf("JOB RUNNING") == -1))\r
+                    if(object instanceof String)\r
                     {\r
-                        parseResult(seqid, result);\r
-                        jobComplete = true;\r
-                        jobsRunning--;\r
+                      parseResult(seqid, (String)object);\r
+                      jobComplete = true;\r
+                      jobsRunning--;\r
                     }\r
 \r
                     Thread.sleep(5000);\r
 \r
-                    // System.out.println("WSWuBlastClient: I'm alive "+seqid+" "+jobid); // log.debug\r
+                    System.out.println("WSWuBlastClient: I'm alive "+seqid+" "+jobid); // log.debug\r
                 }\r
                 catch (Exception ex)\r
                 {\r
@@ -224,8 +270,8 @@ public class WSWUBlastClient
             params.put("matrix", "pam10");\r
             params.put("program", "blastp");\r
             params.put("alignments", "5");\r
-            params.put("outformat", "xml");\r
-            params.put("searchtype", "1");\r
+            params.put("type", "xml");\r
+            params.put("async", "true");\r
 \r
             byte[] seqbytes = sequence.getBytes();\r
 \r
@@ -236,14 +282,21 @@ public class WSWUBlastClient
                         "http://www.ebi.ac.uk/cgi-bin/webservices/WSWUBlast"));\r
                 call.setOperationName(new QName("WSWUBlast", "doWUBlast"));\r
 \r
-                String result = (String) call.invoke(new Object[]\r
+                Object object = call.invoke(new Object[]\r
                         {\r
                             params, seqbytes\r
                         });\r
-                jobid = result;\r
-                System.out.println(\r
-                    "http://www.ebi.ac.uk/cgi-bin/webservices/WSWUBlast JobId '" +\r
-                    jobid + "'");\r
+\r
+                if(object instanceof byte[])\r
+                  jobid = new String( (byte[])object);\r
+\r
+                else\r
+                {\r
+                  jobComplete = true;\r
+                  jobsRunning--;\r
+                  parseResult(seqid, (String)object);\r
+                }\r
+\r
             }\r
             catch (Exception exp)\r
             {\r
index 7775b65..5123317 100755 (executable)
@@ -107,8 +107,8 @@ public class GAlignFrame extends Frame {
             MenuItem item;\r
 \r
             // dynamically fill save as menu with available formats\r
-            for (int i = 0; i < jalview.io.FormatAdapter.formats.size(); i++) {\r
-                item = new MenuItem((String) jalview.io.FormatAdapter.formats.elementAt(\r
+            for (int i = 0; i < jalview.io.AppletFormatAdapter.formats.size(); i++) {\r
+                item = new MenuItem((String) jalview.io.AppletFormatAdapter.formats.elementAt(\r
                             i));\r
                 item.addActionListener(new java.awt.event.ActionListener() {\r
                         public void actionPerformed(ActionEvent e) {\r
@@ -116,7 +116,7 @@ public class GAlignFrame extends Frame {
                         }\r
                     });\r
 \r
-                item = new MenuItem((String) jalview.io.FormatAdapter.formats.elementAt(\r
+                item = new MenuItem((String) jalview.io.AppletFormatAdapter.formats.elementAt(\r
                             i));\r
                 item.addActionListener(new java.awt.event.ActionListener() {\r
                         public void actionPerformed(ActionEvent e) {\r
index ddb2bcd..de46e5a 100755 (executable)
@@ -113,6 +113,10 @@ public class GAlignFrame
   JMenu jMenu2 = new JMenu();\r
   JMenuItem padGapsMenuitem = new JMenuItem();\r
   protected ButtonGroup colours = new ButtonGroup();\r
+  JMenuItem vamsasStore = new JMenuItem();\r
+  protected JCheckBoxMenuItem showTranslation = new JCheckBoxMenuItem();\r
+  protected JTabbedPane tabbedPane = new JTabbedPane();\r
+  protected JMenuItem featureSettings = new JMenuItem();\r
 \r
   public GAlignFrame()\r
   {\r
@@ -906,6 +910,40 @@ public class GAlignFrame
         padGapsMenuitem_actionPerformed(e);\r
       }\r
     });\r
+    vamsasStore.setText("VAMSAS store");\r
+    vamsasStore.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        vamsasStore_actionPerformed(e);\r
+      }\r
+    });\r
+    showTranslation.setText("Translate cDNA");\r
+    showTranslation.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        showTranslation_actionPerformed(e);\r
+      }\r
+    });\r
+\r
+    tabbedPane.addChangeListener(new ChangeListener()\r
+        {\r
+          public void stateChanged(ChangeEvent ece)\r
+          {\r
+\r
+            tabSelected();\r
+          }\r
+        });\r
+//    featureSettings.setEnabled(false);\r
+    featureSettings.setText("Feature Settings...");\r
+    featureSettings.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        featureSettings_actionPerformed(e);\r
+      }\r
+    });\r
     alignFrameMenuBar.add(fileMenu);\r
     alignFrameMenuBar.add(editMenu);\r
     alignFrameMenuBar.add(searchMenu);\r
@@ -913,6 +951,7 @@ public class GAlignFrame
     alignFrameMenuBar.add(colourMenu);\r
     alignFrameMenuBar.add(calculateMenu);\r
     alignFrameMenuBar.add(webService);\r
+    fileMenu.add(vamsasStore);\r
     fileMenu.add(saveAlignmentMenu);\r
     fileMenu.add(jMenu2);\r
     fileMenu.add(outputTextboxMenu);\r
@@ -953,7 +992,9 @@ public class GAlignFrame
     viewMenu.add(colourTextMenuItem);\r
     viewMenu.add(renderGapsMenuItem);\r
     viewMenu.add(annotationPanelMenuItem);\r
+    viewMenu.addSeparator();\r
     viewMenu.add(sequenceFeatures);\r
+    viewMenu.add(featureSettings);\r
     viewMenu.addSeparator();\r
     viewMenu.add(overviewMenuItem);\r
     colourMenu.add(applyToAllGroups);\r
@@ -981,9 +1022,12 @@ public class GAlignFrame
     calculateMenu.addSeparator();\r
     calculateMenu.add(pairwiseAlignmentMenuItem);\r
     calculateMenu.add(PCAMenuItem);\r
+    calculateMenu.addSeparator();\r
+    calculateMenu.add(showTranslation);\r
     webServiceNoServices=new JMenuItem("<No Services>");\r
     webService.add(webServiceNoServices);\r
     this.getContentPane().add(statusBar, BorderLayout.SOUTH);\r
+    this.getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER);\r
     jMenu1.add(pasteNew);\r
     jMenu1.add(pasteThis);\r
     sort.add(sortIDMenuItem);\r
@@ -1285,4 +1329,29 @@ public class GAlignFrame
   protected void ClustalRealign_actionPerformed(ActionEvent e)\r
   {\r
   }\r
+\r
+  public void vamsasStore_actionPerformed(ActionEvent e)\r
+  {\r
+\r
+  }\r
+\r
+  public void vamsasLoad_actionPerformed(ActionEvent e)\r
+  {\r
+\r
+  }\r
+\r
+  public void showTranslation_actionPerformed(ActionEvent e)\r
+  {\r
+\r
+  }\r
+\r
+  public void tabSelected()\r
+  {\r
+\r
+  }\r
+\r
+  public void featureSettings_actionPerformed(ActionEvent e)\r
+  {\r
+\r
+  }\r
 }\r
index 65ef8dc..68a7c92 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
 \r
-    /**\r
+  /**\r
      * Creates a new GDesktop object.\r
      */\r
     public GDesktop()\r
@@ -158,7 +159,15 @@ public class GDesktop extends JFrame
             });\r
         jMenu1.setMnemonic('I');\r
         jMenu1.setText("Input Alignment");\r
-        DesktopMenubar.add(FileMenu);\r
+    vamsasLoad.setText("Vamsas");\r
+    vamsasLoad.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        vamsasLoad_actionPerformed(e);\r
+      }\r
+    });\r
+    DesktopMenubar.add(FileMenu);\r
         DesktopMenubar.add(toolsMenu);\r
         DesktopMenubar.add(HelpMenu);\r
         DesktopMenubar.add(windowMenu);\r
@@ -175,7 +184,8 @@ public class GDesktop extends JFrame
         jMenu1.add(inputLocalFileMenuItem);\r
         jMenu1.add(inputURLMenuItem);\r
         jMenu1.add(inputTextboxMenuItem);\r
-    }\r
+    jMenu1.add(vamsasLoad);\r
+  }\r
 \r
     /**\r
      * DOCUMENT ME!\r
@@ -273,4 +283,9 @@ public class GDesktop extends JFrame
     public void loadJalviewAlign_actionPerformed(ActionEvent e)\r
     {\r
     }\r
+\r
+  public void vamsasLoad_actionPerformed(ActionEvent e)\r
+  {\r
+\r
+  }\r
 }\r
index 50c4cf5..1896e06 100755 (executable)
@@ -79,6 +79,7 @@ public class GPreferences extends JPanel
   protected JCheckBox useProxy = new JCheckBox();\r
   JPanel jPanel1 = new JPanel();\r
   TitledBorder titledBorder1 = new TitledBorder("Proxy Server");\r
+  TitledBorder titledBorder2 = new TitledBorder("File Output");\r
   GridBagLayout gridBagLayout2 = new GridBagLayout();\r
   GridBagLayout gridBagLayout1 = new GridBagLayout();\r
   GridBagLayout gridBagLayout3 = new GridBagLayout();\r
@@ -90,6 +91,28 @@ public class GPreferences extends JPanel
   JPanel exportTab = new JPanel();\r
   JLabel epsLabel = new JLabel();\r
   protected JComboBox epsRendering = new JComboBox();\r
+  JLabel jLabel1 = new JLabel();\r
+  JLabel jLabel2 = new JLabel();\r
+  protected JCheckBox pileupdb = new JCheckBox();\r
+  protected  JCheckBox fastadb = new JCheckBox();\r
+  protected  JCheckBox blcjv = new JCheckBox();\r
+  protected  JCheckBox pileupjv = new JCheckBox();\r
+  protected  JCheckBox msfdb = new JCheckBox();\r
+  protected  JCheckBox pfamdb = new JCheckBox();\r
+  protected  JCheckBox clustaljv = new JCheckBox();\r
+  protected  JCheckBox msfjv = new JCheckBox();\r
+  protected  JCheckBox blcdb = new JCheckBox();\r
+  protected  JCheckBox clustaldb = new JCheckBox();\r
+  protected  JCheckBox fastajv = new JCheckBox();\r
+  protected  JCheckBox pfamjv = new JCheckBox();\r
+  JLabel jLabel10 = new JLabel();\r
+  JLabel jLabel11 = new JLabel();\r
+  FlowLayout flowLayout1 = new FlowLayout();\r
+  protected  JCheckBox pirdb = new JCheckBox();\r
+  protected  JCheckBox pirjv = new JCheckBox();\r
+  JPanel jPanel11 = new JPanel();\r
+  GridLayout gridLayout3 = new GridLayout();\r
+  Font verdana11 = new java.awt.Font("Verdana", Font.PLAIN, 11);\r
   /**\r
      * Creates a new GPreferences object.\r
      */\r
@@ -130,36 +153,36 @@ public class GPreferences extends JPanel
                 }\r
             });\r
         quality.setEnabled(false);\r
-        quality.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+        quality.setFont(verdana11);\r
         quality.setHorizontalAlignment(SwingConstants.RIGHT);\r
         quality.setHorizontalTextPosition(SwingConstants.LEFT);\r
         quality.setSelected(true);\r
         quality.setText("Quality");\r
     visualTab.setBorder(new TitledBorder("Open new alignment"));\r
     visualTab.setLayout(null);\r
-        fullID.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+        fullID.setFont(verdana11);\r
         fullID.setHorizontalAlignment(SwingConstants.RIGHT);\r
         fullID.setHorizontalTextPosition(SwingConstants.LEFT);\r
     fullID.setMargin(new Insets(4, 2, 2, 0));\r
     fullID.setText("Full Sequence ID");\r
-    fullScreen.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+    fullScreen.setFont(verdana11);\r
         fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);\r
         fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);\r
     fullScreen.setMargin(new Insets(2, 2, 2, 0));\r
     fullScreen.setText("Maximise Window");\r
     conservation.setEnabled(false);\r
-        conservation.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+        conservation.setFont(verdana11);\r
         conservation.setHorizontalAlignment(SwingConstants.RIGHT);\r
         conservation.setHorizontalTextPosition(SwingConstants.LEFT);\r
         conservation.setSelected(true);\r
         conservation.setText("Conservation");\r
     identity.setEnabled(false);\r
-        identity.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+        identity.setFont(verdana11);\r
         identity.setHorizontalAlignment(SwingConstants.RIGHT);\r
         identity.setHorizontalTextPosition(SwingConstants.LEFT);\r
         identity.setSelected(true);\r
         identity.setText("Consensus");\r
-    annotations.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+    annotations.setFont(verdana11);\r
         annotations.setHorizontalAlignment(SwingConstants.RIGHT);\r
         annotations.setHorizontalTextPosition(SwingConstants.LEFT);\r
     annotations.setMargin(new Insets(2, 4, 2, 0));\r
@@ -172,31 +195,31 @@ public class GPreferences extends JPanel
                     annotations_actionPerformed(e);\r
                 }\r
             });\r
-        gapLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+        gapLabel.setFont(verdana11);\r
         gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);\r
         gapLabel.setText("Gap Symbol ");\r
-    colour.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+    colour.setFont(verdana11);\r
         colour.setBounds(new Rectangle(148, 171, 154, 21));\r
-        colourLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+        colourLabel.setFont(verdana11);\r
         colourLabel.setHorizontalAlignment(SwingConstants.RIGHT);\r
         colourLabel.setText("Colour ");\r
-    fontLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+    fontLabel.setFont(verdana11);\r
         fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);\r
         fontLabel.setText("Font ");\r
-    fontSizeCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+    fontSizeCB.setFont(verdana11);\r
         fontSizeCB.setBounds(new Rectangle(317, 111, 49, 21));\r
-        fontStyleCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+        fontStyleCB.setFont(verdana11);\r
         fontStyleCB.setBounds(new Rectangle(365, 111, 70, 21));\r
-        fontNameCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+        fontNameCB.setFont(verdana11);\r
         fontNameCB.setBounds(new Rectangle(148, 111, 169, 21));\r
-        gapSymbolCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+        gapSymbolCB.setFont(verdana11);\r
         gapSymbolCB.setBounds(new Rectangle(148, 141, 67, 21));\r
         startupCheckbox.setText("Open file");\r
-    startupCheckbox.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+    startupCheckbox.setFont(verdana11);\r
         startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);\r
         startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);\r
         startupCheckbox.setSelected(true);\r
-        startupFileTextfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+        startupFileTextfield.setFont(verdana11);\r
         startupFileTextfield.setBounds(new Rectangle(148, 232, 302, 20));\r
         startupFileTextfield.addMouseListener(new MouseAdapter()\r
             {\r
@@ -212,16 +235,16 @@ public class GPreferences extends JPanel
      connectTab.setLayout(gridBagLayout3);\r
     serverLabel.setText("Address");\r
     serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);\r
-    serverLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
-    proxyServerTB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
-    proxyPortTB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
-    portLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+    serverLabel.setFont(verdana11);\r
+    proxyServerTB.setFont(verdana11);\r
+    proxyPortTB.setFont(verdana11);\r
+    portLabel.setFont(verdana11);\r
     portLabel.setHorizontalAlignment(SwingConstants.RIGHT);\r
     portLabel.setText("Port");\r
     browserLabel.setFont(new java.awt.Font("SansSerif", 0, 11));\r
     browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);\r
     browserLabel.setText("Default Browser (Unix)");\r
-    defaultBrowser.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+    defaultBrowser.setFont(verdana11);\r
     defaultBrowser.setText("");\r
     newLink.setText("New");\r
     newLink.addActionListener(new java.awt.event.ActionListener() {\r
@@ -268,7 +291,7 @@ public class GPreferences extends JPanel
     linkNameList.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));\r
     linkNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
     linkPanel2.setLayout(borderLayout3);\r
-    linkURLList.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+    linkURLList.setFont(verdana11);\r
     linkURLList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
 \r
     defaultBrowser.addMouseListener(new MouseAdapter()\r
@@ -281,7 +304,7 @@ public class GPreferences extends JPanel
             }\r
       }\r
     });\r
-    useProxy.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+    useProxy.setFont(verdana11);\r
     useProxy.setHorizontalAlignment(SwingConstants.RIGHT);\r
     useProxy.setHorizontalTextPosition(SwingConstants.LEADING);\r
     useProxy.setText("Use a proxy server");\r
@@ -294,9 +317,9 @@ public class GPreferences extends JPanel
     });\r
     jPanel1.setBorder(titledBorder1);\r
     jPanel1.setLayout(gridBagLayout1);\r
-    sortby.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+    sortby.setFont(verdana11);\r
     sortby.setBounds(new Rectangle(148, 200, 302, 21));\r
-    sortLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+    sortLabel.setFont(verdana11);\r
     sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);\r
     sortLabel.setText("Sort by ");\r
     jPanel2.setBounds(new Rectangle(7, 17, 138, 242));\r
@@ -304,12 +327,75 @@ public class GPreferences extends JPanel
     gridLayout2.setRows(8);\r
     jPanel3.setBounds(new Rectangle(147, 46, 274, 26));\r
     exportTab.setLayout(null);\r
-    epsLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+    epsLabel.setFont(verdana11);\r
     epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);\r
     epsLabel.setText("EPS Rendering Style");\r
-    epsLabel.setBounds(new Rectangle(3, 47, 134, 21));\r
-    epsRendering.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
-    epsRendering.setBounds(new Rectangle(145, 47, 286, 21));\r
+    epsLabel.setBounds(new Rectangle(9, 31, 140, 24));\r
+    epsRendering.setFont(verdana11);\r
+    epsRendering.setBounds(new Rectangle(154, 34, 187, 21));\r
+    jLabel1.setFont(verdana11);\r
+    jLabel1.setHorizontalAlignment(SwingConstants.CENTER);\r
+    jLabel1.setText("/start-end suffix");\r
+    jLabel2.setFont(verdana11);\r
+    jLabel2.setHorizontalAlignment(SwingConstants.RIGHT);\r
+    jLabel2.setHorizontalTextPosition(SwingConstants.RIGHT);\r
+    jLabel2.setText("Database ref prefix");\r
+    jLabel1.setFont(verdana11);\r
+    jLabel2.setFont(verdana11);\r
+    fastajv.setFont(verdana11);\r
+    fastajv.setHorizontalAlignment(SwingConstants.CENTER);\r
+    jLabel10.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));\r
+    jLabel10.setHorizontalAlignment(SwingConstants.RIGHT);\r
+    jLabel10.setText("(Uniprot|P02055)");\r
+    jLabel11.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));\r
+    jLabel11.setHorizontalAlignment(SwingConstants.CENTER);\r
+    jLabel11.setText("(/15-380)");\r
+    clustaldb.setFont(verdana11);\r
+    clustaldb.setHorizontalAlignment(SwingConstants.RIGHT);\r
+    clustaldb.setHorizontalTextPosition(SwingConstants.LEFT);\r
+    clustaldb.setText("Clustal     ");\r
+    blcdb.setFont(verdana11);\r
+    blcdb.setHorizontalAlignment(SwingConstants.RIGHT);\r
+    blcdb.setHorizontalTextPosition(SwingConstants.LEFT);\r
+    blcdb.setText("BLC     ");\r
+    fastadb.setFont(verdana11);\r
+    fastadb.setHorizontalAlignment(SwingConstants.RIGHT);\r
+    fastadb.setHorizontalTextPosition(SwingConstants.LEFT);\r
+    fastadb.setText("Fasta     ");\r
+    msfdb.setFont(verdana11);\r
+    msfdb.setHorizontalTextPosition(SwingConstants.LEFT);\r
+    msfdb.setHorizontalAlignment(SwingConstants.RIGHT);\r
+    msfdb.setText("MSF     ");\r
+    pfamdb.setFont(verdana11);\r
+    pfamdb.setHorizontalAlignment(SwingConstants.RIGHT);\r
+    pfamdb.setHorizontalTextPosition(SwingConstants.LEFT);\r
+    pfamdb.setText("PFAM     ");\r
+    pileupdb.setFont(verdana11);\r
+    pileupdb.setHorizontalAlignment(SwingConstants.RIGHT);\r
+    pileupdb.setHorizontalTextPosition(SwingConstants.LEFT);\r
+    pileupdb.setText("Pileup     ");\r
+    msfjv.setFont(verdana11);\r
+    msfjv.setHorizontalAlignment(SwingConstants.CENTER);\r
+    pirdb.setFont(verdana11);\r
+    pirdb.setHorizontalAlignment(SwingConstants.RIGHT);\r
+    pirdb.setHorizontalTextPosition(SwingConstants.LEFT);\r
+    pirdb.setText("PIR     ");\r
+    jPanel11.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+    jPanel11.setBorder(titledBorder2);\r
+    jPanel11.setBounds(new Rectangle(18, 72, 325, 182));\r
+    jPanel11.setLayout(gridLayout3);\r
+    gridLayout3.setColumns(2);\r
+    gridLayout3.setRows(9);\r
+    blcjv.setFont(verdana11);\r
+    blcjv.setHorizontalAlignment(SwingConstants.CENTER);\r
+    clustaljv.setFont(verdana11);\r
+    clustaljv.setHorizontalAlignment(SwingConstants.CENTER);\r
+    pfamjv.setFont(verdana11);\r
+    pfamjv.setHorizontalAlignment(SwingConstants.CENTER);\r
+    pileupjv.setFont(verdana11);\r
+    pileupjv.setHorizontalAlignment(SwingConstants.CENTER);\r
+    pirjv.setFont(verdana11);\r
+    pirjv.setHorizontalAlignment(SwingConstants.CENTER);\r
     jPanel2.add(fullScreen);\r
     jPanel2.add(annotations);\r
     jPanel2.add(fullID);\r
@@ -370,8 +456,6 @@ public class GPreferences extends JPanel
         , GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,\r
         new Insets(15, 0, 0, 15), 307, 1));\r
 \r
-    exportTab.add(epsLabel);\r
-    exportTab.add(epsRendering);\r
 \r
     jPanel1.add(useProxy, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0\r
                                                  , GridBagConstraints.WEST,\r
@@ -383,8 +467,29 @@ public class GPreferences extends JPanel
         gapSymbolCB.setRenderer(dlcr);\r
 \r
     tabbedPane.add(visualTab, "Visual");\r
-    tabbedPane.add(connectTab, "Connections");\r
-    tabbedPane.add(exportTab, "Export");\r
+    tabbedPane.add(connectTab,"Connections");\r
+    tabbedPane.add(exportTab, "File");\r
+    jPanel11.add(jLabel2);\r
+    jPanel11.add(jLabel1);\r
+    jPanel11.add(jLabel10);\r
+    jPanel11.add(jLabel11);\r
+    jPanel11.add(blcdb);\r
+    jPanel11.add(blcjv);\r
+    jPanel11.add(clustaldb);\r
+    jPanel11.add(clustaljv);\r
+    jPanel11.add(fastadb);\r
+    jPanel11.add(fastajv);\r
+    jPanel11.add(msfdb);\r
+    jPanel11.add(msfjv);\r
+    jPanel11.add(pfamdb);\r
+    jPanel11.add(pfamjv);\r
+    jPanel11.add(pileupdb);\r
+    jPanel11.add(pileupjv);\r
+    jPanel11.add(pirdb);\r
+    jPanel11.add(pirjv);\r
+    exportTab.add(epsLabel);\r
+    exportTab.add(epsRendering);\r
+    exportTab.add(jPanel11);\r
   }\r
 \r
     /**\r
index fbaab81..25707ea 100755 (executable)
@@ -1233,7 +1233,7 @@ public class ResidueProperties
       String key = (String) e.nextElement();\r
       Vector tmp = (Vector) codonHash.get(key);\r
 \r
-      if (tmp.contains(codon))\r
+      if (tmp.contains(codon.toUpperCase()))\r
       {\r
         return key;\r
       }\r
index 9a86696..e48c0ca 100755 (executable)
@@ -29,215 +29,246 @@ import jalview.datamodel.*;
  */\r
 public class Comparison\r
 {\r
-    /** DOCUMENT ME!! */\r
-    public static String GapChars = " .-";\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param ii DOCUMENT ME!\r
-     * @param jj DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public static float compare(SequenceI ii, SequenceI jj)\r
+  /** DOCUMENT ME!! */\r
+  public static String GapChars = " .-";\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param ii DOCUMENT ME!\r
+   * @param jj DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public static float compare(SequenceI ii, SequenceI jj)\r
+  {\r
+    return Comparison.compare(ii, jj, 0, ii.getLength() - 1);\r
+  }\r
+\r
+  /**\r
+   * this was supposed to be an ungapped pid calculation\r
+   * @param ii SequenceI\r
+   * @param jj SequenceI\r
+   * @param start int\r
+   * @param end int\r
+   * @return float\r
+   */\r
+  public static float compare(SequenceI ii, SequenceI jj, int start, int end)\r
+  {\r
+    String si = ii.getSequence();\r
+    String sj = jj.getSequence();\r
+\r
+    int ilen = si.length() - 1;\r
+    int jlen = sj.length() - 1;\r
+\r
+    while (jalview.util.Comparison.isGap(si.charAt(start + ilen)))\r
     {\r
-        return Comparison.compare(ii, jj, 0, ii.getLength() - 1);\r
+      ilen--;\r
     }\r
 \r
-    /**\r
-     * this was supposed to be an ungapped pid calculation\r
-     * @param ii SequenceI\r
-     * @param jj SequenceI\r
-     * @param start int\r
-     * @param end int\r
-     * @return float\r
-     */\r
-    public static float compare(SequenceI ii, SequenceI jj, int start, int end)\r
+    while (jalview.util.Comparison.isGap(sj.charAt(start + jlen)))\r
     {\r
-        String si = ii.getSequence();\r
-        String sj = jj.getSequence();\r
+      jlen--;\r
+    }\r
 \r
-        int ilen = si.length() - 1;\r
-        int jlen = sj.length() - 1;\r
+    int count = 0;\r
+    int match = 0;\r
+    float pid = -1;\r
 \r
-        while (jalview.util.Comparison.isGap(si.charAt(start + ilen)))\r
-        {\r
-            ilen--;\r
-        }\r
-\r
-        while (jalview.util.Comparison.isGap(sj.charAt(start + jlen)))\r
+    if (ilen > jlen)\r
+    {\r
+      for (int j = 0; j < jlen; j++)\r
+      {\r
+        if (si.substring(start + j, start + j + 1).equals(sj.substring(start +\r
+            j, start + j + 1)))\r
         {\r
-            jlen--;\r
+          match++;\r
         }\r
 \r
-        int count = 0;\r
-        int match = 0;\r
-        float pid = -1;\r
+        count++;\r
+      }\r
 \r
-        if (ilen > jlen)\r
-        {\r
-            for (int j = 0; j < jlen; j++)\r
-            {\r
-                if (si.substring(start + j, start + j + 1).equals(sj.substring(start +\r
-                                j, start + j + 1)))\r
-                {\r
-                    match++;\r
-                }\r
-\r
-                count++;\r
-            }\r
-\r
-            pid = (float) match / (float) ilen * 100;\r
-        }\r
-        else\r
+      pid = (float) match / (float) ilen * 100;\r
+    }\r
+    else\r
+    {\r
+      for (int j = 0; j < jlen; j++)\r
+      {\r
+        if (si.substring(start + j, start + j + 1).equals(sj.substring(start +\r
+            j, start + j + 1)))\r
         {\r
-            for (int j = 0; j < jlen; j++)\r
-            {\r
-                if (si.substring(start + j, start + j + 1).equals(sj.substring(start +\r
-                                j, start + j + 1)))\r
-                {\r
-                    match++;\r
-                }\r
-\r
-                count++;\r
-            }\r
-\r
-            pid = (float) match / (float) jlen * 100;\r
+          match++;\r
         }\r
 \r
-        return pid;\r
+        count++;\r
+      }\r
+\r
+      pid = (float) match / (float) jlen * 100;\r
     }\r
 \r
-    /**\r
-     * this is a gapped PID calculation\r
-     *\r
-     * @param s1 SequenceI\r
-     * @param s2 SequenceI\r
-     * @return float\r
-     */\r
-    public static float PID(SequenceI s1, SequenceI s2)\r
+    return pid;\r
+  }\r
+\r
+  /**\r
+   * this is a gapped PID calculation\r
+   *\r
+   * @param s1 SequenceI\r
+   * @param s2 SequenceI\r
+   * @return float\r
+   */\r
+  public static float PID(SequenceI s1, SequenceI s2)\r
+  {\r
+    int len;\r
+\r
+    if (s1.getSequence().length() > s2.getSequence().length())\r
     {\r
-        int len;\r
+      len = s1.getSequence().length();\r
+    }\r
+    else\r
+    {\r
+      len = s2.getSequence().length();\r
+    }\r
 \r
-        if (s1.getSequence().length() > s2.getSequence().length())\r
-        {\r
-            len = s1.getSequence().length();\r
-        }\r
-        else\r
+    int bad = 0;\r
+\r
+    for (int i = 0; i < len; i++)\r
+    {\r
+      char chr1;\r
+      char chr2;\r
+\r
+      if (i < s1.getSequence().length())\r
+      {\r
+        chr1 = Character.toUpperCase(s1.getSequence().charAt(i));\r
+      }\r
+      else\r
+      {\r
+        chr1 = '.';\r
+      }\r
+\r
+      if (i < s2.getSequence().length())\r
+      {\r
+        chr2 = Character.toUpperCase(s2.getSequence().charAt(i));\r
+      }\r
+      else\r
+      {\r
+        chr2 = '.';\r
+      }\r
+\r
+      if (! (jalview.util.Comparison.isGap(chr1)) &&\r
+          ! (jalview.util.Comparison.isGap(chr2)))\r
+      {\r
+        if (chr1 != chr2)\r
         {\r
-            len = s2.getSequence().length();\r
+          bad++;\r
         }\r
+      }\r
+    }\r
 \r
-        int bad = 0;\r
+    return ( (float) 100 * (len - bad)) / len;\r
+  }\r
 \r
-        for (int i = 0; i < len; i++)\r
-        {\r
-            char chr1;\r
-            char chr2;\r
-\r
-            if (i < s1.getSequence().length())\r
-            {\r
-                chr1 = Character.toUpperCase(s1.getSequence().charAt(i));\r
-            }\r
-            else\r
-            {\r
-                chr1 = '.';\r
-            }\r
-\r
-            if (i < s2.getSequence().length())\r
-            {\r
-                chr2 = Character.toUpperCase(s2.getSequence().charAt(i));\r
-            }\r
-            else\r
-            {\r
-                chr2 = '.';\r
-            }\r
-\r
-            if (!(jalview.util.Comparison.isGap(chr1)) &&\r
-                    !(jalview.util.Comparison.isGap(chr2)))\r
-            {\r
-                if (chr1 != chr2)\r
-                {\r
-                    bad++;\r
-                }\r
-            }\r
-        }\r
+  // Another pid with region specification\r
+  public static float PID(SequenceI s1, SequenceI s2, int start, int end)\r
+  {\r
+    int len;\r
 \r
-        return ((float) 100 * (len - bad)) / len;\r
+    if (s1.getSequence().length() > s2.getSequence().length())\r
+    {\r
+      len = s1.getSequence().length();\r
+    }\r
+    else\r
+    {\r
+      len = s2.getSequence().length();\r
     }\r
 \r
-    // Another pid with region specification\r
-    public static float PID(SequenceI s1, SequenceI s2, int start, int end)\r
+    if (end < len)\r
     {\r
-        int len;\r
+      len = end;\r
+    }\r
 \r
-        if (s1.getSequence().length() > s2.getSequence().length())\r
-        {\r
-            len = s1.getSequence().length();\r
-        }\r
-        else\r
-        {\r
-            len = s2.getSequence().length();\r
-        }\r
+    if (len < start)\r
+    {\r
+      start = len - 1; // we just use a single residue for the difference\r
+    }\r
 \r
-        if (end < len)\r
-        {\r
-            len = end;\r
-        }\r
+    int bad = 0;\r
 \r
-        if (len < start)\r
+    for (int i = start; i < len; i++)\r
+    {\r
+      char chr1;\r
+      char chr2;\r
+\r
+      if (i < s1.getSequence().length())\r
+      {\r
+        chr1 = Character.toUpperCase(s1.getSequence().charAt(i));\r
+      }\r
+      else\r
+      {\r
+        chr1 = '.';\r
+      }\r
+\r
+      if (i < s2.getSequence().length())\r
+      {\r
+        chr2 = Character.toUpperCase(s2.getSequence().charAt(i));\r
+      }\r
+      else\r
+      {\r
+        chr2 = '.';\r
+      }\r
+\r
+      if (! (jalview.util.Comparison.isGap(chr1)) &&\r
+          ! (jalview.util.Comparison.isGap(chr2)))\r
+      {\r
+        if (chr1 != chr2)\r
         {\r
-            start = len - 1; // we just use a single residue for the difference\r
+          bad++;\r
         }\r
+      }\r
+    }\r
 \r
-        int bad = 0;\r
-\r
-        for (int i = start; i < len; i++)\r
+    return ( (float) 100 * (len - bad)) / len;\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param c DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public static boolean isGap(char c)\r
+  {\r
+    return (c == '-' || c == '.' || c == ' ') ? true : false;\r
+  }\r
+\r
+  public static boolean isNucleotide(SequenceI [] seqs)\r
+  {\r
+    int i = 0, iSize = seqs.length, j, jSize;\r
+    float nt = 0, aa = 0;\r
+    char c;\r
+    while (i < iSize)\r
+    {\r
+      jSize = seqs[i].getLength();\r
+      for (j = 0; j < jSize; j++)\r
+      {\r
+        c = seqs[i].getCharAt(j);\r
+        if ('a' <= c && c <= 'z')\r
+          c -= ('a' - 'A');\r
+\r
+        if (c == 'A' || c == 'G' || c == 'C' || c == 'T' || c == 'U')\r
+          nt++;\r
+        else if (!jalview.util.Comparison.isGap( seqs[i].getCharAt(j)))\r
         {\r
-            char chr1;\r
-            char chr2;\r
-\r
-            if (i < s1.getSequence().length())\r
-            {\r
-                chr1 = Character.toUpperCase(s1.getSequence().charAt(i));\r
-            }\r
-            else\r
-            {\r
-                chr1 = '.';\r
-            }\r
-\r
-            if (i < s2.getSequence().length())\r
-            {\r
-                chr2 = Character.toUpperCase(s2.getSequence().charAt(i));\r
-            }\r
-            else\r
-            {\r
-                chr2 = '.';\r
-            }\r
-\r
-            if (!(jalview.util.Comparison.isGap(chr1)) &&\r
-                    !(jalview.util.Comparison.isGap(chr2)))\r
-            {\r
-                if (chr1 != chr2)\r
-                {\r
-                    bad++;\r
-                }\r
-            }\r
+          aa++;\r
         }\r
-\r
-        return ((float) 100 * (len - bad)) / len;\r
+      }\r
+      i++;\r
     }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param c DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public static boolean isGap(char c)\r
-    {\r
-        return (  c=='-' || c=='.' || c==' ' ) ? true : false;\r
-    }\r
+    if ( (nt / (nt + aa)) > 0.85f)\r
+      return true;\r
+    else\r
+      return false;\r
+\r
+  }\r
 }\r
index fdf0cec..4cb8aee 100755 (executable)
@@ -173,7 +173,8 @@ public class JPredClient
                                                 msf[0].getSequence()));\r
 \r
       this.msa = new vamsas.objects.simple.Msfalignment();\r
-      msa.setMsf(jalview.io.PileUpfile.print(msf));\r
+      jalview.io.PileUpfile pileup = new jalview.io.PileUpfile();\r
+      msa.setMsf(pileup.print(msf));\r
     }\r
 \r
     public void run()\r
index ae1b515..d8cc069 100755 (executable)
@@ -37,7 +37,7 @@ public abstract class Object implements java.io.Serializable {
             return false;\r
         }\r
 \r
-        Object other = (Object) obj;\r
+        //Object other = (Object) obj;\r
 \r
         if (obj == null) {\r
             return false;\r