3232import java .util .TreeSet ;
3333
3434
35- /** Makes remote calls to the Hmmer3 web site and returns Pfam domain annotations for an input protein sequence.
35+ /** Makes remote calls to the HMMER web service at the EBI web site and returns Pfam domain annotations for an input protein sequence.
3636 *
3737 * @author Andreas Prlic
3838 * @since 3.0.3
3939 */
4040public class RemoteHmmerScan implements HmmerScan {
4141
42- public static String HMMER_SERVICE = "http://hmmer.janelia.org/search/hmmscan" ;
42+ public static String HMMER_SERVICE = "http://www.ebi.ac.uk/Tools/hmmer/search/hmmscan" ;
43+
44+ // The Gathering threshold indicates to HMMER to use the threshold defined in the HMM file to be searched.
45+ // This ensures that there are no false positive results.
4346
4447 public boolean DEFAULT_SEARCH_CUT_GA = true ;
4548
@@ -66,8 +69,16 @@ public SortedSet<HmmerResult> scan(ProteinSequence sequence) throws IOException
6669 */
6770 public SortedSet <HmmerResult > scan (ProteinSequence sequence , URL serviceLocation ) throws IOException {
6871
72+ StringBuffer postContent = new StringBuffer ();
73+
74+ postContent .append ("hmmdb=pfam" );
75+
76+ if ( searchWithCutGA )
77+ postContent .append ("&cut_ga=1" );
78+
79+ postContent .append ("&seq=" );
80+ postContent .append (sequence .getSequenceAsString ());
6981
70- String urlparameters = prepareParameters (sequence , searchWithCutGA );
7182
7283 HttpURLConnection connection = (HttpURLConnection ) serviceLocation .openConnection ();
7384 connection .setDoOutput (true );
@@ -76,24 +87,29 @@ public SortedSet<HmmerResult> scan(ProteinSequence sequence, URL serviceLocation
7687 connection .setInstanceFollowRedirects (false );
7788 connection .setRequestMethod ("POST" );
7889 connection .setRequestProperty ("Content-Type" , "application/x-www-form-urlencoded" );
79- connection .setRequestProperty ("Accept" , "application/json" );
90+
91+ connection .setRequestProperty ("Accept:" ,"application/json" );
92+
8093
8194 connection .setRequestProperty ("Content-Length" , "" +
82- Integer .toString (urlparameters .toString ().getBytes ().length ));
95+ Integer .toString (postContent .toString ().getBytes ().length ));
8396
8497 //Send request
8598 DataOutputStream wr = new DataOutputStream (
8699 connection .getOutputStream ());
87- wr .writeBytes ( urlparameters );
100+ wr .write ( postContent . toString (). getBytes () );
88101 wr .flush ();
89102 wr .close ();
90103
91- //Now get the redirect URL
104+
105+
106+
107+ // //Now get the redirect URL
92108 URL respUrl = new URL ( connection .getHeaderField ( "Location" ));
93109
94110 int responseCode = connection .getResponseCode ();
95111 if ( responseCode == 500 ){
96- System .err .println ("something went wrong!" + urlparameters );
112+ System .err .println ("something went wrong!" + serviceLocation );
97113 System .err .println (connection .getResponseMessage ());
98114 }
99115
@@ -110,8 +126,11 @@ public SortedSet<HmmerResult> scan(ProteinSequence sequence, URL serviceLocation
110126 String inputLine ;
111127
112128 StringBuffer result = new StringBuffer ();
113- while ((inputLine = in .readLine ()) != null )
129+ while ((inputLine = in .readLine ()) != null ) {
130+ //System.out.println(inputLine);
114131 result .append (inputLine );
132+ }
133+
115134 in .close ();
116135
117136 // process the response and build up a container for the data.
@@ -174,6 +193,8 @@ public SortedSet<HmmerResult> scan(ProteinSequence sequence, URL serviceLocation
174193 dom .setSqTo (getInteger (d .get ("alisqto" )));
175194 dom .setHmmName ((String )d .get ("alihmmname" ));
176195 domains .add (dom );
196+
197+ System .out .println (d .get ("alicsline" ));
177198 }
178199
179200 hmmResult .setDomains (domains );
@@ -188,34 +209,6 @@ public SortedSet<HmmerResult> scan(ProteinSequence sequence, URL serviceLocation
188209
189210 }
190211
191- private String prepareParameters (ProteinSequence sequence ,
192- boolean searchWithCutGA ) throws UnsupportedEncodingException {
193- StringBuffer urlParameters = new StringBuffer ();
194-
195-
196-
197- urlParameters .append ("hmmdb=" );
198- urlParameters .append (URLEncoder .encode ("pfam" ,"UTF-8" ));
199-
200-
201- // search by cut_ga, not e-values
202- //cut_ga' : '',
203- if ( searchWithCutGA ) {
204- urlParameters .append ("&cut_ga=" );
205- //urlParameters.append(URLEncoder.encode("1","UTF-8"));
206-
207-
208- }
209-
210- urlParameters .append ("&seq=" );
211-
212- urlParameters .append (URLEncoder .encode (">seq\n " +sequence .toString (), "UTF-8" ));
213-
214-
215-
216-
217- return urlParameters .toString ();
218- }
219212
220213 private Integer getInteger (Object object ) {
221214 if ( object instanceof Integer )
0 commit comments