I'm trying to use samtools to view an indexed CRAM file which is stored on our private s3 bucket. I have the config and credential files
$ cat ~/.aws/config [default] s3= addressing_style=path output=json region=us-east-1
$ cat ~/.aws/credentials [default] aws_access_key_id=***** aws_secret_access_key=*****
I can generate a presigned url with the boto3 python library and the following works:
$ url='http://s3.[endpoint]/brynjar-test/sample.cram?AWSAccessKeyId=****************&Signature=************&Expires=1561026577' $ samtools view $url | less -S
I cannot use it to view a specific region (could this be done if samtools allowed to specify an index file instead of always appending .crai to the input file name and looking for that index file?)
I also tried the following:
$ samtools view http://s3.[endpoint]/brynjar-test/sample.cram [E::hts_open_format] Failed to open file http://s3.[endpoint]/brynjar-test/sample.cram samtools view: failed to open "http://s3.[endpoint]/brynjar-test/sample.cram" for reading: Permission denied
If the above worked I would assume given that the .crai file was stored in the same bucket that I could specify a region, although I can't verify this.
I tried setting the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY but that does not help. I have read through A: Tool for random access to indexed BAM files in S3? but that post is using a public S3 bucket.
Any idea how I can solve this?