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 );
# 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
# 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' };
if ( $options->{ 'wiggle' } )
{
- $options->{ "visibility" } = "full";
-
while ( $record = get_record( $in ) )
{
put_record( $record, $out ) if not $options->{ "no_stream" };
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
{
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 );
}
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 );