3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
6 Licensed under the Apache License, Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
23 Please email comments or questions to the
public Ensembl
24 developers list at <http:
26 Questions may also be sent to the Ensembl help desk at
34 supporting features from the database.
38 $supporting_feature_adaptor =
39 $database_adaptor->get_TranscriptSupportingFeatureAdaptor;
48 package Bio::EnsEMBL::DBSQL::TranscriptSupportingFeatureAdaptor;
57 #inherits from BaseAdaptor
62 =head2 fetch_all_by_Transcript
65 The
transcript to fetch supporting features
for
66 Arg [2] : String (optional)
67 Feature type to filter upon (either
'dna_align_feature' or
'protein_align_feature')
68 Example : @sfs = @{$supporting_feat_adaptor->fetch_all_by_Transcript($transcript)};
69 @sfs = @{$supporting_feat_adaptor->fetch_all_by_Transcript($transcript, $feature_type)};
70 Description: Retrieves supporting features (evidence)
for a given
transcript.
71 Returntype : list of Bio::EnsEMBL::BaseAlignFeatures in the same coordinate
72 system as the $transcript argument
73 Exceptions : warning
if $transcript is not in the database (i.e. dbID not defined)
74 throw if a retrieved or requested supporting feature is of unknown type
80 sub fetch_all_by_Transcript {
81 my ( $self, $transcript, $feature_type ) = @_;
84 my $out_feature_type = {};
86 unless($transcript->dbID) {
87 warning(
"Cannot retrieve evidence for transcript without dbID");
91 if(defined $feature_type && $feature_type !~ /(dna)|(protein)_align_feature/) {
92 throw(
"feature type must be dna_align_feature or protein_align_feature");
95 my $sth = $self->prepare(
"SELECT tsf.feature_type, tsf.feature_id
96 FROM transcript_supporting_feature tsf
97 WHERE transcript_id = ?");
100 $sth->bind_param(1,$transcript->dbID,SQL_INTEGER);
103 my $prot_adp = $self->db->get_ProteinAlignFeatureAdaptor;
104 my $dna_adp = $self->db->get_DnaAlignFeatureAdaptor;
107 while(my ($type, $feature_id) = $sth->fetchrow){
108 if ($type eq
'protein_align_feature') {
109 $feature = $prot_adp-> fetch_by_dbID($feature_id);
111 elsif($type eq
'dna_align_feature') {
112 $feature = $dna_adp-> fetch_by_dbID($feature_id);
114 warning(
"Unknown feature type [$type]\n");
118 warning(
"Supporting feature $type $feature_id does not exist in DB");
120 my $new_feature = $feature->transfer($transcript->slice());
122 push @{$out_feature_type->{$type}}, $new_feature
if ($new_feature);
128 if(defined $feature_type){
129 return $out_feature_type->{$feature_type};
131 while(my ($feature_type, $new_features) = each(%$out_feature_type)){
132 push @$out, @{$new_features};
143 Arg [2] : Int $transID
147 Example : $dbea->store($transcript_id, \@features);
148 Description: Stores a set of alignment features and associates an
EnsEMBL transcript
151 Exceptions : thrown when invalid dbID is passed to
this method
152 Caller : TranscriptAdaptor
158 my ( $self, $tran_dbID, $aln_objs ) = @_;
161 "SELECT protein_align_feature_id " .
162 "FROM protein_align_feature " .
163 "WHERE seq_region_id = ? " .
164 "AND seq_region_start = ? " .
165 "AND seq_region_end = ? " .
166 "AND seq_region_strand = ? " .
167 "AND hit_name = ? " .
168 "AND hit_start = ? " .
170 "AND analysis_id = ? " .
171 "AND cigar_line = ? " .
172 "AND hcoverage = ? ";
175 "SELECT dna_align_feature_id " .
176 "FROM dna_align_feature " .
177 "WHERE seq_region_id = ? " .
178 "AND seq_region_start = ? " .
179 "AND seq_region_end = ? " .
180 "AND seq_region_strand = ? " .
181 "AND hit_name = ? " .
182 "AND hit_start = ? " .
184 "AND analysis_id = ? " .
185 "AND cigar_line = ? " .
186 "AND hcoverage = ? " .
187 "AND hit_strand = ? ";
189 my $assoc_check_sql =
191 "FROM transcript_supporting_feature " .
192 "WHERE transcript_id = $tran_dbID " .
193 "AND feature_type = ? " .
194 "AND feature_id = ? ";
196 my $assoc_write_sql =
"INSERT into transcript_supporting_feature " .
197 "(transcript_id, feature_id, feature_type) " .
200 my $pep_check_sth = $self->prepare($pep_check_sql);
201 my $dna_check_sth = $self->prepare($dna_check_sql);
202 my $assoc_check_sth = $self->prepare($assoc_check_sql);
203 my $sf_sth = $self->prepare($assoc_write_sql);
205 my $dna_adaptor = $self->db->get_DnaAlignFeatureAdaptor();
206 my $pep_adaptor = $self->db->get_ProteinAlignFeatureAdaptor();
208 foreach my $f (@$aln_objs) {
209 # check that the feature is in toplevel coords
211 if($f->slice->start != 1 || $f->slice->strand != 1) {
212 #move feature onto a slice of the entire seq_region
213 my $tls = $self->db->get_sliceAdaptor->fetch_by_region($f->slice->coord_system->name(),
214 $f->slice->seq_region_name(),
218 $f->slice->coord_system->version());
219 $f = $f->transfer($tls);
222 throw(
'Could not transfer Feature to slice of ' .
223 'entire seq_region prior to storing');
227 if(!$f->isa(
"Bio::EnsEMBL::BaseAlignFeature")){
228 throw(
"$f must be an align feature otherwise" .
229 "it can't be stored");
232 my ($sf_dbID, $type, $adap, $check_sth);
234 my @check_args = ($self->db->get_SliceAdaptor->get_seq_region_id($f->slice),
245 if($f->isa(
"Bio::EnsEMBL::DnaDnaAlignFeature")){
246 $adap = $dna_adaptor;
247 $check_sth = $dna_check_sth;
248 $type =
'dna_align_feature';
249 push @check_args, $f->hstrand;
250 } elsif($f->isa(
"Bio::EnsEMBL::DnaPepAlignFeature")){
251 $adap = $pep_adaptor;
252 $check_sth = $pep_check_sth;
253 $type =
'protein_align_feature';
255 warning(
"Supporting feature of unknown type. Skipping : [$f]\n");
259 $check_sth->execute(@check_args);
260 $sf_dbID = $check_sth->fetchrow_array;
268 # now check association
269 $assoc_check_sth->execute($type,
271 if (not $assoc_check_sth->fetchrow_array) {
272 $sf_sth->bind_param(1, $tran_dbID, SQL_INTEGER);
273 $sf_sth->bind_param(2, $sf_dbID, SQL_INTEGER);
274 $sf_sth->bind_param(3, $type, SQL_VARCHAR);
279 $dna_check_sth->finish;
280 $pep_check_sth->finish;
281 $assoc_check_sth->finish;