X Tutup
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.biojava.nbio.core.sequence.ProteinSequence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.net.HttpURLConnection;
Expand All @@ -31,14 +33,17 @@
import java.util.TreeSet;


/** Makes remote calls to the HMMER web service at the EBI web site and returns Pfam domain annotations for an input protein sequence.
/**
* Makes remote calls to the HMMER web service at the EBI web site and returns Pfam domain annotations for an input protein sequence.
*
* @author Andreas Prlic
* @since 3.0.3
*/
public class RemoteHmmerScan implements HmmerScan {

public static String HMMER_SERVICE = "http://www.ebi.ac.uk/Tools/hmmer/search/hmmscan";
private static final Logger LOGGER = LoggerFactory.getLogger(RemoteHmmerScan.class);

public static final String HMMER_SERVICE = "http://www.ebi.ac.uk/Tools/hmmer/search/hmmscan";

public RemoteHmmerScan(){

Expand All @@ -54,7 +59,8 @@ public SortedSet<HmmerResult> scan(ProteinSequence sequence) throws IOException

}

/** Scans a protein sequence for Pfam profile matches.
/**
* Scans a protein sequence for Pfam profile matches.
*
* @param sequence
* @param serviceLocation
Expand All @@ -68,7 +74,7 @@ public SortedSet<HmmerResult> scan(ProteinSequence sequence, URL serviceLocation
postContent.append("hmmdb=pfam");


// by default hmmscan runs with the HMMER3 cut_ga parameter enabled, the "gathering freshold", which depends on
// by default hmmscan runs with the HMMER3 cut_ga parameter enabled, the "gathering threshold", which depends on
// the cutoffs defined in the underlying HMM files.
// to request a different cutoff by e-value this could be enabled:
//postContent.append("&E=1");
Expand All @@ -86,7 +92,7 @@ public SortedSet<HmmerResult> scan(ProteinSequence sequence, URL serviceLocation
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

connection.setRequestProperty("Accept:","application/json");
connection.setRequestProperty("Accept","application/json");

connection.setRequestProperty("Content-Length", "" +
Integer.toString(postContent.toString().getBytes().length));
Expand All @@ -99,13 +105,12 @@ public SortedSet<HmmerResult> scan(ProteinSequence sequence, URL serviceLocation
wr.close ();


// //Now get the redirect URL
//Now get the redirect URL
URL respUrl = new URL( connection.getHeaderField( "Location" ));

int responseCode = connection.getResponseCode();
if ( responseCode == 500){
System.err.println("something went wrong!" + serviceLocation);
System.err.println(connection.getResponseMessage());
LOGGER.warn("Got 500 response code for URL {}. Response message: {}.", serviceLocation, connection.getResponseMessage());
}

HttpURLConnection connection2 = (HttpURLConnection) respUrl.openConnection();
Expand All @@ -122,7 +127,6 @@ public SortedSet<HmmerResult> scan(ProteinSequence sequence, URL serviceLocation

StringBuffer result = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
//System.out.println(inputLine);
result.append(inputLine);
}

Expand All @@ -141,7 +145,6 @@ public SortedSet<HmmerResult> scan(ProteinSequence sequence, URL serviceLocation

for(int i =0 ; i < hits.size() ; i++){
JSONObject hit = hits.getJSONObject(i);
//System.out.println("hit: "+ hit);

HmmerResult hmmResult = new HmmerResult();

Expand Down Expand Up @@ -170,35 +173,21 @@ public SortedSet<HmmerResult> scan(ProteinSequence sequence, URL serviceLocation
SortedSet<HmmerDomain> domains = new TreeSet<HmmerDomain>();
for ( int j= 0 ; j < hmmdomains.size() ; j++){
JSONObject d = hmmdomains.getJSONObject(j);
//System.out.println(d);
Integer is_included = getInteger(d.get("is_included"));
if ( is_included == 0) {
// System.out.println(" excluding: " + d.get("alihmmdesc") + " " + d.get("alihmmname") + " " +
// hit.get("evalue") + " " +
// d.get("alisqfrom") + " " +
// d.get("alisqto"));
continue;
}


// this filters out multiple hits to the same clan
Integer outcompeted = getInteger(d.get("outcompeted"));
if ( outcompeted != null && outcompeted == 1) {
// System.out.println(" outcompeted: " + d.get("alihmmdesc") + " " + d.get("alihmmname")+ " " +
// hit.get("evalue") + " " +
// d.get("alisqfrom") + " " +
// d.get("alisqto")
// );
continue;
}

Integer significant = getInteger(d.get("significant"));

if ( significant != 1) {
// System.out.println(" not significant: " + d.get("alihmmdesc") + " " + d.get("alihmmname")+ " " +
// hit.get("evalue") + " " +
// d.get("alisqfrom") + " " +
// d.get("alisqto"));
continue;
}

Expand All @@ -224,8 +213,8 @@ public SortedSet<HmmerResult> scan(ProteinSequence sequence, URL serviceLocation

results.add(hmmResult);
}
} catch (Exception e){
e.printStackTrace();
} catch (NumberFormatException e){
LOGGER.warn("Could not parse number in Hmmer web service json response: {}", e.getMessage());
}

return results;
Expand Down
X Tutup