Commit bfe24052 authored by tim.tucholski's avatar tim.tucholski
Browse files

Updated quarkus version, added API stub and enabled CORS headers

parent 89ab964b
This diff is collapsed.
# GeneinfoService project
# geneinfoservice_new project
This project uses Quarkus, the Supersonic Subatomic Java Framework.
......@@ -14,10 +14,10 @@ You can run your application in dev mode that enables live coding using:
## Packaging and running the application
The application can be packaged using `./mvnw package`.
It produces the `GeneinfoService-1.0-SNAPSHOT-runner.jar` file in the `/target` directory.
It produces the `geneinfoservice_new-1.0-SNAPSHOT-runner.jar` file in the `/target` directory.
Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/lib` directory.
The application is now runnable using `java -jar target/GeneinfoService-1.0-SNAPSHOT-runner.jar`.
The application is now runnable using `java -jar target/geneinfoservice_new-1.0-SNAPSHOT-runner.jar`.
## Creating a native executable
......@@ -25,6 +25,6 @@ You can create a native executable using: `./mvnw package -Pnative`.
Or, if you don't have GraalVM installed, you can run the native executable build in a container using: `./mvnw package -Pnative -Dquarkus.native.container-build=true`.
You can then execute your native executable with: `./target/GeneinfoService-1.0-SNAPSHOT-runner`
You can then execute your native executable with: `./target/geneinfoservice_new-1.0-SNAPSHOT-runner`
If you want to learn more about building native executables, please consult https://quarkus.io/guides/building-native-image.
\ No newline at end of file
......@@ -2,8 +2,8 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.de.unigoettingen.ibeetlebase.api</groupId>
<artifactId>GeneinfoService</artifactId>
<groupId>de.unigoettingen.ibeetlebase.api.core</groupId>
<artifactId>geneinfoservice_new</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
......@@ -12,10 +12,10 @@
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus-plugin.version>1.3.2.Final</quarkus-plugin.version>
<quarkus-plugin.version>1.4.2.Final</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>1.3.2.Final</quarkus.platform.version>
<quarkus.platform.version>1.4.2.Final</quarkus.platform.version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
</properties>
<dependencyManagement>
......@@ -46,31 +46,31 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
<artifactId>quarkus-cache</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-cache</artifactId>
<artifactId>quarkus-hibernate-orm-panache</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-metrics</artifactId>
<artifactId>quarkus-hibernate-orm</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
<artifactId>quarkus-infinispan-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client</artifactId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-panache</artifactId>
<artifactId>quarkus-smallrye-metrics</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-swagger-ui</artifactId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
</dependencies>
<build>
......
package org.de.unigoettingen.ibeetlebase;
package de.unigoettingen.ibeetlebase;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
......
package org.de.unigoettingen.ibeetlebase.api;
package de.unigoettingen.ibeetlebase.api;
import org.de.unigoettingen.ibeetlebase.api.core.FlyBase;
import org.de.unigoettingen.ibeetlebase.api.core.Tribolium;
import org.de.unigoettingen.ibeetlebase.api.core.Gene;
import org.eclipse.microprofile.metrics.annotation.Metered;
import java.util.Map;
import io.quarkus.runtime.Quarkus;
import io.quarkus.runtime.QuarkusApplication;
import io.quarkus.runtime.annotations.QuarkusMain;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.GET;
import javax.ws.rs.PathParam;
import javax.inject.Inject;
import org.eclipse.microprofile.metrics.annotation.Metered;
import de.unigoettingen.ibeetlebase.api.core.FlyBase;
import de.unigoettingen.ibeetlebase.api.core.Gene;
import de.unigoettingen.ibeetlebase.api.core.OrthoAPI;
import de.unigoettingen.ibeetlebase.api.core.Tribolium;
@Path("/geneinfo")
@Produces(MediaType.APPLICATION_JSON)
public class GeneinfoResource {
@QuarkusMain
public class GeneinfoResource implements QuarkusApplication {
private static final String VERSION_STRING = "/{dataversion : [0-9]{6}|current}/v1";
......@@ -23,6 +29,8 @@ public class GeneinfoResource {
FlyBase fb;
@Inject
Tribolium tb;
@Inject
OrthoAPI oa;
/**
* REST Endpoint for the Flybase data
......@@ -98,4 +106,22 @@ public class GeneinfoResource {
return tb.getAllIDs();
}
/**
* This function (requiring Quarkus 1.4.2) is called when the application is started
* If "orthoapi" is given as a command line argument in dev mode, the OrthoDB API calls are executed
* @param args The command line arguments
* @return The exit status (0)
*/
@Override
public int run(String... args) throws Exception {
// Calls the relevant OrthoDB API methods for all genes
if (args.length > 0 && args[0].equals("list_file")) {
//Should write all identifiers to a file.
}
Quarkus.waitForExit();
return 0;
}
}
\ No newline at end of file
package org.de.unigoettingen.ibeetlebase.api.core;
package de.unigoettingen.ibeetlebase.api.core;
import java.io.BufferedReader;
import java.io.FileReader;
......@@ -9,7 +9,7 @@ import java.util.Map;
import java.util.LinkedList;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import org.de.unigoettingen.ibeetlebase.AppServiceBean;
import de.unigoettingen.ibeetlebase.AppServiceBean;
@ApplicationScoped
public class FlyBase implements GeneSource {
......@@ -93,8 +93,26 @@ public class FlyBase implements GeneSource {
/* Check if the gene denoted by fbgn_id exists and add if needed */
Gene new_gene = database_flybase.get(fbgn_id);
if (new_gene == null){
if (wordsArray[2] != null && wordsArray[3] != null) {
id_list.put(wordsArray[2], wordsArray[3]); //Adds gene identifier and full name to the id list
if (wordsArray[2] != null) {
String ncbi_identifier = "UNDEF";
switch (wordsArray[0]) {
case "Dana":
ncbi_identifier = "7217";
break;
case "Dmel":
ncbi_identifier = "7227";
break;
case "Dvir":
ncbi_identifier = "7244";
break;
case "Dpse":
ncbi_identifier = "7237";
break;
case "Dsim":
ncbi_identifier = "7240";
break;
}
id_list.put(wordsArray[2], ncbi_identifier); //Adds gene identifier and NCBI identifier to the id list
}
new_gene = new Gene(fbgn_id, "flybase");
database_flybase.put(fbgn_id, new_gene);
......
package org.de.unigoettingen.ibeetlebase.api.core;
package de.unigoettingen.ibeetlebase.api.core;
import java.util.*;
......
package org.de.unigoettingen.ibeetlebase.api.core;
package de.unigoettingen.ibeetlebase.api.core;
public interface GeneSource {
......
package de.unigoettingen.ibeetlebase.api.core;
import java.util.*;
import javax.enterprise.context.ApplicationScoped;
/**
* This service could later be used for retrieving gene information from OrthoDB.
* OrthoDB v9 is currently the one being used for this.
* These API methods can be called for single IDs, or for all known identifiers
* If the service is started with the argument "list_file", results are also written to a file!
*/
@ApplicationScoped
public class OrthoAPI {
//NCBI IDs and OrthoDB URLs
private static final String DMEL = "7227"; //Drosophila melanogaster
private static final String DPSE = "7237"; //Drosophila pseudoobscura
private static final String DVIR = "7244"; //Drosophila virilis
private static final String DANA = "7217"; //Drosophila ananassae
private static final String DSIM = "7240"; //Drosophila simulans
private static final String TCAS = "7070"; //Tribolium castaneum
private static final String SEARCH_URL = "https://www.orthodb.org/v9/search?query=%s"; //For receiving the cluster IDs for an identifier
private static final String ORTHO_URL = "https://www.orthodb.org/v9/orthologs?id=%s?species=%s"; // Takes a cluster ID, returns all genes
private static final String OGDETAIL_URL = "https://www.orthodb.org/v9/ogdetails?id=%s"; //Takes a gene id (taxid:geneid) and returns relevant data
/**
* Takes a JSON list of all known Flybase identifiers and returns a list of according gene clusters for each.
* Clusters have the Form FFFVVCCCCII (refer to OrthoDB API documentation for further information)
* @param identifiers
* @return
*/
public Map<String, Collection<String>> queryFlybaseIDs(Map<String, String> identifiers) {
return null;
}
public Map<String, Collection<String>> queryTriboliumIDs(Map<String, String> identifiers) {
return null;
}
public Map<String, Collection<String>> search(String clusterid) {
return null;
}
public Map<String, Collection<String>> getGeneInformation(String geneid) {
return null;
}
}
\ No newline at end of file
package org.de.unigoettingen.ibeetlebase.api.core;
package de.unigoettingen.ibeetlebase.api.core;
import java.io.BufferedReader;
import java.io.FileReader;
......@@ -9,7 +9,7 @@ import java.util.Map;
import java.util.LinkedList;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import org.de.unigoettingen.ibeetlebase.AppServiceBean;
import de.unigoettingen.ibeetlebase.AppServiceBean;
@ApplicationScoped
public class Tribolium implements GeneSource {
......@@ -111,8 +111,8 @@ public class Tribolium implements GeneSource {
/* Check if the gene denoted by tc_id exists and add if needed */
Gene new_gene = database_tribolium.get(tc_id);
if (new_gene == null){
if (tc_id != null && gene_name != null) {
id_list.put(tc_id, gene_name); //Adds gene identifier and full name to the id list
if (tc_id != null) {
id_list.put(tc_id, "7070"); //Adds gene identifier and NCBI ID (7070) to the list
}
new_gene = new Gene(tc_id, "trib_gff");
database_tribolium.put(tc_id, new_gene);
......
# Configuration file
# key = value
\ No newline at end of file
# key = value
quarkus.http.cors=true
\ No newline at end of file
package org.de.unigoettingen.ibeetlebase.api;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;
@QuarkusTest
public class GeneinfoResourceTest {
@Test
public void testHelloEndpoint() {
given()
.when().get("/geneinfo")
.then()
.statusCode(200)
.body(is("hello"));
}
}
\ No newline at end of file
package org.de.unigoettingen.ibeetlebase.api;
import io.quarkus.test.junit.NativeImageTest;
@NativeImageTest
public class NativeGeneinfoResourceIT extends GeneinfoResourceTest {
// Execute the same tests but in native mode.
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment