From fce7e886bf0cbdb455710da9719eea9141e4ccbb Mon Sep 17 00:00:00 2001 From: Monika Komorowska <mk8@sanger.ac.uk> Date: Mon, 11 Jun 2012 15:07:29 +0000 Subject: [PATCH] another attempt to accommodate multiple ensembl stable ids linking to the same vega stable id --- .../XrefParser/curated_transcriptParser.pm | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/misc-scripts/xref_mapping/XrefParser/curated_transcriptParser.pm b/misc-scripts/xref_mapping/XrefParser/curated_transcriptParser.pm index c9fbe1d04f..0165622ded 100644 --- a/misc-scripts/xref_mapping/XrefParser/curated_transcriptParser.pm +++ b/misc-scripts/xref_mapping/XrefParser/curated_transcriptParser.pm @@ -156,25 +156,27 @@ sub run_script { print "source id is $source_id, curated_source_id is $curated_source_id\n"; - my $sql = 'select t.stable_id, x.display_label, t.status from analysis a, xref x, object_xref ox , external_db e, transcript t where t.analysis_id = a.analysis_id and a.logic_name like "%havana%" and e.external_db_id = x.external_db_id and x.xref_id = ox.xref_id and t.transcript_id = ox.ensembl_id and e.db_name like ?'; + my $sql = 'select distinct t.stable_id, x.display_label, t.status from analysis a, xref x, object_xref ox , external_db e, transcript t where t.analysis_id = a.analysis_id and a.logic_name like "%havana%" and e.external_db_id = x.external_db_id and x.xref_id = ox.xref_id and t.transcript_id = ox.ensembl_id and e.db_name like ?'; my $sql_vega = 'select t.stable_id, x.display_label, t.status from xref x, object_xref ox , external_db e, transcript t where e.external_db_id = x.external_db_id and x.xref_id = ox.xref_id and t.transcript_id = ox.ensembl_id and t.stable_id <> x.display_label and e.db_name like ?'; my %ott_to_vega_name; - my %enst_to_ott; + my %ott_to_enst; my $sth = $core_dbc->prepare($sql) || die "Could not prepare for core $sql\n"; + my $count_ott_to_enst; foreach my $external_db (qw(Vega_transcript shares_CDS_with_OTTT shares_CDS_and_UTR_with_OTTT OTTT)){ $sth->execute($external_db) or croak( $core_dbc->errstr()); while ( my @row = $sth->fetchrow_array() ) { - $enst_to_ott{$row[0]} = $row[1]; + push (@{$ott_to_enst{$row[1]}},$row[0]); + $count_ott_to_enst++; } } - print "We have ".scalar(keys %enst_to_ott)." ott to enst entries\n " if($verbose); + print "We have $count_ott_to_enst ott to enst entries\n " if($verbose); my $dbi = $self->dbi(); @@ -193,8 +195,7 @@ sub run_script { my $xref_count = 0; - foreach my $enst (keys %enst_to_ott){ - my $ott = $enst_to_ott{$enst}; + foreach my $ott (keys %ott_to_enst){ if(defined($ott_to_vega_name{$ott})){ my $id = $curated_source_id; my $name = $ott_to_vega_name{$ott}; @@ -211,10 +212,12 @@ sub run_script { info_type => "DIRECT"} ); $xref_count++; - $self->add_direct_xref($xref_id, $enst, "transcript", ""); + foreach my $ensembl_stable_id (@{$ott_to_enst{$ott}}) { + $self->add_direct_xref($xref_id, $ensembl_stable_id, "transcript", ""); + } } if(defined($ott_to_status{$ott})){ - $status_insert_sth->execute($enst, $ott_to_status{$ott}); + $status_insert_sth->execute($ott_to_enst{$ott}, $ott_to_status{$ott}); } } @@ -247,4 +250,3 @@ sub run_script { 1; - -- GitLab