I have fastq header of 1000s of reads. I want to check presence all of those reads in another bam file. I have written following script
while IFS='' read -r line || [[ -n "$line" ]]; do samtools view accepted_hits.bam | grep $line ;done < fastqHeaders.txt ;
But this is taking too much time as my .bam file is too big. does anyone know faster way to do this.