Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl
Commits
8a5cacc7
Commit
8a5cacc7
authored
21 years ago
by
Ian Longden
Browse files
Options
Downloads
Patches
Plain Diff
tests for Density features
parent
c3740bcc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/t/densityFeature.t
+32
-26
32 additions, 26 deletions
modules/t/densityFeature.t
modules/t/densityFeatureAdaptor.t
+78
-64
78 additions, 64 deletions
modules/t/densityFeatureAdaptor.t
with
110 additions
and
90 deletions
modules/t/densityFeature.t
+
32
−
26
View file @
8a5cacc7
...
...
@@ -5,6 +5,7 @@ use strict;
use
warnings
;
use
Bio::EnsEMBL::
DensityFeature
;
use
MultiTestDB
;
use
Bio::EnsEMBL::
Analysis
;
use
TestUtils
qw(debug test_getter_setter)
;
...
...
@@ -16,42 +17,47 @@ our $verbose = 0; #set to 1 to turn on debug printouts
BEGIN
{
$|
=
1
;
use
Test
;
plan
tests
=>
7
;
plan
tests
=>
4
;
}
use
TestUtils
qw( debug )
;
my
$
analysis
=
Bio::EnsEMBL::
Analysis
->
new
(
-
DBID
=>
1
,
-
LOGIC_NAME
=>
'
test
');
my
$
multi
=
MultiTestDB
->
new
;
my
$db
=
$multi
->
get_DBAdaptor
('
core
');
my
$start
=
10
;
my
$end
=
102
;
my
$density_value
=
123
;
my
$density_value_type
=
'
ratio
';
my
$analysis
=
new
Bio::EnsEMBL::
Analysis
(
-
program
=>
"
densityFeature.t
",
-
database
=>
"
ensembl
",
-
gff_source
=>
"
densityFeature.t
",
-
gff_feature
=>
"
density
",
-
logic_name
=>
"
GeneDensityTest
");
my
$df
=
Bio::EnsEMBL::
DensityFeature
->
new
(
-
start
=>
$start
,
-
end
=>
$end
,
-
analysis
=>
$analysis
,
-
density_value
=>
$density_value
,
-
density_value_type
=>
$density_value_type
);
my
$dt
=
Bio::EnsEMBL::
DensityType
->
new
(
-
analysis
=>
$analysis
,
-
block_size
=>
600
,
-
value_type
=>
'
sum
');
ok
(
$df
->
start
==
$start
&&
$df
->
analysis
==
$analysis
&&
$d
f
->
end
==
$end
);
ok
(
$df
->
strand
==
0
);
my
$slice_adaptor
=
$d
b
->
get_SliceAdaptor
(
);
my
$slice
=
$slice_adaptor
->
fetch_by_region
('
chromosome
',
'
20
',
1
,
60
0
);
ok
(
$df
->
density_value
==
$density_value
);
$df
=
Bio::EnsEMBL::
DensityFeature
->
new_fast
({'
start
'
=>
$start
,
'
end
'
=>
$end
,
'
analysis
'
=>
$analysis
,
'
density_value
'
=>
$density_value
,
'
density_value_type
'
=>
$density_value_type
});
#
#test the constructor
#
my
$feat
=
Bio::EnsEMBL::
DensityFeature
->
new
(
-
seq_region
=>
$slice
,
-
start
=>
1
,
-
end
=>
300
,
-
density_type
=>
$dt
,
-
density_value
=>
123
);
ok
(
$df
->
start
==
$start
&&
$df
->
analysis
==
$analysis
&&
$df
->
end
==
$end
);
ok
(
$df
->
strand
==
0
);
ok
(
$df
->
density_value
==
$density_value
);
ok
(
$df
->
density_value_type
eq
$density_value_type
);
ok
(
$feat
&&
ref
$feat
&&
$feat
->
isa
('
Bio::EnsEMBL::DensityFeature
'));
#
# Test the getter setter functions;
#
ok
(
&test_getter_setter
(
$feat
,
'
start
',
100
));
ok
(
&test_getter_setter
(
$feat
,
'
end
',
500
));
ok
(
&test_getter_setter
(
$feat
,
'
density_value
',
456
));
This diff is collapsed.
Click to expand it.
modules/t/densityFeatureAdaptor.t
+
78
−
64
View file @
8a5cacc7
use
lib
'
t
';
use
strict
;
use
warnings
;
use
Bio::EnsEMBL::Utils::
Exception
qw(verbose)
;
use
Bio::EnsEMBL::DBSQL::
DBAdaptor
;
use
Bio::EnsEMBL::DBSQL::
SliceAdaptor
;
use
Bio::EnsEMBL::DBSQL::
DensityFeatureAdaptor
;
use
Bio::EnsEMBL::DBSQL::
DensityTypeAdaptor
;
use
Bio::EnsEMBL::
Slice
;
use
Bio::EnsEMBL::
Analysis
;
use
Bio::EnsEMBL::
DensityType
;
use
Bio::EnsEMBL::
DensityFeature
;
use
TestUtils
qw( debug )
;
use
MultiTestDB
;
use
lib
'
t
';
BEGIN
{
$|
=
1
;
use
Test
;
plan
tests
=>
1
1
;
plan
tests
=>
1
8
;
}
...
...
@@ -18,88 +24,96 @@ BEGIN { $| = 1;
our
$verbose
=
0
;
verbose
('
WARNING
');
my
$multi
_db
=
MultiTestDB
->
new
;
my
$db
=
$multi
_db
->
get_DBAdaptor
('
core
');
my
$multi
=
MultiTestDB
->
new
;
my
$db
=
$multi
->
get_DBAdaptor
('
core
');
my
$dfa
=
$db
->
get_DensityFeatureAdaptor
();
ok
(
ref
(
$dfa
)
&&
$dfa
->
isa
('
Bio::EnsEMBL::DBSQL::DensityFeatureAdaptor
'));
my
$slice_adaptor
=
$db
->
get_SliceAdaptor
();
my
$slice
=
$slice_adaptor
->
fetch_by_region
('
chromosome
',
'
20
',
1
,
600
);
my
$dfs
=
$dfa
->
fetch_all_by_Slice
(
$slice
,
'
SNPDensity
');
ok
(
@$dfs
);
print_features
(
$dfs
);
$dfs
=
$dfa
->
fetch_all_by_Slice
(
$slice
,
'
RepeatCoverage
');
ok
(
@$dfs
);
print_features
(
$dfs
);
#
# Teststore
#
$multi
->
save
('
core
',
'
analysis
');
$multi
->
save
('
core
',
'
density_type
');
$multi
->
save
('
core
',
'
density_feature
');
$dfs
=
$dfa
->
fetch_all_by_Slice
(
$slice
,
'
SNPDensity
',
10
,
1
);
ok
(
@$dfs
);
print_features
(
$dfs
);
$dfs
=
$dfa
->
fetch_all_by_Slice
(
$slice
,
'
RepeatCoverage
',
10
,
1
);
ok
(
@$dfs
);
print_features
(
$dfs
);
$dfs
=
$dfa
->
fetch_all_by_Slice
(
$slice
,
'
SNPDensity
',
50
,
1
);
ok
(
@$dfs
);
print_features
(
$dfs
);
$dfs
=
$dfa
->
fetch_all_by_Slice
(
$slice
,
'
RepeatCoverage
',
50
,
1
);
ok
(
@$dfs
);
print_features
(
$dfs
);
$dfs
=
$dfa
->
fetch_all_by_Slice
(
$slice
,
'
SNPDensity
',
2
,
1
);
ok
(
@$dfs
);
print_features
(
$dfs
);
$dfs
=
$dfa
->
fetch_all_by_Slice
(
$slice
,
'
RepeatCoverage
',
2
,
1
);
ok
(
@$dfs
);
print_features
(
$dfs
);
my
$aa
=
$db
->
get_AnalysisAdaptor
();
my
$analysis
=
new
Bio::EnsEMBL::
Analysis
(
-
program
=>
"
densityFeatureAdaptor.t
",
-
database
=>
"
ensembl
",
-
gff_source
=>
"
densityFeatureAdaptor.t
",
-
gff_feature
=>
"
density
",
-
logic_name
=>
"
GeneDensityTest
");
ok
(
!
$analysis
->
is_stored
(
$db
));
$aa
->
store
(
$analysis
);
ok
(
$analysis
->
is_stored
(
$db
));
my
$block_size
=
6000000
;
$slice_adaptor
->
fetch_by_region
('
chromosome
',
'
20
',
50
,
600
);
my
$dta
=
$db
->
get_DensityTypeAdaptor
();
my
$dt
=
Bio::EnsEMBL::
DensityType
->
new
(
-
analysis
=>
$analysis
,
-
block_size
=>
$block_size
,
-
value_type
=>
'
sum
');
$dfs
=
$dfa
->
fetch_all_by_Slice
(
$slice
,
'
SNPDensity
',
50
,
1
);
ok
(
@$dfs
);
print_features
(
$dfs
);
$dfs
=
$dfa
->
fetch_all_by_Slice
(
$slice
,
'
RepeatCoverage
',
50
,
1
);
ok
(
@$dfs
);
print_features
(
$dfs
);
ok
(
!
$dt
->
is_stored
(
$db
));
$dta
->
store
(
$dt
);
ok
(
$dt
->
is_stored
(
$db
));
#
# helper to draw an ascii representation of the density features
#
sub
print_features
{
my
$features
=
shift
;
return
if
(
!
@$features
);
my
$sum
=
0
;
my
$length
=
0
;
my
$type
=
$features
->
[
0
]
->
density_value_type
();
debug
("
\n
");
foreach
my
$f
(
@$features
)
{
my
$draw_width
=
1
;
my
$density_value
=
$f
->
density_value
();
my
$draw_height
=
int
(
0.75
*
$density_value
);
$sum
+=
$density_value
;
$length
+=
$f
->
length
();
for
(
my
$i
=
0
;
$i
<
$draw_width
;
$i
++
)
{
debug
(('
*
'
x$draw_height
)
.
"
(
$density_value
)
");
my
$slice_adaptor
=
$db
->
get_SliceAdaptor
();
my
$slice
=
$slice_adaptor
->
fetch_by_region
('
chromosome
',
'
20
',
1
,
(
$block_size
*
10
));
my
$start
=
$slice
->
start
();
my
$end
=
(
$start
+
$block_size
)
-
1
;
my
$term
=
$slice
->
start
+
$slice
->
length
;
my
@density_features
=
();
while
(
$start
<
$term
){
my
$sub_slice
=
$slice_adaptor
->
fetch_by_region
('
chromosome
','
20
',
$start
,
$end
);
my
$count
=
0
;
foreach
my
$gene
(
@
{
$sub_slice
->
get_all_Genes
()}){
if
(
$gene
->
analysis
()
->
logic_name
()
ne
"
pseudogene
"
and
$gene
->
start
>=
1
){
$count
++
}
}
my
$avg
=
undef
;
$avg
=
$sum
/
$length
if
(
$length
<
0
);
debug
("
Type=
$type
, Sum=
$sum
, Length=
$length
, Avg/Base=
$sum
");
# print $count."\n";
push
@density_features
,
Bio::EnsEMBL::
DensityFeature
->
new
(
-
seq_region
=>
$slice
,
-
start
=>
$start
,
-
end
=>
$end
,
-
density_type
=>
$dt
,
-
density_value
=>
$count
);
$start
=
$end
+
1
;
$end
=
(
$start
+
$block_size
)
-
1
;
}
ok
(
scalar
(
@density_features
)
==
10
);
ok
(
!
$density_features
[
0
]
->
is_stored
(
$db
));
$dfa
->
store
(
@density_features
);
ok
(
$density_features
[
0
]
->
is_stored
(
$db
));
#
# get back from database and check
#
my
@stored_features
=
@
{
$dfa
->
fetch_all_by_Slice
(
$slice
,'
GeneDensityTest
',
10
)};
for
(
my
$i
=
0
;
$i
<
scalar
(
@density_features
);
$i
++
){
ok
(
$density_features
[
0
]
->
density_value
()
==
$stored_features
[
0
]
->
density_value
());
}
$multi
->
restore
('
core
',
'
analysis
');
$multi
->
restore
('
core
',
'
density_type
');
$multi
->
restore
('
core
',
'
density_feature
');
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment