Created
December 15, 2017 05:39
-
-
Save ddbj-repo/ec96049ec11c1d22303d9fcdea9f70cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.LinkedHashMap; | |
import org.springframework.util.LinkedMultiValueMap; | |
import org.springframework.util.MultiValueMap; | |
import org.springframework.web.client.RestTemplate; | |
import org.springframework.web.client.HttpClientErrorException; | |
import net.arnx.jsonic.JSON; | |
/* | |
* (中略) | |
*/ | |
MultiValueMap<String, String> parts = new LinkedMultiValueMap<String, String>(); | |
parts.add("address", ""); | |
parts.add("database", "hum"); | |
parts.add("datasets", "ddbjall"); | |
parts.add("format", "json"); | |
parts.add("parameters", " -v 100 -b 100 -e 10 -F F -W 11"); | |
parts.add("program", "blastn"); | |
parts.add("querySequence", ">my query sequence 1\nCACCCTCTCTTCACTGGAAAGGACACCATGAGCACGGAAAGCATGATCCAGGACGTGGAA\nGCTGGCCGAGGAGGCGCTCCCCAGGAAGACAGCAGGGCCCCAGGGCTCCAGGCGGTGCTG\nGTTCCTCAGCCTCTTCTCCTTCCTGCTCGTGGCAGGCGCCGCCAC\n"); | |
parts.add("result", "www"); | |
try { | |
RestTemplate rest = new RestTemplate(); | |
String response = rest.postForObject("http://ddbj.nig.ac.jp/wabi/blast/", parts, String.class); | |
/* | |
---- response の例 (ここから) -------------------------------- | |
{ | |
"requestId": "wabi_blast_1111-1111-1111-11-111-111111", | |
"program": "blastn", | |
"datasets": "ddbjall", | |
"database": "hum", | |
"parameters": " -v 100 -b 100 -e 10 -F F -W 11", | |
"current-time": "2013-01-01 12:34:56", | |
"start-time": "", | |
"current-state": "" | |
} | |
---- response の例 (ここまで) -------------------------------- | |
*/ | |
LinkedHashMap<String, String> result = JSON.decode(response, LinkedHashMap.class); | |
String requestId = result.get("requestId"); | |
/* | |
* ジョブの投入に成功した場合は Request ID を覚えておく。 | |
*/ | |
} catch (HttpClientErrorException e) { | |
/* | |
* 入力値エラー等。 | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment