+ // update status
+ guiWindow.setProgressBar(MessageManager.formatMessage("status.fetching_sequence_queries_from", new String[]{Integer.valueOf(nqueries).toString(),proxy.getDbName()}), Thread
+ .currentThread().hashCode());
+ isAliSource = proxy.isA(DBRefSource.ALIGNMENTDB);
+ if (proxy.getAccessionSeparator() == null)
+ {
+ while (en.hasNext())
+ {
+ String item = en.next();
+ try
+ {
+ if (aresult != null)
+ {
+ try
+ {
+ // give the server a chance to breathe
+ Thread.sleep(5);
+ } catch (Exception e)
+ {
+ //
+ }
+
+ }
+
+ AlignmentI indres = null;
+ try
+ {
+ indres = proxy.getSequenceRecords(item);
+ } catch (OutOfMemoryError oome)
+ {
+ new OOMWarning("fetching " + item + " from "
+ + proxy.getDbName(), oome, this);
+ }
+ if (indres != null)
+ {
+ aresultq.add(item);
+ aresult.add(indres);
+ }
+ else
+ {
+ nextfetch.add(item);
+ }
+ } catch (Exception e)
+ {
+ jalview.bin.Cache.log.info("Error retrieving " + item
+ + " from " + proxy.getDbName(), e);
+ nextfetch.add(item);
+ }
+ }
+ }
+ else
+ {
+ StringBuffer multiacc = new StringBuffer();
+ ArrayList<String> tosend = new ArrayList<String>();
+ while (en.hasNext())
+ {
+ String nel = en.next();
+ tosend.add(nel);
+ multiacc.append(nel);
+ if (en.hasNext())
+ {
+ multiacc.append(proxy.getAccessionSeparator());
+ }
+ }
+ try
+ {
+ AlignmentI rslt;
+ SequenceI[] rs;
+ List<String> nores = new ArrayList<String>();
+ rslt = proxy.getSequenceRecords(multiacc.toString());
+ if (rslt == null || rslt.getHeight() == 0)
+ {
+ // no results - pass on all queries to next source
+ nextfetch.addAll(tosend);
+ }
+ else
+ {
+ aresultq.add(multiacc.toString());
+ aresult.add(rslt);
+
+ rs = rslt.getSequencesArray();
+ // search for each query in the dbrefs associated with each
+ // sequence
+ // returned.
+ // ones we do not find will be used to query next source (if any)
+ for (String q : tosend)
+ {
+ DBRefEntry dbr = new DBRefEntry(), found[] = null;
+ dbr.setSource(proxy.getDbSource());
+ dbr.setVersion(null);
+ if (proxy.getAccessionValidator() != null)
+ {
+ Regex vgr = proxy.getAccessionValidator();
+ vgr.search(q);
+ if (vgr.numSubs() > 0)
+ {
+ dbr.setAccessionId(vgr.stringMatched(1));
+ }
+ else
+ {
+ dbr.setAccessionId(vgr.stringMatched());
+ }
+ }
+ else
+ {
+ dbr.setAccessionId(q);
+ }
+ boolean rfound = false;
+ for (int r = 0; r < rs.length; r++)
+ {
+ if (rs[r] != null
+ && (found = DBRefUtils.searchRefs(
+ rs[r].getDBRef(), dbr)) != null
+ && found.length > 0)
+ {
+ rfound = true;
+ rs[r] = null;
+ continue;
+ }
+ }
+ if (!rfound)
+ {
+ nextfetch.add(q);
+ }
+ }
+ }
+ } catch (OutOfMemoryError oome)
+ {
+ new OOMWarning("fetching " + multiacc + " from "
+ + database.getSelectedItem(), oome, this);
+ }
+ }