Newer
Older
}
use MultiTestDB;
use TestUtils qw(test_getter_setter debug);
use Bio::EnsEMBL::DnaPepAlignFeature;
our $verbose = 0;
my $multi = MultiTestDB->new();
ok(1);
my $db = $multi->get_DBAdaptor('core');
my $pafa = $db->get_ProteinAlignFeatureAdaptor();
# list_dbIDs
debug("ProteinAlignFeatureAdaptor->list_dbIDs");
my $ids = $pafa->list_dbIDs();
ok (@{$ids});
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
156
157
158
159
160
161
162
#
# Test retrieval via Slice
#
my $feats;
my $chr_slice = $db->get_SliceAdaptor->fetch_by_region('chromosome','20',
30_500_000, 30_700_000);
$feats = $pafa->fetch_all_by_Slice($chr_slice);
debug('---fetching by chromosomal slice---');
debug("Got " . scalar(@$feats) . " features back");
ok(@$feats == 2429);
print_features($feats);
my $ctg_slice;
$ctg_slice = $db->get_SliceAdaptor->fetch_by_region('contig',
'AL031658.11.1.162976',
1,
50_000);
$feats = $pafa->fetch_all_by_Slice($ctg_slice);
debug('--- contig AL031658.11.1.162976 (1-50000) features ---');
debug("Got " . scalar(@$feats));
ok(@$feats == 357);
print_features($feats);
#
# Test fetch_by_dbID
#
my $feat = $pafa->fetch_by_dbID(5339568);
debug('--- fetching by dbID ---');
ok($feat);
print_features([$feat]);
$feat = $feat->transform('supercontig');
debug('--- transforming to supercontig coords ---');
ok($feat);
print_features([$feat]);
#
# Test fetch_by_Slice_and_pid
#
$feats = $pafa->fetch_all_by_Slice_and_pid($chr_slice, '90');
debug('--- fetching by chr Slice and pid (90) ---');
debug("Got " . scalar(@$feats));
ok(@$feats == 64);
print_features($feats);
#
# Test store
#
$multi->save('core', 'protein_align_feature');
my $analysis = $feat->analysis;
my $slice =
$db->get_SliceAdaptor->fetch_by_region('contig','AL031658.11.1.162976');
my $start = 100;
my $end = 200;
my $strand = 1;
my $hstart = 10;
my $hend = 110;
my $hstrand = -1;
my $hseqname = 'test';
my $score = 80;
my $percent_id = 90;
my $evalue = 23.2;
my $cigar_string = '100M';
$feat = Bio::EnsEMBL::DnaPepAlignFeature->new
(-START => $start,
-END => $end,
-STRAND => $strand,
-SLICE => $slice,
-HSTART => $hstart,
-HEND => $hend,
-HSTRAND => 1,
-HSEQNAME => $hseqname,
-CIGAR_STRING => '100M',
-PERCENT_ID => $percent_id,
-SCORE => $score,
-P_VALUE => $evalue,
-ANALYSIS => $analysis);
ok(!$feat->is_stored($db));
$pafa->store($feat);
ok($feat->is_stored($db));
my $dbID = $feat->dbID();
$feat = $pafa->fetch_by_dbID($dbID);
ok($feat->dbID == $dbID);
ok($feat->start == $start);
ok($feat->end == $end);
ok($feat->strand == $strand);
ok($feat->slice->name eq $slice->name);
ok($feat->hstart == $hstart);
ok($feat->hend == $hend);
ok($feat->hseqname eq $hseqname);
ok($feat->cigar_string eq $cigar_string);
ok($feat->percent_id == $percent_id);
ok($feat->score == $score);
ok($feat->p_value == $evalue);
ok($feat->analysis->logic_name eq $analysis->logic_name);
$multi->restore('core', 'protein_align_feature');
sub print_features {
return if(!$verbose);
my $features = shift;
foreach my $f (@$features) {
if(defined($f)) {
my $seqname = $f->slice->seq_region_name();
my $analysis = $f->analysis->logic_name();
debug($seqname . ' ' . $f->start().'-'.$f->end().'('.$f->strand().
') ['. $f->dbID.'] '. $f->cigar_string . ' ' .
$f->hstart .'-'.$f->hend.' ('.$f->hstrand.')'.$f->score() .
" ($analysis) " . $f->percent_id);
} else {
debug('UNDEF');
}
}
}