-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
420f1b4
commit 1c062b1
Showing
7 changed files
with
74 additions
and
43 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
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
41 changes: 10 additions & 31 deletions
41
src/main/java/org/molgenis/vcf/inheritance/matcher/util/VepMetadataServiceFactoryImpl.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 |
---|---|---|
@@ -1,47 +1,26 @@ | ||
package org.molgenis.vcf.inheritance.matcher.util; | ||
|
||
import htsjdk.variant.vcf.VCFInfoHeaderLine; | ||
import org.molgenis.vcf.utils.metadata.FieldMetadataService; | ||
import org.molgenis.vcf.utils.metadata.AbstractFieldMetadataService; | ||
import org.molgenis.vcf.utils.model.FieldMetadata; | ||
import org.molgenis.vcf.utils.vep.VepMetadataService; | ||
import org.molgenis.vcf.utils.metadata.FieldMetadataServiceImpl; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.util.ResourceUtils; | ||
|
||
import java.io.ByteArrayInputStream; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
import java.io.*; | ||
|
||
/** | ||
* Quirky class to enable reuse of {@link VepMetadataService} from vip-utils | ||
* Quirky class to enable reuse of {@link FieldMetadataService} from vip-utils | ||
*/ | ||
@Component | ||
public class VepMetadataServiceFactoryImpl implements VepMetadataServiceFactory { | ||
|
||
@Override | ||
public FieldMetadataService create() { | ||
return new VepMetadataService(new EmptyFieldMetadataService()); | ||
} | ||
|
||
/** | ||
* vip-inheritance-matcher does not require knowledge of custom VEP metadata | ||
*/ | ||
static class EmptyFieldMetadataService extends AbstractFieldMetadataService { | ||
private static final String EMPTY_METADATA_JSON = """ | ||
{ | ||
"format": { | ||
}, | ||
"info": { | ||
"CSQ": { | ||
"nestedFields": { | ||
} | ||
} | ||
} | ||
} | ||
"""; | ||
|
||
@Override | ||
public FieldMetadata load(VCFInfoHeaderLine vcfInfoHeaderLine) { | ||
return this.load(new ByteArrayInputStream(EMPTY_METADATA_JSON.getBytes(UTF_8)), vcfInfoHeaderLine); | ||
File json; | ||
try { | ||
json = ResourceUtils.getFile("classpath:metadata.json"); | ||
} catch (FileNotFoundException e) { | ||
throw new UncheckedIOException(e); | ||
} | ||
return new FieldMetadataServiceImpl(json); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/org/molgenis/vcf/inheritance/matcher/vcf/meta/MissingVepMetadataException.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,14 @@ | ||
package org.molgenis.vcf.inheritance.matcher.vcf.meta; | ||
|
||
import java.io.Serial; | ||
|
||
import static java.lang.String.format; | ||
|
||
public class MissingVepMetadataException extends RuntimeException { | ||
@Serial | ||
private static final long serialVersionUID = 1L; | ||
|
||
public MissingVepMetadataException(String field) { | ||
super(format("VEP metadata is missing in metadata json, vep id: '%s'.", field)); | ||
} | ||
} |
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
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,10 @@ | ||
{ | ||
"format": { | ||
}, | ||
"info": { | ||
"CSQ": { | ||
"nestedFields": { | ||
} | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/java/org/molgenis/vcf/inheritance/matcher/MissingVepMetadataExceptionTest.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,16 @@ | ||
package org.molgenis.vcf.inheritance.matcher; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.molgenis.vcf.inheritance.matcher.vcf.meta.MissingVepMetadataException; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class MissingVepMetadataExceptionTest { | ||
|
||
@Test | ||
void getMessage() { | ||
assertEquals( | ||
"VEP metadata is missing in metadata json, vep id: 'CSQ'.", | ||
new MissingVepMetadataException("CSQ").getMessage()); | ||
} | ||
} |