Unable to view cram files with pysam due to truncation error?
I am working with .cram files and trying to use pysam to extract and view the read sequences in a Jupyter notebook. This script works when I use it to view a smaller publicly available cram file locally on my computer:
cram = pysam.AlignmentFile(path, "rc")
for x in cram.fetch():
print(x.query_sequence)however, when I try and do this for a larger .cram file on the RAP on UK biobank, it does not output anything.
It doesn't work even if I define a region in that lies within a chromosome which I can see contains several overlapping reads with IGV. E.g. when I try:
print(cram.count(contig="chr1",start=76089932,stop=76130891))it gives me this error OSError: truncated file.
However, I am able to view and manipulate the cram files when I run samtools e.g. on Swiss Army Knife, which would suggest they are not truncated? and the issue is just with viewing them with pysam?
i would appreciate any help for why this is happening, or any alternative way for me to extract all/certain reads from a .cram file into a new text file/array etc.?
Comments
0 comments
Please sign in to leave a comment.