$options = Maasha::Biopieces::parse_options(
[
- { long => 'no_stream', short => 'x', type => 'flag', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
- { long => 'data_out', short => 'o', type => 'file', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
- { long => 'compress', short => 'Z', type => 'flag', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ { long => 'key', short => 'k', type => 'string', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ { long => 'step', short => 's', type => 'uint', mandatory => 'no', default => 1, allowed => undef, disallowed => undef },
+ { long => 'no_stream', short => 'x', type => 'flag', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ { long => 'data_out', short => 'o', type => 'file', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
+ { long => 'compress', short => 'Z', type => 'flag', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
]
);
while ( $record = Maasha::Biopieces::get_record( $in ) )
{
- if ( $entry = Maasha::UCSC::Wiggle::biopiece2fixedstep( $record ) ) {
+ if ( $entry = Maasha::UCSC::Wiggle::biopiece2fixedstep( $record, $options->{ "key" }, $options->{ "step" } ) ) {
Maasha::UCSC::Wiggle::fixedstep_entry_put( $entry, $fh );
}
# Converts a Biopiece record to a fixedStep entry.
- my ( $record, # Biopiece record
+ my ( $record, # Biopiece record
+ $opt_key, # Key from option hash
+ $opt_step, # Step from option hash
) = @_;
# Returns a list
- my ( @entry, $beg, $vals );
+ my ( @entry, $chr, $beg, $step, $vals );
- if ( exists $record->{ "REC_TYPE" } and $record->{ "REC_TYPE" } eq 'fixed_step' )
+ $chr = $record->{ 'CHR' } || $record->{ 'S_ID' };
+ $beg = $record->{ 'CHR_BEG' } || $record->{ 'S_BEG' };
+ $step = $record->{ 'STEP' } || $opt_step;
+ $vals = $record->{ 'VALS' };
+ $vals = $record->{ $opt_key } if $opt_key;
+
+ if ( defined $chr and defined $beg and defined $step and defined $vals)
{
- if ( exists $record->{ 'CHR' } and exists $record->{ 'CHR_BEG' } and exists $record->{ 'STEP' } )
- {
- $beg = $record->{ 'CHR_BEG' } + 1; # fixedStep is 1-based
- push @entry, "fixedStep chrom=$record->{ 'CHR' } start=$beg step=$record->{ 'STEP' }";
+ $beg += 1; # fixedStep is 1-based
- $vals = $record->{ 'VALS' };
+ push @entry, "fixedStep chrom=$chr start=$beg step=$step";
- map { push @entry, $_ } split ";", $vals;
- }
- else
- {
- Maasha::Common::error( qq(could not convert Biopiece record to fixedStep) );
- }
+ map { push @entry, $_ } split ";", $vals;
}
unless ( @entry ) {