local das source properties string constants and routine for generating sequence...
authorjprocter <Jim Procter>
Thu, 4 Dec 2008 10:24:02 +0000 (10:24 +0000)
committerjprocter <Jim Procter>
Thu, 4 Dec 2008 10:24:02 +0000 (10:24 +0000)
src/jalview/bin/Cache.java

index d315626..bae40ca 100755 (executable)
@@ -22,6 +22,7 @@ import java.io.*;
 import java.util.*;
 
 import org.apache.log4j.*;
+import org.biojava.dasobert.dasregistry.Das1Source;
 
 /**
  * Stores and retrieves Jalview Application Properties Lists and fields within
@@ -131,6 +132,10 @@ public class Cache
 
   public static final String DAS_LOCAL_SOURCE = "DAS_LOCAL_SOURCE";
 
+  public static final String DAS_REGISTRY_URL = "DAS_REGISTRY_URL";
+
+  public static final String DAS_ACTIVE_SOURCE = "DAS_ACTIVE_SOURCE";
+
   /**
    * Initialises the Jalview Application Log
    */
@@ -485,4 +490,39 @@ public class Cache
     return (groovyJarsArePresent > 0);
   }
 
+  /**
+   * generate Das1Sources from the local das source list
+   * @return Vector of Das1Sources
+   */
+  public static Vector getLocalDasSources()
+  {
+    Vector localSources = new Vector();
+    String local = jalview.bin.Cache.getProperty("DAS_LOCAL_SOURCE");
+    if (local != null)
+    {
+      StringTokenizer st = new StringTokenizer(local, "\t");
+      while (st.hasMoreTokens())
+      {
+        String token = st.nextToken();
+        int bar = token.indexOf("|");
+        Das1Source source = new Das1Source();
+        source.setUrl(token.substring(bar + 1));
+        if (source.getUrl().startsWith("sequence:"))
+        {
+          source.setUrl(source.getUrl().substring(9));
+          // this source also serves sequences as well as features
+          source.setCapabilities(new String[] { "sequence", "features"});
+        } else {
+          // default is that all user added sources serve features
+          source.setCapabilities(new String[] { "features"}); 
+        }
+
+        source.setNickname(token.substring(0, bar));
+
+        localSources.addElement(source);
+      }
+    }
+    return localSources;
+  }
+
 }