Skip to content

Commit

Permalink
Major refactoring: split core and lib libraris
Browse files Browse the repository at this point in the history
  • Loading branch information
imedina committed Oct 21, 2020
1 parent 0b5e6ae commit 07a5f5c
Show file tree
Hide file tree
Showing 51 changed files with 459 additions and 117 deletions.
2 changes: 1 addition & 1 deletion bionetdb-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependencies>
<dependency>
<groupId>org.opencb.bionetdb</groupId>
<artifactId>bionetdb-core</artifactId>
<artifactId>bionetdb-lib</artifactId>
</dependency>
<dependency>
<groupId>org.opencb.bionetdb</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParameterDescription;
import com.beust.jcommander.ParameterException;
import org.opencb.bionetdb.core.BioNetDbManager;
import org.opencb.bionetdb.lib.BioNetDbManager;

import java.io.InputStream;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.apache.commons.lang.StringUtils;
import org.opencb.bionetdb.app.cli.CommandExecutor;
import org.opencb.bionetdb.app.cli.admin.AdminCliOptionsParser;
import org.opencb.bionetdb.core.BioNetDbManager;
import org.opencb.bionetdb.lib.BioNetDbManager;
import org.opencb.bionetdb.core.exceptions.BioNetDBException;
import org.opencb.commons.utils.FileUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import org.opencb.bionetdb.app.cli.main.BioNetDBCliOptionsParser;
import org.opencb.bionetdb.app.cli.CommandExecutor;
import org.opencb.bionetdb.core.api.NetworkDBAdaptor;
import org.opencb.bionetdb.lib.api.NetworkDBAdaptor;
import org.opencb.bionetdb.core.exceptions.BioNetDBException;
import org.opencb.bionetdb.core.io.ExpressionParser;
import org.opencb.bionetdb.core.models.Expression;
import org.opencb.bionetdb.core.neo4j.Neo4JNetworkDBAdaptor;
import org.opencb.bionetdb.lib.db.Neo4JNetworkDBAdaptor;
import org.opencb.commons.utils.FileUtils;
import org.opencb.commons.datastore.core.QueryOptions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import org.apache.commons.lang3.StringUtils;
import org.opencb.bionetdb.app.cli.CommandExecutor;
import org.opencb.bionetdb.app.cli.main.BioNetDBCliOptionsParser;
import org.opencb.bionetdb.core.api.NetworkDBAdaptor;
import org.opencb.bionetdb.lib.api.NetworkDBAdaptor;
import org.opencb.bionetdb.core.config.DatabaseConfiguration;
import org.opencb.bionetdb.core.neo4j.Neo4JNetworkDBAdaptor;
import org.opencb.bionetdb.lib.db.Neo4JNetworkDBAdaptor;
import org.opencb.commons.datastore.core.Query;
import org.opencb.commons.datastore.core.QueryOptions;
import org.opencb.commons.datastore.core.QueryResult;
Expand Down
51 changes: 51 additions & 0 deletions bionetdb-client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>bionetdb</artifactId>
<groupId>org.opencb.bionetdb</groupId>
<version>0.2.0-SNAPSHOT</version>
</parent>

