User:Timothee Flutre/Notebook/Postdoc/2012/05/25

From OpenWetWare
Revision as of 08:19, 21 November 2012 by Timothee Flutre (talk | contribs) (→‎Awk one-liner to convert fasta file into fastq format: dedicate this page for one-liners)
Jump to navigationJump to search
Project name <html><img src="/images/9/94/Report.png" border="0" /></html> Main project page
<html><img src="/images/c/c3/Resultset_previous.png" border="0" /></html>Previous entry<html>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</html>Next entry<html><img src="/images/5/5c/Resultset_next.png" border="0" /></html>

One-liners with GNU tools

  • 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


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