This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Get The Read That Map In Two Postions At Time Using Samtools

I am wondering if it is possible to get the reads that map two postions at same time with samtools, I know that I could get those which map in one positions or all in two, but I am only interested in those which map at same time at two

Am I right if I use this filtering flag in samtools?

samtools view -c -F100 HG00330.1.M_120209_2.bam chr17:41247863-41247882 chr17:41243030-41243049

Thanks

samtools reads mapping

1 answer

This information is not required to be present in the SAM file.

Depending on how the aligner works you may have a row for each alignment in which case you will need to sort with samtools sort -n then use another simple script to find the readnames that are duplicated.

Another possibility is to look for the SAM optional field NH:

NH i Number of reported alignments that contains the query in the current record

Not all aligners fill these attributes though.

Log in to answer this question.