on mouseover, display means for training and selection pops
[sgn.git] / bin / load_trait_formula.pl
blob6b02f7fb0a041f3d1c6659ce3492e0833d7dc477
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
5 use Bio::Chado::Schema;
6 use Getopt::Std;
7 use CXGN::DB::InsertDBH;
8 use SGN::Model::Cvterm;
10 our ($opt_H, $opt_D);
11 getopts("H:D:");
12 my $dbhost = $opt_H;
13 my $dbname = $opt_D;
14 my $file = shift;
15 my @traits;
16 my @formulas;
17 my @array_ref;
19 my $dbh = CXGN::DB::InsertDBH->new( { dbhost=>"$dbhost",
20 dbname=>"$dbname",
21 dbargs => {AutoCommit => 1,
22 RaiseError => 1,
25 } );
28 my $schema= Bio::Chado::Schema->connect( sub { $dbh->get_actual_dbh() });
30 my $formula_cvterm = $schema->resultset("Cv::Cvterm")->create_with({
31 name => "formula",
32 cv => "cvterm_property",
33 });
35 my $type_id = $formula_cvterm->cvterm_id();
37 open (my $file_fh, "<", $file ) || die ("\nERROR: the file $file could not be found\n" );
39 my $header = <$file_fh>;
40 while (my $line = <$file_fh>) {
41 chomp $line;
43 my ($my_trait,$my_formula) = split("\t", $line);
44 push @traits, $my_trait;
45 push @formulas, $my_formula;
48 for (my $n=0; $n<scalar(@traits); $n++) {
49 print STDERR $traits[$n]."\n";
50 my $trait_cvterm = SGN::Model::Cvterm->get_cvterm_row_from_trait_name($schema, $traits[$n]);
51 if (!$trait_cvterm) {
52 print STDERR "The trait $traits[$n] is not in the database. Skipping...\n";
53 next();
56 my $cvterm_id = $trait_cvterm->cvterm_id();
57 my $new_prop= $trait_cvterm->create_cvtermprops({formula=>$formulas[$n]} , {} );