-
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.
Remove dependency on field_metadata.json (#49)
* chore:remove dependency on field_metadata.json * chore:bump vip-utils 1.4.5 to 1.4.6, bump version 3.0.1 to 3.0.2 * fix VepMetadataServiceFactoryImpl
- Loading branch information
1 parent
c0f1fea
commit 0212380
Showing
9 changed files
with
171 additions
and
45 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
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
7 changes: 7 additions & 0 deletions
7
src/main/java/org/molgenis/vcf/inheritance/matcher/util/InheritanceServiceFactory.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,7 @@ | ||
package org.molgenis.vcf.inheritance.matcher.util; | ||
|
||
import org.molgenis.vcf.inheritance.matcher.InheritanceService; | ||
|
||
public interface InheritanceServiceFactory { | ||
InheritanceService create(); | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/org/molgenis/vcf/inheritance/matcher/util/InheritanceServiceFactoryImpl.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,29 @@ | ||
package org.molgenis.vcf.inheritance.matcher.util; | ||
|
||
import org.molgenis.vcf.inheritance.matcher.Annotator; | ||
import org.molgenis.vcf.inheritance.matcher.InheritanceService; | ||
import org.molgenis.vcf.inheritance.matcher.PedigreeInheritanceChecker; | ||
import org.springframework.stereotype.Component; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
/** | ||
* Quirky class to enable use of local {@link org.molgenis.vcf.utils.vep.VepMetadataService} | ||
*/ | ||
@Component | ||
public class InheritanceServiceFactoryImpl implements InheritanceServiceFactory { | ||
private final Annotator annotator; | ||
private final VepMetadataServiceFactory vepMetadataServiceFactory; | ||
private final PedigreeInheritanceChecker pedigreeInheritanceChecker; | ||
|
||
public InheritanceServiceFactoryImpl(Annotator annotator, VepMetadataServiceFactory vepMetadataServiceFactory, PedigreeInheritanceChecker pedigreeInheritanceChecker) { | ||
this.annotator = requireNonNull(annotator); | ||
this.vepMetadataServiceFactory = requireNonNull(vepMetadataServiceFactory); | ||
this.pedigreeInheritanceChecker = requireNonNull(pedigreeInheritanceChecker); | ||
} | ||
|
||
@Override | ||
public InheritanceService create() { | ||
return new InheritanceService(annotator, vepMetadataServiceFactory.create(), pedigreeInheritanceChecker); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/org/molgenis/vcf/inheritance/matcher/util/VepMetadataServiceFactory.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,7 @@ | ||
package org.molgenis.vcf.inheritance.matcher.util; | ||
|
||
import org.molgenis.vcf.utils.metadata.FieldMetadataService; | ||
|
||
public interface VepMetadataServiceFactory { | ||
FieldMetadataService create(); | ||
} |
47 changes: 47 additions & 0 deletions
47
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
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.springframework.stereotype.Component; | ||
|
||
import java.io.ByteArrayInputStream; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
|
||
/** | ||
* Quirky class to enable reuse of {@link VepMetadataService} 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); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...est/java/org/molgenis/vcf/inheritance/matcher/util/InheritanceServiceFactoryImplTest.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,31 @@ | ||
package org.molgenis.vcf.inheritance.matcher.util; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.molgenis.vcf.inheritance.matcher.Annotator; | ||
import org.molgenis.vcf.inheritance.matcher.PedigreeInheritanceChecker; | ||
|
||
import static org.mockito.Mockito.verify; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class InheritanceServiceFactoryImplTest { | ||
@Mock | ||
private Annotator annotator; | ||
@Mock | ||
private VepMetadataServiceFactory vepMetadataServiceFactory; | ||
@Mock | ||
private PedigreeInheritanceChecker pedigreeInheritanceChecker; | ||
private InheritanceServiceFactoryImpl inheritanceServiceFactoryImpl; | ||
@BeforeEach | ||
void setUp() { | ||
inheritanceServiceFactoryImpl = new InheritanceServiceFactoryImpl(annotator, vepMetadataServiceFactory, pedigreeInheritanceChecker); | ||
} | ||
@Test | ||
void create() { | ||
inheritanceServiceFactoryImpl.create(); | ||
verify(vepMetadataServiceFactory).create(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...est/java/org/molgenis/vcf/inheritance/matcher/util/VepMetadataServiceFactoryImplTest.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,19 @@ | ||
package org.molgenis.vcf.inheritance.matcher.util; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class VepMetadataServiceFactoryImplTest { | ||
private VepMetadataServiceFactoryImpl vepMetadataServiceFactoryImpl; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
vepMetadataServiceFactoryImpl = new VepMetadataServiceFactoryImpl(); | ||
} | ||
|
||
@Test | ||
void create() { | ||
// test that no exception is thrown | ||
vepMetadataServiceFactoryImpl.create(); | ||
} | ||
} |