From 0eda2ac2f334f55f6e5f137789453a9f4dfe4d73 Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 16 Nov 2007 15:06:26 +0000 Subject: [PATCH] refactored ebi soap client and AbstractSequenceFetcher machinery to their own packages. --- src/MCview/PDBViewer.java | 2 +- src/jalview/gui/AppJmol.java | 2 +- src/jalview/gui/SequenceFetcher.java | 5 +- src/jalview/ws/DBRefFetcher.java | 1 + src/jalview/ws/SequenceFetcher.java | 93 +++++++++++++++----------- src/jalview/ws/dbsources/EmblSource.java | 2 +- src/jalview/ws/dbsources/EmblXmlSource.java | 2 +- src/jalview/ws/dbsources/Pdb.java | 2 +- src/jalview/ws/dbsources/Pfam.java | 2 +- src/jalview/ws/dbsources/Uniprot.java | 2 +- src/jalview/ws/dbsources/UnprotName.java | 19 ++++++ src/jalview/ws/{ => ebi}/EBIFetchClient.java | 2 +- 12 files changed, 85 insertions(+), 49 deletions(-) create mode 100644 src/jalview/ws/dbsources/UnprotName.java rename src/jalview/ws/{ => ebi}/EBIFetchClient.java (99%) diff --git a/src/MCview/PDBViewer.java b/src/MCview/PDBViewer.java index 35e02b8..e586707 100755 --- a/src/MCview/PDBViewer.java +++ b/src/MCview/PDBViewer.java @@ -27,7 +27,7 @@ import jalview.datamodel.*; import jalview.gui.*; import jalview.io.*; import jalview.schemes.*; -import jalview.ws.EBIFetchClient; +import jalview.ws.ebi.EBIFetchClient; import java.awt.BorderLayout; diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index 5f1a70b..7269e1d 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -33,7 +33,7 @@ import jalview.structure.*; import jalview.datamodel.PDBEntry; import jalview.io.*; import jalview.schemes.*; -import jalview.ws.EBIFetchClient; +import jalview.ws.ebi.EBIFetchClient; import org.jmol.api.*; import org.jmol.adapter.smarter.SmarterJmolAdapter; diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index 3b511a0..70dff68 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -31,7 +31,8 @@ import jalview.datamodel.xdb.embl.*; import java.io.File; import jalview.io.*; import jalview.ws.DBRefFetcher; -import jalview.ws.EBIFetchClient; +import jalview.ws.ebi.EBIFetchClient; +import jalview.ws.seqfetcher.ASequenceFetcher; import java.awt.Rectangle; import java.awt.BorderLayout; @@ -40,7 +41,7 @@ import java.awt.Dimension; public class SequenceFetcher extends JPanel implements Runnable { - jalview.ws.SequenceFetcher sfetch; + ASequenceFetcher sfetch; JInternalFrame frame; AlignFrame alignFrame; StringBuffer result; diff --git a/src/jalview/ws/DBRefFetcher.java b/src/jalview/ws/DBRefFetcher.java index fb7eac9..109f4b4 100644 --- a/src/jalview/ws/DBRefFetcher.java +++ b/src/jalview/ws/DBRefFetcher.java @@ -26,6 +26,7 @@ import org.exolab.castor.xml.*; import jalview.analysis.*; import jalview.datamodel.*; import jalview.gui.*; +import jalview.ws.ebi.EBIFetchClient; /** * DOCUMENT ME! diff --git a/src/jalview/ws/SequenceFetcher.java b/src/jalview/ws/SequenceFetcher.java index 5243111..a1c391b 100644 --- a/src/jalview/ws/SequenceFetcher.java +++ b/src/jalview/ws/SequenceFetcher.java @@ -1,7 +1,6 @@ package jalview.ws; import java.util.Enumeration; -import java.util.Hashtable; import java.util.Vector; import jalview.datamodel.Alignment; @@ -12,7 +11,8 @@ import jalview.ws.seqfetcher.ASequenceFetcher; import jalview.ws.seqfetcher.DbSourceProxy; /** - * prototype of abstract sequence retrieval interface + * This is the the concrete implementation of the sequence retrieval interface + * and abstract class in jalview.ws.seqfetcher. This implements the discovery * */ public class SequenceFetcher extends ASequenceFetcher @@ -25,19 +25,14 @@ public class SequenceFetcher extends ASequenceFetcher */ public SequenceFetcher() { - FETCHABLEDBS = new Hashtable(); - FETCHABLEDBS.put(DBRefSource.EMBL, - new jalview.ws.dbsources.EmblSource()); - FETCHABLEDBS.put(DBRefSource.EMBLCDS, - new jalview.ws.dbsources.EmblCdsSouce()); - FETCHABLEDBS.put(DBRefSource.UNIPROT, - new jalview.ws.dbsources.Uniprot()); - FETCHABLEDBS.put(DBRefSource.UP_NAME, - new jalview.ws.dbsources.Uniprot()); - FETCHABLEDBS.put(DBRefSource.PDB, new jalview.ws.dbsources.Pdb()); - FETCHABLEDBS.put(DBRefSource.PFAM, new jalview.ws.dbsources.Pfam()); + addDBRefSourceImpl(jalview.ws.dbsources.EmblSource.class); + addDBRefSourceImpl(jalview.ws.dbsources.EmblCdsSouce.class); + addDBRefSourceImpl(jalview.ws.dbsources.Uniprot.class); + addDBRefSourceImpl(jalview.ws.dbsources.UnprotName.class); + addDBRefSourceImpl(jalview.ws.dbsources.Pdb.class); + addDBRefSourceImpl(jalview.ws.dbsources.Pfam.class); }; - + public static void main(String[] argv) { AlignmentI ds = null; @@ -47,11 +42,11 @@ public class SequenceFetcher extends ASequenceFetcher System.out .println("Ignoring arguments. Future Usage = dbname:query1;query2;..."); } - SequenceFetcher sfetcher = new SequenceFetcher(); - Enumeration e = sfetcher.FETCHABLEDBS.keys(); - while (e.hasMoreElements()) + ASequenceFetcher sfetcher = new SequenceFetcher(); + String[] dbSources = sfetcher.getSupportedDb(); + for (int dbsource=0; dbsource0) + if (noProds.size() > 0) { Enumeration ts = noProds.elements(); while (ts.hasMoreElements()) - + { Object[] typeSq = (Object[]) ts.nextElement(); - boolean dna = (typeSq.length>1); + boolean dna = (typeSq.length > 1); AlignmentI al = (AlignmentI) typeSq[0]; - System.out.println("Trying getProducts for "+al.getSequenceAt(0).getDisplayId(true)); - System.out.println("Search DS Xref for: "+(dna ? "dna" : "prot")); - // have a bash at finding the products amongst all the retrieved sequences. - SequenceI[] prod = jalview.analysis.CrossRef.findXrefSequences(al - .getSequencesArray(), dna, null, ds).getSequencesArray(); // note should test rather than throw away codon mapping (if present) + System.out.println("Trying getProducts for " + + al.getSequenceAt(0).getDisplayId(true)); + System.out.println("Search DS Xref for: " + (dna ? "dna" : "prot")); + // have a bash at finding the products amongst all the retrieved + // sequences. + SequenceI[] seqs = al.getSequencesArray(); + Alignment prodal = jalview.analysis.CrossRef.findXrefSequences( + seqs, dna, null, ds); System.out.println("Found " - + ((prod == null) ? "no" : "" + prod.length) - + " products"); - if (prod!=null) + + ((prodal == null) ? "no" : "" + prodal.getHeight()) + " products"); + if (prodal != null) { - for (int p=0; p