From 35e11f19b48ca718ba7460f632452f55870e8ea8 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Tue, 26 Aug 2008 01:36:32 +0000 Subject: [PATCH] added fixedStep format to upload_to_ucsc git-svn-id: http://biopieces.googlecode.com/svn/trunk@224 74ccb610-7750-0410-82ae-013aeee3265d --- code_c/Maasha/src/gmon.out | Bin 736261 -> 7202 bytes code_perl/Maasha/Biopieces.pm | 59 ++++++++++++++++++++-------------- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/code_c/Maasha/src/gmon.out b/code_c/Maasha/src/gmon.out index 41152f85f890ab7b5d504a651ea78535c6e3c6ed..6ef1c72af9c77b2ef9324420c7d608769cc6d749 100644 GIT binary patch delta 93 zcmZqup|i-sHa#~#kC6clEZ}nhi&(fp=oh>U3@Jd7;?(5)yp&?F9EiKI@q)A{qktVm L6{{_T1{ntc`A-fW delta 1055 zcmeH`y-NaN9LIlIc52zH)`1R*=@bgmi@hvbV?|JdLx!dH0$xHIzMx zE*yn(2Rp3wQlXetLh(?h1Zux7=yx2YY!~+z^NNx`48@Gd4#ZyhiQdMDUiZYlBwHz? z*DxQo)fZ1~?O9SgadL{BcOTL8CK0EziczBS3=w;@Ld$c4*{cmow6GnVYhedincgZ24pZh|8;V;SVJF{k6ZKN$V$^eRVQiH o54Xm9ea1#4NB`?je1m&e+tg(Kcl=)ME8^97Z%j?H+05Dg0K~Z)ivR!s diff --git a/code_perl/Maasha/Biopieces.pm b/code_perl/Maasha/Biopieces.pm index 072846c..69de5bb 100644 --- a/code_perl/Maasha/Biopieces.pm +++ b/code_perl/Maasha/Biopieces.pm @@ -1428,10 +1428,11 @@ sub script_read_fixedstep if ( $head =~ /^chrom=([^ ]+) start=(\d+) step=(\d+)$/ ) { - $record->{ "CHR" } = $1; - $record->{ "CHR_BEG" } = $2; - $record->{ "STEP" } = $3; - $record->{ "VALS" } = join ",", @{ $entry }; + $record->{ "REC_TYPE" } = "fixed_step"; + $record->{ "CHR" } = $1; + $record->{ "CHR_BEG" } = $2; + $record->{ "STEP" } = $3; + $record->{ "VALS" } = join ",", @{ $entry }; } put_record( $record, $out ); @@ -5837,6 +5838,8 @@ sub script_upload_to_ucsc # Calculate the mean of values of given keys. + # This routine has developed into the most ugly hack. Do something! + my ( $in, # handle to in stream $out, # handle to out stream $options, # options hash @@ -5845,7 +5848,7 @@ sub script_upload_to_ucsc # Returns nothing. my ( $record, $file, $wib_file, $wig_file, $wib_dir, $fh_in, $fh_out, $i, $first, $format, $args, $type, $columns, $append, %fh_hash, - $chr, $beg, $end, $block, $line, $max, $beg_block, $entry, $q_id, $clones ); + $chr, $beg, $end, $block, $line, $max, $beg_block, $entry, $q_id, $clones, $vals ); $options->{ "short_label" } ||= $options->{ 'table' }; $options->{ "long_label" } ||= $options->{ 'table' }; @@ -5865,8 +5868,6 @@ sub script_upload_to_ucsc if ( $options->{ 'wiggle' } ) { - $options->{ "visibility" } = "full"; - while ( $record = get_record( $in ) ) { put_record( $record, $out ) if not $options->{ "no_stream" }; @@ -5946,22 +5947,6 @@ sub script_upload_to_ucsc close $fh_out; - $wig_file = "$options->{ 'table' }.wig"; - $wib_file = "$options->{ 'table' }.wib"; - - $wib_dir = "$ENV{ 'HOME' }/ucsc/wib"; - - Maasha::Common::dir_create_if_not_exists( $wib_dir ); - - # Maasha::Common::run( "wigEncode", "$file $wig_file $wib_file > /dev/null 2>&1" ); - - `cd $BP_TMP && wigEncode $file $wig_file $wib_file > /dev/null 2>&1`; - Maasha::Common::run( "mv", "$BP_TMP/$wib_file $wib_dir" ); - - unlink $file; - - $file = $wig_file; - $format = "WIGGLE"; } else @@ -5972,7 +5957,17 @@ sub script_upload_to_ucsc { put_record( $record, $out ) if not $options->{ "no_stream" }; - if ( $record->{ "REC_TYPE" } eq "PSL" ) + if ( $record->{ "REC_TYPE" } eq "fixed_step" ) + { + $vals = $record->{ "VALS" }; + $vals =~ tr/,/\n/; + + print $fh_out "fixedStep chrom=$record->{ 'CHR' } start=$record->{ 'CHR_BEG' } step=$record->{ 'STEP' }\n"; + print $fh_out "$vals\n"; + + $format = "WIGGLE" if not $format; + } + elsif ( $record->{ "REC_TYPE" } eq "PSL" ) { Maasha::UCSC::psl_put_header( $fh_out ) if $first; Maasha::UCSC::psl_put_entry( $record, $fh_out ); @@ -6088,6 +6083,22 @@ sub script_upload_to_ucsc } elsif ( $format eq "WIGGLE" ) { + $options->{ "visibility" } = "full"; + + $wig_file = "$options->{ 'table' }.wig"; + $wib_file = "$options->{ 'table' }.wib"; + + $wib_dir = "$ENV{ 'HOME' }/ucsc/wib"; + + Maasha::Common::dir_create_if_not_exists( $wib_dir ); + + `cd $BP_TMP && wigEncode $file $wig_file $wib_file > /dev/null 2>&1`; + Maasha::Common::run( "mv", "$BP_TMP/$wib_file $wib_dir" ); + + unlink $file; + + $file = $wig_file; + $type = "wig 0"; Maasha::UCSC::wiggle_upload_to_ucsc( $BP_TMP, $wib_dir, $file, $options ); -- 2.39.5