X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FDasSequenceFeatureFetcher.java;h=fbd7442cf929024aebfcabe32238dd533a232afb;hb=7bc226b58110fa26d9dbd3f0c78095d06909ffc3;hp=f6e6f9b63d3a74b5b0a37c3fcb13c7389fe5b0d3;hpb=63f7dffaa9b668ad5ab7d8092e5232908e4b0bcb;p=jalview.git diff --git a/src/jalview/io/DasSequenceFeatureFetcher.java b/src/jalview/io/DasSequenceFeatureFetcher.java index f6e6f9b..fbd7442 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,13 +114,17 @@ public class DasSequenceFeatureFetcher thread.start(); } else + { startFetching(); + } } else + { startFetching(); - } + } + class FetchDBRefs implements Runnable { @@ -142,173 +136,176 @@ public class DasSequenceFeatureFetcher } } + /** + * Spawns a number of dasobert Fetcher threads to add features to sequences in the dataset + */ + void startFetching() + { + cancelled = false; + startTime = System.currentTimeMillis(); + af.setProgressBar("Fetching DAS Sequence Features", startTime); + + DasSource[] sources = new jalview.gui.DasSourceBrowser().getDASSource(); + + if (selectedSources == null || selectedSources.size() == 0) + { + String active = jalview.bin.Cache.getDefault("DAS_ACTIVE_SOURCE", + "uniprot"); + StringTokenizer st = new StringTokenizer(active, "\t"); + Vector selectedSources = new Vector(); + String token; + while (st.hasMoreTokens()) + { + token = st.nextToken(); + for (int i = 0; i < sources.length; i++) + { + if (sources[i].getNickname().equals(token)) + { + selectedSources.addElement(sources[i]); + break; + } + } + } + } + + if (selectedSources == null || selectedSources.size() == 0) + { + System.out.println("No DAS Sources active"); + af.setProgressBar("No DAS Sources Active", startTime); + return; + } + + sourcesRemaining = selectedSources.size(); + //Now sending requests one at a time to each server + for (int sourceIndex = 0; + sourceIndex < selectedSources.size() + && !cancelled; + sourceIndex++) + { + DasSource dasSource = (DasSource) selectedSources.elementAt( + sourceIndex); + + nextSequence(dasSource, sequences[0]); + } + } + + public void cancel() + { + af.setProgressBar("DAS Feature Fetching Cancelled", startTime); + cancelled = true; + } + + int sourcesRemaining = 0; + void responseComplete(DasSource dasSource, SequenceI seq) + { + if (seq != null) + { + for (int seqIndex = 0; + seqIndex < sequences.length - 1 + && !cancelled; seqIndex++) + { + if (sequences[seqIndex] == seq) + { + nextSequence(dasSource, sequences[++seqIndex]); + return; + } + } + } + + sourcesRemaining--; + + if (sourcesRemaining == 0) + { + af.setProgressBar("DAS Feature Fetching Complete", startTime); + + if (af.featureSettings != null) + { + af.featureSettings.setTableData(); + } + + fsettings.complete(); + } + + } - /** - * Spawns a number of dasobert Fetcher threads to add features to sequences in the dataset - */ - void startFetching() - { - cancelled = false; - startTime = System.currentTimeMillis(); - af.setProgressBar("Fetching DAS Sequence Features", startTime); - - DasSource[] sources = new jalview.gui.DasSourceBrowser().getDASSource(); - - if (selectedSources == null || selectedSources.size() == 0) - { - String active = jalview.bin.Cache.getDefault("DAS_ACTIVE_SOURCE", - "uniprot"); - StringTokenizer st = new StringTokenizer(active, "\t"); - Vector selectedSources = new Vector(); - String token; - while (st.hasMoreTokens()) - { - token = st.nextToken(); - for (int i = 0; i < sources.length; i++) - { - if (sources[i].getNickname().equals(token)) - { - selectedSources.addElement(sources[i]); - break; - } - } - } - } - - if (selectedSources == null || selectedSources.size() == 0) - { - System.out.println("No DAS Sources active"); - af.setProgressBar("No DAS Sources Active", startTime); - return; - } - - sourcesRemaining = selectedSources.size(); - //Now sending requests one at a time to each server - for (int sourceIndex = 0; - sourceIndex < selectedSources.size() - && !cancelled; - sourceIndex++) - { - DasSource dasSource = (DasSource) selectedSources.elementAt( - sourceIndex); - - nextSequence(dasSource, sequences[0]); - } - } - - public void cancel() - { - af.setProgressBar("DAS Feature Fetching Cancelled", startTime); - cancelled = true; - } - - int sourcesRemaining=0; - void responseComplete(DasSource dasSource, SequenceI seq) - { - if (seq != null) - { - for (int seqIndex = 0; - seqIndex < sequences.length-1 - && !cancelled; seqIndex++) - { - if (sequences[seqIndex] == seq) - { - nextSequence(dasSource, sequences[++seqIndex]); - return; - } - } - } - - sourcesRemaining --; - - if(sourcesRemaining==0) - { - af.setProgressBar("DAS Feature Fetching Complete", startTime); - - if(af.featureSettings!=null) - af.featureSettings.setTableData(); - - fsettings.complete(); - } - - } - - void featuresAdded(SequenceI seq) - { - af.getFeatureRenderer().featuresAdded(); - - int start = af.getViewport().getStartSeq(); - int end = af.getViewport().getEndSeq(); - int index; - for(index=start; index 0) { - // we know the id for this entry, so don't note its ID in the unknownSequences list - // for (int j = 0; j < uprefs.length; j++) + // for (int l = 0; l < cs.length; l++) { - // 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 - DasCoordinateSystem cs[] = dasSource.getCoordinateSystem(); - if(cs.length>0) + // + if (jalview.util.DBRefUtils + .isDasCoordinateSystem(cs[0].getName(), uprefs[0])) { - // for (int l = 0; l < cs.length; l++) - { - // - 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()); + + createFeatureFetcher(seq, + dasSource, + uprefs[0].getAccessionId()); } } } - else - { - String id = null; - // try and use the name as the sequence id - if (seq.getName().indexOf("|") > -1) - { - id = seq.getName().substring( - seq.getName().lastIndexOf("|") + 1); - } - else - { - id = seq.getName(); - } - if (id != null) - { - // Should try to call a general feature fetcher that - // queries many sources with name to discover applicable ID references - createFeatureFetcher(seq, - dasSource, - id); - } - } + } + } + else + { + String id = null; + // try and use the name as the sequence id + if (seq.getName().indexOf("|") > -1) + { + id = seq.getName().substring( + seq.getName().lastIndexOf("|") + 1); + } + else + { + id = seq.getName(); + } + if (id != null) + { + // Should try to call a general feature fetcher that + // queries many sources with name to discover applicable ID references + createFeatureFetcher(seq, + dasSource, + id); + } + } - } + } /** * fetch and add das features to a sequence using the given source URL and Id to create a feature request @@ -369,8 +366,8 @@ public class DasSequenceFeatureFetcher } else { - // System.out.println("No features found for " + seq.getName() - // + " from: " + e.getDasSource().getNickname()); + // System.out.println("No features found for " + seq.getName() + // + " from: " + e.getDasSource().getNickname()); } responseComplete(dasSource, seq); @@ -404,7 +401,9 @@ public class DasSequenceFeatureFetcher */ String desc = new String(); if (dasfeature.containsKey("NOTE")) + { desc += (String) dasfeature.get("NOTE"); + } int start = 0, end = 0; float score = 0f; @@ -498,4 +497,3 @@ public class DasSequenceFeatureFetcher } } -