+\r
+ /**\r
+ * Spawns a number of dasobert Fetcher threads to add features to sequences in the dataset\r
+ */\r
+ void startFetching()\r
+ {\r
+ cancelled = false;\r
+ startTime = System.currentTimeMillis();\r
+ af.setProgressBar("Fetching DAS Sequence Features", startTime);\r
+\r
+ DasSource[] sources = new jalview.gui.DasSourceBrowser().getDASSource();\r
+\r
+ if (selectedSources == null || selectedSources.size() == 0)\r
+ {\r
+ String active = jalview.bin.Cache.getDefault("DAS_ACTIVE_SOURCE",\r
+ "uniprot");\r
+ StringTokenizer st = new StringTokenizer(active, "\t");\r
+ Vector selectedSources = new Vector();\r
+ String token;\r
+ while (st.hasMoreTokens())\r
+ {\r
+ token = st.nextToken();\r
+ for (int i = 0; i < sources.length; i++)\r
+ {\r
+ if (sources[i].getNickname().equals(token))\r
+ {\r
+ selectedSources.addElement(sources[i]);\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ if (selectedSources == null || selectedSources.size() == 0)\r
+ {\r
+ System.out.println("No DAS Sources active");\r
+ af.setProgressBar("No DAS Sources Active", startTime);\r
+ return;\r
+ }\r
+\r
+ sourcesRemaining = selectedSources.size();\r
+ //Now sending requests one at a time to each server\r
+ for (int sourceIndex = 0;\r
+ sourceIndex < selectedSources.size()\r
+ && !cancelled;\r
+ sourceIndex++)\r
+ {\r
+ DasSource dasSource = (DasSource) selectedSources.elementAt(\r
+ sourceIndex);\r
+\r
+ nextSequence(dasSource, sequences[0]);\r
+ }\r
+ }\r
+\r
+ public void cancel()\r
+ {\r
+ af.setProgressBar("DAS Feature Fetching Cancelled", startTime);\r
+ cancelled = true;\r
+ }\r
+\r
+ int sourcesRemaining=0;\r
+ void responseComplete(DasSource dasSource, SequenceI seq)\r
+ {\r
+ if (seq != null)\r
+ {\r
+ for (int seqIndex = 0;\r
+ seqIndex < sequences.length-1\r
+ && !cancelled; seqIndex++)\r
+ {\r
+ if (sequences[seqIndex] == seq)\r
+ {\r
+ nextSequence(dasSource, sequences[++seqIndex]);\r
+ return;\r
+ }\r
+ }\r
+ }\r
+\r
+ sourcesRemaining --;\r
+\r
+ if(sourcesRemaining==0)\r
+ {\r
+ af.setProgressBar("DAS Feature Fetching Complete", startTime);\r
+\r
+ if(af.featureSettings!=null)\r
+ af.featureSettings.setTableData();\r
+\r
+ fsettings.complete();\r
+ }\r
+\r
+ }\r
+\r
+ void featuresAdded(SequenceI seq)\r
+ {\r
+ af.getFeatureRenderer().featuresAdded();\r
+\r
+ int start = af.getViewport().getStartSeq();\r
+ int end = af.getViewport().getEndSeq();\r
+ int index;\r
+ for(index=start; index<end; index++)\r
+ if(seq == af.getViewport().getAlignment().getSequenceAt(index).getDatasetSequence())\r
+ {\r
+ af.alignPanel.repaint();\r
+ break;\r
+ }\r
+ }\r
+\r
+\r
+ void nextSequence(DasSource dasSource, SequenceI seq)\r
+ {\r
+ DBRefEntry[] uprefs = jalview.util.DBRefUtils.selectRefs(seq.getDBRef(),\r
+ new String[]\r
+ {\r
+ // jalview.datamodel.DBRefSource.PDB,\r
+ jalview.datamodel.DBRefSource.UNIPROT\r
+ });\r
+\r
+ if (uprefs != null)\r
+ {\r
+ // we know the id for this entry, so don't note its ID in the unknownSequences list\r
+ // for (int j = 0; j < uprefs.length; j++)\r
+ {\r
+ // Will have to pass any mapping information to the fetcher\r
+ //- the start/end for the DBRefEntry may not be the same as the sequence's start/end\r
+ DasCoordinateSystem cs[] = dasSource.getCoordinateSystem();\r
+ if(cs.length>0)\r
+ {\r
+ // for (int l = 0; l < cs.length; l++)\r
+ {\r
+ //\r
+ if (jalview.util.DBRefUtils\r
+ .isDasCoordinateSystem(cs[0].getName(), uprefs[0]))\r