X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fruby%2Fscripts%2Fbioruby_examples%2Fmsa_1.rb;h=ed5d4733613ee407eb457083612283befa1bae32;hb=65cab4a8dc67e82e562572ed5e0f5fa44df6f622;hp=dbf61ac29c64108604dccc4901f02461d196b97a;hpb=193609d92de53eb5c0c97b0e6a0ed87959a7d287;p=jalview.git diff --git a/forester/ruby/scripts/bioruby_examples/msa_1.rb b/forester/ruby/scripts/bioruby_examples/msa_1.rb index dbf61ac..ed5d473 100644 --- a/forester/ruby/scripts/bioruby_examples/msa_1.rb +++ b/forester/ruby/scripts/bioruby_examples/msa_1.rb @@ -3,7 +3,7 @@ require 'bio' ############# -# Reads in a clustalw formatted multiple sequence alignment +# Reads in a ClustalW formatted multiple sequence alignment # from a file named "infile_clustalw.aln" and stores it in 'report'. report = Bio::ClustalW::Report.new(File.read('infile_clustalw.aln')) @@ -16,6 +16,30 @@ align.each do |entry| puts entry.seq end +############## + +DEFAULT_PARSER = Bio::Alignment::MultiFastaFormat +puts DEFAULT_PARSER.to_s + +#file = Bio::Alignment.readfiles('bcl2.fasta', Bio::Alignment::MultiFastaFormat) +#file.each do |entry| +# puts entry.entry_id # Gets the identifier, e.g. 'sp|O35147|BAD_RAT'. +# puts entry.definition # Gets the complete fasta description line. +# puts entry.seq # Gets the actual sequence. + #puts entry.aaseq.composition # Gets the amino acid composition. +#end +#puts 'OK' +#puts + +file = Bio::FastaFormat.open('bcl2.fasta') +file.each do |entry| + puts entry.entry_id # Gets the identifier, e.g. 'sp|O35147|BAD_RAT'. + puts entry.definition # Gets the complete fasta description line. + puts entry.seq # Gets the actual sequence. + # do something on each fasta sequence entry +end + +############## # Creates a new file named "outfile.fasta" and writes # multiple sequence alignment 'align' to it in fasta format.