Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Memory issue with cancer data (analogy)

by BrowserUk (Pope)
on Jul 26, 2013 at 01:28 UTC ( #1046441=note: print w/replies, xml ) Need Help??


in reply to Re^2: Memory issue with cancer data (analogy)
in thread Memory issue with cancer data (analogy)

See how you get on with this:

#! perl -sw use strict; <>; #discard header line my %table; my %lengths; while( <> ) { my( $gene, $id, undef, $site, $len ) = split; my( $pos ) = $site =~ m[(\d+)]; ## extract the digits from t +he site undef $table{ $gene }{ $pos }{ $id }; ## adds the id as a key with + no value (saves space!) $lengths{ $gene } = $len; ## Save the gene lengths for + later } #print 'output header line here if required'; for my $gene ( sort keys %table ) { print "$gene"; my $p = 1; for my $pos ( sort{ $a <=> $b } keys %{ $table{ $gene } } ) { print "\t0" x ( $pos - $p ), "\t", scalar keys %{ $table{ $gen +e }{ $pos } }; $p = $pos + 1; } print "\t0" x ( $lengths{ $gene } - $p ), "\n"; }

Invoke it as thisScript.pl < theInputFile > theOutputFile. It shouldn't take more than a minute or two to run.

It'll probably need tweaking. Like adding an appropriate header line if that is a requirement. I couldn't work out what would be needed as all the output lines will be different lengths, as the genes are different lengths.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1046441]
help
Chatterbox?
[MidLifeXis]: In addition to SOAP (last hour of cb), try water. ;-)
[MidLifeXis]: hahaha: Just received a buzz-word-bingo- compliant email (internal) that starts with "%Firstname% %Lastname%...". It only gets better from there.
choroba finds working in a small company boring comparing to a large corporation
[MidLifeXis]: At least test before mass distribution.
[MidLifeXis]: More opportunities for anonymous snafus :-)

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2017-01-19 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (170 votes). Check out past polls.