Skip to content

Commit

Permalink
Phylip output
Browse files Browse the repository at this point in the history
  • Loading branch information
pjotrp committed May 4, 2013
1 parent bfae0b3 commit eaf4965
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Island masking assumes one unique element, maybe consider a
neighbour. The example in test/data is rather a good one.
1 change: 1 addition & 0 deletions lib/bio-alignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
require 'bio-alignment/alignment'
require 'bio-alignment/format/text'
require 'bio-alignment/format/fasta'
require 'bio-alignment/format/phylip'
2 changes: 1 addition & 1 deletion lib/bio-alignment/edit/edit_rows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def mark_row_elements &block
aln = markrows_clone
aln.rows.each_with_index do | row,rownum |
new_seq = block.call(Coerce::to_elements(row),rownum)
p [rownum,new_seq,row]
# p [rownum,new_seq,row]
aln.rows[rownum] = new_seq
end
aln
Expand Down
25 changes: 25 additions & 0 deletions lib/bio-alignment/format/phylip.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Bio
module BioAlignment
module PhylipOutput
# Calculate header info from alignment and return as string
def PhylipOutput::header alignment
"#{alignment.size} #{alignment[0].length}\n"
end

# Output sequence PAML style and return as a multi-line string
def PhylipOutput::to_paml seq, size=60
buf = seq.id+"\n"
coding = if seq.kind_of?(CodonSequence)
seq.to_nt
else
seq.to_s
end
coding.scan(/.{1,#{size}}/).each do | section |
buf += section + "\n"
end
buf
end
end
end
end

0 comments on commit eaf4965

Please sign in to comment.