Bio-EnsEMBL
view release on metacpan or search on metacpan
lib/Bio/EnsEMBL/DBSQL/IntronSupportingEvidenceAdaptor.pm view on Meta::CPAN
return $sf->dbID();
}
=head2 store_transcript_linkage
Arg[1] : Bio::EnsEMBL::IntronSupportingEvidence Evidence to link
Arg[2] : Bio::EnsEMBL::Transcript Transcript to link
Arg[3] : Integer an optional ID to give if the Transcript's own ID is possibly incorrect
Example : $isea->store_transcript_linkage($ise, $transcript);
$isea->store_transcript_linkage($ise, $transcript, $tid);
Description : Links a Transcript to a portion of Intron evidence
Returntype : None
Exceptions : Thrown if the given object is not a Transcript, if the
transcript is not stored, if the supporting evidence is not
stored and for any DB exception.
=cut
sub store_transcript_linkage {
my ($self, $sf, $transcript, $transcript_id) = @_;
assert_ref($sf, 'Bio::EnsEMBL::IntronSupportingEvidence', 'intron_supporting_evidence');
assert_ref($transcript, 'Bio::EnsEMBL::Transcript', 'transcript');
throw "Cannot perform the link. The IntronSupportingEvidence must be persisted first" unless $sf->is_stored($self->db());
my $insert_ignore = $self->insert_ignore_clause();
my $sql = qq{
${insert_ignore} into transcript_intron_supporting_evidence
(transcript_id, intron_supporting_evidence_id, previous_exon_id, next_exon_id)
values (?,?,?,?)
};
my $intron = $sf->get_Intron($transcript);
my ($previous_exon, $next_exon) = ($intron->prev_Exon(), $intron->next_Exon());
$transcript_id ||= $transcript->dbID();
my $params = [
[$transcript_id, SQL_INTEGER],
[$sf->dbID(), SQL_INTEGER],
[$previous_exon->dbID(), SQL_INTEGER],
[$next_exon->dbID(), SQL_INTEGER],
];
$self->dbc()->sql_helper()->execute_update(-SQL => $sql, -PARAMS => $params);
return;
}
####### UPDATE
=head2 update
Arg[1] : Bio::EnsEMBL::IntronSupportingEvidence Evidence to update
Example : $isea->update($ise);
Description : Updates all attributes of an evidence object
Returntype : None
Exceptions : Thrown if the given object is not a IntronSupportingEvidence,
if the object is not stored and for normal DB errors
=cut
sub update {
my ($self, $sf) = @_;
assert_ref($sf, 'Bio::EnsEMBL::IntronSupportingEvidence', 'intron_supporting_evidence');
if (! $sf->is_stored($self->db())) {
throw "Cannot update the supporting evidence if it has not already been stored in this database";
}
my $params = [
[$sf->analysis()->dbID(), SQL_INTEGER],
[$sf->slice()->get_seq_region_id(), SQL_INTEGER],
[$sf->start(), SQL_INTEGER],
[$sf->end(), SQL_INTEGER],
[$sf->strand(), SQL_INTEGER],
[$sf->hit_name(), SQL_VARCHAR],
[$sf->score(), SQL_FLOAT],
[$sf->score_type(), SQL_VARCHAR],
[$sf->is_splice_canonical() || 0, SQL_INTEGER],
[$sf->dbID(), SQL_INTEGER],
];
my $sql = <<'SQL';
UPDATE intron_supporting_evidence
SET analysis_id =?, seq_region_id =?, seq_region_start =?,
seq_region_end =?, seq_region_strand =?, hit_name =?, score =?, score_type =?,
is_splice_canonical =?
WHERE intron_supporting_evidence_id =?
SQL
$self->dbc()->sql_helper()->execute_update(-SQL => $sql, -PARAMS => $params);
return;
}
####### DELETION
=head2 remove
Arg[1] : Bio::EnsEMBL::IntronSupportingEvidence
Example : $isea->remove($ise);
Description : Deletes the given IntronSupportingEvidence from the database.
This can only occur if the object has no linked transcripts
Returntype : None
Exceptions : Thrown if the IntronSupportingEvidence is not stored, if
the object has linked transcripts and in the event of any
database error
=cut
sub remove {
my ($self, $sf) = @_;
assert_ref($sf, 'Bio::EnsEMBL::IntronSupportingEvidence', 'intron_supporting_evidence');
if (! $sf->is_stored($self->db())) {
throw "Cannot delete the supporting evidence if it has not already been stored in this database";
}
if($sf->has_linked_transcripts()) {
throw sprintf('Cannot delete supporting evidence %d. It still has transcripts attached', $sf->dbID());
}
$self->dbc()->sql_helper()->execute_update(
-SQL => 'DELETE from intron_supporting_evidence where intron_supporting_evidence_id =?',
-PARAMS => [[$sf->dbID(), SQL_INTEGER]],
);
return;
( run in 2.065 seconds using v1.01-cache-2.11-cpan-f56aa216473 )