Bio-BigFile

 view release on metacpan or  search on metacpan

lib/Bio/DB/BigFile.pm  view on Meta::CPAN

AutoSQL name for the type.

=item $string = $ati->sqlName

SQL name for the type.

=item $string = $ati->cName

C struct name for the type.

=item $bool = $ati->isUnsigned

=item $bool = $ati->stringy

=item $bool = $ati->listyName

=item $bool = $ati->nummyName

=item $bool = $ati->outFormat

Not documented here.

=back


=cut

use Carp 'croak';
use base qw(DynaLoader);
use File::Spec;
use Bio::DB::BigFile::Constants;
our $VERSION = '1.07';

bootstrap Bio::DB::BigFile;

sub createBigWig {
    my $self = shift;
    my ($inFile,$chrom_sizes,$outFile,$args) = @_;
    my %defaults = (blockSize   =>1024,
		    itemsPerSlot=>512,
		    clipDontDie => 1,
		    compress    => 1);
    $args ||= {};
    my %merged_args = (%defaults,%$args);
    $self->bigWigFileCreate($inFile,$chrom_sizes,
			    @merged_args{qw(blockSize itemsPerSlot clipDontDie compress)},
			    $outFile);
}

sub set_udc_defaults {
    my $class = shift;

    if (my $override = $ENV{UDC_CACHEDIR}) {
	Bio::DB::BigFile->udcSetDefaultDir($override);
	return;
    }

    my $path = Bio::DB::BigFile->udcGetDefaultDir();
    return if -w $path;
    my $tmp    = File::Spec->tmpdir();
    my ($user) = getpwuid($<);
    $user    ||= $<;
    $path      = File::Spec->catfile($tmp,"udcCache_$user");
    Bio::DB::BigFile->udcSetDefaultDir($path);
}


package Bio::DB::bbiFile;

# this method is fun but slow

sub bigWigBinStats {
    my $self = shift;
    my $extended_summary = $self->bigWigSummary(@_);
    my @tie;
    tie @tie,'Bio::DB::BigWig::binStats',$extended_summary;
    return \@tie;
}


package Bio::DB::BigWig::binStats;

use base 'Tie::Array';
use Carp 'croak';

sub TIEARRAY {
    my $class = shift;
    my $summary = shift;
    $summary 
	or croak "Usage: tie(\@array,'$class',\$summary), where \$summary is a Bio::DB::BigWigExtendedSummary object";
    return bless \$summary,ref($class) || $class;
}

sub FETCH {
    my $self  = shift;
    my $index = shift;
    return Bio::DB::BigWig::binStatElement->new($$self,$index);
}

sub FETCHSIZE {
    my $self = shift;
    return $$self->size;
}

package Bio::DB::BigWig::binStatElement;

sub new {
    my $class = shift;
    my ($base,$index) = @_;
    return bless [$base,$index],ref $class || $class;
}

sub validCount {
    my $self = shift;
    $self->[0]->validCount($self->[1]);
}

sub minVal {
    my $self = shift;
    $self->[0]->minVal($self->[1]);
}



( run in 1.517 second using v1.01-cache-2.11-cpan-39bf76dae61 )