Newer
Older
# Copyright [1999-2013] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Andy Yates
committed
use Test::More;
use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::Test::TestUtils;
our $verbose = 0; #set to 1 to turn on debug printouts
my $multi = Bio::EnsEMBL::Test::MultiTestDB->new();
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
my $db = $multi->get_DBAdaptor( 'core' );
#
# 1 Test AssemblyMapperAdaptor constructor
#
my $asma = $db->get_AssemblyMapperAdaptor();
ok($asma && $asma->isa('Bio::EnsEMBL::DBSQL::AssemblyMapperAdaptor'));
#
# 2 Test fetch_by_CoordSystems
#
my $csa = $db->get_CoordSystemAdaptor();
my $chr_cs = $csa->fetch_by_name('chromosome');
my $cln_cs = $csa->fetch_by_name('clone');
my $sctg_cs = $csa->fetch_by_name('supercontig');
my $asm_mapper = $asma->fetch_by_CoordSystems($cln_cs, $chr_cs);
ok($asm_mapper && $asm_mapper->isa('Bio::EnsEMBL::ChainedAssemblyMapper'));
my $chr_sctg_mapper = $asma->fetch_by_CoordSystems($chr_cs, $sctg_cs);
ok($chr_sctg_mapper &&
$chr_sctg_mapper->isa('Bio::EnsEMBL::ChainedAssemblyMapper'));
#
# test db has chr 20 (50KB -> 62MB)
#
#
# 3 Test map
#
my @coords = $asm_mapper->map('20', 500_001, 60_000_000, 1, $chr_cs);
ok(@coords);
debug("MAP 20->clone\n");
print_coords(@coords);
debug("MAP 'AL359765.6'->chromosome\n");
@coords = $asm_mapper->map('AL359765.6', 1, 13780, 1, $cln_cs);
ok(@coords);
print_coords(@coords);
debug("MAP 20->supercontig\n");
@coords = $chr_sctg_mapper->map('20', 500_001, 60_000_000, 1, $chr_cs);
ok(@coords);
print_coords(@coords);
#
# Test list_seq_regions
#
my @seq_regions =
$asm_mapper->list_seq_regions('20', 500_001, 60_000_000, $chr_cs);
ok(@seq_regions);
my $str = join("\n", "----------", @seq_regions);
debug("$str\n");
@seq_regions =
$asm_mapper->list_seq_regions('AL359765.6', 1, 13780, $cln_cs);
ok(@seq_regions);
$str = join("\n", "----------", @seq_regions);
debug("$str\n");
@seq_regions =
$chr_sctg_mapper->list_seq_regions('NT_028392',600_000, 1_000_000, $sctg_cs);
ok(@seq_regions);
$str = join("\n", "----------", @seq_regions);
debug("$str\n");
@seq_regions =
$chr_sctg_mapper->list_seq_regions('20', 30_000_000, 31_000_000, $chr_cs);
ok(@seq_regions);
$str = join("\n", "----------", @seq_regions);
debug("$str\n");
#
# Test list_seq_ids
#
my @seq_ids =
$asm_mapper->list_ids('20', 500_001, 60_000_000, $chr_cs);
ok(@seq_ids);
$str = join("\n", "----------", @seq_ids);
debug("$str\n");
@seq_ids =
$asm_mapper->list_ids('AL359765.6', 1, 13780, $cln_cs);
ok(@seq_ids);
$str = join("\n", "----------", @seq_ids);
debug("$str\n");
@seq_ids =
$asm_mapper->list_ids('AL359765.6', 1, 13780, $cln_cs);
ok(@seq_ids);
$str = join("\n", "----------", @seq_ids);
debug("$str\n");
@seq_ids =
$chr_sctg_mapper->list_ids('20', 30_000_000, 31_000_000, $chr_cs);
ok(@seq_ids);
$str = join("\n", "----------", @seq_ids);
debug("$str\n");
sub print_coords {
my @coord_list = @_;
return if(!$verbose);
foreach my $coord (@coord_list) {
if($coord->isa('Bio::EnsEMBL::Mapper::Gap')) {
debug("GAP");
next;
}
debug($coord->id()."\t". $coord->start()."-".$coord->end().
" (".$coord->strand.")");
}
}
Andy Yates
committed
done_testing();