I'm still kinda new at this, so please bear with me, but I have tried debugging the program (perl -d) and using Carp as well. I just can't seem to isolate the problem.
I'm using regex to search through a series of sequences read in from BioPerl (this is not the issue). The program will read in the sequences without an issue, and with a smaller amount of test sequences there is no issue.
I'm getting a panic: malloc
thrown during the middle of the regex expression, but I can't figure it out for the life of me. I know what the perl manual says it means, but I'm not seeing what is causing that in my program.
Any help would be greatly appreciated!!
This is the command line output when the error is thrown:
[06:52:41 ~/symmetry 191] $ perl symmetryfinder.pl
Files will be saved to <sf_exons/2008-07-07_18-52-43/>
Creating Regex...
done.
Getting sequences from <exons>...
done.
Loooping through sequences...
panic: malloc at symmetryfinder.pl line 183.
Searching through sequence 0[06:52:58 ~/symmetry 192] $
This is the code segment where the error occurs:
The regular expression is called on line 21
#---------------------------------------
#-- Get Sequences from File ------------
#---------------------------------------
print 'Getting sequences from <'.$filename.">...\n";
@sequences = file2seqs($filename);
print "\tdone.\n";
#$sequences[0] = 'AGGCCTAAACTGAAATAGTTTAG';
#$sequences[1] = 'CTAAACTTG';
print "\n".$sequences[0]->seq()."\n";
print "\n".$sequences[1]->seq()."\n";
#---------------------------------------
#-- Read Sequences for Symmetry --------
#---------------------------------------
print "Loooping through sequences...\n\t";
foreach my $seq (@sequences) { # sequences stored in $_
print "\rSearching through sequence ".$tempcounter++;
@matches = ($seq->seq() =~ /$regex/g) or carp();
} print "\n";
This is my regular expression:
$regex = qr/
##### Find the sequence
([agct]) # initial nucleotide
(?=([agct]{5}
)
)
##### Add sequence to mer list and increment
(?{
# Clear our buffers
$temp = '';
@swaptemp = ();
$swapstring = '';
# Create mer and mer compliment
$temp = $1.$2;
@swaptemp = split('',$temp); # split our seq into an array
while(@swaptemp) { # loop through the array
$swapstring .= $swap{ pop(@swaptemp) }; # symmetry swap
}
# Check for previous existence
if(!exists $merlist{$temp}) {
# Declare & Initialize
$merlist{$temp} = 0;
$merlist{$swapstring} = 0;
# Save swaps (for faster search later)
$merswap{$temp} = $swapstring;
$merswap{$swapstring} = $temp;
}
# increment our mer count
$merlist{$temp}++;
})
/xi;