Hello all, I'm a biologist and novice with perl so bare with me.

I'm running into memory issues with a script I'm trying to run. First I read in a file of genes (5772080 unique gene names) into a HoHoH0A corresponding to push(@{$hash{gene name} { sample ID} {Mutation site (a number)});

Then I read in a second file and initialize a second hash with values that are arrary references to arrays with length of the genes in amino acids. ie. 200AA = 200 cells.

Eventually I get the the point where I am trying to place counts of the sample unique mutations for each gene at the corresponding position in the array eof the second hash for that respective gene.

Heres the main parts of the code
foreach (@file) { chomp; my @r = split (/\t/, $_); push(@{$genes{$r[0]}{$r[3]}{$r[13]}},$r[13]); ## Pus +hing a hash that includes {Gene name}{SampleIdentifier}{AA site} } foreach (@file2){ # Initialize arrays w/ 0's for each gene with siz +e of length for each gene chomp; my @r=split(/\t/,$_); my @zeros = (0) x $r[1]; @{$s_l{$r[0]}} = @zeros; } foreach my $key1 ( sort keys %genes ) { ### this part stores the mutat +ions with and with out Amino acid (string info) the second hash site +is only numbers otherwise ignore this section foreach my $key2 ( sort keys %{$genes{$key1}} ) { foreach my $key3 ( sort keys %{$genes{$key1}{$ +key2}} ) { push(@{$AA{$key1}{$key3}},$key3); my $key4=$key3; $key4=~s/\D\.\D([0-9]+)\D/$1/; $key4=~ +s/(\*|\?|s\d+)//; push (@{$site{$key1}{$key4}},$key4); } } } #this is the problem section foreach my $key1 ( sort keys %AA ) { foreach my $key4 ( sort keys %{$site{$key1}} ) { $site_length_catch{$key1}[$key4] = scalar ( @ +{$site{$key1}{$key4}} ); } }

In reply to Memory issue with large cancer gene data structure by ZWcarp

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.