Skip to content

Commit

Permalink
#2 clipped alignment from Tutorial.ja.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kozo2 committed Jun 16, 2016
1 parent 634ecbc commit e84341d
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Tutorial.ja.alignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## アライメント (Bio::Alignment クラス)

Bio::Alignment クラスは配列のアライメントを格納するためのコンテナです。 Ruby の Hash や Array に似た操作が可能で、BioPerl の Bio::SimpleAlign に似た感じになっています。以下に簡単な使い方を示します。

```ruby
require 'bio'

seqs = [ 'atgca', 'aagca', 'acgca', 'acgcg' ]
seqs = seqs.collect{ |x| Bio::Sequence::NA.new(x) }

# アライメントオブジェクトを作成
a = Bio::Alignment.new(seqs)

# コンセンサス配列を表示
p a.consensus # ==> "a?gc?"

# IUPAC 標準の曖昧な塩基を使用したコンセンサス配列を表示
p a.consensus_iupac # ==> "ahgcr"

# 各配列について繰り返す
a.each { |x| p x }
# ==>
# "atgca"
# "aagca"
# "acgca"
# "acgcg"

# 各サイトについて繰り返す
a.each_site { |x| p x }
# ==>
# ["a", "a", "a", "a"]
# ["t", "a", "c", "c"]
# ["g", "g", "g", "g"]
# ["c", "c", "c", "c"]
# ["a", "a", "a", "g"]

# Clustal W を使用してアライメントを行う。
# 'clustalw' コマンドがシステムにインストールされている必要がある。
factory = Bio::ClustalW.new
a2 = a.do_align(factory)
```

0 comments on commit e84341d

Please sign in to comment.