2
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 3 years have passed since last update.

multi-fastaの改行をワンライナーで削除する

Last updated at Posted at 2020-06-08

multi-fastaファイルは配列が途中で改行されている場合があります。grepなどで任意の配列を抽出する場合は改行のない方が望ましいです。

簡単に変換する方法がないかと検索するとマルチファスタの改行をとる(perl、awk)にawkを用いた下記のワンライナーを掲載されている方がおられました。

cat input.fasta | awk '{if ($1 ~ /^>/) print "\n"$1; else printf $1}' > output.fasta

ただ、実際に実行してみると1行目に空白が入ってしまいます。

対応として、このワンライナーに続けてsedコマンドで1行目を削除することで、目的のfastaファイルを作成できました。

cat input.fasta | awk '{if ($1 ~ /^>/) print "\n"$1; else printf $1}' | sed -e '1d' > output.fasta
2
1
2

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
2
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?