1
$\begingroup$

This question has also been asked on Biostars

I ran Kallisto with the --pseudobam option. How do I extract all the short reads that are mapped to a single transcript (e.g. ENST00000367969.8)? As a person without any previous SAM/BAM experience, I tried the following things without success. Really appreciate some help here.

I first tried:

samtools view -S pseudoalignments.bam ENST00000367969.8

but got the following error:

[E::idx_find_and_load] Could not retrieve index file for 'pseudoalignments.bam'
[main_samview] random alignment retrieval only works for indexed BAM or CRAM files.

I tried to index the file using:

samtools index pseudoalignments.bam

but get the following error:

[E::hts_idx_push] NO_COOR reads not in a single block at the end 79729 -1
[E::sam_index] Read 'A00742:184:HLTF2DSXY:4:1101:4417:1000' with ref_name='ENST00000556431.1', ref_length=4142, flags=83, pos=2098 cannot be indexed
samtools index: failed to create index for "pseudoalignments.bam"
$\endgroup$
0

2 Answers 2

1
$\begingroup$

Sort the BAM file again with samtools sort and then run samtools index on the result. That should fix the issue.

$\endgroup$
1
$\begingroup$

What Devon said. Alternatively, you could also just convert the bam to sam and then look for lines where the 3rd field (the reference the sequence is aligned to) is what you want:

samtools view pseudoalignments.bam | awk '$3=="ENST00000367969.8"'

But really, it's far better to sort and index the file as Devon suggested so you can use dedicated tools in future.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.