I want to extract reads with a known variant form a bam file, I have tried like below:
$samtools -q 30 view <in bam> <position> | grep -i <pattern sequence(like AATTCG)> # reference pattern is AA[C]TCG
However maybe it would be some problem like if a SNP in the pattern or recurrent pattern in reads
So if any one know some better way to do the job, maybe mpileup function could help but I don not know how to do it.
Thanks
see also: how to extract allele specific reads from bamfiles?