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}.=$_;
}
}
Thank you @genomax I still not too sure how to enter code properly on biostar. Any pointers? Is it in markdown as well?
Use the
code
button to format code, commands and such.The problematic pieces of code are the latest changes to the repository, and fairly recent. Maybe you could try with the previous commit.
Either remove the
use strict
from the code or use declare$temp_seqid
asmy $temp_seqid.
use strict` enforces explicit defining the variables before use themI tried both cases, I'm now getting another error uninitialized hash element "sseqid"
Did you try running FASTKs with the provided example dataset?
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.
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.