#!/usr/bin/perl
BEGIN {
plan
tests
=> 25,
}
my
$file
=
"$Bin/data/sample1.useq"
;
my
$useq
= Bio::DB::USeq->new(
$file
);
ok(
$useq
);
die
"unable to open useq file!\n"
unless
$useq
;
ok(
$useq
->type,
'region'
);
my
@seq_ids
=
$useq
->seq_ids;
ok(
scalar
@seq_ids
, 2);
ok(
$useq
->
length
(
'chrI'
), 230042);
my
$segment
=
$useq
->segment(
-seq_id
=>
'chrI'
,
-start
=> 166301,
-end
=> 166500,
);
ok(
$segment
);
ok(
$segment
->start, 166301);
my
@scores
=
$segment
->scores;
ok(
scalar
@scores
, 31);
ok(
sprintf
(
"%.2f"
,
$scores
[0]), 7.91);
ok(
sprintf
(
"%.2f"
,
$scores
[2]), 8.02);
my
$i
=
$segment
->get_seq_stream;
ok(
$i
);
my
$f
=
$i
->next_seq;
ok(
$f
);
ok(
$f
->end, 166302);
my
(
$wiggle
) =
$useq
->features(
-seq_id
=>
'chrII'
,
-start
=> 455001,
-end
=> 475000,
-type
=>
'wiggle:1000'
,
);
ok(
$wiggle
);
my
@wig_bins
=
$wiggle
->wiggle;
ok(
scalar
(
@wig_bins
), 1000);
ok(
sprintf
(
"%.2f"
,
$wig_bins
[9]), 1.94);
my
$chr_mean
=
$useq
->chr_mean(
'chrI'
);
ok(
sprintf
(
"%.2f"
,
$chr_mean
), 1.88);
my
(
$summary
) =
$useq
->features(
-seq_id
=>
'chrII'
,
-start
=> 1,
-end
=> 500000,
-type
=>
'summary'
,
);
ok(
$summary
);
my
$stats
=
$summary
->statistical_summary(10);
ok(
scalar
@$stats
, 10);
my
$second_mean
= binMean(
$stats
->[1] );
my
$second_stdev
= binStdev(
$stats
->[1] );
ok(
sprintf
(
"%.2f"
,
$second_mean
),
'0.60'
);
ok(
sprintf
(
"%.2f"
,
$second_stdev
), 0.62);
$file
=
"$Bin/data/sample2.useq"
;
undef
$useq
;
$useq
= Bio::DB::USeq->new(
-file
=>
$file
);
ok(
$useq
);
die
"unable to open useq file!\n"
unless
$useq
;
my
$stream
=
$useq
->get_seq_stream(
-seq_id
=>
'chrI'
,
-start
=> 20000,
-end
=> 20200,
);
ok(
$stream
);
my
@samples
=
map
{
$stream
->next_seq} (1..5);
ok(
scalar
@samples
, 5);
ok(
$samples
[0]->display_name,
'HWI-EAS240_0001:7:87:16824:7895#0/1'
);
ok(
$samples
[-1]->display_name,
'HWI-EAS240_0001:7:72:3375:4012#0/1'
);
exit
0;