# Reads a BED entry given a filehandle.
- my ( $fh, # file handle
- $cols, # columns to read - OPTIONAL (3,4,5,6,8,9 or 12)
- $check, # check integrity of BED values - OPTIONAL
- ) = @_;
-
- # Returns a hash.
-
- my ( $line, %entry );
-
- $line = <$fh>;
-
- $line =~ tr/\n\r//d; # some people have carriage returns in their BED files -> Grrrr
-
- return if not defined $line;
-
- if ( not defined $cols ) {
- $cols = 1 + $line =~ tr/\t//;
- }
-
- if ( $cols == 3 )
- {
- (
- $entry{ 'chrom' },
- $entry{ 'chromStart' },
- $entry{ 'chromEnd' }
- ) = split "\t", $line, $cols + 1;
- }
- elsif ( $cols == 4 )
- {
- (
- $entry{ 'chrom' },
- $entry{ 'chromStart' },
- $entry{ 'chromEnd' },
- $entry{ 'name' }
- ) = split "\t", $line, $cols + 1;
- }
- elsif ( $cols == 5 )
- {
- (
- $entry{ 'chrom' },
- $entry{ 'chromStart' },
- $entry{ 'chromEnd' },
- $entry{ 'name' },
- $entry{ 'score' }
- ) = split "\t", $line, $cols + 1;
- }
- elsif ( $cols == 6 )
- {
- (
- $entry{ 'chrom' },
- $entry{ 'chromStart' },
- $entry{ 'chromEnd' },
- $entry{ 'name' },
- $entry{ 'score' },
- $entry{ 'strand' }
- ) = split "\t", $line, $cols + 1;
- }
- elsif ( $cols == 8 )
- {
- (
- $entry{ 'chrom' },
- $entry{ 'chromStart' },
- $entry{ 'chromEnd' },
- $entry{ 'name' },
- $entry{ 'score' },
- $entry{ 'strand' },
- $entry{ 'thickStart' },
- $entry{ 'thickEnd' },
- ) = split "\t", $line, $cols + 1;
- }
- elsif ( $cols == 9 )
- {
- (
- $entry{ 'chrom' },
- $entry{ 'chromStart' },
- $entry{ 'chromEnd' },
- $entry{ 'name' },
- $entry{ 'score' },
- $entry{ 'strand' },
- $entry{ 'thickStart' },
- $entry{ 'thickEnd' },
- $entry{ 'itemRgb' },
- ) = split "\t", $line, $cols + 1;
- }
- elsif ( $cols == 12 )
- {
- (
- $entry{ 'chrom' },
- $entry{ 'chromStart' },
- $entry{ 'chromEnd' },
- $entry{ 'name' },
- $entry{ 'score' },
- $entry{ 'strand' },
- $entry{ 'thickStart' },
- $entry{ 'thickEnd' },
- $entry{ 'itemRgb' },
- $entry{ 'blockCount' },
- $entry{ 'blockSizes' },
- $entry{ 'blockStarts' }
- ) = split "\t", $line, $cols + 1;
- }
- else
- {
- Maasha::Common::error( qq(Bad BED entry column count: $cols) );
- }
-
- bed_entry_check( \%entry ) if $check;
-
- return wantarray ? %entry : \%entry;
-}
-
-
-sub bed_entry_get_list
-{
- # Martin A. Hansen, September 2008.
-
- # Reads a BED entry given a filehandle.
-
my ( $fh, # file handle
$cols, # columns to read - OPTIONAL (3,4,5,6,8,9 or 12)
$check, # check integrity of BED values - OPTIONAL
# Writes a BED entry array to file.
- my ( $entry, # hash
+ my ( $entry, # list
$fh, # file handle - OPTIONAL
$cols, # number of columns in BED file - OPTIONAL (3,4,5,6,8,9 or 12)
$check, # check integrity of BED values - OPTIONAL
# Returns nothing.
- $cols = scalar keys %{ $entry } if not $cols;
+ if ( $cols and $cols < scalar @{ $entry } ) {
+ @{ $entry } = @{ $entry }[ 0 .. $cols - 1 ];
+ }
bed_entry_check( $entry ) if $check;
$fh = \*STDOUT if not defined $fh;
- if ( $cols == 3 )
- {
- print $fh join( "\t",
- $entry->{ 'chrom' },
- $entry->{ 'chromStart' },
- $entry->{ 'chromEnd' },
- ), "\n";
- }
- elsif ( $cols == 4 )
- {
- print $fh join( "\t",
- $entry->{ 'chrom' },
- $entry->{ 'chromStart' },
- $entry->{ 'chromEnd' },
- $entry->{ 'name' },
- ), "\n";
- }
- elsif ( $cols == 5 )
- {
- print $fh join( "\t",
- $entry->{ 'chrom' },
- $entry->{ 'chromStart' },
- $entry->{ 'chromEnd' },
- $entry->{ 'name' },
- $entry->{ 'score' },
- ), "\n";
- }
- elsif ( $cols == 6 )
- {
- print $fh join( "\t",
- $entry->{ 'chrom' },
- $entry->{ 'chromStart' },
- $entry->{ 'chromEnd' },
- $entry->{ 'name' },
- $entry->{ 'score' },
- $entry->{ 'strand' },
- ), "\n";
- }
- elsif ( $cols == 8 )
- {
- print $fh join( "\t",
- $entry->{ 'chrom' },
- $entry->{ 'chromStart' },
- $entry->{ 'chromEnd' },
- $entry->{ 'name' },
- $entry->{ 'score' },
- $entry->{ 'strand' },
- $entry->{ 'thickStart' },
- $entry->{ 'thickEnd' },
- ), "\n";
- }
- elsif ( $cols == 9 )
- {
- print $fh join( "\t",
- $entry->{ 'chrom' },
- $entry->{ 'chromStart' },
- $entry->{ 'chromEnd' },
- $entry->{ 'name' },
- $entry->{ 'score' },
- $entry->{ 'strand' },
- $entry->{ 'thickStart' },
- $entry->{ 'thickEnd' },
- $entry->{ 'itemRgb' },
- ), "\n";
- }
- elsif ( $cols == 12 )
- {
- print $fh join( "\t",
- $entry->{ 'chrom' },
- $entry->{ 'chromStart' },
- $entry->{ 'chromEnd' },
- $entry->{ 'name' },
- $entry->{ 'score' },
- $entry->{ 'strand' },
- $entry->{ 'thickStart' },
- $entry->{ 'thickEnd' },
- $entry->{ 'itemRgb' },
- $entry->{ 'blockCount' },
- $entry->{ 'blockSizes' },
- $entry->{ 'blockStarts' },
- ), "\n";
- }
- else
- {
- Maasha::Common::error( qq(Bad BED entry column count: $cols) );
- }
+ print $fh join( "\t", @{ $entry } ), "\n";
}
+
sub bed_entry_check
{
# Martin A. Hansen, November 2008.
# Checks a BED entry for integrity and
# raises an error if there is a problem.
- my ( $bed, # hash ref
+ my ( $bed, # array ref
) = @_;
# Returns nothing.
my ( $cols, @block_sizes, @block_starts );
- $cols = scalar keys %{ $bed };
+ $cols = scalar @{ $bed };
if ( $cols < 3 ) {
Maasha::Common::error( qq(Bad BED entry - must contain at least 3 columns - not $cols) );
Maasha::Common::error( qq(Bad BED entry - must contains no more than 12 columns - not $cols) );
}
- if ( $bed->{ 'chrom' } =~ /\s/ ) {
- Maasha::Common::error( qq(Bad BED entry - no white space allowed in chrom field: "$bed->{ 'chrom' }") );
+ if ( $bed->[ chrom ] =~ /\s/ ) {
+ Maasha::Common::error( qq(Bad BED entry - no white space allowed in chrom field: "$bed->[ chrom ]") );
}
- if ( $bed->{ 'chromStart' } =~ /\D/ ) {
- Maasha::Common::error( qq(Bad BED entry - chromStart must be a whole number - not "$bed->{ 'chromStart' }") );
+ if ( $bed->[ chromStart ] =~ /\D/ ) {
+ Maasha::Common::error( qq(Bad BED entry - chromStart must be a whole number - not "$bed->[ chromStart ]") );
}
- if ( $bed->{ 'chromEnd' } =~ /\D/ ) {
- Maasha::Common::error( qq(Bad BED entry - chromEnd must be a whole number - not "$bed->{ 'chromEnd' }") );
+ if ( $bed->[ chromEnd ] =~ /\D/ ) {
+ Maasha::Common::error( qq(Bad BED entry - chromEnd must be a whole number - not "$bed->[ chromEnd ]") );
}
- if ( $bed->{ 'chromEnd' } < $bed->{ 'chromStart' } ) {
- Maasha::Common::error( qq(Bad BED entry - chromEnd must be greater than chromStart - not "$bed->{ 'chromStart' } > $bed->{ 'chromEnd' }") );
+ if ( $bed->[ chromEnd ] < $bed->[ chromStart ] ) {
+ Maasha::Common::error( qq(Bad BED entry - chromEnd must be greater than chromStart - not "$bed->[ chromStart ] > $bed->[ chromEnd ]") );
}
- return if $cols == 3;
+ return if @{ $bed } == 3;
- if ( $bed->{ 'name' } =~ /\s/ ) {
- Maasha::Common::error( qq(Bad BED entry - no white space allowed in name field: "$bed->{ 'name' }") );
+ if ( $bed->[ name ] =~ /\s/ ) {
+ Maasha::Common::error( qq(Bad BED entry - no white space allowed in name field: "$bed->[ name ]") );
}
- return if $cols == 4;
+ return if @{ $bed } == 4;
- if ( $bed->{ 'score' } =~ /\D/ ) {
- Maasha::Common::error( qq(Bad BED entry - score must be a whole number - not "$bed->{ 'score' }") );
+ if ( $bed->[ score ] =~ /\D/ ) {
+ Maasha::Common::error( qq(Bad BED entry - score must be a whole number - not "$bed->[ score ]") );
}
- # if ( $bed->{ 'score' } < 0 or $bed->{ 'score' } > 1000 ) { # disabled - too restrictive !
- if ( $bed->{ 'score' } < 0 ) {
- Maasha::Common::error( qq(Bad BED entry - score must be between 0 and 1000 - not "$bed->{ 'score' }") );
+ # if ( $bed->[ score ] < 0 or $bed->[ score ] > 1000 ) { # disabled - too restrictive !
+ if ( $bed->[ score ] < 0 ) {
+ Maasha::Common::error( qq(Bad BED entry - score must be between 0 and 1000 - not "$bed->[ score ]") );
}
- return if $cols == 5;
+ return if @{ $bed } == 5;
- if ( $bed->{ 'strand' } ne '+' and $bed->{ 'strand' } ne '-' ) {
- Maasha::Common::error( qq(Bad BED entry - strand must be + or - not "$bed->{ 'strand' }") );
+ if ( $bed->[ strand ] ne '+' and $bed->[ strand ] ne '-' ) {
+ Maasha::Common::error( qq(Bad BED entry - strand must be + or - not "$bed->[ strand ]") );
}
- return if $cols == 6;
+ return if @{ $bed } == 6;
- if ( $bed->{ 'thickStart' } =~ /\D/ ) {
- Maasha::Common::error( qq(Bad BED entry - thickStart must be a whole number - not "$bed->{ 'thickStart' }") );
+ if ( $bed->[ thickStart ] =~ /\D/ ) {
+ Maasha::Common::error( qq(Bad BED entry - thickStart must be a whole number - not "$bed->[ thickStart ]") );
}
- if ( $bed->{ 'thickEnd' } =~ /\D/ ) {
- Maasha::Common::error( qq(Bad BED entry - thickEnd must be a whole number - not "$bed->{ 'thickEnd' }") );
+ if ( $bed->[ thickEnd ] =~ /\D/ ) {
+ Maasha::Common::error( qq(Bad BED entry - thickEnd must be a whole number - not "$bed->[ thickEnd ]") );
}
- if ( $bed->{ 'thickEnd' } < $bed->{ 'thickStart' } ) {
- Maasha::Common::error( qq(Bad BED entry - thickEnd must be greater than thickStart - not "$bed->{ 'thickStart' } > $bed->{ 'thickEnd' }") );
+ if ( $bed->[ thickEnd ] < $bed->[ thickStart ] ) {
+ Maasha::Common::error( qq(Bad BED entry - thickEnd must be greater than thickStart - not "$bed->[ thickStart ] > $bed->[ thickEnd ]") );
}
- if ( $bed->{ 'thickStart' } < $bed->{ 'chromStart' } ) {
- Maasha::Common::error( qq(Bad BED entry - thickStart must be greater than chromStart - not "$bed->{ 'thickStart' } < $bed->{ 'chromStart' }") );
+ if ( $bed->[ thickStart ] < $bed->[ chromStart ] ) {
+ Maasha::Common::error( qq(Bad BED entry - thickStart must be greater than chromStart - not "$bed->[ thickStart ] < $bed->[ chromStart ]") );
}
- if ( $bed->{ 'thickStart' } > $bed->{ 'chromEnd' } ) {
- Maasha::Common::error( qq(Bad BED entry - thickStart must be less than chromEnd - not "$bed->{ 'thickStart' } > $bed->{ 'chromEnd' }") );
+ if ( $bed->[ thickStart ] > $bed->[ chromEnd ] ) {
+ Maasha::Common::error( qq(Bad BED entry - thickStart must be less than chromEnd - not "$bed->[ thickStart ] > $bed->[ chromEnd ]") );
}
- if ( $bed->{ 'thickEnd' } < $bed->{ 'chromStart' } ) {
- Maasha::Common::error( qq(Bad BED entry - thickEnd must be greater than chromStart - not "$bed->{ 'thickEnd' } < $bed->{ 'chromStart' }") );
+ if ( $bed->[ thickEnd ] < $bed->[ chromStart ] ) {
+ Maasha::Common::error( qq(Bad BED entry - thickEnd must be greater than chromStart - not "$bed->[ thickEnd ] < $bed->[ chromStart ]") );
}
- if ( $bed->{ 'thickEnd' } > $bed->{ 'chromEnd' } ) {
- Maasha::Common::error( qq(Bad BED entry - thickEnd must be less than chromEnd - not "$bed->{ 'thickEnd' } > $bed->{ 'chromEnd' }") );
+ if ( $bed->[ thickEnd ] > $bed->[ chromEnd ] ) {
+ Maasha::Common::error( qq(Bad BED entry - thickEnd must be less than chromEnd - not "$bed->[ thickEnd ] > $bed->[ chromEnd ]") );
}
- return if $cols == 8;
+ return if @{ $bed } == 8;
- if ( $bed->{ 'itemRgb' } !~ /^(0|\d{1,3},\d{1,3},\d{1,3},?)$/ ) {
- Maasha::Common::error( qq(Bad BED entry - itemRgb must be 0 or in the form of 255,0,0 - not "$bed->{ 'itemRgb' }") );
+ if ( $bed->[ itemRgb ] !~ /^(0|\d{1,3},\d{1,3},\d{1,3},?)$/ ) {
+ Maasha::Common::error( qq(Bad BED entry - itemRgb must be 0 or in the form of 255,0,0 - not "$bed->[ itemRgb ]") );
}
- return if $cols == 9;
+ return if @{ $bed } == 9;
- if ( $bed->{ 'blockCount' } =~ /\D/ ) {
- Maasha::Common::error( qq(Bad BED entry - blockCount must be a whole number - not "$bed->{ 'blockCount' }") );
+ if ( $bed->[ blockCount ] =~ /\D/ ) {
+ Maasha::Common::error( qq(Bad BED entry - blockCount must be a whole number - not "$bed->[ blockCount ]") );
}
- @block_sizes = split ",", $bed->{ 'blockSizes' };
+ @block_sizes = split ",", $bed->[ blockSizes ];
if ( grep /\D/, @block_sizes ) {
- Maasha::Common::error( qq(Bad BED entry - blockSizes must be whole numbers - not "$bed->{ 'blockSizes' }") );
+ Maasha::Common::error( qq(Bad BED entry - blockSizes must be whole numbers - not "$bed->[ blockSizes ]") );
}
- if ( $bed->{ 'blockCount' } != scalar @block_sizes ) {
- Maasha::Common::error( qq(Bad BED entry - blockSizes "$bed->{ 'blockSizes' }" must match blockCount "$bed->{ 'blockCount' }") );
+ if ( $bed->[ blockCount ] != scalar @block_sizes ) {
+ Maasha::Common::error( qq(Bad BED entry - blockSizes "$bed->[ blockSizes ]" must match blockCount "$bed->[ blockCount ]") );
}
- @block_starts = split ",", $bed->{ 'blockStarts' };
+ @block_starts = split ",", $bed->[ blockStarts ];
if ( grep /\D/, @block_starts ) {
- Maasha::Common::error( qq(Bad BED entry - blockStarts must be whole numbers - not "$bed->{ 'blockStarts' }") );
+ Maasha::Common::error( qq(Bad BED entry - blockStarts must be whole numbers - not "$bed->[ blockStarts ]") );
}
- if ( $bed->{ 'blockCount' } != scalar @block_starts ) {
- Maasha::Common::error( qq(Bad BED entry - blockStarts "$bed->{ 'blockStarts' }" must match blockCount "$bed->{ 'blockCount' }") );
+ if ( $bed->[ blockCount ] != scalar @block_starts ) {
+ Maasha::Common::error( qq(Bad BED entry - blockStarts "$bed->[ blockStarts ]" must match blockCount "$bed->[ blockCount ]") );
}
- if ( $bed->{ 'chromStart' } + $block_starts[ -1 ] + $block_sizes[ -1 ] != $bed->{ 'chromEnd' } ) {
+ if ( $bed->[ chromStart ] + $block_starts[ -1 ] + $block_sizes[ -1 ] != $bed->[ chromEnd ] ) {
Maasha::Common::error( qq(Bad BED entry - chromStart + blockStarts[last] + blockSizes[last] must equal chromEnd: ) .
- qq($bed->{ 'chromStart' } + $block_starts[ -1 ] + $block_sizes[ -1 ] != $bed->{ 'chromEnd' }) );
+ qq($bed->[ chromStart ] + $block_starts[ -1 ] + $block_sizes[ -1 ] != $bed->[ chromEnd ]) );
}
}
{
# Martin A. Hansen, November 2008.
- # Converts a BED entry given as a hashref
+ # Converts a BED entry given as an arrayref
# to a Biopiece record which is returned as
# a hashref.
# will be the exact position in contrary to the
# UCSC scheme.
- my ( $bed_entry, # BED entry as hashref
+ my ( $bed_entry, # BED entry as arrayref
) = @_;
# Returns a hashref
my ( $cols, %bp_record );
- $cols = scalar keys %{ $bed_entry };
+ $cols = scalar @{ $bed_entry };
- if ( not exists $bed_entry->{ 'chrom' } and
- not exists $bed_entry->{ 'chromStart' } and
- not exists $bed_entry->{ 'chromEnd' } )
+ if ( not defined $bed_entry->[ chrom ] and
+ not defined $bed_entry->[ chromStart ] and
+ not defined $bed_entry->[ chromEnd ] )
{
return 0;
}
- $bp_record{ 'REC_TYPE' } = 'BED';
- $bp_record{ 'BED_COLS' } = $cols;
- $bp_record{ 'CHR' } = $bed_entry->{ 'chrom' };
- $bp_record{ 'CHR_BEG' } = $bed_entry->{ 'chromStart' };
- $bp_record{ 'CHR_END' } = $bed_entry->{ 'chromEnd' } - 1;
- $bp_record{ 'BED_LEN' } = $bed_entry->{ 'chromEnd' } - $bed_entry->{ 'chromStart' };
+ $bp_record{ "REC_TYPE" } = "BED";
+ $bp_record{ "BED_COLS" } = $cols;
+ $bp_record{ "CHR" } = $bed_entry->[ chrom ];
+ $bp_record{ "CHR_BEG" } = $bed_entry->[ chromStart ];
+ $bp_record{ "CHR_END" } = $bed_entry->[ chromEnd ] - 1;
+ $bp_record{ "BED_LEN" } = $bed_entry->[ chromEnd ] - $bed_entry->[ chromStart ];
return wantarray ? %bp_record : \%bp_record if $cols == 3;
- $bp_record{ 'Q_ID' } = $bed_entry->{ 'name' };
+ $bp_record{ "Q_ID" } = $bed_entry->[ name ];
return wantarray ? %bp_record : \%bp_record if $cols == 4;
- $bp_record{ 'SCORE' } = $bed_entry->{ 'score' };
+ $bp_record{ "SCORE" } = $bed_entry->[ score ];
return wantarray ? %bp_record : \%bp_record if $cols == 5;
- $bp_record{ 'STRAND' } = $bed_entry->{ 'strand' };
+ $bp_record{ "STRAND" } = $bed_entry->[ strand ];
return wantarray ? %bp_record : \%bp_record if $cols == 6;
- $bp_record{ 'THICK_BEG' } = $bed_entry->{ 'thickStart' };
- $bp_record{ 'THICK_END' } = $bed_entry->{ 'thickEnd' } - 1;
+ $bp_record{ "THICK_BEG" } = $bed_entry->[ thickStart ];
+ $bp_record{ "THICK_END" } = $bed_entry->[ thickEnd ] - 1;
return wantarray ? %bp_record : \%bp_record if $cols == 8;
- $bp_record{ 'COLOR' } = $bed_entry->{ 'itemRgb' };
+ $bp_record{ "COLOR" } = $bed_entry->[ itemRgb ];
return wantarray ? %bp_record : \%bp_record if $cols == 9;
- $bp_record{ 'BLOCK_COUNT' } = $bed_entry->{ 'blockCount' };
- $bp_record{ 'BLOCK_LENS' } = $bed_entry->{ 'blockSizes' };
- $bp_record{ 'Q_BEGS' } = $bed_entry->{ 'blockStarts' };
+ $bp_record{ "BLOCK_COUNT" } = $bed_entry->[ blockCount ];
+ $bp_record{ "BLOCK_LENS" } = $bed_entry->[ blockSizes ];
+ $bp_record{ "Q_BEGS" } = $bed_entry->[ blockStarts ];
return wantarray ? %bp_record : \%bp_record;
}
# Returns arrayref.
- my ( %bed_entry );
+ my ( @bed_entry );
$cols ||= 12; # max number of columns possible
- $bed_entry{ 'chrom' } = $bp_record->{ 'CHR' } ||
- $bp_record->{ 'S_ID' } ||
- return undef;
+ $bed_entry[ chrom ] = $bp_record->{ "CHR" } ||
+ $bp_record->{ "S_ID" } ||
+ return undef;
- if ( exists $bp_record->{ 'CHR_BEG' } ) {
- $bed_entry{ 'chromStart' } = $bp_record->{ 'CHR_BEG' };
- } elsif ( exists $bp_record->{ 'S_BEG' } ) {
- $bed_entry{ 'chromStart' } = $bp_record->{ 'S_BEG' };
+ if ( defined $bp_record->{ "CHR_BEG" } ) {
+ $bed_entry[ chromStart ] = $bp_record->{ "CHR_BEG" };
+ } elsif ( defined $bp_record->{ "S_BEG" } ) {
+ $bed_entry[ chromStart ] = $bp_record->{ "S_BEG" };
} else {
return undef;
}
- if ( exists $bp_record->{ 'CHR_END' } ) {
- $bed_entry{ 'chromEnd' } = $bp_record->{ 'CHR_END' };
- } elsif ( exists $bp_record->{ 'S_END' }) {
- $bed_entry{ 'chromEnd' } = $bp_record->{ 'S_END' };
+ if ( defined $bp_record->{ "CHR_END" } ) {
+ $bed_entry[ chromEnd ] = $bp_record->{ "CHR_END" };
+ } elsif ( defined $bp_record->{ "S_END" }) {
+ $bed_entry[ chromEnd ] = $bp_record->{ "S_END" };
} else {
return undef;
}
- $bed_entry{ 'chromEnd' }++;
+ $bed_entry[ chromEnd ]++;
- return wantarray ? %bed_entry : \%bed_entry if $cols == 3;
+ return wantarray ? @bed_entry : \@bed_entry if $cols == 3;
- $bed_entry{ 'name' } = $bp_record->{ 'Q_ID' } || return wantarray ? %bed_entry : \%bed_entry;
+ $bed_entry[ name ] = $bp_record->{ "Q_ID" } || return wantarray ? @bed_entry : \@bed_entry;
- return wantarray ? %bed_entry : \%bed_entry if $cols == 4;
+ return wantarray ? @bed_entry : \@bed_entry if $cols == 4;
- if ( exists $bp_record->{ 'SCORE' } ) {
- $bed_entry{ 'score' } = $bp_record->{ 'SCORE' };
+ if ( exists $bp_record->{ "SCORE" } ) {
+ $bed_entry[ score ] = $bp_record->{ "SCORE" };
} else {
- return wantarray ? %bed_entry : \%bed_entry;
+ return wantarray ? @bed_entry : \@bed_entry;
}
- return wantarray ? %bed_entry : \%bed_entry if $cols == 5;
+ return wantarray ? @bed_entry : \@bed_entry if $cols == 5;
- if ( exists $bp_record->{ 'STRAND' } ) {
- $bed_entry{ 'strand' } = $bp_record->{ 'STRAND' };
+ if ( exists $bp_record->{ "STRAND" } ) {
+ $bed_entry[ strand ] = $bp_record->{ "STRAND" };
} else {
- return wantarray ? %bed_entry : \%bed_entry;
+ return wantarray ? @bed_entry : \@bed_entry;
}
- return wantarray ? %bed_entry : \%bed_entry if $cols == 6;
+ return wantarray ? @bed_entry : \@bed_entry if $cols == 6;
- if ( defined $bp_record->{ 'THICK_BEG' } and
- defined $bp_record->{ 'THICK_END' } )
+ if ( defined $bp_record->{ "THICK_BEG" } and
+ defined $bp_record->{ "THICK_END" } )
{
- $bed_entry{ 'thickStart' } = $bp_record->{ 'THICK_BEG' };
- $bed_entry{ 'thickEnd' } = $bp_record->{ 'THICK_END' };
+ $bed_entry[ thickStart ] = $bp_record->{ "THICK_BEG" };
+ $bed_entry[ thickEnd ] = $bp_record->{ "THICK_END" };
}
- return wantarray ? %bed_entry : \%bed_entry if $cols == 8;
+ return wantarray ? @bed_entry : \@bed_entry if $cols == 8;
- if ( exists $bp_record->{ 'COLOR' } ) {
- $bed_entry{ 'itemRgb' } = $bp_record->{ 'COLOR' };
+ if ( exists $bp_record->{ "COLOR" } ) {
+ $bed_entry[ itemRgb ] = $bp_record->{ "COLOR" };
} else {
- return wantarray ? %bed_entry : \%bed_entry;
+ return wantarray ? @bed_entry : \@bed_entry;
}
- return wantarray ? %bed_entry : \%bed_entry if $cols == 9;
+ return wantarray ? @bed_entry : \@bed_entry if $cols == 9;
- if ( defined $bp_record->{ 'BLOCK_COUNT' } and
- defined $bp_record->{ 'BLOCK_LENS' } and
- defined $bp_record->{ 'Q_BEGS' } )
+ if ( defined $bp_record->{ "BLOCK_COUNT" } and
+ defined $bp_record->{ "BLOCK_LENS" } and
+ defined $bp_record->{ "Q_BEGS" } )
{
- $bed_entry{ 'blockCount' } = $bp_record->{ 'BLOCK_COUNT' };
- $bed_entry{ 'blockSizes' } = $bp_record->{ 'BLOCK_LENS' };
- $bed_entry{ 'blockStarts' } = $bp_record->{ 'Q_BEGS' };
- $bed_entry{ 'thickEnd' }++;
+ $bed_entry[ blockCount ] = $bp_record->{ "BLOCK_COUNT" };
+ $bed_entry[ blockSizes ] = $bp_record->{ "BLOCK_LENS" };
+ $bed_entry[ blockStarts ] = $bp_record->{ "Q_BEGS" };
+ $bed_entry[ thickEnd ]++;
}
- return wantarray ? %bed_entry : \%bed_entry;
+ return wantarray ? @bed_entry : \@bed_entry;
}