Skip to content

Commit

Permalink
Remove unused organisms after updating
Browse files Browse the repository at this point in the history
After updating genes using the latest species_strain_map, clean up
unused organisms.

Refs #2831
  • Loading branch information
kimrutherford committed Jun 10, 2024
1 parent 9b325f2 commit 40f4af1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions etc/reapply_species_strain_map.pl
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,29 @@ BEGIN
$gene->update();
}
}

# Remove unused organisms
$organism_rs = $curs_schema->resultset('Organism');

while (defined (my $organism = $organism_rs->next())) {
if ($organism->genes()->count() == 0 &&
$organism->genotypes()->count() == 0) {
my $strain_rs = $organism->strains();

while (defined (my $strain = $strain_rs->next())) {
if ($strain->genotypes()->count() == 0) {
$strain->delete();
}
}

if ($strain_rs->count() == 0) {
$organism->delete();
}
}
}
};


my $load_util = Canto::Track::LoadUtil->new(schema => $schema);


Expand Down

0 comments on commit 40f4af1

Please sign in to comment.