-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Wishartlab-openscience/javaloadable-api
Javaloadable api
- Loading branch information
Showing
6 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
# biotransformer-apis | ||
A library that provides APIs to facilitate the integration of various libraries into BioTransformer. | ||
This repository contains the Predictor Model Interface which every Java Loadable prediction application should implement. | ||
|
||
<br> | ||
|
||
To add this to your project - | ||
1. Build the project. | ||
2. Create a lib/ folder outside of src/ in your application. | ||
3. Put the biotransformer-api.jar in the the lib/ folder. | ||
4. Run Maven Goal - | ||
mvn org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile=lib/biotransformer-api.jar -DgroupId=biotransformer -DartifactId=biotransformer-api -Dversion=1.0.0 -Dpackaging=jar | ||
5. This would install the jar in your local .m2 directory. | ||
6. Implement the interface now. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?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> | ||
|
||
<groupId>biotransformer</groupId> | ||
<artifactId>biotransformer-apis</artifactId> | ||
<version>1.0.0</version> | ||
|
||
<properties> | ||
<jdk.version>8</jdk.version> | ||
<maven.compiler.source>${jdk.version}</maven.compiler.source> | ||
<maven.compiler.target>${jdk.version}</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<start-class>Main.java</start-class> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.kie.modules</groupId> | ||
<artifactId>org-apache-commons-lang3</artifactId> | ||
<version>6.5.0.Final</version> | ||
<type>pom</type> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<finalName>biotransformer-apis</finalName> | ||
<resources> | ||
<!-- | ||
<resource> | ||
<directory>src/main/resources/database</directory> | ||
</resource> | ||
<resource> | ||
<directory>src/main/resources/supportfiles</directory> | ||
</resource> | ||
--> | ||
</resources> | ||
|
||
<plugins> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.12.4</version> | ||
<configuration> | ||
<skipTests>true</skipTests> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<version>3.1.1</version> | ||
<configuration> | ||
<!-- get all project dependencies --> | ||
<appendAssemblyId>false</appendAssemblyId> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
<!-- MainClass in mainfest make a executable jar --> | ||
<archive> | ||
<manifest> | ||
<mainClass>executable.BiotransformerExecutable</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>make-assembly</id> | ||
<phase>package</phase> <!-- bind to the packaging phase --> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-site-plugin</artifactId> | ||
<version>3.7.1</version> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-project-info-reports-plugin</artifactId> | ||
<version>3.0.0</version> | ||
</plugin> | ||
</plugins> | ||
|
||
</build> | ||
</project> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
|
||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/biotransformerapis/predictors/BioTransformerAPIs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package biotransformerapis.predictors; | ||
|
||
import java.util.LinkedHashMap; | ||
|
||
public interface BioTransformerAPIs { | ||
|
||
public Object predict (LinkedHashMap<String, Object> inputParameters) throws Exception; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package utils; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.LinkedHashMap; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
public class Validator { | ||
|
||
public enum ioFormats{ | ||
SDFILE, IATOMCONTAINERSET | ||
} | ||
LinkedHashMap<String, ArrayList<String>> validParams = new LinkedHashMap<String, ArrayList<String>>(); | ||
|
||
public Validator() { | ||
ArrayList<String> required = new ArrayList<String>(); | ||
ArrayList<String> optional = new ArrayList<String>(); | ||
required.add("input"); | ||
required.add("inputFormat"); | ||
required.add("outputFormat"); | ||
optional.add("output"); | ||
this.validParams.put("required", required); | ||
this.validParams.put("optional", required); | ||
} | ||
|
||
public Boolean validateParameters(LinkedHashMap<String, Object> parameters) throws Exception { | ||
Boolean isValid = true; | ||
|
||
for(String requiredParam : validParams.get("required")) { | ||
if(!parameters.containsKey(requiredParam)) { | ||
throw new IOException("The required parameter \'" + requiredParam + "\' is missing. Please provide an adequate value."); | ||
} | ||
} | ||
|
||
|
||
ioFormats inputFormat = ioFormats.valueOf( StringUtils.upperCase( (String) parameters.get("inputFormat") )) ; | ||
ioFormats outputFormat = ioFormats.valueOf( StringUtils.upperCase( (String) parameters.get("outputFormat") )) ; | ||
|
||
|
||
if(!Arrays.asList(ioFormats.values()).contains(inputFormat)) { | ||
isValid = false; | ||
throw new IOException("The provided input \'" + inputFormat + "\' format is not support by PhaseIIFilter"); | ||
} | ||
if(!Arrays.asList(ioFormats.values()).contains(outputFormat)) { | ||
isValid = false; | ||
throw new IOException("The provided output \'" + inputFormat + "\' format is not support by PhaseIIFilter"); | ||
} | ||
|
||
if(inputFormat == ioFormats.SDFILE) { | ||
File inputFile = new File((String) parameters.get("input")); | ||
if((!inputFile.exists()) || inputFile.isDirectory()) { | ||
isValid = false; | ||
throw new IOException("A pathname to the input file is missing. Please provide a pathname to the input file"); | ||
|
||
} | ||
} | ||
|
||
if(outputFormat == ioFormats.SDFILE && !parameters.containsKey("output")) { | ||
isValid = false; | ||
throw new IOException("A pathname to the output file is missing. Please provide a pathname to the output file"); | ||
} | ||
|
||
return isValid; | ||
} | ||
} |