From: jprocter Date: Wed, 29 Feb 2012 16:16:58 +0000 (+0000) Subject: refactored das sequence source creation code to the implementor of the das source... X-Git-Tag: Jalview_2_9~532^2~31^2~11 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9d2628ef9266d6c7a953c8fd6e5539069e5997b3;p=jalview.git refactored das sequence source creation code to the implementor of the das source api and das registry api --- diff --git a/src/jalview/ws/SequenceFetcher.java b/src/jalview/ws/SequenceFetcher.java index 4f9e0ab..8c9e08f 100644 --- a/src/jalview/ws/SequenceFetcher.java +++ b/src/jalview/ws/SequenceFetcher.java @@ -17,23 +17,19 @@ */ package jalview.ws; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Vector; - -import org.biojava.dasobert.das2.Das2Source; -import org.biojava.dasobert.dasregistry.Das1Source; -import org.biojava.dasobert.dasregistry.DasCoordinateSystem; -import org.biojava.dasobert.dasregistry.DasSource; - import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefSource; import jalview.datamodel.SequenceI; -import jalview.ws.dbsources.DasSequenceSource; +import jalview.ws.dbsources.das.api.jalviewSourceI; import jalview.ws.seqfetcher.ASequenceFetcher; import jalview.ws.seqfetcher.DbSourceProxy; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.Vector; + /** * This is the the concrete implementation of the sequence retrieval interface * and abstract class in jalview.ws.seqfetcher. This implements the run-time @@ -75,7 +71,7 @@ public class SequenceFetcher extends ASequenceFetcher for (int i = 0; i < srcs.length; i++) { String nm = getSourceProxy(srcs[i]).getDbName(); - if (getSourceProxy(srcs[i]) instanceof jalview.ws.dbsources.DasSequenceSource) + if (getSourceProxy(srcs[i]) instanceof jalview.ws.dbsources.das.datamodel.DasSequenceSource) { if (nm.startsWith("das:")) { @@ -317,91 +313,18 @@ public class SequenceFetcher extends ASequenceFetcher */ public void registerDasSequenceSources() { - DasSource[] sources = jalview.ws.DasSequenceFeatureFetcher - .getDASSources(); - if (sources != null) - { - for (int s = 0; sources != null && s < sources.length; s++) - { - addDasSequenceSource(sources[s]); - } - } - - Vector localsources = jalview.bin.Cache.getLocalDasSources(); - if (localsources != null) - { - for (Enumeration ls = localsources.elements(); ls.hasMoreElements();) - { - addDasSequenceSource((DasSource) ls.nextElement()); - } - } - } - - /** - * Try to create and add a DasSequenceSource to the list of sources. - * - * @param source - * @return null if no source was added, or the new DasSequenceSource created - */ - DasSequenceSource addDasSequenceSource(DasSource source) - { - DasSequenceSource ds = null; - Das1Source d1s = null; - if (source.hasCapability("sequence")) - { - if (source instanceof Das2Source) - { - if (((Das2Source) source).hasDas1Capabilities()) - { - try - { - d1s = org.biojava.dasobert.das2.DasSourceConverter - .toDas1Source((Das2Source) source); - } catch (Exception e) - { - System.err.println("Ignoring DAS2 sequence source " - + source.getNickname() - + " - couldn't map to Das1Source.\n"); - e.printStackTrace(); - } - } - } - else - { - if (source instanceof Das1Source) - { - d1s = (Das1Source) source; - } - } - } - if (d1s != null) + // TODO: define a context as a registry provider (either desktop, + // jalview.bin.cache, or something else). + for (jalviewSourceI source : jalview.bin.Cache.getDasSourceRegistry().getSources()) { - DasCoordinateSystem[] css = d1s.getCoordinateSystem(); - if (css == null || css.length == 0) + if (source.isSequenceSource()) { - // TODO: query das source directly to identify coordinate system... or - // have to make up a coordinate system - css = new DasCoordinateSystem[] - { new DasCoordinateSystem() }; - css[0].setName(d1s.getNickname()); - css[0].setUniqueId(d1s.getNickname()); - } - for (int c = 0; c < css.length; c++) - { - try + List dassources = source.getSequenceSourceProxies(); + for (DbSourceProxy seqsrc : dassources) { - addDbRefSourceImpl(ds = new DasSequenceSource("das:" - + d1s.getNickname() + " (" + css[c].getName() + ")", - css[c].getName(), d1s, css[c])); - } catch (Exception e) - { - System.err.println("Ignoring sequence coord system " + c + " (" - + css[c].getName() + ") for source " + d1s.getNickname() - + "- threw exception when constructing fetcher.\n"); - e.printStackTrace(); + addDbRefSourceImpl(seqsrc); } } } - return ds; } }