5 use Bio
::Chado
::Schema
;
12 print "Password for $opt_H / $opt_D: \n";
16 print STDERR
"Connecting to database...\n";
17 my $dsn = 'dbi:Pg:database='.$opt_D.";host=".$opt_H.";port=5432";
19 my $dbh = DBI
->connect($dsn, "postgres", $pw);
21 print STDERR
"Connecting to DBI schema...\n";
22 my $bcs_schema = Bio
::Chado
::Schema
->connect($dsn, "postgres", $pw);
24 my $female_parent_type_id = $bcs_schema->resultset("Cv::Cvterm")->find( { name
=> "female_parent" })->cvterm_id();
26 my $male_parent_type_id = $bcs_schema->resultset("Cv::Cvterm")->find( { name
=> "male_parent" })->cvterm_id();
30 open(my $F, "<", $file) || die " Can't open file $file\n";
40 print STDERR
"Processing $stock\n";
42 my $stock_row = $bcs_schema->resultset("Stock::Stock")->find( { uniquename
=> $stock });
45 print STDERR
"Could not find stock $stock. Skipping...\n";
50 my $parent_rs = $bcs_schema->resultset("Stock::StockRelationship")->search( { object_id
=> $stock_row->stock_id(), type_id
=> { -in => [ $female_parent_type_id, $male_parent_type_id] } });
52 print STDERR
"Found ".$parent_rs->count()." parents for stock $stock\n";
54 while (my $p = $parent_rs->next()) {
55 print STDERR
"Removing parent with id ".$p->subject_id()."...\n";
61 print STDERR
"Done. Total relationships deleted: $total_count.\n";