Skip to content
Snippets Groups Projects
Commit 7e87c040 authored by Graham McVicker's avatar Graham McVicker
Browse files

storing should now properly handle xrefs relating to Genes, Transcripts, Translations (untested)

parent b6c11600
No related branches found
No related tags found
No related merge requests found
......@@ -742,9 +742,11 @@ sub store {
my $xref_id = 0;
my $sth2 = $self->prepare("INSERT INTO gene(type, analysis_id,
transcript_count, display_xref_id)
VALUES('$type', $analysisId, $trans_count, $xref_id)" );
$sth2->execute();
transcript_count,
display_xref_id)
VALUES(?,?,?,?)
$trans_count, $xref_id)" );
$sth2->execute("$type", $analysisId, $trans_count, $xref_id);
my $gene_dbID = $sth2->{'mysql_insertid'};
......@@ -772,8 +774,8 @@ sub store {
#
my $dbEntryAdaptor = $self->db->get_DBEntryAdaptor();
foreach my $dbl ( @{$gene->get_all_DBLinks} ) {
$dbEntryAdaptor->store( $dbl, $gene_dbID, "Gene" );
foreach my $dbe ( @{$gene->get_all_DBEntries} ) {
$dbEntryAdaptor->store( $dbe, $gene_dbID, "Gene" );
}
#
......@@ -788,9 +790,7 @@ sub store {
}
}
# write exons transcripts and exon_transcript table
my $trans = $gene->get_all_Transcripts;
#force lazy loading of translations before new exon dbIDs are set
......
......@@ -220,13 +220,17 @@ sub fetch_all_by_exon_stable_id {
=head2 store
Title : store
Usage : $transcriptAdaptor->store( $transcript )
Function: writes a particular transcript *but not the exons* into
the database
Example :
Returns :
Args : needs a gene ...
Arg [1] : Bio::EnsEMBL::Transcript $transcript
The transcript to be written to the database
Arg [2] : int $gene_dbID
The identifier of the gene that this transcript is associated
with
Example : $transID = $transcriptAdaptor->store($transcript, $gene->dbID);
Description: Stores a transcript in the database and returns the new
internal identifier for the stored transcript.
Returntype : int
Exceptions : none
Caller : general
=cut
......@@ -256,15 +260,16 @@ sub store {
}
# assuming that the store is used during the Genebuil process, set
# the display_xref_id to 0. This ought to get re-set during the protein
# pipeline run. This probably update to the gene table has yet to be
# implemented.
# first store the transcript w/o a display xref
# the display xref needs to be set after xrefs are stored which needs to
# happen after transcript is stored...
my $xref_id = 0;
# ok - now load this line in
my $tst = $self->prepare("
insert into transcript ( gene_id, translation_id, exon_count, display_xref_id )
insert into transcript ( gene_id, translation_id,
exon_count, display_xref_id )
values ( ?, ?, ?, 0)
");
......@@ -276,12 +281,11 @@ sub store {
my $transc_dbID = $tst->{'mysql_insertid'};
#print STDERR "Going to look at gene links\n";
#store the xrefs/object xref mapping
my $dbEntryAdaptor = $self->db->get_DBEntryAdaptor();
foreach my $dbl ( @{$transcript->get_all_DBLinks} ) {
$dbEntryAdaptor->store( $dbl, $transc_dbID, "Transcript" );
foreach my $dbe ( @{$transcript->get_all_DBEntries} ) {
$dbEntryAdaptor->store( $dbe, $transc_dbID, "Transcript" );
}
#
......@@ -289,16 +293,17 @@ sub store {
#
if(my $dxref = $transcript->display_xref) {
if(my $dxref_id = $dbEntryAdaptor->exists($dxref)) {
my $sth = $self->prepare( "update transcript set display_xref_id = ".
$dxref_id . " where transcript_id = ".$transc_dbID);
$sth->execute();
my $sth = $self->prepare( "update transcript set display_xref_id = ?".
" where transcript_id = ?");
$sth->execute($dxref_id, $transc_dbID);
$dxref->dbID($dxref_id);
$dxref->adaptor($dbEntryAdaptor);
}
}
my $etst = $self->prepare("insert into exon_transcript (exon_id,transcript_id,rank) values (?,?,?)");
my $etst =
$self->prepare("insert into exon_transcript (exon_id,transcript_id,rank)"
." values (?,?,?)");
my $rank = 1;
foreach my $exon ( @{$transcript->get_all_Exons} ) {
$etst->execute($exon->dbID,$transc_dbID,$rank);
......@@ -307,17 +312,15 @@ sub store {
if (defined($transcript->stable_id)) {
if (!defined($transcript->version)) {
$self->throw("Trying to store incomplete stable id information for transcript");
$self->throw("Trying to store incomplete stable id information for " ..
"transcript");
}
my $statement = "INSERT INTO transcript_stable_id(transcript_id," .
"stable_id,version)".
" VALUES(" . $transc_dbID . "," .
"'" . $transcript->stable_id . "'," .
$transcript->version .
")";
my $statement =
"INSERT INTO transcript_stable_id(transcript_id,stable_id,version)" .
" VALUES(?, ?, ?)";
my $sth = $self->prepare($statement);
$sth->execute();
$sth->execute($transc_dbID, $transcript->stable_id, $transcript->version);
}
$transcript->dbID( $transc_dbID );
......
......@@ -134,6 +134,19 @@ sub fetch_all_by_DBEntry {
}
=head2 store
Arg [1] : Bio::EnsEMBL::Translation $translation
The translation object to be stored in the database
Example : $transl_id = $translation_adaptor->store($translation);
Description: Stores a translation object in the database
Returntype :
Exceptions :
Caller :
=cut
sub store {
my ( $self, $translation ) = @_;
......@@ -161,9 +174,11 @@ sub store {
my $transl_dbID = $sth->{'mysql_insertid'};
#store object xref mappings to translations
my $dbEntryAdaptor = $self->db()->get_DBEntryAdaptor();
#store each of the xrefs for this translation
foreach my $dbl ( @{$translation->get_all_DBLinks} ) {
foreach my $dbl ( @{$translation->get_all_DBEntries} ) {
$dbEntryAdaptor->store( $dbl, $transl_dbID, "Translation" );
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment