6 # Reads in a ClustalW formatted multiple sequence alignment
7 # from a file named "infile_clustalw.aln" and stores it in 'report'.
8 report = Bio::ClustalW::Report.new(File.read('infile_clustalw.aln'))
10 # Accesses the actual alignment.
11 align = report.alignment
13 # Goes through all sequences in 'align' and prints the
14 # actual molecular sequence.
21 DEFAULT_PARSER = Bio::Alignment::MultiFastaFormat
22 puts DEFAULT_PARSER.to_s
24 #file = Bio::Alignment.readfiles('bcl2.fasta', Bio::Alignment::MultiFastaFormat)
26 # puts entry.entry_id # Gets the identifier, e.g. 'sp|O35147|BAD_RAT'.
27 # puts entry.definition # Gets the complete fasta description line.
28 # puts entry.seq # Gets the actual sequence.
29 #puts entry.aaseq.composition # Gets the amino acid composition.
34 file = Bio::FastaFormat.open('bcl2.fasta')
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 # do something on each fasta sequence entry
44 # Creates a new file named "outfile.fasta" and writes
45 # multiple sequence alignment 'align' to it in fasta format.
46 File.open('outfile.fasta', 'w') do |f|
47 f.write(align.output(:fasta))
50 # Creates a new file named "outfile.aln" and writes
51 # multiple sequence alignment 'align' to it in clustal format.
52 File.open('outfile.aln', 'w') do |f|
53 f.write(align.output(:clustal))
58 seq1 = Bio::Sequence.auto("gggggg")
61 puts seq1.output(:fasta)
62 #seq2 = Bio::Sequence::AA.new("ggggt")
63 #seq3 = Bio::Sequence::AA.new("ggt")
67 seqs = [ "MFQIPEFEPSEQEDSSSAER",
68 "MGTPKQPSLAPAHALGLRKS",
74 options = [ '--maxiterate', '1000', '--localpair' ]
75 mafft = Bio::MAFFT.new('/home/zma/SOFTWARE/mafft-6.847-without-extensions/scripts/mafft', options )
76 report = mafft.query_align( seqs)
78 # Accesses the actual alignment
79 align = report.alignment
81 # Prints each sequence to the console.
82 align.each { |s| puts s.to_s }
89 clustalw = Bio::ClustalW.new('/home/zma/SOFTWARE/clustalw-2.1/src/clustalw2' )
90 report = clustalw.query_align( seqs)
91 #puts report.alignment.output_fasta.to_s
92 report.alignment.each { |x| puts x.to_s }
97 options = [ '-quiet', '-maxiters', '64' ]
98 muscle = Bio::Muscle.new('/home/zma/SOFTWARE/muscle3.8.31/src/muscle', options )
99 report = muscle.query_align( seqs)
100 #puts report.alignment.output_fasta.to_s
101 report.alignment.each { |x| puts x.to_s }
105 file = Bio::FastaFormat.open('bcl2.fasta')
107 puts entry.entry_id # Gets the identifier, e.g. 'sp|O35147|BAD_RAT'.
108 puts entry.definition # Gets the complete fasta description line.
109 puts entry.seq # Gets the actual sequence.
110 puts entry.aaseq.composition # Gets the amino acid composition.
115 Bio::FlatFile.auto('bcl2.fasta') do |ff|
117 puts entry.entry_id # Gets the identifier, e.g. 'sp|O35147|BAD_RAT'.
118 puts entry.definition # Gets the complete fasta description line.
119 puts entry.seq # Gets the actual sequence.
120 puts entry.aaseq.composition # Gets the amino acid composition.