More Related Content
Similar to Wacode 忙しいバイオインフォマティシャンのための時短ワンライナー (20)
Wacode 忙しいバイオインフォマティシャンのための時短ワンライナー
- 10. • bashから使うコマンド
• 組み込みのコマンド群 export, set, if, while(man builtin)
• /bin/, /usr/binなんかに入っているコマンド群(ふっとばすと使えないやつ)
• ワイルドカードやpipe (|)などはコマンドではない(man bash参照)
bashを動かす
- 11. まずNon-codingを抜きます
!
>grep -A 1 NM ookiifile.fa (後1行)
!
>grep -B 1 NM ookiifile.fa (前1行)
!
>grep -A 1 NM ookiifile.fa | grep -v “--“
> temp.fa
codingはNM, Non-codingはNRなので、NMを含む行とその次の行を出力します
複数行に分割されている場合は例えばawkで >NM のある行だけ改行を入れれば形式ok
cat ookiifile.fa ¦ awk '{if (substr($0,1,3) == ">NM") {print "n"$0 }else{printf $0}}'
- 13. 行数一定で分割(実例)
> split -a 5 -d -l 50 temp.fa tmp
!
!
> ls tmp* | sed 'p; s/tmp0*(.*)(.)/tmp12/g'
| xargs -n 2 mv
!
!
> ls tmp* | sed 'p; s/tmp0*(.*)(.)/tmp12/g'
| xargs -n 2 mv; osascript -e 'say "end" using “Cellos"'
↑ジョブが終わったらendって喋らせる(オススメ)
- 16. 出力を整形
>cat out_0.txt
>NM_000001
1 0.5 0.3
2 0.4 0.1
1 0.3 0.3
# owattayo!
>NM_000002
0 0.8 0.4
0 0.1 0.2
3 0.5 0.5
…
!
> seq 0 10 | xargs -I{} echo
“grep -h “^{} “ out_*.txt >
result_{}.txt” | bash
コメントを入れてい
るとあとで後悔する
ことも。。
- 17. !
> cat log.csv | grep -v "@" | cut -d"," -f3,3 | tr
-d """ | mecab | sort | uniq -c | sort -r -n -k1
> all.txt
おまけ
ワンライナーには空白区切り・csvファイル!
mecabを使って自分のTwitterログを解析してみる