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.4k
バイオシェル芸のためのPerlワンライナー
「本物」のワンライナーを書こう。
ktnyt
October 18, 2017
Tweet
Share
More Decks by ktnyt
See All by ktnyt
runeとUnicodeと文字数と
ktnyt
0
410
ioのテストをうまくやりたい
ktnyt
0
210
若手から生命情報科学を問い直す@IIBMP2020
ktnyt
1
3.5k
ねこでもわかる深層学習入門
ktnyt
2
3.2k
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
RailsConf 2023
tenderlove
29
950
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Unsuck your backbone
ammeep
669
57k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Measuring & Analyzing Core Web Vitals
bluesmoon
5
190
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
190
Become a Pro
speakerdeck
PRO
26
5.1k
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"