Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
iBB
API
geneinfoservice
Commits
54318e6a
Commit
54318e6a
authored
Nov 17, 2020
by
cnguyen2
Browse files
Update endpoints and annotations for OpenAPI
parent
ed3a2eec
Pipeline
#159660
passed with stages
in 12 minutes and 47 seconds
Changes
12
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
54318e6a
...
@@ -12,10 +12,10 @@
...
@@ -12,10 +12,10 @@
<maven.compiler.target>
11
</maven.compiler.target>
<maven.compiler.target>
11
</maven.compiler.target>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<quarkus-plugin.version>
1.
4
.2.Final
</quarkus-plugin.version>
<quarkus-plugin.version>
1.
9
.2.Final
</quarkus-plugin.version>
<quarkus.platform.artifact-id>
quarkus-universe-bom
</quarkus.platform.artifact-id>
<quarkus.platform.artifact-id>
quarkus-universe-bom
</quarkus.platform.artifact-id>
<quarkus.platform.group-id>
io.quarkus
</quarkus.platform.group-id>
<quarkus.platform.group-id>
io.quarkus
</quarkus.platform.group-id>
<quarkus.platform.version>
1.
4
.2.Final
</quarkus.platform.version>
<quarkus.platform.version>
1.
9
.2.Final
</quarkus.platform.version>
<surefire-plugin.version>
2.22.1
</surefire-plugin.version>
<surefire-plugin.version>
2.22.1
</surefire-plugin.version>
</properties>
</properties>
<dependencyManagement>
<dependencyManagement>
...
...
src/main/java/de/unigoettingen/ibeetlebase/AppServiceBean.java
→
src/main/java/de/unigoettingen/ibeetlebase/
geneinfo/
AppServiceBean.java
View file @
54318e6a
package
de.unigoettingen.ibeetlebase
;
package
de.unigoettingen.ibeetlebase
.geneinfo
;
import
javax.enterprise.context.ApplicationScoped
;
import
javax.enterprise.context.ApplicationScoped
;
import
javax.enterprise.event.Observes
;
import
javax.enterprise.event.Observes
;
...
...
src/main/java/de/unigoettingen/ibeetlebase/geneinfo/GeneinfoApplication.java
0 → 100644
View file @
54318e6a
package
de.unigoettingen.ibeetlebase.geneinfo
;
import
javax.ws.rs.core.Application
;
import
org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition
;
import
org.eclipse.microprofile.openapi.annotations.info.Info
;
@OpenAPIDefinition
(
info
=
@Info
(
title
=
"Gene Info Service"
,
description
=
"Get general information for fly and tribolium genes."
,
version
=
"1.0"
)
)
public
class
GeneinfoApplication
extends
Application
{
}
src/main/java/de/unigoettingen/ibeetlebase/geneinfo/model/FlybaseGene.java
0 → 100644
View file @
54318e6a
package
de.unigoettingen.ibeetlebase.geneinfo.model
;
import
java.util.Set
;
import
io.quarkus.runtime.annotations.RegisterForReflection
;
@RegisterForReflection
public
class
FlybaseGene
{
private
String
id
;
private
String
taxanomyId
;
private
String
type
;
private
String
symbol
;
private
String
fullname
;
private
String
annotationId
;
private
String
transcriptType
;
private
Set
<
String
>
transcriptIds
;
public
FlybaseGene
(
String
id
,
String
taxanomyId
,
String
type
,
String
symbol
,
String
fullname
,
String
annotationId
,
String
transcriptType
,
Set
<
String
>
transcriptIds
)
{
super
();
this
.
id
=
id
;
this
.
taxanomyId
=
taxanomyId
;
this
.
type
=
type
;
this
.
symbol
=
symbol
;
this
.
fullname
=
fullname
;
this
.
annotationId
=
annotationId
;
this
.
transcriptType
=
transcriptType
;
this
.
transcriptIds
=
transcriptIds
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getTaxanomyId
()
{
return
taxanomyId
;
}
public
void
setTaxanomyId
(
String
taxanomyId
)
{
this
.
taxanomyId
=
taxanomyId
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getSymbol
()
{
return
symbol
;
}
public
void
setSymbol
(
String
symbol
)
{
this
.
symbol
=
symbol
;
}
public
String
getFullname
()
{
return
fullname
;
}
public
void
setFullname
(
String
fullname
)
{
this
.
fullname
=
fullname
;
}
public
String
getAnnotationId
()
{
return
annotationId
;
}
public
void
setAnnotationId
(
String
annotationId
)
{
this
.
annotationId
=
annotationId
;
}
public
String
getTranscriptType
()
{
return
transcriptType
;
}
public
void
setTranscriptType
(
String
transcriptType
)
{
this
.
transcriptType
=
transcriptType
;
}
public
Set
<
String
>
getTranscriptIds
()
{
return
transcriptIds
;
}
public
void
setTranscriptId
(
Set
<
String
>
transcriptIds
)
{
this
.
transcriptIds
=
transcriptIds
;
}
}
src/main/java/de/unigoettingen/ibeetlebase/
api/core
/Gene.java
→
src/main/java/de/unigoettingen/ibeetlebase/
geneinfo/model
/Gene.java
View file @
54318e6a
package
de.unigoettingen.ibeetlebase.
api.core
;
package
de.unigoettingen.ibeetlebase.
geneinfo.model
;
import
java.util.*
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.Map
;
public
class
Gene
{
public
class
Gene
{
private
String
format
=
"flybase"
;
// Identifier for the source database which also implies a certain format of the contained information
private
String
format
=
"flybase"
;
// Identifier for the source database which also implies a certain format of the contained information
...
...
src/main/java/de/unigoettingen/ibeetlebase/geneinfo/model/TriboliumGene.java
0 → 100644
View file @
54318e6a
package
de.unigoettingen.ibeetlebase.geneinfo.model
;
import
io.quarkus.runtime.annotations.RegisterForReflection
;
@RegisterForReflection
public
class
TriboliumGene
{
private
String
id
;
private
String
taxonomyId
;
private
String
seqname
;
private
String
source
;
private
String
feature
;
private
String
start
;
private
String
end
;
private
String
score
;
private
String
strand
;
private
String
frame
;
private
String
locusTag
;
public
TriboliumGene
(
String
id
,
String
taxonomyId
,
String
seqname
,
String
source
,
String
feature
,
String
start
,
String
end
,
String
score
,
String
strand
,
String
frame
,
String
locusTag
)
{
super
();
this
.
id
=
id
;
this
.
taxonomyId
=
taxonomyId
;
this
.
seqname
=
seqname
;
this
.
source
=
source
;
this
.
feature
=
feature
;
this
.
start
=
start
;
this
.
end
=
end
;
this
.
score
=
score
;
this
.
strand
=
strand
;
this
.
frame
=
frame
;
this
.
locusTag
=
locusTag
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getSeqname
()
{
return
seqname
;
}
public
void
setSeqname
(
String
seqname
)
{
this
.
seqname
=
seqname
;
}
public
String
getSource
()
{
return
source
;
}
public
void
setSource
(
String
source
)
{
this
.
source
=
source
;
}
public
String
getFeature
()
{
return
feature
;
}
public
void
setFeature
(
String
feature
)
{
this
.
feature
=
feature
;
}
public
String
getStart
()
{
return
start
;
}
public
void
setStart
(
String
start
)
{
this
.
start
=
start
;
}
public
String
getEnd
()
{
return
end
;
}
public
void
setEnd
(
String
end
)
{
this
.
end
=
end
;
}
public
String
getScore
()
{
return
score
;
}
public
void
setScore
(
String
score
)
{
this
.
score
=
score
;
}
public
String
getStrand
()
{
return
strand
;
}
public
void
setStrand
(
String
strand
)
{
this
.
strand
=
strand
;
}
public
String
getFrame
()
{
return
frame
;
}
public
void
setFrame
(
String
frame
)
{
this
.
frame
=
frame
;
}
public
String
getLocusTag
()
{
return
locusTag
;
}
public
void
setLocusTag
(
String
locusTag
)
{
this
.
locusTag
=
locusTag
;
}
public
String
getTaxonomyId
()
{
return
taxonomyId
;
}
public
void
setTaxonomyId
(
String
taxonomyId
)
{
this
.
taxonomyId
=
taxonomyId
;
}
}
src/main/java/de/unigoettingen/ibeetlebase/
api/G
eneinfoResource.java
→
src/main/java/de/unigoettingen/ibeetlebase/
g
eneinfo
/resource/Gene
Resource.java
View file @
54318e6a
package
de.unigoettingen.ibeetlebase.
api
;
package
de.unigoettingen.ibeetlebase.
geneinfo.resource
;
import
java.util.
ArrayList
;
import
java.util.
Collection
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Optional
;
import
io.quarkus.runtime.Quarkus
;
import
java.util.Set
;
import
io.quarkus.runtime.QuarkusApplication
;
import
java.util.stream.Collectors
;
import
io.quarkus.runtime.annotations.QuarkusMain
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.GET
;
...
@@ -15,18 +14,26 @@ import javax.ws.rs.PathParam;
...
@@ -15,18 +14,26 @@ import javax.ws.rs.PathParam;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.QueryParam
;
import
javax.ws.rs.QueryParam
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.MediaType
;
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"
)
import
org.eclipse.microprofile.metrics.annotation.Metered
;
import
org.eclipse.microprofile.openapi.annotations.Operation
;
import
org.eclipse.microprofile.openapi.annotations.enums.ParameterIn
;
import
org.eclipse.microprofile.openapi.annotations.media.ExampleObject
;
import
org.eclipse.microprofile.openapi.annotations.parameters.Parameter
;
import
de.unigoettingen.ibeetlebase.geneinfo.model.FlybaseGene
;
import
de.unigoettingen.ibeetlebase.geneinfo.model.Gene
;
import
de.unigoettingen.ibeetlebase.geneinfo.model.TriboliumGene
;
import
de.unigoettingen.ibeetlebase.geneinfo.service.FlyBase
;
import
de.unigoettingen.ibeetlebase.geneinfo.service.OrthoAPI
;
import
de.unigoettingen.ibeetlebase.geneinfo.service.Tribolium
;
@Path
(
"/"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
@QuarkusMain
//
@QuarkusMain
public
class
Gene
info
Resource
implements
QuarkusApplication
{
public
class
GeneResource
{
//
implements QuarkusApplication {
private
static
final
String
VERSION_STRING
=
"/{dataversion : [0-9]{6}|current}/v1"
;
//
private static final String VERSION_STRING = "/{dataversion : [0-9]{6}|current}/v1";
@Inject
@Inject
FlyBase
fb
;
FlyBase
fb
;
...
@@ -35,57 +42,67 @@ public class GeneinfoResource implements QuarkusApplication {
...
@@ -35,57 +42,67 @@ public class GeneinfoResource implements QuarkusApplication {
@Inject
@Inject
OrthoAPI
oa
;
OrthoAPI
oa
;
/**
* REST Endpoint for the Flybase data
* @param dataversion Version ID of the requested data - Required so older versions can be requested in the future
* @param fbgn The flybase identifier that information is requested for
* @return Gene information for all matching flybase gene identifiers (FBgn)
*/
@GET
@GET
@Metered
@Metered
@Path
(
VERSION_STRING
+
"/flybase/{fbgn: FBgn[0-9]{7}}"
)
@Path
(
"/flybase/genes/{id: FBgn[0-9]{7}}"
)
public
Gene
getFlybaseInfo
(
@PathParam
(
"dataversion"
)
final
String
dataversion
,
@PathParam
(
"fbgn"
)
final
String
fbgn
)
{
@Operation
(
summary
=
"Get information for a fly gene."
)
if
(!
checkFBgnID
(
fbgn
))
{
public
FlybaseGene
getFlybaseGene
(
return
null
;
@Parameter
(
}
description
=
"Flybase gene identifier in format FBgn[0-9]{7}."
,
return
fb
.
retrieve
(
fbgn
);
example
=
"FBgn0000015"
)
@PathParam
(
"id"
)
String
id
)
{
return
Optional
.
ofNullable
(
fb
.
retrieve
(
id
)).
map
(
this
::
convertToFlybaseGene
).
orElse
(
null
);
}
@GET
@Metered
@Path
(
"/flybase/genes"
)
@Operation
(
summary
=
"Get information for a list of fly genes"
)
public
List
<
FlybaseGene
>
getFlybaseGenes
(
@Parameter
(
in
=
ParameterIn
.
QUERY
,
description
=
"Flybase gene identifiers in format FBgn[0-9]{7}"
,
examples
=
@ExampleObject
(
name
=
"FBgn0000015"
,
value
=
"FBgn0000015"
))
@QueryParam
(
"ids"
)
Set
<
String
>
ids
)
{
return
ids
.
stream
()
.
filter
(
id
->
checkFBgnID
(
id
))
.
map
(
id
->
fb
.
retrieve
(
id
))
.
filter
(
gene
->
gene
!=
null
)
.
map
(
this
::
convertToFlybaseGene
)
.
collect
(
Collectors
.
toList
());
}
}
/**
* REST Endpoint for the Tribolium data (from the iBB gff file)
* @param dataversion Version ID of the requested data - Required so older versions can be requested in the future
* @param tc The TC identifier that information is requested for
* @return Gene information for all matching tribolium gene identifiers (TC)
*/
@GET
@GET
@Metered
@Metered
@Path
(
VERSION_STRING
+
"/tribolium/{tc: TC[0-9]{6}}"
)
@Path
(
"/tribolium/genes/{id: TC[0-9]{6}}"
)
public
Gene
getTriboliumInfo
(
@PathParam
(
"dataversion"
)
final
String
dataversion
,
@PathParam
(
"tc"
)
final
String
tc
)
{
@Operation
(
summary
=
"Get information for a tribolium gene."
)
if
(!
checkTCID
(
tc
))
{
public
TriboliumGene
getTriboliumGene
(
return
null
;
@Parameter
(
}
description
=
"Tribolium gene identifier in format TC[0-9]{6}}."
,
return
tb
.
retrieve
(
tc
);
example
=
"TC001906"
)
@PathParam
(
"id"
)
String
tc
)
{
return
Optional
.
ofNullable
(
tb
.
retrieve
(
tc
)).
map
(
this
::
convertToTriboliumGene
).
orElse
(
null
);
}
}
/**
* Accepts multiple comma-separated gene IDs and returns the resulting gene information.
* @param ids The list of IDs
* @return Gene information for each queried ID
*/
@GET
@GET
@Metered
@Metered
@Path
(
VERSION_STRING
+
"/gene"
)
@Path
(
"/tribolium/genes"
)
public
List
<
Gene
>
getInfo
(
@QueryParam
(
"ids"
)
final
String
ids
)
{
@Operation
(
summary
=
"Get information for a list of fly genes"
)
List
<
Gene
>
result_list
=
new
ArrayList
<
Gene
>();
public
List
<
TriboliumGene
>
getTriboliumGenes
(
for
(
String
id
:
ids
.
split
(
","
))
{
@Parameter
(
if
(
checkTCID
(
id
))
{
in
=
ParameterIn
.
QUERY
,
result_list
.
add
(
tb
.
retrieve
(
id
));
description
=
"Tribolium gene identifiers in format TC[0-9]{6}"
,
}
examples
=
@ExampleObject
(
name
=
"TC001906"
,
value
=
"TC001906"
))
else
if
(
checkFBgnID
(
id
))
{
@QueryParam
(
"ids"
)
Set
<
String
>
ids
)
{
result_list
.
add
(
fb
.
retrieve
(
id
));
return
ids
.
stream
()
}
.
filter
(
id
->
checkTCID
(
id
))
}
.
map
(
id
->
tb
.
retrieve
(
id
))
return
result_list
;
.
filter
(
gene
->
gene
!=
null
)
.
map
(
this
::
convertToTriboliumGene
)
.
collect
(
Collectors
.
toList
());
}
}
/**
/**
...
@@ -111,24 +128,28 @@ public class GeneinfoResource implements QuarkusApplication {
...
@@ -111,24 +128,28 @@ public class GeneinfoResource implements QuarkusApplication {
* @param dataversion Version ID of the requested data - Required so older versions can be requested in the future
* @param dataversion Version ID of the requested data - Required so older versions can be requested in the future
* @return All flybase gene identifiers and their according gene names
* @return All flybase gene identifiers and their according gene names
*/
*/
/*
@GET
@GET
@Metered
@Metered
@Path
(
VERSION_STRING
+
"/flybase/identifiers"
)
@Path("/flybase/identifiers")
public
Map
<
String
,
String
>
getAllFlybaseIDs
(
@PathParam
(
"dataversion"
)
final
String
dataversion
)
{
public Map<String, String> getAllFlybaseIDs() {
return fb.getAllIDs();
return fb.getAllIDs();
}
}
*/
/**
/**
* REST Endpoint that returns all tribolium gene identifiers and their according gene names
* REST Endpoint that returns all tribolium gene identifiers and their according gene names
* @param dataversion Version ID of the requested data - Required so older versions can be requested in the future
* @param dataversion Version ID of the requested data - Required so older versions can be requested in the future
* @return All TC gene identifiers and their according gene names
* @return All TC gene identifiers and their according gene names
*/
*/
/*
@GET
@GET
@Metered
@Metered
@Path
(
VERSION_STRING
+
"/tribolium/identifiers"
)
@Path("/tribolium/identifiers")
public
Map
<
String
,
String
>
getAllTriboliumIDs
(
@PathParam
(
"dataversion"
)
final
String
dataversion
)
{
public Map<String, String> getAllTriboliumIDs() {
return tb.getAllIDs();
return tb.getAllIDs();
}
}
*/
/**
/**
* This function (requiring Quarkus 1.4.2) is called when the application is started
* This function (requiring Quarkus 1.4.2) is called when the application is started
...
@@ -136,6 +157,7 @@ public class GeneinfoResource implements QuarkusApplication {
...
@@ -136,6 +157,7 @@ public class GeneinfoResource implements QuarkusApplication {
* @param args The command line arguments
* @param args The command line arguments
* @return The exit status (0)
* @return The exit status (0)
*/
*/
/*
@Override
@Override
public int run(String... args) throws Exception {
public int run(String... args) throws Exception {
...
@@ -147,5 +169,54 @@ public class GeneinfoResource implements QuarkusApplication {
...
@@ -147,5 +169,54 @@ public class GeneinfoResource implements QuarkusApplication {
Quarkus.waitForExit();
Quarkus.waitForExit();
return 0;
return 0;
}
}
*/
private
FlybaseGene
convertToFlybaseGene
(
Gene
gene
)
{
Map
<
String
,
Collection
<
String
>>
info
=
gene
.
getInformation
();
return
new
FlybaseGene
(
gene
.
getGeneID
(),
collectionToString
(
organismToTaxonomyId
(
info
.
get
(
"organism"
))),
collectionToString
(
info
.
get
(
"gene_type"
)),
collectionToString
(
info
.
get
(
"gene_symbol"
)),
collectionToString
(
info
.
get
(
"gene_fullname"
)),
collectionToString
(
info
.
get
(
"annotation_ID"
)),
collectionToString
(
info
.
get
(
"transcript_Type"
)),
info
.
get
(
"transcript_ID"
).
stream
().
collect
(
Collectors
.
toSet
()));
}
private
TriboliumGene
convertToTriboliumGene
(
Gene
gene
)
{
Map
<
String
,
Collection
<
String
>>
info
=
gene
.
getInformation
();
return
new
TriboliumGene
(
gene
.
getGeneID
(),
"7070"
,
collectionToString
(
info
.
get
(
"seqname"
)),
collectionToString
(
info
.
get
(
"source"
)),
collectionToString
(
info
.
get
(
"feature"
)),
collectionToString
(
info
.
get
(
"start"
)),
collectionToString
(
info
.
get
(
"end"
)),
collectionToString
(
info
.
get
(
"score"
)),
collectionToString
(
info
.
get
(
"strand"
)),
collectionToString
(
info
.
get
(
"frame"
)),
collectionToString
(
info
.
get
(
"locus_tag"
)));
}
private
Collection
<
String
>
organismToTaxonomyId
(
Collection
<
String
>
organisms
)
{
return
organisms
.
stream
().
map
(
o
->
{
switch
(
o
)
{
case
"Dana"
:
return
"7217"
;
case
"Dmel"
:
return
"7227"
;
case
"Dvir"
:
return
"7244"
;
case
"Dpse"
:
return
"7237"
;
case
"Dsim"
:
return
"7240"
;
}
return
null
;
}).
collect
(
Collectors
.
toList
());
}
private
String
collectionToString
(
Collection
<
String
>
items
)
{
return
items
.
stream
().
collect
(
Collectors
.
joining
(
", "
));
}
}
}
\ No newline at end of file
src/main/java/de/unigoettingen/ibeetlebase/
api/cor
e/FlyBase.java
→
src/main/java/de/unigoettingen/ibeetlebase/
geneinfo/servic
e/FlyBase.java
View file @
54318e6a
package
de.unigoettingen.ibeetlebase.
api.cor
e
;
package
de.unigoettingen.ibeetlebase.
geneinfo.servic
e
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.FileReader
;
import
java.io.FileReader
;
...
@@ -9,7 +9,9 @@ import java.util.Map;
...
@@ -9,7 +9,9 @@ import java.util.Map;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
import
javax.enterprise.context.ApplicationScoped
;
import
javax.enterprise.context.ApplicationScoped
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
de.unigoettingen.ibeetlebase.AppServiceBean
;
import
de.unigoettingen.ibeetlebase.geneinfo.AppServiceBean
;
import
de.unigoettingen.ibeetlebase.geneinfo.model.Gene
;
@ApplicationScoped
@ApplicationScoped
public
class
FlyBase
implements
GeneSource
{
public
class
FlyBase
implements
GeneSource
{
...
...
src/main/java/de/unigoettingen/ibeetlebase/
api/cor
e/GeneSource.java
→
src/main/java/de/unigoettingen/ibeetlebase/
geneinfo/servic
e/GeneSource.java
View file @
54318e6a
package
de.unigoettingen.ibeetlebase.api.core
;
package
de.unigoettingen.ibeetlebase.geneinfo.service
;
import
de.unigoettingen.ibeetlebase.geneinfo.model.Gene
;
public
interface
GeneSource
{
public
interface
GeneSource
{