# Returns nothing.
- my ( $bed_file, $fh_in, $fh_out, $cols, $record, $file_hash, $chr, $bed_entry, $fixedstep_file, $fixedstep_entry );
+ my ( $bed_file, $fh_in, $fh_out, $record, $file_hash, $chr, $bed_entry, $fixedstep_file, $fixedstep_entry );
$bed_file = "$BP_TMP/calc_fixedstep.bed";
$fh_out = Maasha::Filesys::file_write_open( $bed_file );
- $cols = 5; # we only need the first 5 BED columns
while ( $record = get_record( $in ) )
{
- if ( $bed_entry = Maasha::UCSC::BED::biopiece2bed( $record, $cols ) ) {
- Maasha::UCSC::BED::bed_entry_put( $bed_entry, $fh_out, $cols, $options->{ 'check' } );
+ if ( $bed_entry = Maasha::UCSC::BED::biopiece2bed( $record ) ) {
+ Maasha::UCSC::BED::bed_entry_put( $bed_entry, $fh_out, undef, $options->{ 'check' } );
}
}
close $fh_out;
- $file_hash = Maasha::UCSC::BED::bed_file_split_on_chr( $bed_file, $BP_TMP, $cols );
+ $file_hash = Maasha::UCSC::BED::bed_file_split_on_chr( $bed_file, $BP_TMP );
unlink $bed_file;
# Returns a bitarray.
- my ( $bed, $clones, @array );
+ my ( $bed, $clones, @begs, @lens, $i, @array );
- while ( $bed = Maasha::UCSC::BED::bed_entry_get( $fh_in, 4 ) )
+ while ( $bed = Maasha::UCSC::BED::bed_entry_get( $fh_in ) )
{
if ( $use_score ) {
$clones = $bed->[ score ];
$clones = 1;
}
- map { $array[ $_ ] += $clones } ( $bed->[ chromStart ] .. $bed->[ chromEnd ] - 1 );
+ if ( $bed->[ blockCount ] and $bed->[ blockCount ] > 1 )
+ {
+ @begs = split ",", $bed->[ blockStarts ];
+ @lens = split ",", $bed->[ blockSizes ];
+
+ for ( $i = 0; $i < @begs; $i++ ) {
+ map { $array[ $_ ] += $clones } ( $begs[ $i ] .. $begs[ $i ] + $lens[ $i ] - 1 );
+ }
+ }
+ else
+ {
+ map { $array[ $_ ] += $clones } ( $bed->[ chromStart ] .. $bed->[ chromEnd ] - 1 );
+ }
}
return wantarray ? @array : \@array;