- @array = @{ $contig_hash->{ $s_id }->{ $strand } }[ $beg .. $end - 1 ];
-
- ( $min, $max ) = Maasha::Calc::minmax( \@array );
- $mean = Maasha::Calc::mean( \@array );
-
- $new_record->{ 'S_ID' } = $s_id;
- $new_record->{ 'STRAND' } = $strand;
- $new_record->{ 'CONTIG_ID' } = $contig;
- $new_record->{ 'CONTIG_BEG' } = $beg;
- $new_record->{ 'CONTIG_END' } = $end;
- $new_record->{ 'CONTIG_LEN' } = $end - $beg + 1;
- $new_record->{ 'CONTIG_MIN' } = $min;
- $new_record->{ 'CONTIG_MAX' } = $max;
- $new_record->{ 'CONTIG_MEAN' } = sprintf "%.2f", $mean;
- $new_record->{ 'CONTIG' } = join ( ";", @array );
-
- $beg = $end + 1;
- $contig++;
-
- Maasha::Biopieces::put_record( $new_record, $out );
+ $beg = 0;
+ $end = 0;
+
+ while ( ( $beg, $end ) = Maasha::UCSC::Wiggle::fixedstep_scan( $contig_hash->{ $s_id }->{ $q_id }->{ $strand }, $beg ) )
+ {
+ @array = @{ $contig_hash->{ $s_id }->{ $q_id }->{ $strand } }[ $beg .. $end - 1 ];
+
+ ( $min, $max ) = Maasha::Calc::minmax( \@array );
+ $mean = Maasha::Calc::mean( \@array );
+
+ $new_record->{ 'S_ID' } = $s_id;
+ $new_record->{ 'Q_ID' } = $q_id if $options->{ 'q_id' };
+ $new_record->{ 'STRAND' } = $strand if $options->{ 'strand' };
+ $new_record->{ 'S_BEG' } = $beg;
+ $new_record->{ 'S_END' } = $end;
+ $new_record->{ 'CONTIG_ID' } = $contig;
+ $new_record->{ 'CONTIG_LEN' } = $end - $beg + 1;
+ $new_record->{ 'CONTIG_MIN' } = $min;
+ $new_record->{ 'CONTIG_MAX' } = $max;
+ $new_record->{ 'CONTIG_MEAN' } = sprintf "%.2f", $mean;
+ $new_record->{ 'CONTIG' } = join ( ";", @array );
+
+ $beg = $end + 1;
+ $contig++;
+
+ Maasha::Biopieces::put_record( $new_record, $out );
+ }