rocketperl has asked for the wisdom of the Perl Monks concerning the following question:
Hi Mokers, Please help me with the 'out of memory' issue. My input file <PROTEOME> is around 30mb (due to which i assume my program is not running as expected), please advice me regarding improvement of the script and avoid populating unwanted memory. Below is my code for your ref. Thanks
#!/usr/bin/perl use 5.010; use strict; use warnings; use diagnostics; open GENES,'genes.txt' or print "cant open genes\t"; open LOG,'log.txt' or print "cant open log\t"; open START,'start.txt' or print "cant open start\t"; open STOP,'stop.txt' or print "cant open stop\t"; open DIST,'diff.txt' or print "cant open diff"; open O,'>logratio_g0_revised_withnp.txt'; my @genes=<GENES>; my @start=<START>; my @stop=<STOP>; my @log=<LOG>; my @dist=<DIST>; chomp @genes; chomp @start; chomp @stop; chomp @log; chomp @dist; my $index=0; my $index1=1; my $ind=0; my $in=0; my $count=1; do { $ind=0; $ind1=1; $hit=0; undef @hold; undef @aminoacid; if($proteome[$index]=~m/^>/) { $val++; $proteome[$index] =~ /\|(.+)\|(.+)$/; $id=$1; $name=$2; $index++; print O "$name\t$id\t"; push @hold,$proteome[$index]; $index++; do { push @hold,$proteome[$index]; $index++; } until($proteome[$index]=~m/^>/); $peptide= join ('', @hold); undef @hold; @aminoacid=split(//,$peptide); } if(@aminoacid>0) { do { if($aminoacid[$ind]=~/^X$/) { $ind++; $ind1++; } else { if($aminoacid[$ind] eq $aminoacid[$ind1]) { do { $hit++; $ind++; $ind1++; } until($aminoacid[$ind] ne $aminoacid[$ind1] or $ind==@ +aminoacid); $hit++; if($hit>9) { print O "$aminoacid[$ind]\t$hit\t"; } else { $hit=0; } $ind++; $ind1++; $hit=0; } else { $ind++; $ind1++; } } } until($ind==@aminoacid); undef @aminoacid; print O "\n"; } } until($index==@proteome); say $val;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: warning "Out of memory!"
by tobyink (Canon) on Jan 23, 2014 at 10:20 UTC | |
|
Re: warning "Out of memory!"
by vitoco (Hermit) on Jan 23, 2014 at 10:27 UTC | |
|
Re: warning "Out of memory!"
by vitoco (Hermit) on Jan 23, 2014 at 12:37 UTC | |
|
Re: warning "Out of memory!"
by locked_user sundialsvc4 (Abbot) on Jan 23, 2014 at 14:45 UTC | |
|
Re: warning "Out of memory!"
by dasgar (Priest) on Jan 23, 2014 at 17:44 UTC | |
|
Re: warning "Out of memory!"
by mtmcc (Hermit) on Jan 23, 2014 at 21:31 UTC |