Upgrade to Pro — share decks privately, control downloads, hide ads and more …

バイオシェル芸のためのPerlワンライナー

ktnyt
October 18, 2017
1.3k

 バイオシェル芸のためのPerlワンライナー

「本物」のワンライナーを書こう。

ktnyt

October 18, 2017
Tweet

Transcript

  1. $ cat test.fastq | perl -MList::Util -lne '$d[($.-1)/4]->[($.-1)%4]=$_}{ print join("\n",

    map{join("\n",@{$_})} grep{ List::Util::sum( map{ ord($_)-33 }split(//,$_->[3]) )>2000 }@d )' > filtered.fastq FASTQ Filter
  2. $ cat test.fastq | perl -MList::Util -lne '$d[($.-1)/4]->[($.-1)%4]=$_}{ print join("\n",

    map{join("\n",@{$_})} grep{ List::Util::sum( map{ ord($_)-33 }split(//,$_->[3]) )>2000 }@d )' > filtered.fastq FASTQ Filter
  3. ֤छϑϥά ϑϥά ػೳ -e ϫϯϥΠφʔϞʔυ -l print ڧ੍վߦ -n ෳ਺ߦॲཧ

    -a AWKϞʔυ -p ෳ਺ߦ+print -MModule use Module; https://qiita.com/tossh/items/f8d448c0c039f68c0ea3
  4. $ cat test.fastq | perl -MList::Util -lne '$d[($.-1)/4]->[($.-1)%4]=$_}{ print join("\n",

    map{join("\n",@{$_})} grep{ List::Util::sum( map{ ord($_)-33 }split(//,$_->[3]) )>2000 }@d )' > filtered.fastq FASTQ Filter
  5. $ cat test.fastq | perl -MList::Util -lne '$d[($.-1)/4]->[($.-1)%4]=$_}{ print join("\n",

    map{join("\n",@{$_})} grep{ List::Util::sum( map{ ord($_)-33 }split(//,$_->[3]) )>2000 }@d )' > filtered.fastq FASTQ Filter
  6. $ cat test.fastq | perl -MList::Util -lne '$d[($.-1)/4]->[($.-1)%4]=$_}{ print join("\n",

    map{join("\n",@{$_})} grep{ List::Util::sum( map{ ord($_)-33 }split(//,$_->[3]) )>2000 }@d )' > filtered.fastq FASTQ Filter
  7. ͓·͚ɿॏෳͷౕ $ cat hoge | tr -dc a-z | perl

    -le 'sub{map{print}split(//,shift)}->(<>)' | uniq -c | sort -nr | head -n 1 7 a
  8. ͓·͚ɿFASTQੜ੒ $ seq 10 | perl -lne 'print join("\n", (sprintf("\@seq%03d",$.),join("",map{qw(a

    t g c) [rand(4)]}0..99),sprintf("\+seq%03d", $.),join("",map{chr(rand(41)+33)}0..99)))'