From: martinahansen Date: Thu, 13 Nov 2008 01:22:00 +0000 (+0000) Subject: added -c switch to write_bed X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=338ba355147de2a10ad2df50e3807cdb46f72305;p=biopieces.git added -c switch to write_bed git-svn-id: http://biopieces.googlecode.com/svn/trunk@310 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/code_perl/Maasha/Biopieces.pm b/code_perl/Maasha/Biopieces.pm index a09f78e..d5a33fe 100644 --- a/code_perl/Maasha/Biopieces.pm +++ b/code_perl/Maasha/Biopieces.pm @@ -674,6 +674,7 @@ sub get_options elsif ( $script eq "write_bed" ) { @options = qw( + cols|c=s no_stream|x data_out|o=s compress|Z @@ -4445,7 +4446,9 @@ sub script_write_bed # Returns nothing. - my ( $fh, $record, $new_record ); + my ( $cols, $fh, $record, $new_record ); + + $cols = $options->{ 'cols' }->[ 0 ]; $fh = write_stream( $options->{ "data_out" }, $options->{ "compress" } ); @@ -4453,7 +4456,9 @@ sub script_write_bed { if ( $record->{ "REC_TYPE" } eq "BED" ) # ---- Hits from BED ---- { - Maasha::UCSC::bed_put_entry( $record, $fh, $record->{ "BED_COLS" } ); + $cols ||= $record->{ "BED_COLS" }; + + Maasha::UCSC::bed_put_entry( $record, $fh, $cols ); } elsif ( $record->{ "REC_TYPE" } eq "PSL" and $record->{ "S_ID" } =~ /^chr/i ) # ---- Hits from BLAT (PSL) ---- { @@ -4464,11 +4469,15 @@ sub script_write_bed $new_record->{ "SCORE" } = $record->{ "SCORE" } || 999; $new_record->{ "STRAND" } = $record->{ "STRAND" }; - Maasha::UCSC::bed_put_entry( $new_record, $fh, 6 ); + $cols ||= 6; + + Maasha::UCSC::bed_put_entry( $new_record, $fh, $cols ); } elsif ( $record->{ "REC_TYPE" } eq "PATSCAN" and $record->{ "CHR" } ) # ---- Hits from patscan_seq ---- { - Maasha::UCSC::bed_put_entry( $record, $fh, 6 ); + $cols ||= 6; + + Maasha::UCSC::bed_put_entry( $record, $fh, $cols ); } elsif ( $record->{ "REC_TYPE" } eq "BLAST" and $record->{ "S_ID" } =~ /^chr/i ) # ---- Hits from BLAST ---- { @@ -4479,7 +4488,9 @@ sub script_write_bed $new_record->{ "SCORE" } = $record->{ "SCORE" } || 999; # or use E_VAL somehow $new_record->{ "STRAND" } = $record->{ "STRAND" }; - Maasha::UCSC::bed_put_entry( $new_record, $fh, 6 ); + $cols ||= 6; + + Maasha::UCSC::bed_put_entry( $new_record, $fh, $cols ); } elsif ( $record->{ "REC_TYPE" } eq "VMATCH" and $record->{ "S_ID" } =~ /^chr/i ) # ---- Hits from Vmatch ---- { @@ -4490,9 +4501,11 @@ sub script_write_bed $new_record->{ "SCORE" } = $record->{ "SCORE" } || 999; # or use E_VAL somehow $new_record->{ "STRAND" } = $record->{ "STRAND" }; - Maasha::UCSC::bed_put_entry( $new_record, $fh, 6 ); + $cols ||= 6; + + Maasha::UCSC::bed_put_entry( $new_record, $fh, $cols ); } - elsif ( $record->{ "REC_TYPE" } eq "SOAP" and $record->{ "S_ID" } =~ /^chr/i ) # ---- Hits from Vmatch ---- + elsif ( $record->{ "REC_TYPE" } eq "SOAP" and $record->{ "S_ID" } =~ /^chr/i ) # ---- Hits from Soap ---- { $new_record->{ "CHR" } = $record->{ "S_ID" }; $new_record->{ "CHR_BEG" } = $record->{ "S_BEG" }; @@ -4501,11 +4514,13 @@ sub script_write_bed $new_record->{ "SCORE" } = $record->{ "SCORE" } || 999; $new_record->{ "STRAND" } = $record->{ "STRAND" }; - Maasha::UCSC::bed_put_entry( $new_record, $fh, 6 ); + $cols ||= 6; + + Maasha::UCSC::bed_put_entry( $new_record, $fh, $cols ); } elsif ( $record->{ "CHR" } and defined $record->{ "CHR_BEG" } and $record->{ "CHR_END" } ) # ---- Generic data from tables ---- { - Maasha::UCSC::bed_put_entry( $record, $fh ); + Maasha::UCSC::bed_put_entry( $record, $fh, $cols ); } put_record( $record, $out ) if not $options->{ "no_stream" };