3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

FASTAファイルの整形

Last updated at Posted at 2016-11-26

FASTAファイルをダウンロードすると、

>GENENAME
ACGTACGTACGTACGTACGTACGTACGTACGTACGTACGT
ACGTACGTACGTACGTACGTACGTACGTACGTACGTACGT
ACGTACGTACGTACGTACGT

というかたちで改行がついてきてしまう。このままだと扱いにくいため、遺伝子名を残したまま改行を取り去るワンライナー

FASTA.faをcatでsedに渡す

cat FASTA.fa

>で始まる行の文末だけ<を付加する

sed -e '/^>/s/$/</g'

すべての改行コード(この場合\n)を消す

tr -d "\n" 

>を\n>(改行コードと>)で置換する

sed -e 's/>/\n>/gp'

目的遺伝子(GENEOFINTEREST)を含む行のみ取り出し、<を\n(改行コード)に置換する

sed -n -E '/GENEOFINTEREST* /s/</\n/gp

これらをパイプで繋いで

cat FASTA.fa | sed -e '/^>/s/$/</g' | tr -d "\n" | sed -e 's/>/\n>/gp' | sed -n -E '/GENEOFINTEREST/s/</\n/gp' > output.txt
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?