X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FDasSequenceFeatureFetcher.java;h=33791ad773008352344294067f74eeb425336896;hb=ac5f3842d7230ae9761f2330b86e515efab29ee5;hp=f6e6f9b63d3a74b5b0a37c3fcb13c7389fe5b0d3;hpb=63f7dffaa9b668ad5ab7d8092e5232908e4b0bcb;p=jalview.git diff --git a/src/jalview/io/DasSequenceFeatureFetcher.java b/src/jalview/io/DasSequenceFeatureFetcher.java index f6e6f9b..33791ad 100755 --- a/src/jalview/io/DasSequenceFeatureFetcher.java +++ b/src/jalview/io/DasSequenceFeatureFetcher.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -18,29 +18,19 @@ */ package jalview.io; -import jalview.datamodel.*; - -import jalview.gui.*; - +import java.net.*; import java.util.*; -import java.net.URL; - -import org.biojava.dasobert.das.FeatureThread; -import org.biojava.dasobert.eventmodel.FeatureEvent; -import org.biojava.dasobert.eventmodel.FeatureListener; -import org.biojava.dasobert.dasregistry.DasSource; - -import org.biojava.dasobert.das2.io.DasSourceReaderImpl; -import org.biojava.dasobert.dasregistry.Das1Source; -import org.biojava.dasobert.dasregistry.DasSource; -import org.biojava.dasobert.das2.Das2Source; -import org.biojava.dasobert.das2.DasSourceConverter; +import javax.swing.*; +import org.biojava.dasobert.das.*; +import org.biojava.dasobert.das2.*; +import org.biojava.dasobert.das2.io.*; +import org.biojava.dasobert.dasregistry.*; +import org.biojava.dasobert.eventmodel.*; import jalview.bin.Cache; -import org.biojava.dasobert.dasregistry.DasCoordinateSystem; - -import javax.swing.*; +import jalview.datamodel.*; +import jalview.gui.*; /** * DOCUMENT ME! @@ -124,10 +114,14 @@ public class DasSequenceFeatureFetcher thread.start(); } else + { startFetching(); } + } else + { startFetching(); + } } @@ -226,7 +220,9 @@ public class DasSequenceFeatureFetcher af.setProgressBar("DAS Feature Fetching Complete", startTime); if(af.featureSettings!=null) + { af.featureSettings.setTableData(); + } fsettings.complete(); } @@ -241,12 +237,15 @@ public class DasSequenceFeatureFetcher int end = af.getViewport().getEndSeq(); int index; for(index=start; index0) + + for(int csIndex=0; csIndex 0 && jalview.util.DBRefUtils + .isDasCoordinateSystem(cs[csIndex].getName(), uprefs[j])) { - // - if (jalview.util.DBRefUtils - .isDasCoordinateSystem(cs[0].getName(), uprefs[0])) - { - Cache.log.debug("Launched fetcher for coordinate system " + - cs[0].getName()); - - createFeatureFetcher(seq, - dasSource, - uprefs[0].getAccessionId()); - } + Cache.log.debug("Launched fetcher for coordinate system " + + cs[0].getName()); + // Will have to pass any mapping information to the fetcher + //- the start/end for the DBRefEntry may not be the same as the sequence's start/end + + System.out.println(seq.getName() + " " + (seq.getDatasetSequence() == null) + + " " + dasSource.getUrl()); + + dasCoordSysFound = false; + createFeatureFetcher(seq, + dasSource, + uprefs[j]); + break; // only do this for one reference - assume same source will send same features for all IDs } + else + System.out.println("IGNORE " + cs[csIndex].getName()); } } } - else + + if(!dasCoordSysFound) { String id = null; // try and use the name as the sequence id @@ -310,12 +318,89 @@ public class DasSequenceFeatureFetcher } - /** - * fetch and add das features to a sequence using the given source URL and Id to create a feature request - * @param seq - * @param SourceUrl - * @param id - */ + +/** + * fetch and add das features to a sequence using the given source URL and compatible DbRef id. + * new features are mapped using the DbRef mapping to the local coordinate system. + * @param seq + * @param SourceUrl + * @param dbref + */ + protected void createFeatureFetcher(final SequenceI seq, final DasSource dasSource, + final DBRefEntry dbref) { + + ////////////// + /// fetch DAS features + final Das1Source source = new Das1Source(); + source.setUrl(dasSource.getUrl()); + source.setNickname(dasSource.getNickname()); + if (dbref==null || dbref.getAccessionId()==null || dbref.getAccessionId().length()<1) + { + return; + } + Cache.log.debug("new Das Feature Fetcher for " + dbref.getSource()+":"+dbref.getAccessionId() + " querying " + + dasSource.getUrl()); + FeatureThread fetcher = new FeatureThread(dbref.getAccessionId() + // + ":" + start + "," + end, + , source); + + fetcher.addFeatureListener(new FeatureListener() + { + public void comeBackLater(FeatureEvent e) + { + responseComplete(dasSource, seq); + Cache.log.debug("das source " + e.getDasSource().getNickname() + + " asked us to come back in " + e.getComeBackLater() + + " secs."); + } + + public void newFeatures(FeatureEvent e) + { + + Das1Source ds = e.getDasSource(); + + Map[] features = e.getFeatures(); + // add features to sequence + Cache.log.debug("das source " + ds.getUrl() + " returned " + + features.length + " features"); + + if (features.length > 0) + { + for (int i = 0; i < features.length; i++) + { + SequenceFeature f = newSequenceFeature(features[i], + source.getNickname()); + if (dbref.getMap()!=null && f.getBegin()>0 && f.getEnd()>0) { + Cache.log.debug("mapping from "+f.getBegin()+" - "+f.getEnd()); + SequenceFeature vf[] = dbref.getMap().locateFeature(f); + if (vf!=null) { + for (int v=0;v