This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Is there is Python module / library deals with the flag field in SAM files?

I am writing some python script for sam file , and I want to get the information from the flag file about the sequence, Is there any module or lib that can do it or I need to write mine?

if there is not previous code to do it what is the pseudo code that deals with it shall I convert from int to hex then bin and use some tabular to get the info or what?

Thanks

sequence sam bam python

Have you tried pysam library? I think the sam/bam object has an attribute called flag.

Three replies of "try pysam" at once must be a new record.

is there any badge for it ? :-P

We should request one :)

It means, I need to make my homework with more concentration before I post a question

You just need more coffee :)

:D I agree

2 answers

pysam?

pysam can do that for you. An AlignedSegment object has fields such as is_duplicate, is_proper_pair, is_read1, etc.. That makes things pretty convenient.

Log in to answer this question.