X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Febi%2FhmmerClient.java;h=41cd0d8e8ff3e19c8d6f5ccf0d03e68044adbd85;hb=2db272981f2778cc64df63bab6893c8347e120f8;hp=3db35bea2e640d95d7645beb86802f59f9a65171;hpb=53bf23b889e1a3d0a51bdbcba18c6d9ac5b2578b;p=jalview.git diff --git a/src/jalview/ws/ebi/hmmerClient.java b/src/jalview/ws/ebi/hmmerClient.java index 3db35be..41cd0d8 100644 --- a/src/jalview/ws/ebi/hmmerClient.java +++ b/src/jalview/ws/ebi/hmmerClient.java @@ -1,6 +1,13 @@ 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 java.io.File; +import java.io.IOException; import java.util.regex.Matcher; import org.apache.axis.transport.http.HTTPConstants; @@ -50,6 +57,7 @@ public class hmmerClient System.out.println("Result\n" + res); return; } + /** * * @param input @@ -154,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 @@ -204,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/" . @@ -219,4 +227,93 @@ public class hmmerClient * results...... */ } + + /** + * retrieve an alignment annotated with scores from JackHmmer + * + * @param jobid + * @param dataset + * @return + */ + AlignmentI retrieveJackhmmerResult(String jobid, AlignmentI dataset) + throws OutOfMemoryError, IOException + { + AlignmentI searchResult = null; + + // get results + + searchResult = new AppletFormatAdapter().readFile(baseUrl + + "/download/" + jobid + "/score?format=afa&t=.gz", + DataSourceType.URL, FileFormat.Fasta); + + // TODO extract gapped columns as '.' - inserts to query profile + + // TODO match up jackhammer results to dataset. + + // 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, 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 jsonsource) throws IOException, OutOfMemoryError + { + 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 ? + + /** + * for a sequence q sort any t against q according to overallScore(q,t) + * maxFragment(q,t) in sequence features parlance: for alignment + * s.getFeature("overallScore",q) -> range on q and range on s + * + * + */ + + // 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 + // + // 4h1o_A 4h1o_A 560 jackhmmer - 163 2.1e-57 197.3 0.0 2 2 7.6e-31 3.7e-28 + // 102.219146728516 0.03 66 161 127 236 124 238 0.94 Tyrosine-protein + // phosphatase non-receptor typ 4h1o_A + + } + }