Skip to content

Commit

Permalink
Merge pull request #91 from molgenis/feat/relative_paths
Browse files Browse the repository at this point in the history
Relative file paths are relative to tree file directory
  • Loading branch information
bartcharbon authored Aug 20, 2024
2 parents 2b6a059 + 44a0eda commit c1826fd
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 155 deletions.
305 changes: 153 additions & 152 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,170 +1,171 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<groupId>org.molgenis</groupId>
<artifactId>vip-decision-tree</artifactId>
<version>4.1.1</version>
<groupId>org.molgenis</groupId>
<artifactId>vip-decision-tree</artifactId>
<version>4.1.2</version>

<name>vip-decision-tree</name>
<description>Decision tree module for filtering and labelling VCF files</description>
<name>vip-decision-tree</name>
<description>Decision tree module for filtering and labelling VCF files</description>

<licenses>
<license>
<name>The GNU Lesser General Public License, Version 3.0</name>
<url>http://www.gnu.org/licenses/lgpl-3.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<licenses>
<license>
<name>The GNU Lesser General Public License, Version 3.0</name>
<url>http://www.gnu.org/licenses/lgpl-3.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<connection>scm:git:git://github.com/molgenis/vip-decision-tree.git</connection>
<developerConnection>scm:git:ssh://git@github.com/molgenis/vip-decision-tree.git
</developerConnection>
<url>https://github.com/molgenis/vip-decision-tree</url>
</scm>
<scm>
<connection>scm:git:git://github.com/molgenis/vip-decision-tree.git</connection>
<developerConnection>scm:git:ssh://git@github.com/molgenis/vip-decision-tree.git
</developerConnection>
<url>https://github.com/molgenis/vip-decision-tree</url>
</scm>

<issueManagement>
<system>GitHub</system>
<url>https://github.com/molgenis/vip-decision-tree/issues</url>
</issueManagement>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/molgenis/vip-decision-tree/issues</url>
</issueManagement>

<properties>
<java.version>17</java.version>
<commons.cli.version>1.6.0</commons.cli.version>
<samtools.htsjdk.version>4.1.0</samtools.htsjdk.version>
<jacoco-maven-plugin.version>0.8.11</jacoco-maven-plugin.version>
<vip.utils.version>2.0.0</vip.utils.version>
</properties>
<properties>
<java.version>17</java.version>
<commons.cli.version>1.6.0</commons.cli.version>
<samtools.htsjdk.version>4.1.0</samtools.htsjdk.version>
<jacoco-maven-plugin.version>0.8.11</jacoco-maven-plugin.version>
<vip.utils.version>2.0.0</vip.utils.version>
</properties>

<profiles>
<profile>
<id>coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<profiles>
<profile>
<id>coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.molgenis</groupId>
<artifactId>vip-utils</artifactId>
<version>${vip.utils.version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>${commons.cli.version}</version>
</dependency>
<dependency>
<groupId>com.github.samtools</groupId>
<artifactId>htsjdk</artifactId>
<version>${samtools.htsjdk.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.molgenis</groupId>
<artifactId>vip-utils</artifactId>
<version>${vip.utils.version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>${commons.cli.version}</version>
</dependency>
<dependency>
<groupId>com.github.samtools</groupId>
<artifactId>htsjdk</artifactId>
<version>${samtools.htsjdk.version}</version>
</dependency>
<dependency>
<groupId>org.molgenis</groupId>
<artifactId>vip-utils</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.github.samtools</groupId>
<artifactId>htsjdk</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.molgenis</groupId>
<artifactId>vip-utils</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.github.samtools</groupId>
<artifactId>htsjdk</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>vcf-decision-tree</finalName>

<build>
<finalName>vcf-decision-tree</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-Xlint</arg>
<arg>-Xlint:-processing
</arg><!-- disable: perfectly normal for annotations to not have a processor -->
</compilerArgs>
</configuration>
</plugin>
</plugins>
</pluginManagement>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-Xlint</arg>
<arg>-Xlint:-processing</arg><!-- disable: perfectly normal for annotations to not have a processor -->
</compilerArgs>
</configuration>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<!-- By default provided dependencies are included -->
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
</plugins>
</build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<!-- By default provided dependencies are included -->
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ConfigDecisionTree load(Path decisionTreeConfigPath) {
ObjectMapper mapper = new ObjectMapper();
SimpleModule module = new SimpleModule();
module.addDeserializer(ConfigNode.class, new ConfigNodeDeserializer());
module.addDeserializer(Path.class, new PathDeserializer());
module.addDeserializer(Path.class, new PathDeserializer(decisionTreeConfigPath));
mapper.registerModule(module);

ConfigDecisionTree configDecisionTree;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,24 @@
import java.io.IOException;
import java.nio.file.Path;

import static java.util.Objects.requireNonNull;

public class PathDeserializer extends JsonDeserializer<Path> {
private final Path rootPath;

public PathDeserializer(Path decisionTreeConfigPath) {
this.rootPath = requireNonNull(decisionTreeConfigPath);
}

@Override
public Path deserialize(JsonParser jp, DeserializationContext context) throws IOException {
ObjectCodec objectCodec = jp.getCodec();
ObjectNode root = objectCodec.readTree(jp);
String pathString = root.get("path").asText();
return Path.of(pathString);
Path path = Path.of(pathString);
if (!path.isAbsolute()) {
path = Path.of(rootPath.getParent().toString(), pathString).normalize();
}
return path;
}
}
2 changes: 1 addition & 1 deletion src/test/resources/example.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"files": {
"clinvar" : {
"path" : "src/test/resources/clinvar.txt"
"path" : "clinvar.txt"
}
},
"rootNode": "filter",
Expand Down

0 comments on commit c1826fd

Please sign in to comment.