blib/htdocs/tutorial/bin/random_segments.pl untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 4 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 50 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/perl
2  
3 use strict;
4 use constant FLEN => 10000;
5 use constant SLEN => 50000;
6 use constant FNUM => 15;
7  
8 my $fclass = shift || "Match";
9 my $fprefix = shift || 'seg';
10  
11 # open STDOUT,"|sort -k4,4n" or die;
12  
13 for (1..FNUM) {
14 my $start = int(rand(SLEN));
15 my $end = $start + int(rand(FLEN));
16 $end = SLEN if $end > SLEN;
17 my $strand = rand(1) > 0.5 ? '+' : '-';
18 my $name = sprintf("$fprefix%02d",$_);
19  
20 my @rows = <<END;
21 ctgA example match $start $end . $strand . $fclass $name
22 END
23 ;
24  
25 my ($seg_start,$seg_end,$last_start,$last_end);
26 $seg_start = $start;
27 do {
28 $seg_end = $seg_start + int(rand(500));
29 $seg_end = $end if $seg_end > $end;
30 push @rows,<<END;
31 ctgA example similarity $seg_start $seg_end . $strand . $fclass $name
32 END
33 ;
34 $last_end = $seg_end;
35 $last_start = $seg_start;
36 $seg_start = $seg_end + int(rand(500));
37 } until ($seg_start > $end);
38  
39 if ($last_end < $end) {
40 $rows[-1] = <<END;
41 ctgA example similarity $last_start $end . $strand . $fclass $name
42 END
43 ;
44 }
45  
46 print @rows;
47  
48 }
49  
50 close STDOUT;