From 94b83b671d9714a407048da057db2a611e7efb6e Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 4 Nov 2015 17:59:56 +0000 Subject: [PATCH] JAL-1950 hook up JSON result dump parser to hmmerClient --- src/jalview/ws/ebi/hmmerClient.java | 40 +++++++++++++++-------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/src/jalview/ws/ebi/hmmerClient.java b/src/jalview/ws/ebi/hmmerClient.java index 474f01b..37e6775 100644 --- a/src/jalview/ws/ebi/hmmerClient.java +++ b/src/jalview/ws/ebi/hmmerClient.java @@ -5,10 +5,8 @@ import jalview.io.AppletFormatAdapter; import jalview.io.FileParse; import jalview.io.FormatAdapter; -import java.io.BufferedReader; import java.io.File; import java.io.IOException; -import java.util.StringTokenizer; import java.util.regex.Matcher; import org.apache.axis.transport.http.HTTPConstants; @@ -58,6 +56,7 @@ public class hmmerClient System.out.println("Result\n" + res); return; } + /** * * @param input @@ -162,8 +161,8 @@ public class hmmerClient if ("PEND".equals(st) || "RUN".equals("st")) { JSONArray iters = jobstate.getJSONArray("result"); - lastiter = iters.getJSONObject(iters.length() - 1) - .getString("uuid"); + lastiter = iters.getJSONObject(iters.length() - 1).getString( + "uuid"); if (lastiter.length() > 0) { java.util.regex.Pattern p = java.util.regex.Pattern @@ -212,7 +211,7 @@ public class hmmerClient // $ua->get( $rootUrl."/results/".$lastIteration->{uuid} . "/score" return lastiter; /* - * * #Job should have finished, but we may have converged, so get the last + * * #Job should have finished, but we may have converged, so get the last * job. my $results = $json->decode( $response->content ); my $lastIteration * = pop( @{ $results->{result} } ); #Now fetch the results of the last * iteration my $searchResult = $ua->get( $rootUrl."/results/" . @@ -243,21 +242,21 @@ public class hmmerClient // get results searchResult = new AppletFormatAdapter().readFile(baseUrl - + "/download/" + jobid - + "/score?format=afa&t=.gz", FormatAdapter.URL, "FASTA"); + + "/download/" + jobid + "/score?format=afa&t=.gz", + FormatAdapter.URL, "FASTA"); - // extract gapped columns as '.' - inserts to query profile - // match up to dataset. + // TODO extract gapped columns as '.' - inserts to query profile - // and do scores + // TODO match up jackhammer results to dataset. - FileParse csvsource = new FileParse(baseUrl + "/download/" + jobid - + "/score?format=csv", FormatAdapter.URL); - if (!csvsource.isValid()) + // do scores + FileParse jsonsource = new FileParse(baseUrl + "/download/" + jobid + + "/score?format=json", FormatAdapter.URL); + if (!jsonsource.isValid()) { throw new IOException("Couldn't access scores for Jackhammer results"); } - readJackhmmerScores(searchResult, csvsource); + readJackhmmerScores(searchResult, jsonsource); return searchResult; } @@ -273,18 +272,13 @@ public class hmmerClient * typ 4h1o_A */ private static String[] _hmmsearchcols = new String[] { "acc", "name", "" }; + private void readJackhmmerScores(AlignmentI searchResult, - FileParse csvsource) - throws IOException + FileParse jsonsource) throws IOException, OutOfMemoryError { - String line; - BufferedReader rl = new BufferedReader(csvsource.getReader()); + HmmerJSONProcessor hjp = new HmmerJSONProcessor(searchResult); + hjp.parseFrom(jsonsource); - while ((line = rl.readLine()) != null) - { - StringTokenizer st = new StringTokenizer(line, "\t"); - - } // http://www.ebi.ac.uk/Tools/hmmer/download/60048B38-7CEC-11E5-A230-CED6D26C98AD.5/score?format=csv // 1gri_A 1gri_A 217 jackhmmer - 163 4.7e-62 212.4 0.1 1 2 4.4e-46 2.1e-43 // 151.758316040039 0.04 11 151 3 139 1 150 0.94 GROWTH FACTOR BOUND PROTEIN -- 1.7.10.2