From dbaf8071b4afefc679daff6809e817fe8da567fe Mon Sep 17 00:00:00 2001 From: Kim Rutherford Date: Mon, 8 Apr 2024 23:24:44 +1200 Subject: [PATCH] Check for "from" and "to" Iwhen changing genes ID In --change-gene-id we use a GeneLookup adaptor to check that the "to" and "from" IDs are available in the main database. Refs pombase/canto#2677 --- lib/Canto/Track/TrackUtil.pm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/Canto/Track/TrackUtil.pm b/lib/Canto/Track/TrackUtil.pm index 6d18641b3..c430befc5 100644 --- a/lib/Canto/Track/TrackUtil.pm +++ b/lib/Canto/Track/TrackUtil.pm @@ -444,6 +444,20 @@ sub change_gene_id my $from_id = shift; my $to_id = shift; + my $gene_lookup = Canto::Track::get_adaptor($self->config(), 'gene'); + + my $from_id_lookup_result = $gene_lookup->lookup([$from_id]); + + if (@{$from_id_lookup_result->{found}} == 0) { + die qq|no gene found in the database for "from" ID $from_id\n|; + } + + my $to_id_lookup_result = $gene_lookup->lookup([$to_id]); + + if (@{$to_id_lookup_result->{found}} == 0) { + die qq|no gene found in the database for "to" ID $to_id\n|; + } + my $track_schema = $self->schema(); my $proc = sub {