public SamReader open()

in S3HtsjdkPlugin/src/main/java/com/epam/cmbi/s3/S3ReaderFactory.java [56:78]


    public SamReader open(URL url) {
        PerformanceMonitor.start();
        AmazonS3URI amazonURI = new AmazonS3URI(url.toString());
        S3Client client = new S3Client();
        S3InputStreamFactory streamFactory = new S3InputStreamFactory(client);

        //download index file if is possible, and then start download .bam file
        final Optional<SeekableStream> indexStream;
        try {
            IndexLoader loader = new IndexLoader(client);
            indexStream = loader.loadIndex(amazonURI);
        } catch (IOException e) {
            throw new RuntimeIOException(e.getMessage() + " failed to download index", e);
        }

        SeekableStream stream = new S3SeekableStream(amazonURI, client, streamFactory);
        SamReaderFactory factory = SamReaderFactory.makeDefault();
        SamInputResource inputResource = SamInputResource.of(stream);

        indexStream.ifPresent(inputResource::index);

        return factory.open(inputResource);
    }