X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fruby%2Fscripts%2Fbioruby_examples%2Fmsa_1.rb;h=bb8210bf53b23c41a6e6da41e7a208a795b6d1c4;hb=0b1f98e56d39ab1acd58da0f57fda383696d92c9;hp=ed5d4733613ee407eb457083612283befa1bae32;hpb=65cab4a8dc67e82e562572ed5e0f5fa44df6f622;p=jalview.git diff --git a/forester/ruby/scripts/bioruby_examples/msa_1.rb b/forester/ruby/scripts/bioruby_examples/msa_1.rb index ed5d473..bb8210b 100644 --- a/forester/ruby/scripts/bioruby_examples/msa_1.rb +++ b/forester/ruby/scripts/bioruby_examples/msa_1.rb @@ -8,11 +8,11 @@ require 'bio' report = Bio::ClustalW::Report.new(File.read('infile_clustalw.aln')) # Accesses the actual alignment. -align = report.alignment +msa = report.alignment -# Goes through all sequences in 'align' and prints the +# Goes through all sequences in 'msa' and prints the # actual molecular sequence. -align.each do |entry| +msa.each do |entry| puts entry.seq end @@ -42,16 +42,29 @@ end ############## # Creates a new file named "outfile.fasta" and writes -# multiple sequence alignment 'align' to it in fasta format. +# multiple sequence alignment 'msa' to it in fasta format. File.open('outfile.fasta', 'w') do |f| - f.write(align.output(:fasta)) + f.write(msa.output(:fasta)) end -# Creates a new file named "outfile.aln" and writes -# multiple sequence alignment 'align' to it in clustal format. -File.open('outfile.aln', 'w') do |f| - f.write(align.output(:clustal)) +# Other formats +File.open('outfile.clustal', 'w') do |f| + f.write(msa.output(:clustal)) +end +File.open('outfile.phylip', 'w') do |f| + f.write(msa.output(:phylip)) +end +File.open('outfile.phylipnon', 'w') do |f| + f.write(msa.output(:phylipnon)) +end +File.open('outfile.msf', 'w') do |f| + f.write(msa.output(:msf)) end +File.open('outfile.molphy', 'w') do |f| + f.write(msa.output(:molphy)) +end + + ############# @@ -64,15 +77,15 @@ puts seq1.output(:fasta) -seqs = [ "MFQIPEFEPSEQEDSSSAER", - "MGTPKQPSLAPAHALGLRKS", - "PKQPSLAPAHALGLRKS", - "MCSTSGCDLE" ] +seqs = ['MFQIPEFEPSEQEDSSSAER', + 'MGTPKQPSLAPAHALGLRKS', + 'PKQPSLAPAHALGLRKS', + 'MCSTSGCDLE'] # MAFFT options = [ '--maxiterate', '1000', '--localpair' ] -mafft = Bio::MAFFT.new('/home/zma/SOFTWARE/mafft-6.847-without-extensions/scripts/mafft', options ) +mafft = Bio::MAFFT.new('mafft', options ) report = mafft.query_align( seqs) # Accesses the actual alignment