<artifactId>bionetdb-client</artifactId>
<version>${bionetdb.version}</version>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.opencb.bionetdb</groupId>
<artifactId>bionetdb-core</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Copyright 2015-2020 OpenCB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.opencb.bionetdb.client.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
* Created by imedina on 12/05/16.
*/
public class ClientConfiguration {

private String version;
private String logLevel;
private RestConfig rest;

public ClientConfiguration() {
}

public static ClientConfiguration load(InputStream configurationInputStream) throws IOException {
return load(configurationInputStream, "YAML");
}

public static ClientConfiguration load(InputStream configurationInputStream, String format)
throws IOException {
ClientConfiguration clientConfiguration;
ObjectMapper objectMapper;
switch (format.toUpperCase()) {
case "JSON":
objectMapper = new ObjectMapper();
clientConfiguration = objectMapper.readValue(configurationInputStream, ClientConfiguration.class);
break;
case "YML":
case "YAML":
default:
objectMapper = new ObjectMapper(new YAMLFactory());
clientConfiguration = objectMapper.readValue(configurationInputStream, ClientConfiguration.class);
break;
}

return clientConfiguration;
}

public void serialize(OutputStream configurationOutputStream) throws IOException {
ObjectMapper jsonMapper = new ObjectMapper(new YAMLFactory());
jsonMapper.writerWithDefaultPrettyPrinter().writeValue(configurationOutputStream, this);
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("ClientConfiguration{");
sb.append("version='").append(version).append('\'');
sb.append(", logLevel='").append(logLevel).append('\'');
sb.append(", rest=").append(rest);
sb.append('}');
return sb.toString();
}

public String getVersion() {
return version;
}

public ClientConfiguration setVersion(String version) {
this.version = version;
return this;
}

public String getLogLevel() {
return logLevel;
}

public ClientConfiguration setLogLevel(String logLevel) {
this.logLevel = logLevel;
return this;
}

public RestConfig getRest() {
return rest;
}

public ClientConfiguration setRest(RestConfig rest) {
this.rest = rest;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright 2015-2020 OpenCB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.opencb.bionetdb.client.config;

/**
* Created by imedina on 04/05/16.
*/
public class RestConfig {

private String host;
private int timeout;

public RestConfig() {
}

public RestConfig(String host, int timeout) {
this.host = host;
this.timeout = timeout;
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("RestConfig{");
sb.append("host=").append(host);
sb.append(", timeout=").append(timeout);
sb.append('}');
return sb.toString();
}

public String getHosts() {
return host;
}

public RestConfig setHosts(String host) {
this.host = host;
return this;
}

public int getTimeout() {
return timeout;
}

public RestConfig setTimeout(int timeout) {
this.timeout = timeout;
return this;
}
}
Empty file.
8 changes: 8 additions & 0 deletions bionetdb-client/src/main/resources/client-configuration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
version: "v1"

## These are the RESTful configurations parameters
rest:
host: "localhost:8080/bionetdb"
timeout: 2000

17 changes: 10 additions & 7 deletions bionetdb-core/src/main/resources/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@ logFile: null

## More than one database can be defined, you can pass the database id to BioNetDbManager.
## If not passed the default database will always be the first one.
databases:
- id: "${BIONETDB.DB.DATABASE}"
species: "${BIONETDB.DB.SPECIES}" ## examples: hsapiens, mmusculus, ...
database:
host: "${BIONETDB.DB.HOST}"
port: "${BIONETDB.DB.PORT}"
user: "${BIONETDB.DB.USER}"
password: "${BIONETDB.DB.PASSWORD}"
options: null ## map containing specific database options
# options: null ## map containing specific database options


## Raw data download URLs
download:
network:
## In this version we are loading Ractome as default network
host: https://www.reactome.org/download/current/biopax.zip
gene:
host: http://bioinfo.hpc.cam.ac.uk/downloads/cellbase/v5/homo_sapiens_grch38/build/gene.json.gz
protein:
host: http://bioinfo.hpc.cam.ac.uk/downloads/cellbase/v5/homo_sapiens_grch38/build/protein.json.gz
## panel:
## host: ftp://mirbase.org/pub/mirbase/CURRENT/miRNA.xls.gz
clinvar:
clinicalVariant:
host: http://bioinfo.hpc.cam.ac.uk/downloads/cellbase/v5/homo_sapiens_grch38/build/clinical_variants.json.gz
reactome:
host: https://www.reactome.org/download/current/biopax.zip

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.opencb.bionetdb.core.neo4j.query;

import org.junit.Test;
import org.opencb.bionetdb.core.api.query.VariantQueryParam;
import org.opencb.bionetdb.core.api.query.NetworkPathQuery;
import org.opencb.bionetdb.core.api.query.NodeQuery;
import org.opencb.bionetdb.lib.api.iterators.query.VariantQueryParam;
import org.opencb.bionetdb.lib.api.iterators.query.NetworkPathQuery;
import org.opencb.bionetdb.lib.api.iterators.query.NodeQuery;
import org.opencb.bionetdb.core.models.network.Node;
import org.opencb.commons.datastore.core.Query;
import org.opencb.commons.datastore.core.QueryOptions;
Expand Down
Loading

0 comments on commit 07a5f5c

Please sign in to comment.