DimitriC has asked for the wisdom of the Perl Monks concerning the following question:

Hi, i m trying to align a fasta file(sequence.fasta) that contains 10 proteins.I want to use MUSCLE in order to do the alignment.I 've installed MUSCLE 3.6 and now im trying to have the right code.I m really new to all this stuff and my onle experience with perl is during the last 3 months so i need your help. MY Code: (or basically the code from bioperl.wiki)

#!/ usr/bin/ perl use strict; use warnings; 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 );
After trying to execute it, i get the message " Global symbol "@params" requires explicit package name". How do i define @params? I mean wthats the code thats missing? My task is to make a phylogentic tree from this fasta file, but the first step is to make the alignhment.The howtos don't really help me...

Replies are listed 'Best First'.
Re: Aligning protein sequences using MUSCLE through Perl
by kevbot (Vicar) on Mar 14, 2015 at 04:30 UTC
    The link from Anonymous Monk shows that Bio::Tools::Run::Alignment->new only takes one argument. The argument specifies the name of the output file of the alignment. So, you could do something like this...
    #!/usr/bin/env perl use strict; use warnings; use Bio::Tools::Run::Alignment::Muscle; # Build a muscle alignment factory my @params = ( -outfile_name => 'outfile.fa' ); my $factory = Bio::Tools::Run::Alignment::Muscle->new(@params); # Pass the factory a list of sequences to be aligned . my $inputfilename = 'sequence.fa'; # $aln is a SimpleAlign object . my $aln = $factory->align( $inputfilename ); exit;
    I grabbed some example data from here, and stored it in a file called sequence.fa

    sequence.fa

    When the script is running you should see some output from muscle.

    Muscle Output

    When the script finishes you should see that the outfile.fa file was created and it should contain the aligned sequences.

    outfile.fa

      i changed my code and downloaded your fasta to make a check but i get this annoying message :

      '-in' not recognized as an internal or external command, executable program or script file. --------------------- WARNING --------------------- MSG: Muscle call crashed: 256 [command -in sequence.fa -out outfile. +fa] ---------------------------------------------------
      any more clue??? really thanks for your help!

Re: Aligning protein sequences using MUSCLE through Perl
by Anonymous Monk on Mar 14, 2015 at 02:24 UTC
Re: Aligning protein sequences using MUSCLE through Perl
by ww (Archbishop) on Mar 14, 2015 at 03:37 UTC

    The message means that despite invoking strict, you haven't declared @params before using it (or upon first use). You can make the message 'go away' by declaring my @params before your Line 6. (NB: that makes it global; something generally wise to avoid.)

    Knowing nothing about Muscle, I have mention that making the message 'go away' may not be the actual solution to your problem. So heed the suggestion above from the Anonymous Monk, as the reference may tell you otherwise.