[Bioperl-l] Error calling alignment method
Lorenzo Carretero Paulet
locarpau at upvnet.upv.es
Tue May 31 11:26:59 UTC 2011
Hi,
The last versions of my script had the typo corrected:
my $kaks_factory = new Bio::Tools::Run::Phylo::PAML::Codeml
( -params => {
#'verbose' => 0,
#'noisy' => 0,
'runmode' => -2,
'seqtype' => 1,
#'model' => 0,
#'NSsites' => 0,
#'icode' => 0,
#'fix_alpha' => 0,
#'fix_kappa' => 0,
#'RateAncestor' => 0,
'CodonFreq' => 2,
'cleandata' => 1,
'ndata' => 1
},
);
$kaks_factory->alignment($dna_aln);
but still returns the same error.
Best,
Lorenzo
El 27/05/11 21:45, Jason Stajich escribió:
> Lorenzo -
>
> The problem is not that $dna_alignment is not defined - that is not
> what the error message is saying.
> It is saying you can't call 'alignment' on an undefined value
>
> This is the line:
> my $kaks_factory->alignment($dna_aln);
> Should be
> $ks_factory->alignment($dna_aln);
>
> If you star with the simple code in the perldoc you can see how the
> steps are intended to be run.
> my $codeml = Bio::Tools::Run::Phylo::PAML::Codeml->new();
> $codeml->alignment($aln);
> my ($rc,$parser) = $codeml->run();
> my $result = $parser->next_result;
> my $MLmatrix = $result->get_MLmatrix();
> print "Ka = ", $MLmatrix->[0]->[1]->{'dN'},"\n";
>
> You can also initialize the Codeml object with the alignment directly
> my $ks_factory = new Bio::Tools::Run::Phylo::PAML::Codeml(-alignment
> => $dna_aln,
> -params => .... ); # as you did before
>
>
> On May 25, 10:58 am, Lorenzo Carretero Paulet<locar... at upvnet.upv.es>
> wrote:
>> Hi all,
>> I'm trying to create the following subroutine but I get the error message:
>> "Can't call method "alignment" on an undefined value at
>> /Users/marioafares/Documents/workspace/PlantEvolGen/test.pl line 80,
>> <GEN1> line 2."
>> which indicates $dna_aln is undefined. However, I manage to print it
>> using Dumper, so I guess it is actually defined.
>> Can anyone see where the problem is?
>> I attach the two files I'm using in the test.
>> Thanks in advance,
>> Lorenzo
>>
>> #!/usr/local/bin/perl -w
>> use 5.010;
>> use strict;
>> use Data::Dumper;
>> # definition of the environmental variable CLUSTALDIR
>> BEGIN {$ENV{CLUSTALDIR} =
>> '/Applications/Bioinformatics/clustalw-2.1-macosx/'}
>> use Bio::Tools::Run::Alignment::Clustalw;
>> use Bio::Align::Utilities qw(aa_to_dna_aln);
>>
>> BEGIN {$ENV{PAMLDIR} = '/Applications/Bioinformatics/paml44/bin/'}
>> use Bio::Tools::Run::Phylo::PAML::Codeml;
>>
>> my $sequencesfilenameAA =
>> "/Users/marioafares/Documents/SequenceDatabase/plaza_public_02_Apr27/plaza_ public_02/BLAST_Parsed_results/PerSpecies/test_vs_test.par.aa.1.fas";
>>
>> my $sequencesfilenameNT =
>> "/Users/marioafares/Documents/SequenceDatabase/plaza_public_02_Apr27/plaza_ public_02/BLAST_Parsed_results/PerSpecies/test_vs_test.par.nt.1.fas";
>>
>> my $format = 'fasta';
>>
>> GettingBioperlAlignmentAAtoDNAplusPAMLcalculation
>> ($sequencesfilenameAA, $sequencesfilenameNT, $format);
>>
>> sub GettingBioperlAlignmentAAtoDNAplusPAMLcalculation
>> {
>> my ( $sequencesfilenameAA, $sequencesfilenameNT, $format, $ktuple,
>> $matrix ) = @_;
>> my %hashNTseqs = ();
>> my $likelihood;
>> my $Ks;
>> my $Ka;
>> my $omega;
>> my $factory = Bio::Tools::Run::Alignment::Clustalw->new (); #use
>> default parameters in here
>> my $pep_aln = $factory->align($sequencesfilenameAA);
>>
>> my $inseq = Bio::SeqIO->new(-file => "<$sequencesfilenameNT",
>> -format => $format );
>> while (my $seq = $inseq->next_seq)
>> {
>> my $seq_id = $seq->display_id();
>> $hashNTseqs{$seq_id} = $seq;
>> }
>> my $dna_aln = aa_to_dna_aln($pep_aln, \%hashNTseqs);
>> say Dumper \%hashNTseqs;
>> say Dumper $dna_aln;
>> ###########################################################
>> #my $codeml_runs = 5;
>> my $ks_factory = new Bio::Tools::Run::Phylo::PAML::Codeml
>> ( -params => {
>> #'verbose' => 0,
>> #'noisy' => 0,
>> 'runmode' => -2,
>> 'seqtype' => 1,
>> #'model' => 0,
>> #'NSsites' => 0,
>> #'icode' => 0,
>> #'fix_alpha' => 0,
>> #'fix_kappa' => 0,
>> #'RateAncestor' => 0,
>> 'CodonFreq' => 2,
>> 'cleandata' => 1,
>> 'ndata' => 1
>> },
>>
>> );
>>
>> my $kaks_factory->alignment($dna_aln);
>>
>> say "\nCalculating Ks-values of current cluster ...";
>>
>> # The estimation of the Ks-values is repeated $codeml_runs
>> times ...
>> # for(my $k=1;$k<= $codeml_runs;$k++)
>> # {
>> # print "\nCodeml-Run $k:\n\n";
>>
>> # Ka and Ks-vlaues are calculated using codeml
>> my ($rc,$parser) = $kaks_factory->run();
>> #$kaks_factory->cleanup();
>> # If the calculation was succsessful ...
>> # if($rc != 0)
>> # {
>> my $result = $parser->next_result;#not sure what it
>> does here
>> #my $NGmatrix = $result->get_MLmatrix();
>> my $MLmatrix = $result->get_MLmatrix();
>> $likelihood = $MLmatrix->[0]->[1]->{'lnL'};
>> $Ks = $MLmatrix->[0]->[1]->{'dS'};
>> $Ka = $MLmatrix->[0]->[1]->{'dA'};
>> $omega = $MLmatrix->[0]->[1]->{'omega'};
>> print " likelihood = $likelihood, Ka = $Ka, Ks =
>> $Ks, Ka/Ks = $omega\n";
>> # }
>> # else # If an error occured during the Ks-calculation ...
>> # {
>> # return (-1);
>> # }
>> # }
>> return ( $likelihood, $Ks, $Ka, $omega );
>> }
>>
>> --
>> *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
>> Lorenzo Carretero Paulet
>> Institute for Plant Molecular and Cell Biology - IBMCP (CSIC-UPV)
>> Integrative Systems Biology Group
>> C/ Ingeniero Fausto Elio s/n.
>> 46022 Valencia, Spain
>>
>> Phone: +34 963879934
>> Fax: +34 963877859
>> e-mail:locar... at upvnet.upv.es
>> *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
>>
>> test_vs_test.par.nt.1.fas
>> 3KViewDownload
>>
>> test_vs_test.par.aa.1.fas
>> 1KViewDownload
>>
>> _______________________________________________
>> Bioperl-l mailing list
>> Bioper... at lists.open-bio.orghttp://lists.open-bio.org/mailman/listinfo/bioperl-l
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
--
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Lorenzo Carretero Paulet
Institute for Plant Molecular and Cell Biology - IBMCP (CSIC-UPV)
Integrative Systems Biology Group
C/ Ingeniero Fausto Elio s/n.
46022 Valencia, Spain
Phone: +34 963879934
Fax: +34 963877859
e-mail: locarpau at upvnet.upv.es
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
More information about the Bioperl-l
mailing list