Skip to content

Commit

Permalink
make it work without a population name.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmueller committed Feb 5, 2024
1 parent 346d89b commit 28b1f75
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions bin/load_stocks.pl
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,19 @@ =head1 AUTHORS
my $synonym_string = $spreadsheet->value_at($accession, "synonyms");
my @synonyms = split /\|/ , $synonym_string;
print "Creating a stock for population $population_name (cvterm = " . $population_cvterm->name . ")\n";
my $population = $stock_rs->find_or_create(
{
'me.name' => $population_name,
'me.uniquename' => $population_name,
'me.organism_id' => $organism_id,
type_id => $population_cvterm->cvterm_id,
},
{ join => 'type' }
);
my $population;
if ($population_name) {
print "Creating a stock for population $population_name (cvterm = " . $population_cvterm->name . ")\n";
$population = $stock_rs->find_or_create(
{
'me.name' => $population_name,
'me.uniquename' => $population_name,
'me.organism_id' => $organism_id,
type_id => $population_cvterm->cvterm_id,
},
{ join => 'type' }
);
}
print "Find or create stock for accesssion $accession\n";
my $stock = $schema->resultset("Stock::Stock")->find_or_create(
Expand All @@ -180,11 +183,13 @@ =head1 AUTHORS
# the stock belongs to the population:
# add new stock_relationship
#
print "Accession $accession is member_of population $population_name \n";
$population->find_or_create_related('stock_relationship_objects', {
type_id => $member_of->cvterm_id(),
subject_id => $stock->stock_id(),
} );
if ($population_name) {
print "Accession $accession is member_of population $population_name \n";
$population->find_or_create_related('stock_relationship_objects', {
type_id => $member_of->cvterm_id(),
subject_id => $stock->stock_id(),
} );
}
if ($synonym_string) {print "Adding synonyms #" . scalar(@synonyms) . "\n"; }
foreach my $syn (@synonyms) {
if ($syn && defined($syn) && ($syn ne $accession) ) {
Expand Down

0 comments on commit 28b1f75

Please sign in to comment.