Skip to content

Commit 4c5f7f9

Browse files
authored
Merge pull request #722 from josemduarte/master
Fixing hmmer scan web service and adding test for it
2 parents 9d45d91 + 67d9923 commit 4c5f7f9

File tree

3 files changed

+70
-29
lines changed

3 files changed

+70
-29
lines changed

biojava-ws/src/main/java/demo/HmmerDemo.java

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,55 +30,54 @@
3030

3131
import java.util.SortedSet;
3232

33-
/** The cookbook recipe for how to request Pfam annotations for a protein sequence using the Hmmer3 service
33+
/**
34+
* The cookbook recipe for how to request Pfam annotations for a protein sequence using the Hmmer3 service
3435
*
3536
* @author Andreas Prlic
3637
* @since 3.0.3
3738
*/
3839
public class HmmerDemo {
3940

40-
public static void main(String[] args){
41+
public static void main(String[] args) throws Exception {
4142

42-
try {
43-
// first we get a UniProt sequence
44-
String uniProtID = "P08487";
45-
ProteinSequence seq = getUniprot(uniProtID);
4643

44+
// first we get a UniProt sequence
45+
String uniProtID = "P08487";
46+
ProteinSequence seq = getUniprot(uniProtID);
4747

48-
// now we submit this sequence to the Hmmer web site
49-
RemoteHmmerScan hmmer = new RemoteHmmerScan();
5048

51-
SortedSet<HmmerResult> results = hmmer.scan(seq);
49+
// now we submit this sequence to the Hmmer web site
50+
RemoteHmmerScan hmmer = new RemoteHmmerScan();
5251

53-
// and now let's print out the obtained annotations
52+
SortedSet<HmmerResult> results = hmmer.scan(seq);
5453

55-
System.out.println(String.format("#\t%15s\t%10s\t%s\t%s\t%8s\t%s",
56-
"Domain","ACC", "Start","End","eValue","Description"));
54+
// and now let's print out the obtained annotations
5755

58-
int counter = 0;
59-
for (HmmerResult hmmerResult : results) {
60-
//System.out.println(hmmerResult);
56+
System.out.println(String.format("#\t%15s\t%10s\t%s\t%s\t%8s\t%s",
57+
"Domain","ACC", "Start","End","eValue","Description"));
6158

62-
for ( HmmerDomain domain : hmmerResult.getDomains()) {
63-
counter++;
64-
System.out.println(String.format("%d\t%15s\t%10s\t%5d\t%5d\t%.2e\t%s",
65-
counter,
66-
hmmerResult.getName(), domain.getHmmAcc(),
67-
domain.getSqFrom(),domain.getSqTo(),
68-
domain.getEvalue(), hmmerResult.getDesc()
69-
));
59+
int counter = 0;
60+
for (HmmerResult hmmerResult : results) {
61+
//System.out.println(hmmerResult);
7062

71-
}
63+
for ( HmmerDomain domain : hmmerResult.getDomains()) {
64+
counter++;
65+
System.out.println(String.format("%d\t%15s\t%10s\t%5d\t%5d\t%.2e\t%s",
66+
counter,
67+
hmmerResult.getName(), domain.getHmmAcc(),
68+
domain.getSqFrom(),domain.getSqTo(),
69+
domain.getEvalue(), hmmerResult.getDesc()
70+
));
7271

7372
}
7473

75-
} catch (Exception e) {
76-
// TODO Auto-generated catch block
77-
e.printStackTrace();
7874
}
75+
76+
7977
}
8078

81-
/** Fetch a protein sequence from the UniProt web site
79+
/**
80+
* Fetch a protein sequence from the UniProt web site
8281
*
8382
* @param uniProtID
8483
* @return a Protein Sequence

biojava-ws/src/main/java/org/biojava/nbio/ws/hmmer/RemoteHmmerScan.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class RemoteHmmerScan implements HmmerScan {
4343

4444
private static final Logger LOGGER = LoggerFactory.getLogger(RemoteHmmerScan.class);
4545

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

4848
public RemoteHmmerScan(){
4949

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package org.biojava.nbio.ws.hmmer;
2+
3+
import java.util.SortedSet;
4+
5+
import org.biojava.nbio.core.sequence.ProteinSequence;
6+
import org.junit.Test;
7+
import static org.junit.Assert.*;
8+
9+
public class TestRemoteHmmerScan {
10+
11+
/**
12+
* Sequence for UniProt id P30340 (PDB 1SMT)
13+
*/
14+
private static final String TEST_SEQ = "MTKPVLQDGETVVCQGTHAAIASELQAIAPEVAQSLAEFFAVLADPNRLRLLSLLARSEL" +
15+
"CVGDLAQAIGVSESAVSHQLRSLRNLRLVSYRKQGRHVYYQLQDHHIVALYQNALDHLQE" +
16+
"CR";
17+
18+
@Test
19+
public void testHmmerWs() throws Exception {
20+
21+
ProteinSequence seq = new ProteinSequence(TEST_SEQ);
22+
23+
// now we submit this sequence to the Hmmer web site
24+
RemoteHmmerScan hmmer = new RemoteHmmerScan();
25+
26+
SortedSet<HmmerResult> results = hmmer.scan(seq);
27+
28+
assertNotNull(results);
29+
// 2 results (domains) for P30340 (PDB 1smt) as of Jan 2018
30+
assertEquals(2, results.size());
31+
32+
boolean gotSh2Domain = false;
33+
34+
for (HmmerResult hmmerResult : results) {
35+
if (hmmerResult.getName().equals("HTH_5")) {
36+
gotSh2Domain = true;
37+
}
38+
}
39+
40+
assertTrue("A HTH_5 domain should be present as one of the hmmer scan matches",gotSh2Domain);
41+
}
42+
}

0 commit comments

Comments
 (0)