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
d79cddb0
Commit
d79cddb0
authored
Jul 29, 2021
by
cnguyen2
Browse files
Use embedded database
parent
2e743e2a
Changes
26
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
d79cddb0
...
...
@@ -2,7 +2,7 @@
<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>
de.unigoettingen.ibeetlebase.api.core
</groupId>
<groupId>
ibb.api
</groupId>
<artifactId>
geneinfoservice
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<properties>
...
...
@@ -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.13.7
.Final
</quarkus-plugin.version>
<quarkus-plugin.version>
2.0.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.13.7
.Final
</quarkus.platform.version>
<quarkus.platform.version>
2.0.2
.Final
</quarkus.platform.version>
<surefire-plugin.version>
2.22.1
</surefire-plugin.version>
</properties>
<dependencyManagement>
...
...
@@ -44,6 +44,10 @@
<artifactId>
rest-assured
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
io.quarkus
</groupId>
<artifactId>
quarkus-config-yaml
</artifactId>
</dependency>
<dependency>
<groupId>
io.quarkus
</groupId>
<artifactId>
quarkus-smallrye-openapi
</artifactId>
...
...
@@ -56,6 +60,14 @@
<groupId>
io.quarkus
</groupId>
<artifactId>
quarkus-container-image-docker
</artifactId>
</dependency>
<dependency>
<groupId>
io.quarkus
</groupId>
<artifactId>
quarkus-hibernate-orm-rest-data-panache
</artifactId>
</dependency>
<dependency>
<groupId>
io.quarkus
</groupId>
<artifactId>
quarkus-jdbc-h2
</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
...
...
sample_data/drosophila.gene.tsv.gz
View file @
d79cddb0
No preview for this file type
src/main/docker/Dockerfile.jvm
View file @
d79cddb0
...
...
@@ -8,24 +8,24 @@ ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
&& microdnf update \
&& microdnf clean all \
&& mkdir /
deployments
\
&& chown 1001 /
deployments
\
&& chmod "g+rwX" /
deployments
\
&& chown 1001:root /
deployments
\
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /
deployments
/run-java.sh \
&& chown 1001 /
deployments
/run-java.sh \
&& chmod 540 /
deployments
/run-java.sh \
&& mkdir /
work
\
&& chown 1001 /
work
\
&& chmod "g+rwX" /
work
\
&& chown 1001:root /
work
\
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /
work
/run-java.sh \
&& chown 1001 /
work
/run-java.sh \
&& chmod 540 /
work
/run-java.sh \
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security
# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=1001 target/quarkus-app/lib/ /
deployments
/lib/
COPY --chown=1001 target/quarkus-app/*.jar /
deployments
/
COPY --chown=1001 target/quarkus-app/app/ /
deployments
/app/
COPY --chown=1001 target/quarkus-app/quarkus/ /
deployments
/quarkus/
COPY --chown=1001 target/quarkus-app/lib/ /
work
/lib/
COPY --chown=1001 target/quarkus-app/*.jar /
work
/
COPY --chown=1001 target/quarkus-app/app/ /
work
/app/
COPY --chown=1001 target/quarkus-app/quarkus/ /
work
/quarkus/
EXPOSE 8080
USER 1001
ENTRYPOINT [ "/
deployments
/run-java.sh" ]
ENTRYPOINT [ "/
work
/run-java.sh" ]
src/main/java/ibb/api/geneinfo/GeneinfoService.java
View file @
d79cddb0
package
ibb.api.geneinfo
;
import
javax.enterprise.context.ApplicationScoped
;
import
javax.ws.rs.core.Application
;
import
org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition
;
...
...
@@ -10,5 +11,6 @@ import org.eclipse.microprofile.openapi.annotations.info.Info;
description
=
"Get general information for Drosophila and Tribolium genes."
,
version
=
"0.1"
)
)
@ApplicationScoped
public
class
GeneinfoService
extends
Application
{
}
\ No newline at end of file
src/main/java/ibb/api/geneinfo/config/SpeciesConfig.java
0 → 100644
View file @
d79cddb0
package
ibb.api.geneinfo.config
;
//@ConfigMapping(prefix = "species")
public
interface
SpeciesConfig
{
String
name
();
}
src/main/java/ibb/api/geneinfo/
repo
/DrosophilaGene
InMemoryRepo
.java
→
src/main/java/ibb/api/geneinfo/
loader
/DrosophilaGene
Loader
.java
View file @
d79cddb0
package
ibb.api.geneinfo.
repo
;
package
ibb.api.geneinfo.
loader
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.
Map
;
import
java.util.
Set
;
import
javax.annotation.PostConstruct
;
import
javax.
enterprise.context.ApplicationScoped
;
import
javax.
transaction.Transactional
;
import
org.eclipse.microprofile.config.inject.ConfigProperty
;
import
org.jboss.logging.Logger
;
import
ibb.api.geneinfo.model.DrosophilaGene
;
import
ibb.api.geneinfo.
util
.Parser
;
import
ibb.api.geneinfo.
parser
.Parser
;
import
io.quarkus.runtime.Startup
;
@Deprecated
@Startup
@ApplicationScoped
public
class
DrosophilaGeneInMemoryRepo
extends
InMemoryRepo
<
DrosophilaGene
>
{
// private static final Logger LOGGER = Logger.getLogger(DrosophilaGeneInMemoryRepo.class);
public
class
DrosophilaGeneLoader
{
private
static
final
Logger
LOG
=
Logger
.
getLogger
(
DrosophilaGeneLoader
.
class
);
@ConfigProperty
(
name
=
"data.drosophila.gene.tsv"
)
String
geneSetPath
;
@PostConstruct
public
void
init
()
{
prepareData
(
List
.
of
(
"annotationId"
,
"symbol"
,
"fullname"
));
}
@Override
public
List
<
DrosophilaGene
>
genItems
()
{
List
<
DrosophilaGene
>
genes
=
new
ArrayList
<>();
Map
<
String
,
DrosophilaGene
>
geneMap
=
new
HashMap
<>();
@PostConstruct
@Transactional
public
void
load
()
{
if
(
DrosophilaGene
.
count
()
>
0
)
return
;
LOG
.
info
(
"Attempting to initialize Drosophila data..."
);
Set
<
String
>
idSet
=
new
HashSet
<>();
Parser
.
parseTSV
(
geneSetPath
,
List
.
of
(
"organism"
,
...
...
@@ -44,23 +42,21 @@ public class DrosophilaGeneInMemoryRepo extends InMemoryRepo<DrosophilaGene> {
"transcript_symbol"
,
"polypeptide_ID"
,
"polypeptide_symbol"
),
record
->
{
DrosophilaGene
gene
=
new
DrosophilaGene
.
Builder
(
record
.
get
(
"gene_ID"
))
.
type
(
record
.
get
(
"gene_type"
))
.
symbol
(
record
.
get
(
"gene_symbol"
))
.
fullname
(
record
.
get
(
"gene_fullname"
))
.
annotationId
(
record
.
get
(
"annotation_ID"
))
.
transcriptType
(
record
.
get
(
"transcript_type"
))
.
build
();
if
(!
geneMap
.
containsKey
(
gene
.
getId
()))
{
genes
.
add
(
gene
);
geneMap
.
put
(
gene
.
getId
(),
gene
);
}
geneMap
.
get
(
gene
.
getId
()).
addTranscriptId
(
record
.
get
(
"transcript_ID"
));
if
(!
"Dmel"
.
equals
(
record
.
get
(
"organism"
)))
return
;
String
id
=
record
.
get
(
"gene_ID"
);
if
(
idSet
.
contains
(
id
))
return
;
DrosophilaGene
gene
=
new
DrosophilaGene
();
gene
.
id
=
id
;
gene
.
symbol
=
record
.
get
(
"gene_symbol"
);
gene
.
fullname
=
record
.
get
(
"gene_fullname"
);
gene
.
annotationId
=
record
.
get
(
"annotation_ID"
);
gene
.
persist
();
idSet
.
add
(
id
);
});
return
genes
;
}
LOG
.
infov
(
"Loaded {0} Drosophila genes"
,
DrosophilaGene
.
count
())
;
}
}
src/main/java/ibb/api/geneinfo/
repo
/TriboliumGene
InMemoryRepo
.java
→
src/main/java/ibb/api/geneinfo/
loader
/TriboliumGene
Loader
.java
View file @
d79cddb0
package
ibb.api.geneinfo.
repo
;
package
ibb.api.geneinfo.
loader
;
import
static
java
.
util
.
stream
.
Collectors
.
toMap
;
...
...
@@ -11,21 +11,20 @@ import java.util.regex.Matcher;
import
java.util.regex.Pattern
;
import
javax.annotation.PostConstruct
;
import
javax.
enterprise.context.ApplicationScoped
;
import
javax.
transaction.Transactional
;
import
org.eclipse.microprofile.config.inject.ConfigProperty
;
import
ibb.api.geneinfo.model.TriboliumGene
;
import
ibb.api.geneinfo.
util
.FastaRecord
;
import
ibb.api.geneinfo.
util
.GFFRecord
;
import
ibb.api.geneinfo.
util
.Parser
;
import
ibb.api.geneinfo.
parser
.FastaRecord
;
import
ibb.api.geneinfo.
parser
.GFFRecord
;
import
ibb.api.geneinfo.
parser
.Parser
;
import
io.quarkus.runtime.Startup
;
@Deprecated
@Startup
@ApplicationScoped
public
class
TriboliumGeneInMemoryRepo
extends
InMemoryRepo
<
TriboliumGene
>
{
// private static final Logger LOGGER = Logger.getLogger(TriboliumGeneInMemoryRepo.class);
private
static
final
Pattern
TC_PATTERN
=
Pattern
.
compile
(
"(TC[0-9]{6})"
);
public
class
TriboliumGeneLoader
{
private
static
final
Pattern
TC_PATTERN
=
Pattern
.
compile
(
"(TC[0-9]{6})"
);
@ConfigProperty
(
name
=
"data.tribolium.gene.gff"
)
String
gff
;
...
...
@@ -40,36 +39,33 @@ public class TriboliumGeneInMemoryRepo extends InMemoryRepo<TriboliumGene> {
String
proteinFasta
;
@PostConstruct
public
void
init
()
{
prepareData
(
List
.
of
());
}
@Override
public
List
<
TriboliumGene
>
genItems
()
{
@Transactional
public
void
load
()
{
List
<
TriboliumGene
>
genes
=
new
ArrayList
<>();
Parser
.
parseGFF
(
gff
,
record
->
{
Optional
<
TriboliumGene
>
opt
=
Optional
.
of
(
record
)
.
filter
(
r
->
"gene"
.
equals
(
r
.
getFeature
()))
.
map
(
this
::
getTCNo
)
.
map
(
tc
->
new
TriboliumGene
.
Builder
(
tc
)
.
seqname
(
record
.
getSeqname
())
.
start
(
record
.
getStart
())
.
end
(
record
.
getEnd
())
.
strand
(
record
.
getStrand
())
.
build
());
opt
.
ifPresent
(
genes:
:
add
);
});
Parser
.
parseGFF
(
gff
,
record
->
Optional
.
of
(
record
)
.
filter
(
r
->
"gene"
.
equals
(
r
.
getFeature
()))
.
map
(
this
::
getTCNo
)
.
map
(
tc
->
{
TriboliumGene
gene
=
new
TriboliumGene
();
gene
.
id
=
tc
;
gene
.
seqname
=
record
.
getSeqname
();
gene
.
start
=
record
.
getStart
();
gene
.
end
=
record
.
getEnd
();
gene
.
strand
=
record
.
getStrand
();
return
gene
;
})
.
ifPresent
(
genes:
:
add
));
Map
<
String
,
TriboliumGene
>
geneMap
=
genes
.
stream
()
.
collect
(
toMap
(
TriboliumGene:
:
getI
d
,
Function
.
identity
()));
.
collect
(
toMap
(
gene
->
gene
.
i
d
,
Function
.
identity
()));
Parser
.
parseFasta
(
cdsFasta
,
record
->
{
Optional
.
of
(
record
)
.
map
(
FastaRecord:
:
getHeader
)
.
map
(
this
::
getTCNo
)
.
map
(
geneMap:
:
get
)
.
ifPresent
(
gene
->
gene
.
setCDS
(
record
.
getSequence
())
)
;
.
ifPresent
(
gene
->
gene
.
CDS
=
record
.
getSequence
());
});
Parser
.
parseFasta
(
mRNAFasta
,
record
->
{
...
...
@@ -77,7 +73,7 @@ public class TriboliumGeneInMemoryRepo extends InMemoryRepo<TriboliumGene> {
.
map
(
FastaRecord:
:
getHeader
)
.
map
(
this
::
getTCNo
)
.
map
(
geneMap:
:
get
)
.
ifPresent
(
gene
->
gene
.
set
mRNA
(
record
.
getSequence
())
)
;
.
ifPresent
(
gene
->
gene
.
mRNA
=
record
.
getSequence
());
});
Parser
.
parseFasta
(
proteinFasta
,
record
->
{
...
...
@@ -85,10 +81,9 @@ public class TriboliumGeneInMemoryRepo extends InMemoryRepo<TriboliumGene> {
.
map
(
FastaRecord:
:
getHeader
)
.
map
(
this
::
getTCNo
)
.
map
(
geneMap:
:
get
)
.
ifPresent
(
gene
->
gene
.
setP
rotein
(
record
.
getSequence
())
)
;
.
ifPresent
(
gene
->
gene
.
p
rotein
=
record
.
getSequence
());
});
return
genes
;
TriboliumGene
.
persist
(
genes
);
}
private
String
getTCNo
(
GFFRecord
record
)
{
...
...
src/main/java/ibb/api/geneinfo/model/DrosophilaGene.java
View file @
d79cddb0
package
ibb.api.geneinfo.model
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
io.quarkus.hibernate.orm.panache.PanacheEntityBase
;
import
io.quarkus.runtime.annotations.RegisterForReflection
;
@RegisterForReflection
public
class
DrosophilaGene
{
private
String
id
;
private
String
type
;
private
String
symbol
;
private
String
fullname
;
private
String
annotationId
;
private
String
transcriptType
;
private
List
<
String
>
transcriptIds
;
@Deprecated
@Entity
public
class
DrosophilaGene
extends
PanacheEntityBase
{
@Id
public
String
id
;
public
String
symbol
;
public
String
fullname
;
public
String
annotationId
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
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
static
List
<
DrosophilaGene
>
findByFullname
(
String
fullname
)
{
return
find
(
"fullname"
,
fullname
).
list
();
}
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
List
<
String
>
getTranscriptIds
()
{
return
transcriptIds
;
}
public
void
setTranscriptIds
(
List
<
String
>
transcriptIds
)
{
this
.
transcriptIds
=
transcriptIds
;
}
public
void
addTranscriptId
(
String
transcriptId
)
{
if
(
transcriptId
==
null
)
{
return
;
}
if
(
transcriptIds
==
null
)
{
transcriptIds
=
new
ArrayList
<
String
>();
}
transcriptIds
.
add
(
transcriptId
);
public
static
List
<
DrosophilaGene
>
findBySymbol
(
String
symbol
)
{
return
find
(
"symbol"
,
symbol
).
list
();
}
public
static
class
Builder
{
private
String
id
;
private
String
type
;
private
String
symbol
;
private
String
fullname
;
private
String
annotationId
;
private
String
transcriptType
;
public
Builder
(
String
id
)
{
this
.
id
=
id
;
}
public
Builder
type
(
String
val
)
{
type
=
val
;
return
this
;
}
public
Builder
symbol
(
String
val
)
{
symbol
=
val
;
return
this
;
}
public
Builder
fullname
(
String
val
)
{
fullname
=
val
;
return
this
;
}
public
Builder
annotationId
(
String
val
)
{
annotationId
=
val
;
return
this
;
}
public
Builder
transcriptType
(
String
val
)
{
transcriptType
=
val
;
return
this
;
}
public
DrosophilaGene
build
()
{
DrosophilaGene
gene
=
new
DrosophilaGene
();
gene
.
id
=
id
;
gene
.
type
=
type
;
gene
.
symbol
=
symbol
;
gene
.
fullname
=
fullname
;
gene
.
annotationId
=
annotationId
;
gene
.
transcriptType
=
transcriptType
;
return
gene
;
}
public
static
List
<
DrosophilaGene
>
findByAnnotationId
(
String
annotationId
)
{
return
find
(
"annotationId"
,
annotationId
).
list
();
}
}
src/main/java/ibb/api/geneinfo/model/Gene.java
0 → 100644
View file @
d79cddb0
package
ibb.api.geneinfo.model
;
import
java.util.Objects
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
javax.persistence.JoinColumn
;
import
javax.persistence.ManyToOne
;
import
io.quarkus.hibernate.orm.panache.PanacheEntityBase
;
import
io.quarkus.runtime.annotations.RegisterForReflection
;
@Entity
@RegisterForReflection
public
class
Gene
extends
PanacheEntityBase
{
@Id
public
String
id
;
public
String
symbol
;
public
String
name
;
public
String
annoId
;
@ManyToOne
@JoinColumn
(
name
=
"species"
,
referencedColumnName
=
"name"
)
public
Species
species
;
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
Gene
gene
=
(
Gene
)
o
;
return
Objects
.
equals
(
id
,
gene
.
id
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
id
);
}
}
src/main/java/ibb/api/geneinfo/model/Species.java
0 → 100644
View file @
d79cddb0
package
ibb.api.geneinfo.model
;
import
java.util.List
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
javax.persistence.OneToMany
;
import
io.quarkus.hibernate.orm.panache.PanacheEntityBase
;
import
io.quarkus.runtime.annotations.RegisterForReflection
;
@Entity
@RegisterForReflection
public
class
Species
extends
PanacheEntityBase
{
@Id
public
String
name
;
@OneToMany
(
mappedBy
=
"species"
)
public
List
<
Gene
>
genes
;
}
src/main/java/ibb/api/geneinfo/model/TriboliumGene.java
View file @
d79cddb0
package
ibb.api.geneinfo.model
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
io.quarkus.hibernate.orm.panache.PanacheEntityBase
;
import
io.quarkus.runtime.annotations.RegisterForReflection
;
@RegisterForReflection
public
class
TriboliumGene
{
private
String
id
;
private
String
seqname
;
private
String
start
;
private
String
end
;
private
String
strand
;
private
String
CDS
;
private
String
mRNA
;
private
String
protein
;
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
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
getStrand
()
{
return
strand
;
}
public
void
setStrand
(
String
strand
)
{
this
.
strand
=
strand
;
}
public
String
getCDS
()
{
return
CDS
;
}
public
void
setCDS
(
String
cDS
)
{
CDS
=
cDS
;
}
public
String
getmRNA
()
{
return
mRNA
;