From: Naama M. <nm...@us...> - 2008-03-17 20:13:43
|
Update of /cvsroot/gmod/schema/chado/bin/cxgn In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv5125/bin/cxgn Modified Files: load_cvterms.pl Log Message: load_cvterms checks first if relationship ontology is loaded. When inserting a cvterm_relationship will use relationships under RO namespace before looking for predicate terms from the loaded ontology name. Index: load_cvterms.pl =================================================================== RCS file: /cvsroot/gmod/schema/chado/bin/cxgn/load_cvterms.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** load_cvterms.pl 10 Mar 2008 17:39:56 -0000 1.4 --- load_cvterms.pl 17 Mar 2008 20:13:46 -0000 1.5 *************** *** 6,10 **** =head1 DESCRIPTION ! Usage: perl load_cvterms.pl -H dbhost -D dbname [-vDnFo] file parameters --- 6,10 ---- =head1 DESCRIPTION ! Usage: perl load_cvterms.pl -H dbhost -D dbname [-vdntuFo] file parameters *************** *** 117,121 **** =head1 VERSION AND DATE ! Version 0.12, February 2007. =cut --- 117,121 ---- =head1 VERSION AND DATE ! Version 0.12, February 2008. =cut *************** *** 146,150 **** my $DBPROFILE = $opt_p; ! $DBPROFILE ||= 'default'; my $gmod_conf = Bio::GMOD::Config->new(); my $db_conf = Bio::GMOD::DB::Config->new( $gmod_conf, $DBPROFILE ); --- 146,150 ---- my $DBPROFILE = $opt_p; ! $DBPROFILE ||= undef; my $gmod_conf = Bio::GMOD::Config->new(); my $db_conf = Bio::GMOD::DB::Config->new( $gmod_conf, $DBPROFILE ); *************** *** 187,191 **** my $dbh = CXGN::DB::InsertDBH->new( { dbhost=>$dbhost, dbname=>$dbname, ! dbprofile=>$DBPROFILE, } ); --- 187,191 ---- my $dbh = CXGN::DB::InsertDBH->new( { dbhost=>$dbhost, dbname=>$dbname, ! #dbprofile=>$DBPROFILE, } ); *************** *** 204,208 **** push @onts, $ont; } ! #$new_ont = $onts[-1]; foreach my $new_ont(@onts) { --- 204,208 ---- push @onts, $ont; } ! foreach my $new_ont(@onts) { *************** *** 212,216 **** --- 212,231 ---- if ($opt_n && ( $opt_n ne $new_ont_name) ) { print STDERR "$opt_n: skipping to next ontology..\n"; next (); } + #check if relationship ontology is already loaded: + if ($new_ont_name ne 'relationship') { + my $rel_cv= CXGN::Chado::Ontology->new_with_name($dbh, 'relationship'); + my @rel=$rel_cv->get_predicate_terms(); + if (!@rel) { + warn "Relationship ontology must be loaded first!!\n" ; + exit(0); + } + } + my $cv = CXGN::Chado::Ontology->new_with_name($dbh, $new_ont->name()); # also get a CXGN::Chado::Ontology object for the cv_id (see later). + #store a new cv if the ontology namespace does not exist + if (!$cv->get_cv_id() ) { + $cv->name($new_ont_name); + $cv->store(); + } print STDERR "cv_id = ".($cv->get_cv_id())."\n"; *************** *** 235,240 **** print STDERR "Retrieved ".(scalar(@all_file_terms))." terms.\n"; ! print OUT "Retrieved ".(scalar(@all_file_terms))." terms.\n" if $opt_o; #look at all predecate terms (Typedefs) my @all_db_predicate_terms = $db_ont->get_predicate_terms(); --- 250,256 ---- print STDERR "Retrieved ".(scalar(@all_file_terms))." terms.\n"; ! print OUT "Retrieved ".(scalar(@all_file_terms))." terms.\n" if $opt_o; + #look at all predecate terms (Typedefs) my @all_db_predicate_terms = $db_ont->get_predicate_terms(); *************** *** 299,303 **** print STDERR "Determining which terms are new...\n"; ! foreach my $k (keys(%file_index)) { --- 315,319 ---- print STDERR "Determining which terms are new...\n"; ! #exit(); foreach my $k (keys(%file_index)) { *************** *** 570,582 **** my $predicate_term_name = $file_relationships{$r}->predicate_term()->name(); ! my $cv_id= CXGN::Chado::CV->new_with_name($dbh, "relationship")->get_cv_id(); ! if (!$cv_id) { $cv_id= CXGN::Chado::CV->new_with_name($dbh, $db_ont->name)->get_cv_id(); } ! my $predicate_term = CXGN::Chado::Cvterm->new_with_term_name($dbh, $predicate_term_name, $cv_id); ! if (!$predicate_term->get_cvterm_id()) { ! die "The predicate term $predicate_term_name does not exist in the database\n"; } $new_rel->predicate_term($predicate_term); ! if ($opt_v) { print STDERR "Storing relationship $r. type cv_id=$cv_id\n"; } if (!$opt_t) { $new_rel->store(); --- 586,601 ---- my $predicate_term_name = $file_relationships{$r}->predicate_term()->name(); ! my $rel_cv_id= CXGN::Chado::Ontology->new_with_name($dbh, "relationship")->identifier(); ! my $cv_id= $db_ont->identifier(); ! my $predicate_term = CXGN::Chado::Cvterm->new_with_term_name($dbh, $predicate_term_name, $rel_cv_id); ! if (!$predicate_term->get_cvterm_id()) { ! $predicate_term=CXGN::Chado::Cvterm->new_with_term_name($dbh, $predicate_term_name, $cv_id); ! if (!$predicate_term->get_cvterm_id()) { ! die "The predicate term $predicate_term_name does not exist in the database\n"; ! } } $new_rel->predicate_term($predicate_term); ! if ($opt_v) { print STDERR "Storing relationship $r. type cv_id=" . $predicate_term->get_cv_id() ."\n"; } if (!$opt_t) { $new_rel->store(); |