Global symbol requires explicit package name issue
0
0
Entering edit mode
6.9 years ago
apulunuj ▴ 30

I have really little background on perl. Currently, I am trying to make use of the FASTKs pipeline by mrckrain on github. The pipeline works primarily through a bash script called run_kspipeline.sh file. The bash script makes use of a perl script.

When I run the perl script I get the global symbol requires explicit package at the following lines, which are highlighted.

Here is the original script as reference: https://github.com/mrmckain/FASTKs/blob/master/bin/FAST_kspipe_part2.pl

I would appreciate some help with the current issue. The lines where I get the error are lines are where the variable $temp_seqid = $1 within the block. If you check the original code on github, the error come up at lines 74 ,91, 108, and 127.

I would like help in finding a solution to the "Global symbol requires explecit package error".

The script below:

!/usr/bin/perl -w

use strict;

my $qsho = $ARGV[0];

my $ssho = $ARGV[1];

my $setid = substr($ARGV[2], 0, index($ARGV[2], "."));

system "mkdir $qsho\_$ssho\_ks/set$setid";

my $prequery = substr($ARGV[3], 0, index($ARGV[3], "."));

my $prehit = substr($ARGV[4], 0, index($ARGV[4], "."));

my %qindex = index_input($prequery);

my %sindex = index_input($prehit);

my %rqindex = index_input_rev($prequery);

my %rsindex = index_input_rev($prehit);

my ($qseqs, $sseqs, $pepq, $peps) = subset_seqs($ARGV[2],%qindex, %sindex);

#my %qseqs = %$qseqs;

#my %sseqs = %$sseqs;

open my $setfile, "<", $ARGV[2];

while(<$setfile>){

        chomp;
        my ($pair_id, $line_info) = split /,/;
        create_fasta($pair_id, $line_info);
        run_muscle($pair_id);
        run_pal2nal($pair_id);
        create_phyml_aln($pair_id);
        run_paml($pair_id);
        get_kaks_values($pair_id, $line_info);
}

open my $newfile, ">", "$qsho\_$ssho\_ks/$qsho\_$ssho.kaks.2.txt";

print $newfile "Pair\tKa\tKs\tKa/Ks\tSeqQ\tSeqS\n";        

my $home = `pwd`;
print "$home\n";


sub index_input {
    my %index;
    open my $infile, "<", "$qsho\_$ssho\_ks/$_[0].index";

    while(<$infile>){
        chomp;
        my ($new, $old) = split /\s+/;
        $index{$old}=$new;
    }
    return(%index);
} 


sub index_input_rev {
        my %index;
        open my $infile, "<", "$qsho\_$ssho\_ks/$_[0].index";


        while(<$infile>){
                chomp;
                my ($new, $old) = split /\s+/;
                $index{$new}=$old;
        }
        return(%index);
sub subset_seqs {
    my (%qseqs, %sseqs, %pepq, %peps, %fullq, %fulls, %fullpq, %fullps);

    open my $qin, "<", $ARGV[3];
        my $seqid;
        while(<$qin>){
            chomp;
            if(/^>/){
                if(/\s/){
                    />(.*?)\s/;
##74                    $temp_seqid = $1;
                }
                else{
                    $seqid = substr($_, 1);
                }
            }
            else{
                $fullq{$seqid}.=$_;
            }
        }
    open my $sin, "<", $ARGV[4];
        $seqid=();
        while(<$sin>){
            chomp;
            if(/^>/){
                if(/\s/){
                    />(.*?)\s/;
##91                    $temp_seqid = $1;
                }
                else{
                    $seqid = substr($_, 1);
                }
            }
            else{
                $fulls{$seqid}.=$_;
            }
        }
     open my $pqin, "<", $prequery . ".pep";
        $seqid=();
        while(<$pqin>){
            chomp;
            if(/^>/){
                if(/\s/){
                    />(.*?)\s/;
##108                   $temp_seqid = $1;

                }
                else{
                    $seqid = substr($_, 1);
                }
            }
            else{
                $fullpq{$seqid}.=$_;
            }
        }

     open my $psin, "<", $prehit . ".pep";
        $seqid=();
        while(<$psin>){
            chomp;
            if(/^>/){
                if(/\s/){
                    />(.*?)\s/;
##127                   $temp_seqid = $1;
                }
                else{
                    $seqid = substr($_, 1);
                }
            }
            else{
                $fullps{$seqid}.=$_;
            }
        }
perl FASKTks • 5.3k views
ADD COMMENT
0
Entering edit mode

Thank you @genomax I still not too sure how to enter code properly on biostar. Any pointers? Is it in markdown as well?

ADD REPLY
1
Entering edit mode

Use the code button to format code, commands and such. 101010 Button

ADD REPLY
0
Entering edit mode

The problematic pieces of code are the latest changes to the repository, and fairly recent. Maybe you could try with the previous commit.

ADD REPLY
0
Entering edit mode

Either remove the use strict from the code or use declare $temp_seqid as my $temp_seqid.use strict` enforces explicit defining the variables before use them

ADD REPLY
0
Entering edit mode

I tried both cases, I'm now getting another error uninitialized hash element "sseqid"

ADD REPLY
0
Entering edit mode

Did you try running FASTKs with the provided example dataset?

ADD REPLY
0
Entering edit mode

Yes I did after organizing my directories, I ran it with the dataset and it worked. And I know my input files are the right ones as well. And I don't see any differences with the format of my input files against the example dataset.

ADD REPLY
0
Entering edit mode

I have resolved the matter, after investigating the perl script above. I saw that the variable $temp_seqid is necessarily defined outside the block. So it was removed and the script works well again. A fix was pushed to github as well.

ADD REPLY

Login before adding your answer.

Traffic: 1976 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6