@@ -74,13 +74,36 @@ public class NCBIQBlastService implements RemotePairwiseAlignmentService {
7474
7575 private Map <String , BlastJob > jobs = new HashMap <String , BlastJob >();
7676
77+ /** Constructs a service object that targets the public NCBI BLAST network
78+ * service.
79+ */
7780 public NCBIQBlastService () {
81+ init (SERVICE_URL );
82+ }
83+
84+ /** Constructs a service object which targets a custom NCBI BLAST network
85+ * service (e.g.: an instance of BLAST in the cloud).
86+ *
87+ * @param svcUrl : a {@code String} containing the base URL to send requests to,
88+ * e.g.: http://host.my.cloud.service.provider.com/cgi-bin/blast.cgi
89+ *
90+ * @see <a href="https://blast.ncbi.nlm.nih.gov/Blast.cgi?PAGE_TYPE=BlastDocs&DOC_TYPE=CloudBlast">BLAST on the cloud documentation</a>
91+ */
92+ public NCBIQBlastService (String svcUrl ) {
93+ init (svcUrl );
94+ }
95+
96+ /** Initialize the serviceUrl data member
97+ * @throws MalformedURLException on invalid URL
98+ */
99+ private void init (String svcUrl ) {
78100 try {
79- serviceUrl = new URL (SERVICE_URL );
101+ serviceUrl = new URL (svcUrl );
80102 } catch (MalformedURLException e ) {
81- throw new RuntimeException ("It looks like the URL for NCBI QBlast service is wrong. Cause: " + e .getMessage (), e );
103+ throw new RuntimeException ("It looks like the URL for remote NCBI BLAST service ("
104+ + svcUrl + ") is wrong. Cause: " + e .getMessage (), e );
82105 }
83- }
106+ }
84107
85108 /**
86109 * A simple method to check the availability of the QBlast service. Sends {@code Info} command to QBlast
@@ -252,7 +275,7 @@ public boolean isReady(String id, long present) throws Exception {
252275 OutputStreamWriter writer = null ;
253276 BufferedReader reader = null ;
254277 try {
255- String checkRequest = "CMD=Get&RID=" + job .getId ();
278+ String checkRequest = "CMD=Get&RID=" + job .getId () + "&FORMAT_OBJECT=SearchInfo" ;
256279 URLConnection serviceConnection = setQBlastServiceProperties (serviceUrl .openConnection ());
257280 writer = new OutputStreamWriter (serviceConnection .getOutputStream ());
258281 writer .write (checkRequest );
0 commit comments