Skip to content

Commit

Permalink
Fixed bug when using aggregate mapping from resources folder (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmmut authored and Cristina Yenyxe Gonzalez Garcia committed Feb 28, 2017
1 parent 6056c72 commit 3225152
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/uk/ac/ebi/eva/utils/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 3225152

Please sign in to comment.