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
470
ioのテストをうまくやりたい
ktnyt
0
230
若手から生命情報科学を問い直す@IIBMP2020
ktnyt
1
3.5k
ねこでもわかる深層学習入門
ktnyt
2
3.2k
Featured
See All Featured
Producing Creativity
orderedlist
PRO
344
40k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Optimising Largest Contentful Paint
csswizardry
37
3.2k
Statistics for Hackers
jakevdp
798
220k
Why Our Code Smells
bkeepers
PRO
336
57k
We Have a Design System, Now What?
morganepeng
52
7.5k
Raft: Consensus for Rubyists
vanstee
137
6.9k
A Tale of Four Properties
chriscoyier
158
23k
What's in a price? How to price your products and services
michaelherold
245
12k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
13
810
The Pragmatic Product Professional
lauravandoore
33
6.6k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
770
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"