elsif ( $script eq "write_tab" ) { script_write_tab( $in, $out, $options ) }
elsif ( $script eq "write_bed" ) { script_write_bed( $in, $out, $options ) }
elsif ( $script eq "write_psl" ) { script_write_psl( $in, $out, $options ) }
+ elsif ( $script eq "write_fixedstep" ) { script_write_fixedstep( $in, $out, $options ) }
elsif ( $script eq "write_2bit" ) { script_write_2bit( $in, $out, $options ) }
elsif ( $script eq "write_solid" ) { script_write_solid( $in, $out, $options ) }
elsif ( $script eq "head_records" ) { script_head_records( $in, $out, $options ) }
compress|Z
);
}
+ elsif ( $script eq "write_fixedstep" )
+ {
+ @options = qw(
+ no_stream|x
+ data_out|o=s
+ compress|Z
+ );
+ }
elsif ( $script eq "write_2bit" )
{
@options = qw(
# Write BED format for the UCSC genome browser using records in stream.
- # Crude - needs lots of work!
-
my ( $in, # handle to in stream
$out, # handle to out stream
$options, # options hash
}
+sub script_write_fixedstep
+{
+ # Martin A. Hansen, Juli 2008.
+
+ # Write fixedStep entries from recrods in the stream.
+
+ my ( $in, # handle to in stream
+ $out, # handle to out stream
+ $options, # options hash
+ ) = @_;
+
+ # Returns nothing.
+
+ my ( $fh, $record, $vals );
+
+ $fh = write_stream( $options->{ "data_out" }, $options->{ "compress" } );
+
+ while ( $record = get_record( $in ) )
+ {
+ if ( $record->{ "CHR" } and $record->{ "CHR_BEG" } and $record->{ "STEP" } and $record->{ "VALS" } )
+ {
+ print $fh "fixedStep chrom=$record->{ 'CHR' } start=$record->{ 'CHR_BEG' } step=$record->{ 'STEP' }\n";
+
+ $vals = $record->{ 'VALS' };
+
+ $vals =~ tr/,/\n/;
+
+ print $fh "$vals\n";
+ }
+
+ put_record( $record, $out ) if not $options->{ "no_stream" };
+ }
+
+ close $fh;
+}
+
+
sub script_write_2bit
{
# Martin A. Hansen, March 2008.