5 load_trait_formula.pl - loads formulas for computing derived traits
9 load_trait_formula.pl -H [database host] -D [database name] load_trait_formula_file.txt
16 load_trait_formula_file.txt: A file with two columns: trait name, trait formula.
18 If the trait name is found in the database, formula for computing the trait will be added as a cvtermprops.
22 Alex Ogbonna <aco46@cornell.edu>
29 use Bio
::Chado
::Schema
;
31 use CXGN
::DB
::InsertDBH
;
32 use SGN
::Model
::Cvterm
;
43 my $dbh = CXGN
::DB
::InsertDBH
->new( { dbhost
=>"$dbhost",
45 dbargs
=> {AutoCommit
=> 1,
52 my $schema= Bio
::Chado
::Schema
->connect( sub { $dbh->get_actual_dbh() });
54 my $formula_cvterm = $schema->resultset("Cv::Cvterm")->create_with({
56 cv
=> "cvterm_property",
59 my $type_id = $formula_cvterm->cvterm_id();
61 open (my $file_fh, "<", $file ) || die ("\nERROR: the file $file could not be found\n" );
63 my $header = <$file_fh>;
64 while (my $line = <$file_fh>) {
67 my ($my_trait,$my_formula) = split("\t", $line);
68 push @traits, $my_trait;
69 push @formulas, $my_formula;
72 for (my $n=0; $n<scalar(@traits); $n++) {
73 print STDERR
$traits[$n]."\n";
74 my $trait_cvterm = SGN
::Model
::Cvterm
->get_cvterm_row_from_trait_name($schema, $traits[$n]);
76 print STDERR
"The trait $traits[$n] is not in the database. Skipping...\n";
80 my $cvterm_id = $trait_cvterm->cvterm_id();
81 my $new_prop= $trait_cvterm->create_cvtermprops({formula
=>$formulas[$n]} , {} );