3 # An example of how to use the different alignment tools in bioperl
4 # to align some sequences
6 # All these methods except Bio::Tools::pSW will work for DNA sequence
7 # (need to use a different matrix however)
9 use Bio
::Factory
::EMBOSS
;
14 use Bio
::Tools
::Run
::Alignment
::Clustalw
;
15 use Bio
::Tools
::Run
::Alignment
::TCoffee
;
16 use Bio
::Tools
::Run
::StandAloneBlast
;
19 # build the sequences since EMBOSS expects seqs to be in files
20 my $seq = new Bio
::PrimarySeq
(-seq
=>
21 'MAVNPELAPFTLSRGIPSFDDQALSTIIQLQDCIQQAIQQLNYSTAEFLAELLYAECSILDKSSVYWSDAVYLYALSLFLNKSYHTAFQISKEFKEYHLGIAYIFGRCALQLSQGVNEAILTLLSIINVFSSNSSNTRINMVLNSNLVHIPDLATLNCLLGNLYMKLDHSKEGAFYHSEALAINPYLWESYEAICKMRATVDLKRVFFDIAGKKSNSHNNNAASSFPSTSLSHFEPRSQPSLYSKTNKNGNNNINNNVNTLFQSSNSPPSTSASSFSSIQHFSRSQQQQANTSIRTCQNKNTQTPKNPAINSKTSSALPNNISMNLVSPSSKQPTISSLAKVYNRNKLLTTPPSKLLNNDRNHQNNNNNNNNNNNNNNNNNNNNNNNNIINKTTFKTPRNLYSSTGRLTTSKKNPRSLIISNSILTSDYQITLPEIMYNFALILRSSSQYNSFKAIRLFESQIPSHIKDTMPWCLVQLGKLHFEIINYDMSLKYFNRLKDLQPARVKDMEIFSTLLWHLHDKVKSSNLANGLMDTMPNKPETWCCIGNLLSLQKDHDAAIKAFEKATQLDPNFAYAYTLQGHEHSSNDSSDSAKTCYRKALACDPQHYNAYYGLGTSAMKLGQYEEALLYFEKARSINPVNVVLICCCGGSLEKLGYKEKALQYYELACHLQPTSSLSKYKMGQLLYSMTRYNVALQTFEELVKLVPDDATAHYLLGQTYRIVGRKKDAIKELTVAMNLDPKGNQVIIDELQKCHMQE',
24 my $seq2 = new Bio
::PrimarySeq
( -seq
=>
25 'CLIFXRLLLIQMIHPQARRAFTFLQQQEPYRIQSMEQLSTLLWHLADLPALSHLSQSLISISRSSPQAWIAVGNCFSLQKDHDEAMRCFRRATQVDEGCAYAWTLCGYEAVEMEEYERAMAFYRTAIRTDARHYNAWYVLFFFFFFFFVPGDIDSXPKKGMEWGXFISKRIDRGMRSIILKEPSKSIQLIPFFYVALVWXVGVSSYPLETMTNIDFPKKKKALEKSNDVVQALHFYERASKYAPTSAMVQFKRIRALVALQRYDEAISALVPLTHSAPDEANVFFLLGKCLLKKERRQEATMAFTNARELEPK',
28 my $out = new Bio
::SeqIO
(-format
=> 'fasta',
30 $out->write_seq($seq);
32 $out = new Bio
::SeqIO
(-format
=> 'fasta',
34 $out->write_seq($seq2);
38 my $embossfactory = Bio
::Factory
::EMBOSS
->new();
40 my @alignprogs = qw(water needle stretcher matcher);
41 my $alignout = new Bio
::AlignIO
(-format
=> 'msf');
44 foreach my $prog ( @alignprogs ) {
45 my $alignfactory = $embossfactory->program('water');
48 $alignfactory->run({ '-sequencea' => 'seq1.fa',
49 '-seqall' => 'seq2.fa',
51 '-datafile' => 'EBLOSUM62',
53 '-outfile' => "seq1_vs_seq2.$prog"});
55 my $alnin = new Bio
::AlignIO
(-format
=> 'emboss',
56 -file
=> "seq1_vs_seq2.$prog");
57 my $aln = $alnin->next_aln();
58 $alignout->write_aln($aln);
61 # this should produce the same alignment as 'water'
62 my $factory = new Bio
::Tools
::pSW
(-matrix
=> 'blosum62.bla',
65 my $aln = $factory->pairwise_alignment($seq,$seq2);
66 $alignout->write_aln($aln);
68 $factory = new Bio
::Tools
::Run
::Alignment
::Clustalw
('ktuple' => 2,
69 'matrix' => 'BLOSUM');
70 $aln = $factory->align([$seq,$seq2]);
71 $alignout->write_aln($aln);
73 $factory = new Bio
::Tools
::Run
::Alignment
::TCoffee
('ktuple' => 2,
74 'matrix' => 'BLOSUM');
75 $aln = $factory->align([$seq,$seq2]);
76 $alignout->write_aln($aln);
78 $factory = new Bio
::Tools
::Run
::StandAloneBlast
();
79 $aln = $factory->bl2seq($seq,$seq2);
81 # this actually returns a Bio::Tools::BPbl2seq object
82 # it can be transformed to a SimpleAlign object see
83 # the code in Bio::AlignIO::bl2seq
84 # A transformer object will be written at some point