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
500
ioのテストをうまくやりたい
ktnyt
0
240
若手から生命情報科学を問い直す@IIBMP2020
ktnyt
1
3.5k
ねこでもわかる深層学習入門
ktnyt
2
3.3k
Featured
See All Featured
A designer walks into a library…
pauljervisheath
207
24k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.4k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
700
Into the Great Unknown - MozCon
thekraken
40
1.9k
Agile that works and the tools we love
rasmusluckow
329
21k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Automating Front-end Workflow
addyosmani
1370
200k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
5.9k
Facilitating Awesome Meetings
lara
54
6.5k
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"