@Override public VariantFileMetadata readVariantFileMetadata(URI input) throws StorageEngineException { VariantFileMetadata source; if (input.getScheme() == null || input.getScheme().startsWith("file")) { return VariantReaderUtils.readVariantFileMetadata(Paths.get(input.getPath()), null); } Path metaPath = new Path(VariantReaderUtils.getMetaFromTransformedFile(input.toString())); FileSystem fs = null; try { fs = FileSystem.get(conf); } catch (IOException e) { throw new StorageEngineException("Unable to get FileSystem", e); } try ( InputStream inputStream = new GZIPInputStream(fs.open(metaPath)) ) { source = VariantReaderUtils.readVariantFileMetadataFromJson(inputStream); } catch (IOException e) { throw new StorageEngineException("Unable to read VariantFileMetadata", e); } return source; } }
@Override public boolean pre() { if (metadataPath != null) { Files.exists(metadataPath); try (InputStream inputStream = FileUtils.newInputStream(metadataPath)) { // Read global JSON file and copy its info into the already available VariantSource object VariantFileMetadata readMetadata = VariantReaderUtils.readVariantFileMetadataFromJson(inputStream); fileMetadata.setId(readMetadata.getId()); fileMetadata.setPath(readMetadata.getPath()); fileMetadata.setHeader(readMetadata.getHeader()); fileMetadata.setSamplesPosition(readMetadata.getSamplesPosition()); fileMetadata.setStats(readMetadata.getStats()); } catch (IOException ex) { throw new UncheckedIOException(ex); } } if (fileMetadata != null) { Map<String, Integer> samplesPosition = fileMetadata.getSamplesPosition(); this.samplesPosition = new LinkedHashMap<>(samplesPosition.size()); String[] samples = new String[samplesPosition.size()]; for (Map.Entry<String, Integer> entry : samplesPosition.entrySet()) { samples[entry.getValue()] = entry.getKey(); } for (int i = 0; i < samples.length; i++) { this.samplesPosition.put(samples[i], i); } } return true; }
return VariantReaderUtils.readVariantFileMetadataFromJson(inputStream); } catch (IOException | RuntimeException e) { throw new StorageEngineException("Unable to read VariantSource", e);