6 seqs = Bio::Alignment::MultiFastaFormat.new(File.open('bcl2.fasta').read)
7 seqs.entries.each do |seq|
8 puts seq.to_seq.output(:genbank)
16 # Reads in a ClustalW formatted multiple sequence alignment
17 # from a file named "infile_clustalw.aln" and stores it in 'report'.
18 report = Bio::ClustalW::Report.new(File.read('infile_clustalw.aln'))
20 # Accesses the actual alignment.
21 msa = report.alignment
23 # Goes through all sequences in 'msa' and prints the
24 # actual molecular sequence.
31 DEFAULT_PARSER = Bio::Alignment::MultiFastaFormat
32 puts DEFAULT_PARSER.to_s
34 #file = Bio::Alignment.readfiles('bcl2.fasta', Bio::Alignment::MultiFastaFormat)
36 # puts entry.entry_id # Gets the identifier, e.g. 'sp|O35147|BAD_RAT'.
37 # puts entry.definition # Gets the complete fasta description line.
38 # puts entry.seq # Gets the actual sequence.
39 #puts entry.aaseq.composition # Gets the amino acid composition.
44 file = Bio::FastaFormat.open('bcl2.fasta')
46 puts entry.entry_id # Gets the identifier, e.g. 'sp|O35147|BAD_RAT'.
47 puts entry.definition # Gets the complete fasta description line.
48 puts entry.seq # Gets the actual sequence.
49 # do something on each fasta sequence entry
55 # Creates a new file named "outfile.fasta" and writes
56 # multiple sequence alignment 'msa' to it in fasta format.
57 File.open('outfile.fasta', 'w') do |f|
58 f.write(msa.output(:fasta))
62 File.open('outfile.clustal', 'w') do |f|
63 f.write(msa.output(:clustal))
65 File.open('outfile.phylip', 'w') do |f|
66 f.write(msa.output(:phylip))
68 File.open('outfile.phylipnon', 'w') do |f|
69 f.write(msa.output(:phylipnon))
71 File.open('outfile.msf', 'w') do |f|
72 f.write(msa.output(:msf))
74 File.open('outfile.molphy', 'w') do |f|
75 f.write(msa.output(:molphy))
82 seq1 = Bio::Sequence.auto("gggggg")
85 puts seq1.output(:fasta)
86 #seq2 = Bio::Sequence::AA.new("ggggt")
87 #seq3 = Bio::Sequence::AA.new("ggt")
91 seqs = ['MFQIPEFEPSEQEDSSSAER',
92 'MGTPKQPSLAPAHALGLRKS',
98 options = [ '--maxiterate', '1000', '--localpair' ]
99 mafft = Bio::MAFFT.new('mafft', options )
100 report = mafft.query_align( seqs)
102 # Accesses the actual alignment
103 align = report.alignment
105 # Prints each sequence to the console.
106 align.each { |s| puts s.to_s }
113 clustalw = Bio::ClustalW.new('/home/zma/SOFTWARE/clustalw-2.1/src/clustalw2' )
114 report = clustalw.query_align( seqs)
115 #puts report.alignment.output_fasta.to_s
116 report.alignment.each { |x| puts x.to_s }
121 options = [ '-quiet', '-maxiters', '64' ]
122 muscle = Bio::Muscle.new('/home/zma/SOFTWARE/muscle3.8.31/src/muscle', options )
123 report = muscle.query_align( seqs)
124 #puts report.alignment.output_fasta.to_s
125 report.alignment.each { |x| puts x.to_s }
129 file = Bio::FastaFormat.open('bcl2.fasta')
131 puts entry.entry_id # Gets the identifier, e.g. 'sp|O35147|BAD_RAT'.
132 puts entry.definition # Gets the complete fasta description line.
133 puts entry.seq # Gets the actual sequence.
134 puts entry.aaseq.composition # Gets the amino acid composition.
139 Bio::FlatFile.auto('bcl2.fasta') do |ff|
141 puts entry.entry_id # Gets the identifier, e.g. 'sp|O35147|BAD_RAT'.
142 puts entry.definition # Gets the complete fasta description line.
143 puts entry.seq # Gets the actual sequence.
144 puts entry.aaseq.composition # Gets the amino acid composition.