18 July 2011

An interactive 'dialog' generating a SAM Flag

The following shell script uses the dialog utility to generate a numeric Sam flag.

$ sh selectsam.sh 
┌───────────────────────SAM FLAGS──────────────────────────┐
│ SELECT FLAGS │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ [X] 1 Read Paired │ │
│ │ [ ] 2 Read mapped in proper pair │ │
│ │ [X] 4 Read unmapped │ │
│ │ [ ] 8 Mate unmapped │ │
│ │ [ ] 16 Read reverse strand │ │
│ │ [X] 32 Mate reverse strand │ │
│ │ [ ] 64 First in pair │ │
│ │ [X] 128 Second in pair │ │
│ │ [ ] 256 Not primary alignment │ │
│ │ [ ] 512 Read fails platform/vendor quality checks │ │
│ │ [ ] 1024 Read is PCR or optical duplicate │ │
│ └─────↓(+)─────────────────────────────────────────────┘ │
│ │
│ │
├──────────────────────────────────────────────────────────┤
│ < OK > │
└──────────────────────────────────────────────────────────┘

$ 165


dialog --stdout --title "SAM FLAGS" \
--nocancel \
--separate-output \
--checklist "SELECT FLAGS" 20 60 11 \
1 "Read Paired" off \
2 "Read mapped in proper pair" off \
4 "Read unmapped" off \
8 "Mate unmapped" off \
16 "Read reverse strand" off \
32 "Mate reverse strand" off \
64 "First in pair" off \
128 "Second in pair" off \
256 "Not primary alignment" off \
512 "Read fails platform/vendor quality checks" off \
1024 "Read is PCR or optical duplicate" off \
| awk 'BEGIN { i=0;} {i+=int($1);} END {printf("%s\n",i);}'
view raw samflags.sh hosted with ❤ by GitHub


Source available at: https://github.com/lindenb/samtools-utilities/blob/master/script/selectflag.sh

That's it,

Pierre

1 comment:

István Albert said...

should be part of SAMtools