Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
バイオシェル芸のためのPerlワンライナー
Search
ktnyt
October 18, 2017
0
1.5k
バイオシェル芸のためのPerlワンライナー
「本物」のワンライナーを書こう。
ktnyt
October 18, 2017
Tweet
Share
More Decks by ktnyt
See All by ktnyt
runeとUnicodeと文字数と
ktnyt
0
490
ioのテストをうまくやりたい
ktnyt
0
240
若手から生命情報科学を問い直す@IIBMP2020
ktnyt
1
3.5k
ねこでもわかる深層学習入門
ktnyt
2
3.3k
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
The Pragmatic Product Professional
lauravandoore
35
6.7k
Why You Should Never Use an ORM
jnunemaker
PRO
56
9.4k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.5k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
Testing 201, or: Great Expectations
jmmastey
42
7.5k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Adopting Sorbet at Scale
ufuk
77
9.4k
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Transcript
όΠΦγΣϧܳͷͨΊͷ PerlϫϯϥΠφʔ @kotone_nyt
ࣗݾհ ࣾձෆద߹ऀΩϟϯύεʹि̍Ͱ௨͍ͬͯΔ ͦͷੲόΠΦܥͷιϑτΣΞΛ։ൃͯͨ͠ ΞΠυϧϚελʔγϯσϨϥΨʔϧζΛѪ͢Δ υϫϯΰਓೳݚڀॴͷόΠτ ͜ͱ @kotone_nyt
ΤΠϦΞεΛషΔ͚ͩͰ͍͍͔ΒҠ২ੑ͕ߴ͍ ίϐϖ͢Δ͚ͩͰ͑ΔͷͰಋೖͷোน͕͍ ϓϩάϥϜΛҰߦͰهड़͢ΔͷͰݟ௨͕͠ྑ͍ ϝϦοτ ͋ͱָ͍͠ʂʂʂ✌('ω' ✌)ࡾ✌('ω')✌ࡾ(✌ 'ω')✌
One Line FASTQ Filter
$ 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 ίʔυࣗମͨͬͨͷ129όΠτʂ
$ 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
$ 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
֤छϑϥά ϑϥά ػೳ -e ϫϯϥΠφʔϞʔυ -l print ڧ੍վߦ -n ෳߦॲཧ
-a AWKϞʔυ -p ෳߦ+print -MModule use Module; https://qiita.com/tossh/items/f8d448c0c039f68c0ea3
$ 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
$. Perlͷ҉มͷ͏ͪͷҰͭ ߦ൪߸͕֨ೲ͞Ε͍ͯΔ 0Ͱͳ͘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
}{ ͍ΘΏΔൿີԋࢉࢠͷҰͭ ϫϯϥΠφʔʹENDϒϩοΫΛՃ͢Δԋࢉࢠ ϑΝΠϧΛॲཧͯ͠࠷ޙʹprintΈ͍ͨͳࣄ͕Ͱ͖Δ
$ 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
·ͱΊ • ͜ΕͬͯPerlܳ͡Όͳ͍ʁ • ·͊ɺͦ͏Ͱ͢Ͷ... • ͩ͜ΘΓΛ࣋ͭͱָ͍͠ • ηϛίϩϯΛΘͳ͍ͱ͔ •
grep/map/subΛ͏·͍͘·͠ΐ͏
͓·͚ɿॏෳͷౕ $ cat hoge | tr -dc a-z | perl
-le 'sub{map{print}split(//,shift)}->(<>)' | uniq -c | sort -nr | head -n 1 7 a
͓·͚ɿ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)))'
͓·͚ɿST*P while("STAP"ne$s){print$s=join("",map{qw(S T A P)[4*rand]}0..3),"\n"}print"ཅੑ͔͘ʹΜ! Α͔ ͬͨˑ\n"