Skip to content

Commit

Permalink
Merge branch 'develop' into TASK-5392
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga authored Jan 26, 2024
2 parents 5d00721 + 8faeba2 commit ffdf27a
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 41 deletions.
2 changes: 1 addition & 1 deletion cellbase-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>5.9.0-SNAPSHOT</version>
<version>6.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion cellbase-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>5.9.0-SNAPSHOT</version>
<version>6.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion cellbase-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>5.9.0-SNAPSHOT</version>
<version>6.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
6 changes: 3 additions & 3 deletions cellbase-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>5.9.0-SNAPSHOT</version>
<version>6.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -137,10 +137,10 @@
<groupId>com.github.samtools</groupId>
<artifactId>htsjdk</artifactId>
</dependency>
<dependency>
<!-- <dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
</dependency>
</dependency>-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private boolean updateRocksDB(Variant variant) throws RocksDBException, IOExcept

if (normalisedVariantStringList != null) {
for (String normalisedVariantString : normalisedVariantStringList) {
VariantAnnotation variantAnnotation = getVariantAnnotation(variant.toString().getBytes());
VariantAnnotation variantAnnotation = getVariantAnnotation(normalisedVariantString.getBytes());

// Add haplotype property to all EvidenceEntry objects in variant if there are more than 1 variants in
// normalisedVariantStringList, i.e. if this variant is part of an MNV (haplotype)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@

package org.opencb.cellbase.lib.impl.core;


import com.fasterxml.jackson.databind.ObjectMapper;
import com.mongodb.ReadPreference;
import com.mongodb.WriteConcern;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.Updates;
import org.bson.BsonDocument;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.codehaus.jackson.map.ObjectMapper;
import org.opencb.cellbase.core.api.key.ApiKeyStats;
import org.opencb.cellbase.core.api.query.AbstractQuery;
import org.opencb.cellbase.core.api.query.ProjectionQueryOptions;
import org.opencb.cellbase.core.exception.CellBaseException;
import org.opencb.cellbase.core.result.CellBaseDataResult;
import org.opencb.cellbase.core.api.key.ApiKeyStats;
import org.opencb.cellbase.lib.iterator.CellBaseIterator;
import org.opencb.commons.datastore.core.FacetField;
import org.opencb.commons.datastore.core.QueryOptions;
Expand Down Expand Up @@ -55,7 +58,7 @@ public MetaMongoDBAdaptor(MongoDataStore mongoDataStore) {
private void init() {
logger.debug("MetaMongoDBAdaptor: in 'constructor'");
mongoDBCollection = mongoDataStore.getCollection("metadata");
apiKeyStatsMongoDBCollection = mongoDataStore.getCollection("apikey_stats");
apiKeyStatsMongoDBCollection = mongoDataStore.getCollection("apikey_stats", WriteConcern.ACKNOWLEDGED, ReadPreference.primary());
}

public CellBaseDataResult getAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ private List<GeneMirnaTarget> getTargets(Gene mirna) throws QueryException, Ille
}
}
GeneQuery geneQuery = new GeneQuery();
geneQuery.setDataRelease(dataRelease);
geneQuery.setAnnotationTargets(new LogicalList<>(mirnas, false));
List<GeneMirnaTarget> geneMirnaTargets = new ArrayList<>();
List<Gene> genes = (geneManager.search(geneQuery)).getResults();
Expand Down Expand Up @@ -679,9 +680,9 @@ public List<Gene> getBatchGeneList(List<Variant> variantList)

List<Gene> geneList = new ArrayList<>();
GeneQuery geneQuery = new GeneQuery();
geneQuery.setDataRelease(dataRelease);
geneQuery.setIncludes(includeGeneFields);
geneQuery.setRegions(regionList);
geneQuery.setDataRelease(dataRelease);

if (StringUtils.isNotEmpty(consequenceTypeSource)) {
// sources can be "ensembl" and/or "refseq". query is validated before execution, will fail if invalid value
Expand Down Expand Up @@ -1354,6 +1355,7 @@ private boolean[] getRegulatoryRegionOverlaps(String chromosome, Integer start,
boolean[] overlapsRegulatoryRegion = {false, false};

RegulationQuery query = new RegulationQuery();
query.setDataRelease(dataRelease);
query.setExcludes(Collections.singletonList("_id"));
query.setIncludes(Collections.singletonList("chromosome"));
query.setLimit(1);
Expand Down
2 changes: 1 addition & 1 deletion cellbase-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>5.9.0-SNAPSHOT</version>
<version>6.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,18 @@ public GenericRestWSServer(@PathParam("version") String version, @PathParam("spe
this.species = species;

try {
init();
if (!INITIALIZED.get()) {
init();
}
initQuery();
} catch (Exception e) {
throw new CellBaseServerException(e.getMessage());
}
}

private void init() throws IOException, CellBaseException {
private synchronized void init() throws IOException, CellBaseException {
// we need to make sure we only init one single time
if (INITIALIZED.compareAndSet(false, true)) {
if (!INITIALIZED.get()) {
SERVICE_START_DATE = new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime());
WATCH = new StopWatch();
WATCH.start();
Expand Down Expand Up @@ -159,19 +161,21 @@ private void init() throws IOException, CellBaseException {
cellBaseManagerFactory = new CellBaseManagerFactory(cellBaseConfiguration);
logger.info("***************************************************");

// Get default API key (for anonymous queries)
if (apiKeyManager == null) {
apiKeyManager = new ApiKeyManager(cellBaseConfiguration.getSecretKey());
defaultApiKey = apiKeyManager.getDefaultApiKey();
logger.info("default API key {}", defaultApiKey);
}

// Initialize Monitor
monitor = new Monitor(cellBaseManagerFactory.getMetaManager());

INITIALIZED.set(true);
}
}

private void initQuery() throws CellBaseException {
// Get default API key (for anonymous queries)
if (apiKeyManager == null) {
apiKeyManager = new ApiKeyManager(cellBaseConfiguration.getSecretKey());
defaultApiKey = apiKeyManager.getDefaultApiKey();
logger.info("default API key {}", defaultApiKey);
}

startTime = System.currentTimeMillis();
query = new Query();
uriParams = convertMultiToMap(uriInfo.getQueryParameters());
Expand All @@ -184,12 +188,10 @@ private void initQuery() throws CellBaseException {

// Set default API key, if necessary
String apiKey = uriParams.getOrDefault(API_KEY_PARAM, null);
logger.info("Before checking, API key {}", apiKey);
if (StringUtils.isEmpty(apiKey)) {
apiKey = defaultApiKey;
uriParams.put(API_KEY_PARAM, apiKey);
}
logger.info("After checking, API key {}", uriParams.get(API_KEY_PARAM));

checkLimit();

Expand Down Expand Up @@ -228,11 +230,6 @@ protected int getDataRelease() throws CellBaseException {
throw new CellBaseException("Invalid data release number '" + uriParams.get(DATA_RELEASE_PARAM) + "'");
}
}
// If no data release is present in the query, then use the default data release
if (!DONT_CHECK_SPECIES.equals(species)) {
logger.info("No data release present in query: using the default data release '" + defaultDataRelease + "' for CellBase version"
+ " '" + version + "'");
}
return defaultDataRelease;
}

Expand Down Expand Up @@ -273,7 +270,8 @@ private void checkVersion() throws CellBaseException {
}

private void checkApiKey() throws CellBaseException {
if (!uriInfo.getPath().contains("health")) {
// Update the API key content only for non-meta endpoints
if (!uriInfo.getPath().contains("/meta/")) {
String apiKey = getApiKey();
ApiKeyJwtPayload payload = apiKeyManager.decode(apiKey);

Expand Down Expand Up @@ -414,7 +412,7 @@ protected Response createOkResponse(Object obj) {

// Update API key stats, if necessary
try {
if (!uriInfo.getPath().contains("health")) {
if (!uriInfo.getPath().contains("/meta/")) {
String apiKey = getApiKey();
MetaManager metaManager = cellBaseManagerFactory.getMetaManager();
long bytes = (jsonResponse.getEntity() != null) ? jsonResponse.getEntity().toString().length() : 0;
Expand Down
21 changes: 11 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>5.9.0-SNAPSHOT</version>
<version>6.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>CellBase project</name>
Expand All @@ -23,18 +23,20 @@

<properties>
<pycellbase.version>${project.version}</pycellbase.version>
<java-common-libs.version>4.13.0-SNAPSHOT</java-common-libs.version>
<biodata.version>2.13.0-SNAPSHOT</biodata.version>
<java-common-libs.version>5.0.0-SNAPSHOT</java-common-libs.version>
<biodata.version>3.0.0-SNAPSHOT</biodata.version>
<bionetdb.version>0.1.0</bionetdb.version>
<jackson.version>2.11.4</jackson.version>
<jackson-asl.version>1.9.13</jackson-asl.version>
<jetty.version>9.4.51.v20230217</jetty.version>

<jackson.version>2.14.3</jackson.version>
<commons-lang3.version>3.14.0</commons-lang3.version>
<slf4j.version>1.7.36</slf4j.version>

<jersey.version>2.30.1</jersey.version>
<slf4j.version>1.7.32</slf4j.version>
<log4j.version>2.17.2</log4j.version>
<junit.platform.version>1.5.2</junit.platform.version>
<junit.jupiter.version>5.5.2</junit.jupiter.version>
<jacoco.version>0.8.8</jacoco.version>
<jetty.version>9.4.17.v20190418</jetty.version>
<jjwt.version>0.11.5</jjwt.version>
<swagger-annotations.version>1.6.5</swagger-annotations.version>
<javax.servlet-api.version>3.1.0</javax.servlet-api.version>
Expand All @@ -50,7 +52,6 @@
<grpc.version>1.48.0</grpc.version>
<commons-lang.version>2.4</commons-lang.version>
<commons-io.version>2.4</commons-io.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<jakarta.ws.rs-api.version>2.1.6</jakarta.ws.rs-api.version>
<commons-collections4.version>4.4</commons-collections4.version>
<jcommander.version>1.69</jcommander.version>
Expand Down Expand Up @@ -412,11 +413,11 @@
<artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations.version}</version>
</dependency>
<dependency>
<!-- <dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>${jackson-asl.version}</version>
</dependency>
</dependency>-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
Expand Down

0 comments on commit ffdf27a

Please sign in to comment.