+\r
+ /**\r
+ * query the currently defined DAS source registry for sequence sources and\r
+ * add a DasSequenceSource instance for each source to the SequenceFetcher\r
+ * source list.\r
+ */\r
+ public void registerDasSequenceSources()\r
+ {\r
+ DasSource[] sources = jalview.ws.DasSequenceFeatureFetcher\r
+ .getDASSources();\r
+ if (sources != null)\r
+ {\r
+ for (int s = 0; sources != null && s < sources.length; s++)\r
+ {\r
+ addDasSequenceSource(sources[s]);\r
+ }\r
+ }\r
+\r
+ Vector localsources = jalview.bin.Cache.getLocalDasSources();\r
+ if (localsources != null)\r
+ {\r
+ for (Enumeration ls = localsources.elements(); ls.hasMoreElements();)\r
+ {\r
+ addDasSequenceSource((DasSource) ls.nextElement());\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Try to create and add a DasSequenceSource to the list of sources.\r
+ * \r
+ * @param source\r
+ * @return null if no source was added, or the new DasSequenceSource created\r
+ */\r
+ DasSequenceSource addDasSequenceSource(DasSource source)\r
+ {\r
+ DasSequenceSource ds = null;\r
+ Das1Source d1s = null;\r
+ if (source.hasCapability("sequence"))\r
+ {\r
+ if (source instanceof Das2Source)\r
+ {\r
+ if (((Das2Source) source).hasDas1Capabilities())\r
+ {\r
+ try\r
+ {\r
+ d1s = org.biojava.dasobert.das2.DasSourceConverter\r
+ .toDas1Source((Das2Source) source);\r
+ } catch (Exception e)\r
+ {\r
+ System.err.println("Ignoring DAS2 sequence source "\r
+ + source.getNickname()\r
+ + " - couldn't map to Das1Source.\n");\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ }\r
+ else\r
+ {\r
+ if (source instanceof Das1Source)\r
+ {\r
+ d1s = (Das1Source) source;\r
+ }\r
+ }\r
+ }\r
+ if (d1s != null)\r
+ {\r
+ DasCoordinateSystem[] css = d1s.getCoordinateSystem();\r
+ if (css == null || css.length == 0)\r
+ {\r
+ // TODO: query das source directly to identify coordinate system... or\r
+ // have to make up a coordinate system\r
+ css = new DasCoordinateSystem[]\r
+ { new DasCoordinateSystem() };\r
+ css[0].setName(d1s.getNickname());\r
+ css[0].setUniqueId(d1s.getNickname());\r
+ }\r
+ for (int c = 0; c < css.length; c++)\r
+ {\r
+ try\r
+ {\r
+ addDbRefSourceImpl(ds = new DasSequenceSource("das:"\r
+ + d1s.getNickname() + " (" + css[c].getName() + ")",\r
+ css[c].getName(), d1s, css[c]));\r
+ } catch (Exception e)\r
+ {\r
+ System.err.println("Ignoring sequence coord system " + c + " ("\r
+ + css[c].getName() + ") for source " + d1s.getNickname()\r
+ + "- threw exception when constructing fetcher.\n");\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ }\r
+ return ds;\r
+ }\r