Question: Aligning protein sequences using Perl
0
gravatar for Andrea
4.5 years ago by
Andrea40
Sweden
Andrea40 wrote:

hi everyone. 

Im trying to align a fasta file (sequence.fasta) using MUSCLE through Perl,

and i get this very annoying message : 

Can't call method "align" on an undefined value at C:\perlscripts\new1.pl line 8 

Any clue??? 

What might be the problem???

#!/ usr/bin/ perl
use Bio::Tools::Run::Alignment::Muscle
# Build a muscle alignment factory
my $factory =Bio::Tools::Run::Alignment::Muscle -> new( @params );
# Pass the factory a list of sequences to be aligned .
my $inputfilename = 'sequence.fasta ';
# $aln is a SimpleAlign object .
my $aln = $factory -> align ( $inputfilename );
# Perform a profile alignment on a MSA to include more seqs
my $alnfilename = 'sequence.fasta ';
my $seqsfilename = 'outfile ';
$aln = $factory -> profile ( $alnfilename , $seqsfilename );
use strict ;
muscle bioperl alighn sequence perl • 2.2k views
ADD COMMENTlink modified 4.5 years ago by Jean-Karim Heriche20k • written 4.5 years ago by Andrea40
1
gravatar for SES
4.5 years ago by
SES8.2k
Vancouver, BC
SES8.2k wrote:

You haven't defined @params before you use it to create the $factory object, which results in you calling a method (align) on an undefined object. The synopsis sections of some BioPerl modules do not provide working examples, so copying the code may not do much (except generate warnings or errors).

Another approach would be to run muscle with system() and use Bio::SearchIO to parse the resulting alignment, which I assume is what you want to do.

ADD COMMENTlink modified 4.5 years ago • written 4.5 years ago by SES8.2k
1

'use strict' would have picked up the undefined @params.

ADD REPLYlink written 4.5 years ago by Jean-Karim Heriche20k

'use strict' is in the script (at the end). It is an unconventional placement, but it doesn't matter where you put it because pragma imports happen at compile-time.

ADD REPLYlink written 4.5 years ago by SES8.2k

 'use strict' only takes effect for code positioned after it. Consider:

#!/usr/bin/perl

$c = $a + $b;
use strict;
$d = $a + $b;

This gives:

Global symbol "$d" requires explicit package name at ./test.pl line 5.
Execution of ./test.pl aborted due to compilation errors.

 

ADD REPLYlink written 4.4 years ago by Jean-Karim Heriche20k

You are right about the order, I stand corrected. If you specify a version above 5.12, that will have the same effect and enable modern features. There are other problems with this code as well (use of reserved variables).

ADD REPLYlink written 4.4 years ago by SES8.2k

ok!and how should i define @params? i m really new to all this stuff ..

ADD REPLYlink written 4.5 years ago by Andrea40

@params should contain whatever parameters you want to pass to MUSCLE as key=value pairs.

ADD REPLYlink written 4.5 years ago by Jean-Karim Heriche20k

ok i m really confused. I read the HOWTO from bioperl.wiki but i have no result.Can u suggest me any book that should help me??

ADD REPLYlink written 4.5 years ago by Andrea40

The BioPerl documentation is lacking in some areas. In your case, you should actually look at the MUSCLE documentation since this is what you want BioPerl to run. As SES wrote above, you could try running MUSCLE directly and parse the output with BioPerl. This might be better documented.

ADD REPLYlink written 4.4 years ago by Jean-Karim Heriche20k
0
gravatar for Jean-Karim Heriche
4.5 years ago by
EMBL Heidelberg, Germany
Jean-Karim Heriche20k wrote:

You should  'use strict' and 'use warnings'.  It would have caught the missing ; at the end of the second line: use Bio::Tools::Run::Alignment::Muscle ;

ADD COMMENTlink written 4.5 years ago by Jean-Karim Heriche20k

That is correct, and the code that is posted would not even compile so I'm guessing this is a typo in the question.

ADD REPLYlink written 4.5 years ago by SES8.2k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 526 users visited in the last hour