BLASTS Demo

This is the DDBJ SOAP Demo system.
Enter the Accession Number and you can get three BLAST results.

-> blastn(DDBJ Bacteria)
GetEntry -> blastx(SwissProt)-> result
-> blastx(PDB)
Accession Number: (e.g. AF058429)
Program (Require both java and GLUE library.)
import electric.registry.Registry;
import java.io.*;
import java.util.*;

class ResultManager {
        public HashMap allresult = new HashMap();

        synchronized void addresult(String threadName, String result) {
                allresult.put(threadName, result);
        }

        public String getResult(String threadName) {
                return (String)allresult.get(threadName);
        }
}

class InvokeBlastsThread extends Thread {
        ResultManager resultManager;
        String url, method;
        String[] param;

        InvokeBlastsThread(ResultManager resultManager, String url, String method, String[] param) {
                this.resultManager = resultManager;
                this.url = url;
                this.method = method;
                this.param = param;
        }

        public void run() {
                String result = "";
                try {
                        result = blastInvoke(url, method, param);
                        resultManager.addresult(getName(), result);
                } catch(Throwable e) {
                        e.printStackTrace();
                }
        }

        synchronized String blastInvoke(String url, String method, String[] param) {
                String result = "";
                try {
                        result = (String)Registry.invoke(url, method, param);
                } catch(Throwable e) {
                        e.printStackTrace();
                }
                return result;
        }
}

public class InvokeBlasts {
        public String execute(String accession) {
                String url, query;
                StringBuffer result;
                ResultManager resultManager = new ResultManager();
                try {
                url = "http://xml.nig.ac.jp/wsdl/GetEntry.wsdl";
                query = (String)Registry.invoke(url, "getFASTA_DDBJEntry", new Object[]{accession});
                url = "http://xml.nig.ac.jp/wsdl/Blast.wsdl";
                InvokeBlastsThread thread0, thread1, thread2;
                String[] param0 = {"blastn", "ddbjbct", query, "-a 16 -v 50 -b 5"};
                thread0 = new InvokeBlastsThread(resultManager, url, "search", param0);
                thread0.setName("0");
                thread0.start();
                String[] param1 = {"blastx", "SWISS", query, "-a 16 -v 50 -b 5"};
                thread1 = new InvokeBlastsThread(resultManager, url, "search", param1);
                thread1.setName("1");
                thread1.start();
                String[] param2 = {"blastx", "PDB", query, "-a 16 -v 50 -b 5"};
                thread2 = new InvokeBlastsThread(resultManager, url, "search", param2);
                thread2.setName("2");
                thread2.start();

                thread0.join();
                thread1.join();
                thread2.join();

                result = new StringBuffer("");
                result.append(resultManager.getResult("0"));
                result.append(resultManager.getResult("1"));
                result.append(resultManager.getResult("2"));

                } catch(Throwable e) {
                        result = new StringBuffer("");
                        System.out.println("throwable");
                        e.printStackTrace();
                }
                return result.toString();
        }

        public static void main(String args[]) {
                InvokeBlasts iblasts = new InvokeBlasts();
                String result = iblasts.execute("AF058429");
                try {
                        PrintWriter pw = new PrintWriter(new FileWriter("result"));
                        pw.println(result);
                        pw.close();
                } catch(Exception e) {
                        e.printStackTrace();
                }
        }
}

Construct with Taverna
The following image was generated by Taverna GUI.

This workflow's xml file for Taverna is here.
Execution result of AF058429 is here. DDBJ Bacteria SwissProt PDB (Last update: Feb. 22, 2010.)

Top