in S3HtsjdkPlugin/src/main/java/com/epam/cmbi/s3/IndexLoader.java [57:81]
Optional<SeekableStream> loadIndex(AmazonS3URI bamURI) throws IOException {
LOG.info("Trying to set index file for " + bamURI.toString());
Optional<AmazonS3URI> index = providedIndexURI()
.map(Optional::of)
.orElseGet(() -> nearbyIndexURI(bamURI));
if (!index.isPresent()) {
LOG.info("Index wasn't provided for " + bamURI.toString());
return Optional.empty();
}
LOG.info("Start download index: " + index.get());
AmazonS3URI indexURI = index.get();
S3InputStreamFactory streamFactory = new S3InputStreamFactory(client);
InputStream stream = streamFactory.loadFully(indexURI);
long fileSize = client.getFileSize(indexURI);
byte[] buffer = IOUtils.toByteArray(stream);
if (fileSize != buffer.length) {
throw new IOException("Failed to fully download index " + indexURI);
}
LOG.info("Finished download index: " + index.get());
return Optional.of(new SeekableMemoryStream(buffer, indexURI.toString()));
}