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;

In reply to warning "Out of memory!" by rocketperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.