X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Febi%2FhmmerClient.java;h=41cd0d8e8ff3e19c8d6f5ccf0d03e68044adbd85;hb=2db272981f2778cc64df63bab6893c8347e120f8;hp=c29d355dc1c903bafe37d8b00237490c7872feac;hpb=ecdc8f7020e2fe1b510e03635801528a08480ec8;p=jalview.git diff --git a/src/jalview/ws/ebi/hmmerClient.java b/src/jalview/ws/ebi/hmmerClient.java index c29d355..41cd0d8 100644 --- a/src/jalview/ws/ebi/hmmerClient.java +++ b/src/jalview/ws/ebi/hmmerClient.java @@ -2,13 +2,12 @@ package jalview.ws.ebi; import jalview.datamodel.AlignmentI; import jalview.io.AppletFormatAdapter; +import jalview.io.DataSourceType; +import jalview.io.FileFormat; 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 +57,7 @@ public class hmmerClient System.out.println("Result\n" + res); return; } + /** * * @param input @@ -162,8 +162,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 +212,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,36 +243,53 @@ 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", + DataSourceType.URL, FileFormat.Fasta); - // 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", DataSourceType.URL); + if (!jsonsource.isValid()) { throw new IOException("Couldn't access scores for Jackhammer results"); } - readJackhmmerScores(searchResult, csvsource); + readJackhmmerScores(searchResult, jsonsource); return searchResult; } + /** + * // 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 // 2 1cj1_J 1gri_B // 1gri_A 1gri_A 217 jackhmmer - 163 4.7e-62 + * 212.4 0.1 2 2 1.6e-17 7.9e-15 // 58.8796501159668 0.01 7 66 157 215 153 216 + * 0.95 GROWTH FACTOR BOUND // PROTEIN 2 1cj1_J 1gri_B // 4h1o_A 4h1o_A 560 + * jackhmmer - 163 2.1e-57 197.3 0.0 1 2 7.5e-28 3.6e-25 // 92.4921493530273 + * 0.00 65 161 20 122 17 124 0.95 Tyrosine-protein // phosphatase non-receptor + * 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()); - while ((line = rl.readLine()) != null) - { - StringTokenizer st = new StringTokenizer(line, "\t"); + HmmerJSONProcessor hjp = new HmmerJSONProcessor(searchResult); + hjp.parseFrom(jsonsource); - } // 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 + // 2 1cj1_J 1gri_B + // 1gri_A 1gri_A 217 jackhmmer - 163 4.7e-62 212.4 0.1 2 2 1.6e-17 7.9e-15 + // 58.8796501159668 0.01 7 66 157 215 153 216 0.95 GROWTH FACTOR BOUND + // PROTEIN 2 1cj1_J 1gri_B + // 4h1o_A 4h1o_A 560 jackhmmer - 163 2.1e-57 197.3 0.0 1 2 7.5e-28 3.6e-25 + // 92.4921493530273 0.00 65 161 20 122 17 124 0.95 Tyrosine-protein + // phosphatase non-receptor typ 4h1o_A // each line scores a fragment // so for a combined score ?