X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=code_perl%2FMaasha%2FUCSC%2FBED.pm;fp=code_perl%2FMaasha%2FUCSC%2FBED.pm;h=3d873e660ec6d85b92a48b341e7c5fe940a4cd9c;hb=112de27df38163c34f7463c8797dae5eb7dc358b;hp=6bfa590b364d486f8202ddc454793b24d5fbc21d;hpb=29472b5aae00354d6b521fcdca902d09e08f7823;p=biopieces.git diff --git a/code_perl/Maasha/UCSC/BED.pm b/code_perl/Maasha/UCSC/BED.pm index 6bfa590..3d873e6 100644 --- a/code_perl/Maasha/UCSC/BED.pm +++ b/code_perl/Maasha/UCSC/BED.pm @@ -188,121 +188,122 @@ sub bed_entry_check # Returns nothing. - my ( $cols, @block_sizes, @block_starts ); + my ( $entry, $cols, @block_sizes, @block_starts ); - $cols = scalar @{ $bed }; + $entry = join "\t", @{ $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 "$entry" - must contain at least 3 columns - not $cols) ); } if ( $cols > 12 ) { - Maasha::Common::error( qq(Bad BED entry - must contains no more than 12 columns - not $cols) ); + Maasha::Common::error( qq(Bad BED entry "$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 ]") ); + Maasha::Common::error( qq(Bad BED entry "$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 ]") ); + Maasha::Common::error( qq(Bad BED entry "$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 ]") ); + Maasha::Common::error( qq(Bad BED entry "$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 ]") ); + Maasha::Common::error( qq(Bad BED entry "$entry" - chromEnd must be greater than chromStart - not "$bed->[ chromStart ] > $bed->[ chromEnd ]") ); } return if $cols == 3; if ( $bed->[ name ] =~ /\s/ ) { - Maasha::Common::error( qq(Bad BED entry - no white space allowed in name field: "$bed->[ name ]") ); + Maasha::Common::error( qq(Bad BED entry "$entry" - no white space allowed in name field: "$bed->[ name ]") ); } return if $cols == 4; if ( $bed->[ score ] =~ /\D/ ) { - Maasha::Common::error( qq(Bad BED entry - score must be a whole number - not "$bed->[ score ]") ); + Maasha::Common::error( qq(Bad BED entry "$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 ]") ); + Maasha::Common::error( qq(Bad BED entry "$entry" - score must be between 0 and 1000 - not "$bed->[ score ]") ); } return if $cols == 5; if ( $bed->[ strand ] ne '+' and $bed->[ strand ] ne '-' ) { - Maasha::Common::error( qq(Bad BED entry - strand must be + or - not "$bed->[ strand ]") ); + Maasha::Common::error( qq(Bad BED entry "$entry" - strand must be + or - not "$bed->[ strand ]") ); } return if $cols == 6; if ( $bed->[ thickStart ] =~ /\D/ ) { - Maasha::Common::error( qq(Bad BED entry - thickStart must be a whole number - not "$bed->[ thickStart ]") ); + Maasha::Common::error( qq(Bad BED entry "$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 ]") ); + Maasha::Common::error( qq(Bad BED entry "$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 ]") ); + Maasha::Common::error( qq(Bad BED entry "$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 ]") ); + Maasha::Common::error( qq(Bad BED entry "$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 ]") ); + Maasha::Common::error( qq(Bad BED entry "$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 ]") ); + Maasha::Common::error( qq(Bad BED entry "$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 ]") ); + Maasha::Common::error( qq(Bad BED entry "$entry" - thickEnd must be less than chromEnd - not "$bed->[ thickEnd ] > $bed->[ chromEnd ]") ); } return if $cols == 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 ]") ); + Maasha::Common::error( qq(Bad BED entry "$entry" - itemRgb must be 0 or in the form of 255,0,0 - not "$bed->[ itemRgb ]") ); } return if $cols == 9; if ( $bed->[ blockCount ] =~ /\D/ ) { - Maasha::Common::error( qq(Bad BED entry - blockCount must be a whole number - not "$bed->[ blockCount ]") ); + Maasha::Common::error( qq(Bad BED entry "$entry" - blockCount must be a whole number - not "$bed->[ blockCount ]") ); } @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 "$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 ]") ); + Maasha::Common::error( qq(Bad BED entry "$entry" - blockSizes "$bed->[ blockSizes ]" must match blockCount "$bed->[ blockCount ]") ); } @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 "$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 ]") ); + Maasha::Common::error( qq(Bad BED entry "$entry" - blockStarts "$bed->[ blockStarts ]" must match blockCount "$bed->[ blockCount ]") ); } 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: ) . + Maasha::Common::error( qq(Bad BED entry "$entry" - chromStart + blockStarts[last] + blockSizes[last] must equal chromEnd: ) . qq($bed->[ chromStart ] + $block_starts[ -1 ] + $block_sizes[ -1 ] != $bed->[ chromEnd ]) ); } }