diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/AggregatedVcfLineMapper.java b/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/AggregatedVcfLineMapper.java index 13612b730..d7dbc9482 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/AggregatedVcfLineMapper.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/AggregatedVcfLineMapper.java @@ -21,6 +21,7 @@ import uk.ac.ebi.eva.commons.models.data.Variant; import uk.ac.ebi.eva.utils.FileUtils; +import java.io.FileInputStream; import java.io.IOException; import java.util.List; import java.util.Properties; @@ -49,7 +50,7 @@ public AggregatedVcfLineMapper(String fileId, String studyId, VariantSource.Aggr Properties mappings = null; if(mappingFilePath!=null){ - mappings = FileUtils.getPropertiesFile(mappingFilePath); + mappings = FileUtils.getPropertiesFile(new FileInputStream(mappingFilePath)); } switch (aggregation) { diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/VariantVcfEVSFactory.java b/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/VariantVcfEVSFactory.java index 38821c68b..64731e354 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/VariantVcfEVSFactory.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/VariantVcfEVSFactory.java @@ -16,14 +16,11 @@ */ package uk.ac.ebi.eva.pipeline.io.mappers; -import org.opencb.biodata.models.variant.VariantSource; - import uk.ac.ebi.eva.commons.models.data.Variant; import uk.ac.ebi.eva.commons.models.data.VariantSourceEntry; import uk.ac.ebi.eva.commons.models.data.VariantStats; import uk.ac.ebi.eva.utils.FileUtils; -import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Set; @@ -68,7 +65,7 @@ public VariantVcfEVSFactory(Properties tagMap) { @Override protected void loadDefaultMappings() { try { - loadMappings(FileUtils.getPropertiesFile(FileUtils.getResource(EVS_MAPPING_FILE).getAbsolutePath())); + loadMappings(FileUtils.getPropertiesFile(FileUtils.getResourceAsStream(EVS_MAPPING_FILE))); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/VariantVcfExacFactory.java b/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/VariantVcfExacFactory.java index ec30a5351..3de6ef2b4 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/VariantVcfExacFactory.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/VariantVcfExacFactory.java @@ -17,14 +17,12 @@ package uk.ac.ebi.eva.pipeline.io.mappers; import org.opencb.biodata.models.feature.Genotype; -import org.opencb.biodata.models.variant.VariantSource; import uk.ac.ebi.eva.commons.models.data.Variant; import uk.ac.ebi.eva.commons.models.data.VariantSourceEntry; import uk.ac.ebi.eva.commons.models.data.VariantStats; import uk.ac.ebi.eva.utils.FileUtils; -import java.io.File; import java.io.IOException; import java.util.LinkedHashMap; import java.util.Map; @@ -80,7 +78,7 @@ public VariantVcfExacFactory(Properties tagMap) { @Override protected void loadDefaultMappings() { try { - loadMappings(FileUtils.getPropertiesFile(FileUtils.getResource(EXAC_MAPPING_FILE).getAbsolutePath())); + loadMappings(FileUtils.getPropertiesFile(FileUtils.getResourceAsStream(EXAC_MAPPING_FILE))); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/src/main/java/uk/ac/ebi/eva/utils/FileUtils.java b/src/main/java/uk/ac/ebi/eva/utils/FileUtils.java index 4b030431b..c5b315b28 100644 --- a/src/main/java/uk/ac/ebi/eva/utils/FileUtils.java +++ b/src/main/java/uk/ac/ebi/eva/utils/FileUtils.java @@ -22,7 +22,6 @@ import uk.ac.ebi.eva.pipeline.io.GzipLazyResource; import java.io.File; -import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -66,10 +65,13 @@ public static File getResource(String resourcePath) { return new File(FileUtils.class.getResource(resourcePath).getFile()); } - public static Properties getPropertiesFile(String propertiesFilePath) throws IOException { - InputStream input = new FileInputStream(propertiesFilePath); + public static InputStream getResourceAsStream(String resourcePath) { + return FileUtils.class.getResourceAsStream(resourcePath); + } + + public static Properties getPropertiesFile(InputStream propertiesInputStream) throws IOException { Properties properties = new Properties(); - properties.load(input); + properties.load(propertiesInputStream); return properties; } }