User:Timothee Flutre/Notebook/Postdoc/2012/05/25: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
(Autocreate 2012/05/25 Entry for User:Timothee_Flutre/Notebook/Postdoc)
 
(→‎One-liners with GNU tools: add tutorial + list of other tools)
(2 intermediate revisions by the same user not shown)
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. ##### -->
==Entry title==
==One-liners with GNU tools==
* Insert content here...


* '''Tutorial''': [http://www.ibm.com/developerworks/aix/library/au-unixtext/index.html Introduction to text manipulation on UNIX-based systems] by Brad Yoes (IBM)
* '''Toolbox''':
** [http://en.wikipedia.org/wiki/AWK AWK]
** grep
** sed
** cut
** tr
** wc
* '''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>
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
</nowiki>


<!-- ##### DO NOT edit below this line unless you know what you are doing. ##### -->
<!-- ##### DO NOT edit below this line unless you know what you are doing. ##### -->

Revision as of 00:01, 22 November 2012

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


  • Toolbox:
    • AWK
    • grep
    • sed
    • cut
    • tr
    • wc


  • 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