|
|
Web services to access the data
package query;
import javax.ws.rs.core.MediaType;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
public class TestQuery {
/**
* @param args
*/
public static final String BASE_URI = "http://123.59.132.21:8080/Ontogene";
public static final String PATH_NAME_Query_Gene = "/query/getAllGenes";
public static final String PATH_NAME_Query_Term = "/query/getAllTerms";
public static final String PATH_NAME_Query_Term_Annotation = "/query/getTermAnnnotations/";
public static final String PATH_NAME_Query_Gene_Annotation = "/query/getGeneAnnnotations/";
public static final String PATH_NAME_Query_Associations = "/query/getAllAssociations/";
public static final String PATH_NAME_Query_Term_Associations = "/query/getTermAssociations/";
public static void main(String[] args) {
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource resource = client.resource(BASE_URI);
WebResource nameResource = resource.path("rest").path(PATH_NAME_Query_Gene);
//Response all genes, For examle: A1BG mRNA HGNC:5
System.out.println(getResponse(nameResource));
//Response all terms, For examle: GO:0005488 binding
nameResource = resource.path("rest").path(PATH_NAME_Query_Term);
System.out.println(getResponse(nameResource));
//Response all Associations, For examle:
nameResource = resource.path("rest").path(PATH_NAME_Query_Associations);
System.out.println(getResponse(nameResource));
//Response all the annotations of the term. The following is one of the annotation results of DOID:0050671: DOID:0050671 female breast cancer BRCA1 mRNA HGNC:1100 The four most frequent BRCA1 mutations found in female breast cancer cases in Guangxi are all located in exon 10. BRCA1-associated breast cancer cases have earlier onset age, higher nuclear grade and 25337278
nameResource = resource.path("rest").path(PATH_NAME_Query_Term_Annotation + "DOID:0050671");
System.out.println(getResponse(nameResource));
//Response all the annotations of the gene. The following is one of the annotation results of HGNC:11998: GO:0016310 phosphorylation TP53 mRNA HGNC:11998 phosphorylation of p53 was rapidly induced in human fibroblasts upon exposure of cells to hydrogen peroxide (H(2)O(2)) 11447225 GO:0002039 p53 binding TP53 mRNA HGNC:11998 Binding to the p53 binding sites of the Mdm2 promoter alleviates the requirement for p53 C-terminal activation. 11328884
nameResource = resource.path("rest").path(PATH_NAME_Query_Gene_Annotation + "HGNC:11998");
System.out.println(getResponse(nameResource));
//Response all the associated terms of a specified term. The following is one of the annotation results of HP:0010554: HP:0010554 Cutaneous finger syndactyly HP:0010561 Undulate ribs 0.0333333333333333 0.00688434362344392
nameResource = resource.path("rest").path(PATH_NAME_Query_Term_Associations + "HP:0010554");
System.out.println(getResponse(nameResource));
}
/**
* Response all results.
*
*
* @param service
* @return
*/
private static String getResponse(WebResource resource) {
return resource.accept(new String [] {MediaType.TEXT_PLAIN}).get(String.class).toString();
}
}