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 features from the database.
39 $registry->get_adaptor(
'Human',
'Core',
'SupportingFeature' );
47 package Bio::EnsEMBL::DBSQL::SupportingFeatureAdaptor;
57 #inherits from BaseAdaptor
62 =head2 fetch_all_by_Exon
65 The
exon to fetch supporting features.
67 @{ $supporting_feat_adaptor->fetch_all_by_Exon($exon) };
68 Description: Retrieves supporting features (evidence)
for a given
70 Returntype : List of Bio::EnsEMBL::BaseAlignFeatures in the same
71 coordinate system as the $exon argument
72 Exceptions : Warning
if $exon is not in the database (i.e. dbID
74 Throw
if a retrieved supporting feature is of unknown
81 sub fetch_all_by_Exon {
82 my ( $self, $exon ) = @_;
87 warning(
"Cannot retrieve evidence for exon without dbID");
91 my $sth = $self->prepare(
"SELECT sf.feature_type, sf.feature_id
92 FROM supporting_feature sf
95 $sth->bind_param(1,$exon->dbID,SQL_INTEGER);
98 my $prot_adp = $self->db->get_ProteinAlignFeatureAdaptor;
99 my $dna_adp = $self->db->get_DnaAlignFeatureAdaptor;
102 while(my ($type, $feature_id) = $sth->fetchrow){
103 if($type eq
'protein_align_feature'){
104 $feature = $prot_adp->fetch_by_dbID($feature_id);
105 } elsif($type eq
'dna_align_feature'){
106 $feature = $dna_adp->fetch_by_dbID($feature_id);
108 warning(
"Unknown feature type [$type]\n");
112 warning(
"Supporting feature $type $feature_id does not exist in DB");
114 my $new_feature = $feature->transfer($exon->slice());
115 push @$out, $new_feature
if( $new_feature );
126 Arg [1] : Int $exonsID
131 Example : $sfa->store($exon_id, \@features);
132 Description: Stores a set of alignment features and associates an
135 Exceptions : thrown when invalid dbID is passed to
this method
136 Caller : TranscriptAdaptor
142 my ( $self, $exon_dbID, $aln_objs ) = @_;
145 "SELECT protein_align_feature_id " .
146 "FROM protein_align_feature " .
147 "WHERE seq_region_id = ? " .
148 "AND seq_region_start = ? " .
149 "AND seq_region_end = ? " .
150 "AND seq_region_strand = ? " .
151 "AND hit_name = ? " .
152 "AND hit_start = ? " .
154 "AND analysis_id = ? " .
155 "AND cigar_line = ? ";
158 "SELECT dna_align_feature_id " .
159 "FROM dna_align_feature " .
160 "WHERE seq_region_id = ? " .
161 "AND seq_region_start = ? " .
162 "AND seq_region_end = ? " .
163 "AND seq_region_strand = ? " .
164 "AND hit_name = ? " .
165 "AND hit_start = ? " .
167 "AND analysis_id = ? " .
168 "AND cigar_line = ? " .
169 "AND hit_strand = ? ";
171 my $assoc_check_sql =
173 "FROM supporting_feature " .
174 "WHERE exon_id = $exon_dbID " .
175 "AND feature_type = ? " .
176 "AND feature_id = ? ";
178 my $assoc_write_sql =
"INSERT into supporting_feature " .
179 "(exon_id, feature_id, feature_type) " .
182 my $pep_check_sth = $self->prepare($pep_check_sql);
183 my $dna_check_sth = $self->prepare($dna_check_sql);
184 my $assoc_check_sth = $self->prepare($assoc_check_sql);
185 my $sf_sth = $self->prepare($assoc_write_sql);
187 my $dna_adaptor = $self->db->get_DnaAlignFeatureAdaptor();
188 my $pep_adaptor = $self->db->get_ProteinAlignFeatureAdaptor();
190 foreach my $f (@$aln_objs) {
191 # check that the feature is in toplevel coords
193 if($f->slice->start != 1 || $f->slice->strand != 1) {
194 #move feature onto a slice of the entire seq_region
195 my $tls = $self->db->get_sliceAdaptor->fetch_by_region($f->slice->coord_system->name(),
196 $f->slice->seq_region_name(),
200 $f->slice->coord_system->version());
201 $f = $f->transfer($tls);
204 throw(
'Could not transfer Feature to slice of ' .
205 'entire seq_region prior to storing');
209 if(!$f->isa(
"Bio::EnsEMBL::BaseAlignFeature")){
210 throw(
"$f must be an align feature otherwise" .
211 "it can't be stored");
214 my ($sf_dbID, $type, $adap, $check_sth);
216 my @check_args = ($self->db->get_SliceAdaptor->get_seq_region_id($f->slice),
226 if($f->isa(
"Bio::EnsEMBL::DnaDnaAlignFeature")){
227 $adap = $dna_adaptor;
228 $check_sth = $dna_check_sth;
229 $type =
'dna_align_feature';
230 push @check_args, $f->hstrand;
231 } elsif($f->isa(
"Bio::EnsEMBL::DnaPepAlignFeature")){
232 $adap = $pep_adaptor;
233 $check_sth = $pep_check_sth;
234 $type =
'protein_align_feature';
236 warning(
"Supporting feature of unknown type. Skipping : [$f]\n");
240 $check_sth->execute(@check_args);
241 $sf_dbID = $check_sth->fetchrow_array;
247 # now check association
248 $assoc_check_sth->execute($type,
250 if (not $assoc_check_sth->fetchrow_array) {
251 $sf_sth->bind_param(1, $exon_dbID, SQL_INTEGER);
252 $sf_sth->bind_param(2, $sf_dbID, SQL_INTEGER);
253 $sf_sth->bind_param(3, $type, SQL_VARCHAR);
258 $dna_check_sth->finish;
259 $pep_check_sth->finish;
260 $assoc_check_sth->finish;