1
$\begingroup$

a. Is there a SAM flag that specifies all reads? b. Is there a SAM flag that specifies none of the reads?

So that if I run samtools view -f (a) -F (b) the result will be all reads of the file (as if omitting the specification) ?

$\endgroup$

1 Answer 1

3
$\begingroup$

Instead of doing this kind of tweaking I would write my script in a way that these options are passed as strings that can be empty. Something like:

#/ dummy syntax just for illustration:
if(you_want_filtering){
  filter_f='-f something'
  filter_F='-F something_else'
} else {
  filter_f=filter_F=''
}

samtools view (...) ${filter_f} ${filter_F}

So if you want all reads then make these strings empty. That is far more generic than your idea because it can well be that the flag values you need do not exist.

$\endgroup$
1
  • 1
    $\begingroup$ This is the proper approach and I'll add that you can't specify all reads using -f unless all of the reads happen to have a given flag set (or all not have a particular flag set). The best you could do was exclude a flag of 4 to ensure only mapped reads. $\endgroup$
    – Devon Ryan
    Oct 12, 2021 at 20:25

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.