package jalview.ws; import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefSource; import jalview.datamodel.SequenceI; /** * prototype of abstract sequence retrieval interface * */ public class SequenceFetcher extends ASequenceFetcher { /** * Thread safe construction of database proxies TODO: extend to a configurable * database plugin mechanism where classes are instantiated by reflection and * queried for their DbRefSource and version association. * */ 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()); }; public static void main(String[] argv) { AlignmentI ds = null; Vector noProds = new Vector(); if (argv != null && argv.length > 0) { System.out .println("Ignoring arguments. Future Usage = dbname:query1;query2;..."); } SequenceFetcher sfetcher = new SequenceFetcher(); Enumeration e = sfetcher.FETCHABLEDBS.keys(); while (e.hasMoreElements()) { String db = (String) e.nextElement(); // skip me if (db.equals(DBRefSource.PDB)) continue; DbSourceProxy sp = sfetcher.getSourceProxy(db); System.out .println("" + db + ": retrieving test:" + sp.getTestQuery()); AlignmentI al = null; try { al = sp.getSequenceRecords(sp.getTestQuery()); if (al != null && al.getHeight() > 0) { boolean dna = sp.getDbSourceProperties().containsKey( DBRefSource.DNACODINGSEQDB) || sp.getDbSourceProperties().containsKey( DBRefSource.DNASEQDB) || sp.getDbSourceProperties().containsKey( DBRefSource.CODINGSEQDB); // try and find products String types[] = jalview.analysis.CrossRef.findSequenceXrefTypes( dna, al.getSequencesArray()); if (types != null) { System.out.println("Xref Types for: "+(dna ? "dna" : "prot")); for (int t = 0; t < types.length; t++) { System.out.println("Type: " + types[t]); SequenceI[] prod = jalview.analysis.CrossRef.findXrefSequences(al .getSequencesArray(), dna, types[t]).getSequencesArray(); System.out.println("Found " + ((prod == null) ? "no" : "" + prod.length) + " products"); if (prod!=null) { for (int p=0; p0) { Enumeration ts = noProds.elements(); while (ts.hasMoreElements()) { Object[] typeSq = (Object[]) ts.nextElement(); 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("Found " + ((prod == null) ? "no" : "" + prod.length) + " products"); if (prod!=null) { for (int p=0; p