User:Timothee Flutre/Notebook/Postdoc/2012/05/25
From OpenWetWare
(Difference between revisions)
(→Entry title) |
(→Awk one-liner to convert fasta file into fastq format: dedicate this page for one-liners) |
||
| Line 6: | Line 6: | ||
| colspan="2"| | | colspan="2"| | ||
<!-- ##### DO NOT edit above this line unless you know what you are doing. ##### --> | <!-- ##### DO NOT edit above this line unless you know what you are doing. ##### --> | ||
| - | == | + | ==One-liners with GNU tools== |
| - | * | + | * [http://en.wikipedia.org/wiki/AWK AWK] is a programming language very useful to perform, from the command line, quick checks, format conversions and exploratory analyzes on any text file. |
| + | |||
| + | |||
| + | * '''Use absolute values:''' | ||
| + | |||
| + | awk 'function abs(x){return (((x < 0.0) ? -x : x) + 0.0)} {print abs($1)}' input.txt | ||
| + | |||
| + | |||
| + | |||
| + | * '''Convert file from fasta to fastq''': we can use the built-in variable "RS" ([http://www.gnu.org/software/gawk/manual/gawk.html#Records split records]) and use "split" ([http://www.gnu.org/software/gawk/manual/gawk.html#String-Functions string function]): | ||
<nowiki> | <nowiki> | ||
Revision as of 11:19, 21 November 2012
Main project page Previous entry Next entry
| |
One-liners with GNU tools
awk 'function abs(x){return (((x < 0.0) ? -x : x) + 0.0)} {print abs($1)}' input.txt
awk 'BEGIN{RS=">"} {if(NF==0)next; split($0,a,"\n"); printf "@"a[1]"\n"a[2]"\n+\n"; \
for(i=1;i<=length(a[2]);i++)printf "}"; printf"\n"}' probes.fa > probes.fq
| |



