...
Code Block | ||||
---|---|---|---|---|
| ||||
tail yeast_pe.sam | cut -f 3 |
By default cut assumes the field delimiter is Tab, which is the delimiter used in the majority of NGS file formats. You can specify a different delimiter with the -d option.
...
Code Block | ||||
---|---|---|---|---|
| ||||
grep -v -P '^@' yeast_pe.sam | cut -f 3 | grep -v '*' | wc -l |
Read more at Some Linux commands: Advanced commands
Exercise: About how many records represent aligned sequences? What alignment rate does this represent?
Expand | |||||||
---|---|---|---|---|---|---|---|
| |||||||
The expression above returns 612,968. There were 1,184,360 records total, so the percentage is:
or about 51%. Not great. Note we perform this calculation in awk's BEGIN block, which is always executed, instead of the body block, which is only executed for lines of input. And here we call awk without piping it any input. See Linux fundamentals: cut,sort,uniq,grep,awk |
Exercise: What might we try in order to improve the alignment rate?
...
Expand | |||||||
---|---|---|---|---|---|---|---|
| |||||||
|
Code Block | ||
---|---|---|
| ||
# If not already loaded module load biocontainers # takes a while module load samtools samtools |
...
Exercise: What samtools view option will include the header records in its output? Which option would show only the header records?
Expand | ||
---|---|---|
| ||
Note that samtools (like bwa) writes its help to standard error, but less and more only accept input on standard input. So the syntax redirecting standard error to standard input must be used before the pipe to less or more. samtools view 2>&1 | less then search for "header" ( /header ) |
Expand | ||
---|---|---|
| ||
samtools view -h shows header records along with alignment records. samtools view -H shows header records only. |
...
Here we use the tee command which reports its standard input outputto standard output before also writing it to the specified file.
...