foreach $chr ( sort keys %{ $file_hash } )
{
$bed_file = $file_hash->{ $chr };
- $fixedstep_file = "$bed_file.fixedstep";
+
+ $fixedstep_file = Maasha::UCSC::Wiggle::fixedstep_calc( $bed_file, $chr, $options->{ 'use_score' }, $options->{ 'use_log10' } );
+
+ #$fixedstep_file = "$bed_file.fixedstep";
- Maasha::Common::run( "bed2fixedstep", "< $bed_file > $fixedstep_file" );
+ # Maasha::Common::run( "bed2fixedstep", "< $bed_file > $fixedstep_file" );
+
$fh_in = Maasha::Filesys::file_read_open( $fixedstep_file );
use Data::Dumper;
use Maasha::Common;
use Maasha::Filesys;
-use Maasha::C_bitarray;
use Maasha::Calc;
use vars qw( @ISA @EXPORT_OK );
$fh ||= \*STDOUT;
- map { print $fh "$_\n" } @{ $entry };
+ print $fh join( "\n", @{ $entry } ), "\n";
}
# Returns a string
- my ( $fixedstep_file, $fh_in, $fh_out, $array, $beg, $end, @block );
+ my ( $fixedstep_file, $fh_in, $fh_out, $array, $beg, $end, @block, $i );
$fixedstep_file = "$bed_file.fixedstep";
$beg = 0;
- while ( ( $beg, $end ) = Maasha::C_bitarray::c_array_interval_scan( $array, $beg ) and $beg != -1 )
+ while ( ( $beg, $end ) = fixedstep_scan( $array, $beg ) and $beg != -1 )
{
- @block = Maasha::C_bitarray::c_array_interval_get( $array, $beg, $end );
+ @block = "fixedStep chrom=$chr start=" . ( $beg + 1 ) . " step=1";
- map { $_ = sprintf "%.4f", Maasha::Calc::log10( $_ ) } @block if $use_log10;
-
- unshift @block, "fixedStep chrom=$chr start=" . ( $beg + 1 ) . " step=1";
+ for ( $i = $beg; $i <= $end; $i++ )
+ {
+ if ( $use_log10 ) {
+ push @block, sprintf "%.4f", Maasha::Calc::log10( $array->[ $i ] );
+ } else {
+ push @block, $array->[ $i ];
+ }
+ }
fixedstep_entry_put( \@block, $fh_out );
# Returns a bitarray.
- my ( $bed, $clones, $vec );
-
- $vec = Maasha::C_bitarray::c_array_init( SEQ_MAX, BITS );
+ my ( $bed, $clones, @array );
- while ( $bed = Maasha::UCSC::BED::bed_entry_get( $fh_in, 5 ) )
+ while ( $bed = Maasha::UCSC::BED::bed_entry_get( $fh_in, 4 ) )
{
if ( $use_score ) {
$clones = $bed->[ score ];
$clones = 1;
}
- Maasha::C_bitarray::c_array_interval_fill( $vec, $bed->[ chromStart ], $bed->[ chromEnd ] - 1, $clones );
+ map { $array[ $_ ] += $clones } ( $bed->[ chromStart ] .. $bed->[ chromEnd ] - 1 );
}
- return $vec;
+ return wantarray ? @array : \@array;
}