Greetings experts,

The script below has a loop where each passage cuts a
single-column slice out of a ~1 gb file mapfraw file.
The script completes, but the physical memory slowly
grows to the size of the file. Would you know how to
avoid that, so the memory is let go for each passage
of the loop? I am not very experienced with PDL. The
file referred to below I put as (75 mb compressed)

ftp://biobase.com/pub/current_prokMSA_aligned.pdl.gz

if this is a problem, and not just me. The files can
be much larger.

Niels Larsen
Danish Genome Institute




#!/usr/bin/env perl

use strict;
use warnings FATAL => qw ( all );

{
    local $SIG{__DIE__};

    require PDL::Lite;
    require PDL::Char;
    require PDL::IO::FastRaw;
}

my ( $header, $pdl, $ndx, $incr, $sums, $col, $cols, $rows );

$header = {
    'NDims' => 2,
    'Type' => 'byte',
    'Dims' => [ 7688, 137050 ],
    'ReadOnly' => 1,
};

$pdl = PDL->mapfraw( "current_prokMSA_aligned.pdl", $header );

( $cols, $rows ) = @{ $header->{"Dims"} };

$incr = PDL->ones( $rows );
$sums = PDL->zeroes( 128 );

foreach $ndx ( 0 .. $cols )
{
    $col = $pdl->slice( "($ndx),:" )->sever;

    $incr->indadd( $col, $sums );

    $sums .= 0;
}


_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to