From: <sco...@us...> - 2009-09-25 18:45:30
|
Revision: 22113 http://gmod.svn.sourceforge.net/gmod/?rev=22113&view=rev Author: scottcain Date: 2009-09-25 18:45:15 +0000 (Fri, 25 Sep 2009) Log Message: ----------- fixing the annoying bug that cause the bulk loader to sometimes assign the wrong featureloc.srcfeature_id Modified Paths: -------------- schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm schema/trunk/chado/load/bin/bulk_load_gff3.PLS Modified: schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm =================================================================== --- schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm 2009-09-25 18:10:47 UTC (rev 22112) +++ schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm 2009-09-25 18:45:15 UTC (rev 22113) @@ -170,6 +170,10 @@ WHERE type_id = ? AND organism_id = ? AND uniquename = ?"; +use constant VALIDATE_ORGANISM_ID => + "SELECT feature_id FROM public.tmp_gff_load_cache + WHERE organism_id = ? AND + uniquename = ?"; use constant VALIDATE_UNIQUENAME => "SELECT feature_id FROM public.tmp_gff_load_cache WHERE uniquename=?"; use constant INSERT_CACHE_TYPE_ID => @@ -326,6 +330,8 @@ = $dbh->prepare(SEARCH_SYNONYM); $self->{'queries'}{'validate_type_id'} = $dbh->prepare(VALIDATE_TYPE_ID); + $self->{'queries'}{'validate_organism_id'} + = $dbh->prepare(VALIDATE_ORGANISM_ID); $self->{'queries'}{'validate_uniquename'} = $dbh->prepare(VALIDATE_UNIQUENAME); $self->{'queries'}{'insert_cache_type_id'} @@ -994,6 +1000,16 @@ return $feature_id; } + elsif (defined $argv{organism_id}) { #validate uniquename and organism + $self->{'queries'}{'validate_organism_id'}->execute( + $argv{organism_id}, + $argv{uniquename}, + ); + + my ($feature_id) + = $self->{'queries'}{'validate_organism_id'}->fetchrow_array; + return $feature_id; + } else { #just validate the uniquename $self->{'queries'}{'validate_uniquename'}->execute($argv{uniquename}); @@ -2366,8 +2382,10 @@ my $self = shift; my ($name,$string) = @_; - my $uniquename = $self->modified_uniquename(orig_id=>$name) - ? $self->modified_uniquename(orig_id=>$name) + my $organism_id = $self->organism_id; + + my $uniquename = $self->modified_uniquename(orig_id=>$name, organism_id => $organism_id) + ? $self->modified_uniquename(orig_id=>$name, organism_id => $organism_id) : $name; my $fh = $self->file_handles('sequence'); @@ -2740,7 +2758,9 @@ =item Usage - $obj->modified_uniquename(orig_id => $id, modified_id => $new_id) + $obj->modified_uniquename(orig_id => $id, + modified_id => $new_id, + organism_id => $organism_id) =item Function @@ -2749,14 +2769,15 @@ =item Returns -When called with two pairs of args, nothing. When called with one pair of -args, return the value of the other arg. For example, when called with -"orig_id => $id", the method would return $new_id. +When called with all three pairs of args, nothing. When called with one of +orig_id or modified_id args, return the value of the other arg. For example, +when called with "orig_id => $id", the method would return $new_id. =item Arguments Two possible hash pairs: orig_id for the ID that was present in the GFF file -and modified_id for the uniquename that will be in Chado. +and modified_id for the uniquename that will be in Chado. Additionally, +the organism_id hash pair must be supplied. =back @@ -2765,16 +2786,29 @@ sub modified_uniquename { my ($self, %argv) = @_; + if (!defined $argv{'organism_id'}) { + confess "organism_id must be supplied to the modified_uniquename method"; + } + if (defined $argv{'orig_id'} && defined $argv{'modified_id'}) { #set - $self->{'modified_uniquename'}->{'orig2mod'}->{$argv{'orig_id'}} = $argv{'modified_id'}; - $self->{'modified_uniquename'}->{'mod2orig'}->{$argv{'modified_id'}} = $argv{'orig_id'}; + + cluck "organism_id is: ",$argv{'organism_id'}; + + $self->{'modified_uniquename'}-> + {$argv{'organism_id'}}-> + {'orig2mod'}-> + {$argv{'orig_id'}} = $argv{'modified_id'}; + $self->{'modified_uniquename'}-> + {$argv{'organism_id'}}-> + {'mod2orig'}-> + {$argv{'modified_id'}} = $argv{'orig_id'}; return; } elsif (defined $argv{'orig_id'}) { - return $self->{'modified_uniquename'}->{'orig2mod'}->{$argv{'orig_id'}}; + return $self->{'modified_uniquename'}->{$argv{'organism_id'}}->{'orig2mod'}->{$argv{'orig_id'}}; } elsif (defined $argv{'modified_id'}) { - return $self->{'modified_uniquename'}->{'mod2orig'}->{$argv{'modified_id'}}; + return $self->{'modified_uniquename'}->{$argv{'organism_id'}}->{'mod2orig'}->{$argv{'modified_id'}}; } else { cluck"this shouldn't happen in modified_uniquename"; @@ -3091,6 +3125,7 @@ my $self = shift; my ($feature, $uniquename,$name,$featuretype,$type) = @_; + my $organism_id = $self->organism_id; my @targets = $feature->annotation->get_Annotations('Target'); my $rank = 1; foreach my $target (@targets) { @@ -3106,8 +3141,8 @@ my $created_target_feature = 0; #check for an existing feature with the Target's uniquename - my $real_target_id = $self->modified_uniquename(orig_id => $target_id) ? - $self->modified_uniquename(orig_id => $target_id) + my $real_target_id = $self->modified_uniquename(orig_id => $target_id, organism_id => $organism_id) ? + $self->modified_uniquename(orig_id => $target_id, organism_id => $organism_id) : $target_id; if ( $self->uniquename_cache(validate=>1,uniquename=>$real_target_id) ) { $self->print_floc( @@ -3724,6 +3759,8 @@ my $feat = shift; my $dbh = $self->dbh; + my $organism_id = $self->organism_id; + # warn Dumper($feat); my $feat_id = ($feat->annotation->get_Annotations('ID'))[0]->value @@ -3735,8 +3772,8 @@ #assume that an exon can have at most one grandparent (gene, operon) my $first_parent = $feat_parents[0]; my $f_parent_uniquename - = $self->modified_uniquename(orig_id=>$first_parent) - ? $self->modified_uniquename(orig_id=>$first_parent) + = $self->modified_uniquename(orig_id=>$first_parent, organism_id => $organism_id) + ? $self->modified_uniquename(orig_id=>$first_parent, organism_id => $organism_id) : $first_parent; my $parent_id = $self->cache('feature',$f_parent_uniquename) if $f_parent_uniquename; @@ -4171,10 +4208,12 @@ my $self = shift; my ($feature) = @_; + my $organism_id = $self->organism_id; + for my $p_anot ( $feature->annotation->get_Annotations('Parent') ) { my $orig_pname = $p_anot->value; - my $pname = $self->modified_uniquename(orig_id => $orig_pname) - ? $self->modified_uniquename(orig_id => $orig_pname) + my $pname = $self->modified_uniquename(orig_id => $orig_pname, organism_id => $organism_id) + ? $self->modified_uniquename(orig_id => $orig_pname, organism_id => $organism_id) : $orig_pname; my $parent = $self->cache('feature',$pname); confess "\nno parent $orig_pname ($pname);\nyou probably need to rerun the loader with the --recreate_cache option\n\n" unless $parent; @@ -4191,10 +4230,12 @@ my $self = shift; my ($feature) = @_; + my $organism_id = $self->organism_id; + for my $p_anot ( $feature->annotation->get_Annotations('Derives_from') ) { my $orig_pname = $p_anot->value; - my $pname = $self->modified_uniquename(orig_id => $orig_pname) - ? $self->modified_uniquename(orig_id => $orig_pname) + my $pname = $self->modified_uniquename(orig_id => $orig_pname, organism_id => $organism_id) + ? $self->modified_uniquename(orig_id => $orig_pname, organism_id => $organism_id) : $orig_pname; my $parent = $self->cache('feature',$pname); confess "no parent ".$orig_pname unless $parent; @@ -4303,6 +4344,8 @@ my $self = shift; my ($feature) = @_; + my $organism_id = $self->organism_id; + my $src; if($feature->seq_id eq '.'){ $src = '\N'; @@ -4310,8 +4353,8 @@ #check to see if the uniquename had to be changed my $src_uniquename = - $self->modified_uniquename(orig_id => $feature->seq_id) ? - $self->modified_uniquename(orig_id => $feature->seq_id) + $self->modified_uniquename(orig_id => $feature->seq_id, organism_id => $organism_id) ? + $self->modified_uniquename(orig_id => $feature->seq_id, organism_id => $organism_id) : $feature->seq_id; my ($temp_f_id)= $self->uniquename_cache( @@ -4361,6 +4404,8 @@ my $self = shift; my ($feature) = @_; + my $organism_id = $self->organism_id; + my ($src,$seqlen); if ( defined(($feature->annotation->get_Annotations('ID'))[0]) && $feature->seq_id @@ -4374,10 +4419,16 @@ } else { # normal case my $src_uniquename - = $self->modified_uniquename(orig_id=>$feature->seq_id) - ? $self->modified_uniquename(orig_id=>$feature->seq_id) + = $self->modified_uniquename(orig_id=>$feature->seq_id, organism_id => $organism_id) + ? $self->modified_uniquename(orig_id=>$feature->seq_id, organism_id => $organism_id) : $feature->seq_id; - $src = $self->cache('feature',$feature->seq_id); + $src = $self->uniquename_cache( + validate => 1, + organism_id => $organism_id, + uniquename => $src_uniquename + ); + warn "using new src sub"; +# $src = $self->cache('feature',$feature->seq_id); $seqlen = '\N'; } Modified: schema/trunk/chado/load/bin/bulk_load_gff3.PLS =================================================================== --- schema/trunk/chado/load/bin/bulk_load_gff3.PLS 2009-09-25 18:10:47 UTC (rev 22112) +++ schema/trunk/chado/load/bin/bulk_load_gff3.PLS 2009-09-25 18:45:15 UTC (rev 22113) @@ -34,7 +34,7 @@ use strict; use warnings; -use lib '/Users/cain/cvs_stuff/schema/chado/lib'; +use lib '/Users/cain/cvs_stuff/schema/trunk/chado/lib'; use Bio::FeatureIO; use Getopt::Long; use Data::Dumper; @@ -869,7 +869,8 @@ #need to keep a temporary map of modified uniquenames $chado->modified_uniquename( orig_id => ($feature->annotation->get_Annotations('ID'))[0]->value, - modified_id => $uniquename); + modified_id => $uniquename, + organism_id=>$chado->organism_id); } my($name) = defined(($feature->annotation->get_Annotations('Name'))[0]) ? @@ -881,8 +882,8 @@ $name = $name->value if ref($name); if ($uniquename eq $feature->seq_id or - (defined( $chado->modified_uniquename(modified_id => $uniquename)) and - $chado->modified_uniquename(modified_id => $uniquename) eq $feature->seq_id)) { + (defined( $chado->modified_uniquename(modified_id => $uniquename, organism_id => $chado->organism_id)) and + $chado->modified_uniquename(modified_id => $uniquename, organism_id => $chado->organism_id) eq $feature->seq_id)) { $chado->reftype_property($featuretype,$type); # a reference sequence?? yes } @@ -990,8 +991,8 @@ } #if the uniquename was modified, put the orig ID in the alias list - push @aliases, $chado->modified_uniquename(modified_id=>$uniquename) - if $chado->modified_uniquename(modified_id=>$uniquename); + push @aliases, $chado->modified_uniquename(modified_id=>$uniquename,organism_id=>$chado->organism_id) + if $chado->modified_uniquename(modified_id=>$uniquename,organism_id=>$chado->organism_id); #Un-denormalizing the synonym table #if ($name ne '\N') { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nm...@us...> - 2009-09-29 14:40:40
|
Revision: 22125 http://gmod.svn.sourceforge.net/gmod/?rev=22125&view=rev Author: nm249 Date: 2009-09-29 14:40:24 +0000 (Tue, 29 Sep 2009) Log Message: ----------- added script for loading NCBI taxonomy into the phylogeny module Modified Paths: -------------- schema/trunk/chado/lib/CXGN/Chado/Db.pm schema/trunk/chado/lib/CXGN/Chado/Dbxref.pm schema/trunk/chado/lib/CXGN/Chado/Organism.pm schema/trunk/chado/lib/CXGN/DB/Connection.pm schema/trunk/chado/lib/CXGN/DB/InsertDBH.pm schema/trunk/chado/lib/CXGN/Debug.pm schema/trunk/chado/lib/CXGN/VHost.pm Added Paths: ----------- schema/trunk/chado/bin/cxgn/load_ncbi_taxonomy.pl Added: schema/trunk/chado/bin/cxgn/load_ncbi_taxonomy.pl =================================================================== --- schema/trunk/chado/bin/cxgn/load_ncbi_taxonomy.pl (rev 0) +++ schema/trunk/chado/bin/cxgn/load_ncbi_taxonomy.pl 2009-09-29 14:40:24 UTC (rev 22125) @@ -0,0 +1,539 @@ + +=head1 NAME + + load_ncbi_taxonomy.pl + +=head1 DESCRIPTION + + Usage: perl load_ncbi_taxonomy.pl -H [dbhost] -D [dbname] [-vt] -i file + +populate a chado database with organism information (see the organism module and phylogeny module) +Requires downloading from NCBI +ftp://ftp.ncbi.nih.gov/pub/taxonomy/ +names.dmp +nodes.dmp + +parameters + +=over 7 + +=item -H + +hostname for database + +=item -D + +database name + +=item -i + +input file [optional] + +List taxonomy ids to be stored. The rest of the taxons in the name and node files will be excluded. +http://www.ncbi.nlm.nih.gov/sites/entrez?db=Taxonomy +and search by taxid (e.g. txis4070[Subtree] ) + +=item p [optional] + +phylotree name + +name you phylotree. Default = 'NCBI taxonomy tree' + +=item -v + +verbose output + +=item -t + +trial mode. Do not perform any store operations at all. + + +=item -g + +GMOD database profile name (can provide host and DB name) Default: 'default' + +=back + + +The script stores ncbi taxonomy in chado organism and phylogeny modules +This script works with SGN's public schema (chado compatible) and accesse the following tables: + +=over 7 + +=item db (DB:NCBI_taxonomy) + +=item dbxref (genbank taxon ids will be stored in the accession field) + +=item organism + +=item organism_dbxref + +=item phylotree + +=item phylonode + +=item phylonode_organism + + + +=back + + +For storing phylonodes a new phylotree will be stored with the name 'NCBI taxonomy tree'. +Each organism will get a phylonode id and will be stored in a tmp table, since each phylonode (except for the root) has a parent_phylonode_id, which is an internal foreign key. +Next each phylonode will get a left and right indexes, which are calculated by walking down the entire tree structure (see article by Aaron Mackey: http://www.oreillynet.com/pub/a/network/2002/11/27/bioconf.html?page=2). +Only after each phylonode will have calculated indexes, the phylonode table will be populated from the tmp table. + + +=head1 AUTHOR + +Adapted from GMOD load_taxonomy.pl: +#$Id: load_taxonomy.pl,v 1.1 2006/04/17 05:22:22 allenday Exp $ +#download from ftp://ftp.ncbi.nih.gov/pub/taxonomy/ + +by +Naama Menda <nm...@co...> + +=head1 VERSION AND DATE + +Version 1.0, June 2009. + +=head1 TODO + +Add an option for updating phlonode (requires wiping out the phylonodes of this phylotree and recalulating everything) + + +=cut + + +#! /usr/bin/perl + +use strict; +use CXGN::DB::InsertDBH; +use CXGN::DB::Connection; +use CXGN::Chado::Organism; +use CXGN::Chado::Db; +use CXGN::Chado::Dbxref; + +use Bio::GMOD::Config; +use Bio::GMOD::DB::Config; + +use Bio::Chado::Schema; + +use Getopt::Std; + +our ($opt_H, $opt_D, $opt_v, $opt_t, $opt_i, $opt_p, $opt_g); + +getopts('H:D:i:p:tv'); + +my $dbhost = $opt_H; +my $dbname = $opt_D; +my $infile = $opt_i; +my $phylotree_name= $opt_p || 'NCBI taxonomy tree'; +my $DBPROFILE = $opt_g ; +my $gmod_conf = Bio::GMOD::Config->new() if $opt_g; +my $db_conf = Bio::GMOD::DB::Config->new( $gmod_conf, $DBPROFILE ) if $opt_g; + +print "H= $opt_H, D= $opt_D, v=$opt_v, t=$opt_t, i=$opt_i \n"; + +my $dbh; +if (!$dbhost && !$dbname) { + $dbh= CXGN::DB::Connection->new(); +} else { + $dbh = CXGN::DB::InsertDBH->new( { dbhost=>$dbhost, + dbname=>$dbname, + dbschema => 'public', + #dbprofile=>$DBPROFILE, + } ); +} + +my $schema= Bio::Chado::Schema->connect( sub { $dbh->get_actual_dbh() }, + { on_connect_do => ['SET search_path TO public, sgn'], + },); + +my $sth; +my %okay_level = map { chomp; $_=>1 } grep { $_ !~ /^#/ } <DATA>; +my %node = (); +my %seen = (); +my %seq = ( + db => 'db_db_id_seq', + organism => 'organism_organism_id_seq', + dbxref => 'dbxref_dbxref_id_seq', + organism_dbxref => 'organism_dbxref_organism_dbxref_id_seq', + phylotree=> 'phylotree_phylotree_id_seq', + phylonode=> 'phylonode_phylonode_id_seq', + phylonode_organism => 'phylonode_organism_phylonode_organism_id_seq', +); + + + +#Create and retrieve NCBI Tax database + +my $db_name= 'DB:NCBI_taxonomy'; + +my $db=CXGN::Chado::Db->new_with_name($dbh, $db_name); +my $db_id = $db->get_db_id(); +if (!$db_id) { + $db->set_db_name($db_name); + $db->set_url('ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id='); + $db->set_urlprefix('http://'); + print STDERR "String a new db for $db_name!\n"; + $db_id=$db->store(); +} + + +######## + +#Fetch last database ids of relevant tables for resetting in case of rollback +my %maxval=(); +foreach my $key( keys %seq) { + my $id_column= $key . "_id"; + my $table = $key; + my $query = "SELECT max($id_column) FROM $table"; + $sth=$dbh->prepare($query); + $sth->execute(); + my ($next) = $sth->fetchrow_array(); + print STDERR "max $key is $next!\n"; + $maxval{$key}= $next; +} + +#store a new phylotree for NCBI taxonomy + +my $tree_accession= 'taxonomy'; +my $tree_dbxref=CXGN::Chado::Dbxref->new_with_accession($dbh, $tree_accession, $db_id); +my $tree_dbxref_id= $tree_dbxref->get_dbxref_id(); +if ( !$tree_dbxref_id ) { + $tree_dbxref->set_accession($tree_accession); + $tree_dbxref->set_db_name($db_name); + print STDERR "Storing a new dbxref for $tree_accession (db_name = $db_name) !\n"; + $tree_dbxref_id=$tree_dbxref->store(); + print STDERR "the tree dbxref_id is $tree_dbxref_id!!!\n\n"; +} + +my $phylotree = $schema->resultset('Phylogeny::Phylotree')->find_or_create( + { dbxref_id => $tree_dbxref_id, + name => $phylotree_name, + } + ); + +my $phylotree_id = $phylotree->phylotree_id(); +print STDERR "Created a new phylotee with id $phylotree_id!!!!\n\n\n"; + +#remove all existing phylonodes for this tree and reset the database sequence + +$schema->resultset('Phylogeny::Phylonode')->search( + { phylotree_id => $phylotree_id })->delete(); + +$maxval{phylonode} = set_maxval( 'phylonode' ); +$maxval{phylonode_organism} = set_maxval( 'phylonode_organism' ); + + +my %tax_file=() ; # hash for soring taxonomy ids from -i +if ($infile) { + open (INFILE, "<$infile") || die "Can't open infile $infile!!\n\n"; # + while (my $t_id = <INFILE>) { + chomp $t_id; + $tax_file{$t_id} = $t_id; + } +} +my $error = "load_taxonomy.err"; +open (ERR, ">$error") || die "Can't open error file for writing ($error)!\n"; + +####################### +########################## +#read in the taxonomy tree +open( NODE, "nodes.dmp" ); +while ( my $line = <NODE> ) { + my ( $id, $parent, $level ) = split /\t\|\t/, $line; + next unless $okay_level{ $level }; + if ($infile) { next() unless exists $tax_file{$id} ; } # skip nodes not in tax_file + $node{ $id }{ 'parent_taxid' } = $parent; + $node{ $id }{ 'self_taxid' } = $id; + $node{ $id }{ 'level' } = $level; +## $node{ $id }{ 'organism_id' } = $next_organism++; #do we really need an incremented organism_id?? +} +close( NODE ); + +open( NAME, "names.dmp" ); +while ( my $line = <NAME> ) { + #next unless $line =~ /scientific name/; + my ( $id, $name ) = split /\t\|\t/, $line; + next unless $node{ $id }; #skip nodes + if ( $line =~ /scientific name/) { + $node{ $id }{ 'name' } = $name; + $node{ $id }{ 'name' } .= " Taxonomy:$id" if $seen{ $name }++; + } elsif ( $line =~ /common name/) { # genbank common names + push(@{ $node{ $id }{ 'common_name' } } , $name); + push(@{ $node{$id}{ 'synonyms' } }, $name); + + } elsif ( $line =~ /synonym/ ) { + push @{ $node{$id}{ 'synonyms' } }, $name; + } +} + +close( NAME ); + +foreach my $id ( keys %node ) { + if ( $node{ $id }{ 'level' } eq 'species' ) { + $node{ $id }{ 'genus' } = $node{ $node{ $id }{ 'parent_taxid' } }{ 'name' }; + $node{ $id }{ 'species' } = $node{ $id }{ 'name' }; + } + else { + $node{ $id }{ 'genus' } = $node{ $id }{ 'level' }; + $node{ $id }{ 'species' } = $node{ $id }{ 'name' }; + } +} + + + +########################## +#use temp table for generating the phylonode_ids + +$dbh->do("CREATE TEMP TABLE tmp_phylonode ( + phylonode_id integer NOT NULL PRIMARY KEY, + phylotree_id integer , + organism_id integer, + parent_phylonode_id integer, + left_idx integer, + right_idx integer, + type_id integer)" + ); + + +############################################ +my $next_phylonode_id= $maxval{'phylonode'} +1 ; +my %phylonode=(); +my $node_count=0; + +eval { + my $root_id; + my $organism_id = $maxval{'organism'}; + foreach my $id ( keys %node ) { + ###### + #Store the genbank taxon_id in dbxref and in organism_dbxref + # + my $genbank_taxon_accession= $node{ $id }{ 'self_taxid' }; + my $dbxref= CXGN::Chado::Dbxref->new_with_accession($dbh, $genbank_taxon_accession, $db_id); + my $dbxref_id = $dbxref->get_dbxref_id(); + if (!$dbxref_id) { + $dbxref->set_db_name($db_name); + $dbxref->set_accession( $genbank_taxon_accession ); + $dbxref_id= $dbxref->store(); + } + + + my $organism= CXGN::Chado::Organism->new($schema); + my $abbreviation; + if ($node{ $id }{level} eq 'species' ) { + + if ( $node{ $id }{ 'species' } =~ m/(.*)\s(.*)/ ) { + my $gen=$1; + my $sp=$2; + $abbreviation= uc( substr( $gen ,0, 1 ) ) . "." . $sp; + } + } + my $common_name; + + my $c= @{ $node{$id}{'common_name'} } if (defined @{ $node{$id}{'common_name'}}); + $common_name = join("," , @{ $node{ $id }{ 'common_name' } }) if $c; + + $organism->set_genus($node{ $id }{ 'genus' } ); + $organism->set_species($node{ $id }{ 'species' } ); + $organism->set_common_name($common_name); + $organism->set_abbreviation($abbreviation ); + print STDERR "Genus= " . $organism->get_genus() . " Species= " . $organism->get_species() . "\n"; + my $existing_id = $organism->exists_in_database(); + if ($existing_id) { + $organism=CXGN::Chado::Organism->new($schema, $existing_id); + print STDERR "Organism $existing_id exists in database! ($abbreviation)\n"; + $organism->set_genus($node{ $id }{ 'genus' } ); + $organism->set_species($node{ $id }{ 'species' } ); + $organism->set_common_name($common_name); + $organism->set_abbreviation($abbreviation); + }else { + print STDERR "New organism: " . $organism->get_species() . "\n"; + print ERR "New organism: " . $organism->get_species() . "\n"; + } + + #store the organism in the organism table: + $organism->store(); + + print STDERR " COMMON_NAME= " . $organism->get_common_name() . "\n" if $common_name; + my $organism_id= $organism->get_organism_id(); + + ########################################### + #store the organism synonyms + foreach (@{$node{ $id }{synonyms} } ) { + $organism->add_synonym($_); #an organismprop. Requires to have name = 'synonym' in the cvterm table. + print STDERR $node{ $id }{name} . " LEVEL=( " . $node{ $id }{level} . ") Synonym is $_ \n" ; + } + #################################################################### + + + my $organism_dbxref = $schema->resultset('Organism::OrganismDbxref')->find_or_create( + { + organism_id => $organism_id, + dbxref_id => $dbxref_id, + }, + ); + + #get the cvterm_id of the taxonomy level + my $level= $node{ $id }{level}; + my ($level_cvterm) = $schema->resultset("Cv::Cvterm")->find( + { + name => $level, + cv_id => $schema->resultset("Cv::Cv")->find( { name => 'taxonomy' } )->get_column('cv_id'), + }, + ); + + my $level_id = $level_cvterm->get_column("cvterm_id") if $level_cvterm ; + + if (!$level_cvterm) { + print STDERR "No cvterm found for type $level! Check your cvterm table for loaded taxonomy (cv name should be 'taxonomy') \n\n"; + print ERR "No cvterm found for type $level! Check your cvterm table for loaded taxonomy (cv name should be 'taxonomy') \n\n"; + + } + #store a new phylonode_id + phylonode_organism. This is necessary for storing later the parent_phylonode_id + # and eventuay the left_idx and right_idx. + + $phylonode{ $id }{ 'phylonode_id' } = $next_phylonode_id++; + $phylonode{ $id }{ 'organism_id' } = $organism_id; + $phylonode{ $id }{ 'parent_taxid' } = $node{ $id }{ 'parent_taxid' }; + $phylonode{ $id }{ 'type_id' } = $level_id ; + + } + + +#now that all the organisms are stored, we can sore the relationships (=phylonodes) + my %stored=(); + my %test=(); + foreach my $id (keys %phylonode ) { + + my $phylonode_id = $phylonode{ $id }{ 'phylonode_id' }; + my $organism_id = $phylonode{ $id }{ 'organism_id' } ; + my $parent_phylonode_id = $phylonode{ $phylonode{ $id }{ 'parent_taxid' } }{ 'phylonode_id' } || 'NULL'; + $root_id = $phylonode_id if $parent_phylonode_id eq 'NULL'; + if ($parent_phylonode_id eq 'NULL') { print STDERR "organism $organism_id does not have a parent! (phylonode_id = $phylonode_id)\n"; } + my $type_id = $phylonode{ $id }{'type_id'} || 'NULL'; + push @{$test{$parent_phylonode_id} } , $phylonode_id ; + my $insert="INSERT INTO tmp_phylonode (phylotree_id, phylonode_id, parent_phylonode_id, organism_id, type_id) + VALUES ($phylotree_id,$phylonode_id, $parent_phylonode_id, $organism_id, $type_id)"; + + $node_count++; + $dbh->do($insert); + } + + #now walk through the tmp table and update the indexes + + our $ctr = 1; + print STDERR "the root_id is $root_id\n"; + + walktree($root_id); + + print STDERR "Updating the phylonode and phylonode_organism tables\n\n"; + my @updates=( + "INSERT INTO phylonode (phylonode_id, phylotree_id, parent_phylonode_id, left_idx, right_idx, type_id) SELECT phylonode_id, phylotree_id, parent_phylonode_id, left_idx, right_idx, type_id FROM tmp_phylonode", + "INSERT INTO phylonode_organism (phylonode_id, organism_id) SELECT phylonode_id, organism_id FROM tmp_phylonode" + ); + + + + foreach (@updates) { $dbh->do( $_ ); } + + sub walktree { + my $id = shift; + + my $children = $dbh->prepare("SELECT phylonode_id + FROM tmp_phylonode + WHERE parent_phylonode_id = ?"); + my $setleft = $dbh->prepare("UPDATE tmp_phylonode + SET left_idx = ? + WHERE phylonode_id = ?"); + my $setright = $dbh->prepare("UPDATE tmp_phylonode + SET right_idx = ? + WHERE phylonode_id = ?"); + + print STDERR "\nwalking the tree for $id...\n"; + $setleft->execute($ctr++, $id); + print STDERR "Setting left index= $ctr for parent $id\n\n"; + $children->execute($id); + + while(my ($id) = $children->fetchrow_array() ) { + print STDERR "Found child_id $id \n "; + walktree($id); + } + $setright->execute($ctr++, $id); + print STDERR "Setting right index= $ctr for id $id\n\n"; + } + +}; + +if ($@ || $opt_t) { + $dbh->rollback(); + + print STDERR "Rolling back! \n $@\n Resetting database sequences...\n"; + print ERR "Rolling back! \n $@\n Resetting database sequences...\n"; + + #reset sequences + foreach my $key ( keys %seq ) { + my $value= $seq{$key}; + my $maxvalue= $maxval{$key} || 0; + print STDERR "$key: $value, $maxvalue \n"; + if ($maxvalue) { $dbh->do("SELECT setval ('$value', $maxvalue, true)") ; } + else { $dbh->do("SELECT setval ('$value', 1, false)"); } + } +}else { + print STDERR "Commiting!! \n"; + print STDERR "Inserted $node_count phylonodes. \n"; + print ERR "Inserted $node_count phylonodes. \n"; + + $dbh->commit(); +} + + +sub set_maxval { + my $key=shift; + my $id_column= $key . "_id"; + my $table = $key; + my $query = "SELECT max($id_column) FROM $table"; + $sth=$dbh->prepare($query); + $sth->execute(); + my ($next) = $sth->fetchrow_array(); + print STDERR "max $key is $next!\n"; + return $next; +} + + +#http://www.eyesopen.com/docs/cplusprog_1_2/node220.html +__DATA__ +no rank +superkingdom +subkingdom +kingdom +superphylum +phylum +subphylum +superclass +class +subclass +infraclass +cohort +subcohort +superorder +order +suborder +infraorder +parvorder +superfamily +family +subfamily +tribe +subtribe +genus +subgenus +species group +species subgroup +species +subspecies +varietas +forma Modified: schema/trunk/chado/lib/CXGN/Chado/Db.pm =================================================================== --- schema/trunk/chado/lib/CXGN/Chado/Db.pm 2009-09-28 22:42:49 UTC (rev 22124) +++ schema/trunk/chado/lib/CXGN/Chado/Db.pm 2009-09-29 14:40:24 UTC (rev 22125) @@ -40,7 +40,7 @@ package CXGN::Chado::Db; -use base qw / CXGN::Chado::Main /; +use base qw / CXGN::DB::Object /; =head2 new Modified: schema/trunk/chado/lib/CXGN/Chado/Dbxref.pm =================================================================== --- schema/trunk/chado/lib/CXGN/Chado/Dbxref.pm 2009-09-28 22:42:49 UTC (rev 22124) +++ schema/trunk/chado/lib/CXGN/Chado/Dbxref.pm 2009-09-29 14:40:24 UTC (rev 22125) @@ -42,7 +42,7 @@ use CXGN::Chado::Feature; use CXGN::Chado::Db; -use base qw / CXGN::Chado::Main /; +use base qw / CXGN::DB::Object /; =head2 new @@ -137,22 +137,31 @@ sub store { my $self= shift; - my $dbxref_id= $self->get_dbxref_id(); + my $dbxref_id= $self->get_dbxref_id() ; if (!$dbxref_id) { #do an insert if (!$self->db_exists() ) { # insert a new db - print STDERR "***Dbxref.pm: storing a new db '".$self->get_db_name() ."'.\n"; + $self->d( "***Dbxref.pm: storing a new db '".$self->get_db_name() ."'.\n"); my $db=CXGN::Chado::Db->new($self->get_dbh() ); $db->set_db_name($self->get_db_name() ); $db->store; $self->set_db_id($db->get_db_id() ); + }else { + my $q= "SELECT db_id FROM db WHERE db.name = ?"; + my $s=$self->get_dbh()->prepare($q); + $s->execute($self->get_db_name() ) ; + my ($db_id)= $s->fetchrow_array(); + $self->set_db_id($db_id); } - #insert the new dbxref - my $query = "INSERT INTO public.dbxref (db_id, accession, description, version) VALUES((SELECT db_id FROM db WHERE db.name = ?),?,?,?)"; - my $sth= $self->get_dbh()->prepare($query); - if (!$self->get_version()) { $self->set_version(""); } #version field is not null - $sth->execute($self->get_db_name, $self->get_accession, $self->get_description, $self->get_version()); - $dbxref_id= $self->get_dbh()->last_insert_id("dbxref", "public"); - $self->set_dbxref_id($dbxref_id); + my $existing_id= $self->exists_in_database(); + if (!$existing_id) { + #insert the new dbxref + my $query = "INSERT INTO public.dbxref (db_id, accession, description, version) VALUES(?,?,?,?)"; + my $sth= $self->get_dbh()->prepare($query); + if (!$self->get_version()) { $self->set_version(""); } #version field is not null + $sth->execute($self->get_db_id, $self->get_accession, $self->get_description, $self->get_version()); + $dbxref_id= $self->get_dbh()->last_insert_id("dbxref", "public"); + $self->set_dbxref_id($dbxref_id); + } else { $self->set_dbxref_id($existing_id); } }else { # do an update my $query = "UPDATE public.dbxref SET description=?, version=? WHERE dbxref_id=?"; my $sth= $self->get_dbh()->prepare($query); @@ -161,6 +170,28 @@ return $dbxref_id; } +=head2 exists_in_database + + Usage: $self->exists_in_database() + Desc: check if the dbxref exists with the db_id, accession, and version + prior to updating + Ret: dbxref_id or undef if no dbxref exists + Args: non + Side Effects: none + Example: + +=cut + +sub exists_in_database { + my $self=shift; + my $query="SELECT dbxref_id FROM public.dbxref WHERE db_id=? AND accession=?"; + my $sth=$self->get_dbh()->prepare($query); + $sth->execute($self->get_db_id(), $self->get_accession()); + my ($existing_id) = $sth->fetchrow_array(); + return $existing_id; +} + + =head2 Class properties The following class properties have accessors (get_dbxref_id, set_dbxref_id...): Modified: schema/trunk/chado/lib/CXGN/Chado/Organism.pm =================================================================== --- schema/trunk/chado/lib/CXGN/Chado/Organism.pm 2009-09-28 22:42:49 UTC (rev 22124) +++ schema/trunk/chado/lib/CXGN/Chado/Organism.pm 2009-09-29 14:40:24 UTC (rev 22125) @@ -1,374 +1,1027 @@ + =head1 NAME -CXGN::Chado::Organism - a class for accessing and inserting new organisms (the chado organism table, in public schema) into the database. +CXGN::Chado::Organism - a class to create and manipulate Chado organism objects. -=head1 SYNOPSIS +Version:1.0 - =head1 DESCRIPTION -=head1 AUTHORS - Naama Menda <nm...@co...> +=head1 AUTHOR -=cut +Naama Menda <nm...@co...> +=cut + + + use strict; use warnings; -package CXGN::Chado::Organism; +package CXGN::Chado::Organism ; # -use base qw /CXGN::Chado::Dbxref/; +use Carp; + +use base qw / CXGN::DB::Object / ; + =head2 new - Usage: my $feature = CXGN::Chado::Organism->new($dbh, $organism_id); - Desc: - Ret: - Args: $dbh, $organism_id (the primary key of the organism table) - Side Effects: - Example: - + Usage: my $organism = CXGN::Chado::Organism->new($schema, $organism_id); + Desc: + Ret: a CXGN::Chado::Organism object + Args: a $schema a schema object, preferentially created using: + Bio::Chado::Schema->connect( sub{ CXGN::DB::Connection->new()->get_actual_dbh()}, %other_parameters); + $organism_id, if $organism_id is omitted, an empty metadata object is created. + Side_Effects: accesses the database, check if exists the database columns that this object use. die if the id is not an integer. + =cut sub new { my $class = shift; - my $dbh= shift; - my $id= shift; - - my $args = {}; - my $self = bless $args, $class; + my $schema = shift; + my $id = shift; + ### First, bless the class to create the object and set the schema into the object. + my $self = $class->SUPER::new($schema); + + ##Setting sbh for using some legacy functions from the old Organism object + my $dbh= $schema->storage->dbh(); $self->set_dbh($dbh); - $self->set_organism_id($id); - - if ($id) { - $self->fetch(); + + #Check if $id is an integer + my $organism; + if (defined $id) { + unless ($id =~ m/^\d+$/) { ## The id can be only an integer + my $error_message = "\nDATA TYPE ERROR: The organism_id ($id) for CXGN::Chado::Organism->new() IS NOT AN INTEGER.\n\n"; + croak($error_message); + } + + $organism = $self->get_resultset('Organism::Organism')->find({ organism_id => $id }); + + unless (defined $organism) { + my $error_message2 = "\nDATABASE COHERENCE ERROR: The organism_id ($id) for CXGN::Chado::Organism->new(\$schema, \$id) "; + $error_message2 .= "DOES NOT EXIST IN THE DATABASE.\n"; + $error_message2 .= "If you need enforce it, you can create an empty object (my \$org = CXGN::Chado::Organism->new(\$schema)"; + $error_message2 .= " and set the variable (\$org->set_organism_id(\$id);)"; + warn($error_message2); + return undef; + } + } else { + $self->debug("Creating a new empty Organism object! " . $self->get_resultset('Organism::Organism')); + $organism = $self->get_resultset('Organism::Organism')->new({}); ### Create an empty resultset object; } + ###It's important to set the object row for using the accesor in other class functions + $self->set_object_row($organism); return $self; } + + +=head2 store -=head2 new_with_common_name + Usage: $self->store + Desc: store a new organism + Ret: a database id + Args: none + Side Effects: checks if the organism exists in the database, and if does, will attempt to update + Example: - Usage: my $organism = CXGN::Chado::Organism->new_with_common_name($dbh, $common_name); - Desc: returns an organism object for the common name $common_name. - note that some common names have several database entries. In that - case, it returns the object for the first one listed. +=cut + +sub store { + my $self=shift; + my $id= $self->get_organism_id(); + my $schema=$self->get_schema(); + #no organism id . Check first if genus + species exists in te database + if (!$id) { + my $exists= $self->exists_in_database(); + if (!$exists) { + + my $new_row = $self->get_object_row(); + $new_row->insert(); + + $id=$new_row->organism_id(); + + $self->set_organism_id($id); + $self->d( "Inserted a new organism " . $self->get_organism_id() ." database_id = $id\n"); + }else { + $self->set_organism_id($exists); + my $existing_organism=$self->get_resultset('Organism::Organism')->find($exists); + #don't update here if organism already exist. User should call from the code exist_in_database + #and instantiate a new organism object with the database organism_id + #updating here is not a good idea, since it might not be what the user intended to do + #and it can mess up the database. + + $self->debug("Organism " . $self->get_species() . " " . $self->get_genus() . " exists in database!"); + + } + }else { # id exists + $self->d( "Updating existing organism_id $id\n"); + $self->get_object_row()->update(); + } + return $self->get_organism_id() +} + + +=head2 exists_in_database + + Usage: $self->exists_in_database() + Desc: check if the genus + species exists in the organism table Ret: Args: - Side Effects: accesses the database. + Side Effects: Example: =cut -sub new_with_common_name { - my $class = shift; - my $dbh = shift; - my $common_name = shift; - my $query = "SELECT organism_id FROM public.organism WHERE common_name ilike ?"; - my $sth = $dbh->prepare($query); - $sth->execute($common_name); - my ($organism_id) = $sth->fetchrow_array(); - my $self = CXGN::Chado::Organism->new($dbh, $organism_id); - return $self; - +sub exists_in_database { + my $self=shift; + my $genus= $self->get_genus() ; + my $species = $self->get_species(); + my $o = $self->get_resultset('Organism::Organism')->search({ + genus => { 'ilike' => $genus }, + species => { 'ilike' => $species } + })->single(); # ->single() for retrieving a single row (there sould be only one genus-species entry) + if ($o) { return $o->organism_id(); } + + # search if the genus+species where set together in the species field + if ($species =~ m/(.*)\s(.*)/) { + $o = $self->get_resultset('Organism::Organism')->search( + { + genus => { 'ilike'=> $1 }, + species => {'ilike' => $2 } + })->single(); + if ($o) { return $o->organism_id(); } + } + return undef; } -=head2 fetch +=head2 get_dbxrefs - Usage: $self->fetch(); - Desc: populates the CXGN::Chado::Organism object from - the database. - Ret: nothing - Args: none - Side Effects: accesses the database. + Usage: $self->get_dbxrefs() + Desc: create a list of all dbxref objects associated with the organism + via the organism_dbxref table + Ret: a list of CXGN::Chado::Dbxref objects + Args: none + Side Effects: none Example: =cut -sub fetch { +sub get_dbxrefs { my $self=shift; - my $query = "SELECT abbreviation, genus, species, common_name, comment, genbank_taxon_id - FROM public.organism WHERE organism_id=?"; - my $sth=$self->get_dbh()->prepare($query); - $sth->execute($self->get_organism_id() ); - - my ($abbreviation, $genus, $species, $common_name, $comment, $genbank_taxon_id)= $sth->fetchrow_array(); + my @organism_dbxrefs= $self->get_schema()->resultset('Organism::OrganismDbxref')->search( {organism_id => $self->get_organism_id() } ); - $self->set_abbreviation($abbreviation); - $self->set_genus($genus); - $self->set_species($species); - $self->set_common_name($common_name); - $self->set_comment($comment); - $self->set_genbank_taxon_id($genbank_taxon_id); + my @dbxrefs=(); + foreach my $od (@organism_dbxrefs) { + my $dbxref_id= $od->dbxref_id(); + push @dbxrefs, $self->get_resultset("General::Dbxref")->search( { dbxref_id => $dbxref_id } ); + } + return @dbxrefs; } -=head2 store - Usage: $self->store(); - Desc: stores an organism in public.organism table - Ret: $organism_id - Args: none - Side Effects: none +=head2 add_dbxref + + Usage: $self->add_dbxref($dbxref) + Desc: store a new organism_dbxref + Ret: database id + Args: dbxref object + Side Effects: accesses the database Example: =cut -sub store { +sub add_dbxref { my $self=shift; + my $dbxref=shift; + + my $schema=$self->get_schema; + my $organism_id= $self->get_organism_id(); + my $dbxref_id = $dbxref->get_dbxref_id(); + my $organism_dbxref = $schema->resultset('Organism::OrganismDbxref')->find_or_create( + { + organism_id => $organism_id, + dbxref_id => $dbxref_id, + }, + ); + my $id = $organism_dbxref->get_column('dbxref_id'); + return $id; +} + + +=head2 add_synonym + + Usage: $self->add_synonym($synonym) + Desc: Store a new synonym for this organism + Ret: an organismprop object + Args: a synonym (text) + Side Effects: stores a new organismprop with a type_id of 'synonym' + Example: + +=cut + +sub add_synonym { + my $self=shift; + my $synonym=shift; + + my $cvterm= $self->get_resultset("Cv::Cvterm")->search( {name => 'synonym' } )->single();; + my $type_id; + if ($cvterm) { + $type_id= $cvterm->get_column('cvterm_id'); + my $rank=1; + my @organismprops= $self->get_schema()->resultset("Organism::Organismprop")->search( + { + organism_id=>$self->get_organism_id(), + type_id =>$type_id + }); + if (@organismprops) { + my @sorted_ranks = reverse sort { $a <=> $b } ( map($_->get_column('rank'), @organismprops) ) ; + my $max_rank = $sorted_ranks[0]; + $rank = $max_rank+1; + } + my ($organismprop)= $self->get_schema()->resultset("Organism::Organismprop")->search( + { + organism_id => $self->get_organism_id(), + type_id => $type_id, + value => $synonym, + }); + if (!$organismprop) { + $organismprop= $self->get_schema()->resultset("Organism::Organismprop")->create( + { + organism_id => $self->get_organism_id(), + type_id => $type_id, + value => $synonym, + rank => $rank, + }); + return $organismprop; + } + } + $self->d("add_synonym ERROR: 'synonym' is not a cvterm! Please update your cvterm table. a cvterm with name='synonym' is required for storing organismprop for synonyms\n"); + return undef; +} + + +=head2 get_synonyms + + Usage: my @synonyms= $self->get_synonyms() + Desc: find the synonyms for this organism + Ret: a list + Args: none + Side Effects: get the organismprops for type_id of cvterm.name = synonym + Example: + +=cut + +sub get_synonyms { + my $self=shift; + my @props= $self->get_resultset("Organism::Organismprop")->search( + { organism_id => $self->get_organism_id(), + type_id => $self->get_resultset("Cv::Cvterm")->search( { name => 'synonym'} )->first()->get_column('cvterm_id') + }); + my @synonyms; + foreach my $prop (@props) { + push @synonyms, $prop->get_column('value'); + } + return @synonyms; +} + + + +=head2 get_ploidy + + Usage: my $ploidy= $self->get_ploidy() + Desc: find the ploidy value for this organism + Ret: a scalar + Args: none + Side Effects: get the organismprops for type_id of cvterm.name = ploidy + Example: + +=cut + +sub get_ploidy { + my $self=shift; + + my $name = "ploidy"; + my $value = $self->get_organismprop($name); + return $value; +} + + +=head2 get_chromosome_number + + Usage: my $chr= $self->get_chromosome_number() + Desc: find the chromosome number value for this organism + Ret: a scalar + Args: none + Side Effects: get the organismprops for type_id of cvterm.name = chromosome_number_variation + Example: + +=cut + +sub get_chromosome_number { + my $self=shift; + my $name = "chromosome_number_variation"; + my $value = $self->get_organismprop($name); + return $value; +} + +=head2 get_genome_size + + Usage: my $genome_size= $self->get_genome_size() + Desc: find the genome size value for this organism + Ret: a scalar + Args: none + Side Effects: get the organismprops for type_id of cvterm.name = 'genome size' + Example: + +=cut + +sub get_genome_size { + my $self=shift; + my $name = "genome size"; + my $value = $self->get_organismprop($name); + return $value; +} + + +=head2 get_est_attribution + + Usage: my $att= $self->get_est_attribution() + Desc: find the est attribution for this organism + Ret: a scalar + Args: none + Side Effects: get the organismprops for type_id of cvterm.name = 'est attribution' + Example: + +=cut + +sub get_est_attribution { + my $self=shift; + my $name= "est attribution"; + my $value= $self->get_organismprop($name); + return $value; +} + +=head2 get_organismprop + + Usage: $self->get_organismprop($value) + Desc: find the value of the organismprop for value $value + Ret: a string or undef + Args: $value (a cvterm name) + Side Effects: + Example: + +=cut + +sub get_organismprop { + my $self=shift; + my $name = shift; + + my ($prop)= $self->get_resultset("Organism::Organismprop")->search( + { organism_id => $self->get_organism_id(), + type_id => $self->get_resultset("Cv::Cvterm")->search( { name => $name } )->first()->get_column('cvterm_id') + }); + if ($prop) { + my $value= $prop->get_column('value'); + return $value; + } + return undef; +} + +=head2 get_parent + + Usage: $self->get_parent() + Desc: get the parent organism of this object + Ret: Chado::Organism object or undef if organism has no parent (i.e. is the root in the tree) + Args: none + Side Effects: accesses the phylonode table + Example: + +=cut + +sub get_parent { + my $self=shift; my $organism_id = $self->get_organism_id(); - my $abbreviation = $self->get_abbreviation(); - my $genus= ucfirst( $self->get_genus() ); - my $species= $self->get_species(); - my $common_name= $self->get_common_name(); - my $comment= $self->get_comment(); - my $genbank_taxon_id= $self->get_genbank_taxon_id(); - - if ($organism_id) { - my $query = "UPDATE public.organism SET - abbreviation=? ,genus=?, species=?, common_name=?, comment=?, genbank_taxon_id=? - WHERE organism_id=?"; - my $sth= $self->get_dbh()->prepare($query); + + my ($phylonode)= $self->get_resultset("Phylogeny::PhylonodeOrganism")->search( + { organism_id =>$self->get_organism_id() })->search_related('phylonode'); + + if ($phylonode) { + my $parent_phylonode_id= $phylonode->get_column('parent_phylonode_id'); - $sth->execute($abbreviation, $genus, $species, $common_name, $comment, $genbank_taxon_id, $organism_id); - - }else { - my $query = "INSERT INTO public.organism - (abbreviation, genus, species, common_name, comment, genbank_taxon_id) - VALUES (?,?,?,?,?,?)"; - my $sth= $self->get_dbh()->prepare($query); - $sth->execute($abbreviation, $genus, $species, $common_name, $comment, $genbank_taxon_id); - $organism_id= $self->get_dbh()->last_insert_id('organism', 'public'); - $self->set_organism_id($organism_id); + my ($parent_phylonode)= $self->get_resultset("Phylogeny::Phylonode")->search( + { phylonode_id=> $parent_phylonode_id } ); + if ($parent_phylonode) { + my ($phylonode_organism)= $self->get_resultset("Phylogeny::PhylonodeOrganism")->search( + { phylonode_id => $parent_phylonode->get_column('phylonode_id') } ); + + my $parent_organism= CXGN::Chado::Organism->new($self->get_schema(), $phylonode_organism->organism_id ); + + return $parent_organism; + } } - return $organism_id; + return undef; } -=head2 delete +=head2 get_taxon - Usage: $organism->delete() - Desc: hard delete of an organism from the database - Ret: undef if succedded , $message if failed + Usage: $sef->get_taxon() + Desc: get the taxon for this organism + Ret: a taxon name Args: none - Side Effects: checks if the organism has associated features with it. - TODO: once we migrate to one public.organism table this check should be extended!! + Side Effects: looks in the phylonode table Example: =cut -sub delete { - my $self=shift; - my $message=undef; - my $organism = $self->get_abbreviation() ." (". $self->get_common_name() . ")"; - my $check = "SELECT COUNT(*) FROM public.feature WHERE organism_id=?"; - my $check_sth=$self->get_dbh()->prepare($check); - $check_sth->execute($self->get_organism_id() ); - my $count= $check_sth->fetchrow_array(); - if ($count) { $message = "Cannot delete!! Found $count features associated with $organism"; } - else { - my $query = "DELETE FROM public.organism WHERE organism_id=?"; - my $sth=$self->get_dbh()->prepare($query); - $sth->execute($self->get_organism_id() ); - } - return $message; +sub get_taxon { + my $self = shift; + my ($phylonode) = $self->get_resultset("Phylogeny::PhylonodeOrganism")->search( + { organism_id=>$self->get_organism_id() } )->search_related("phylonode"); + if ($phylonode) { + my $type_id = $phylonode->get_column('type_id'); + + my ($cvterm) = $self->get_resultset("Cv::Cvterm")->find( { cvterm_id=>$type_id }); + if ($cvterm) { + my $taxon = $cvterm->get_column('name'); + return $taxon; + } + } + return undef; + } -=head2 get_organism_id + +############################################# + +=head2 accessors get_species, set_species + Usage: Desc: - Ret: - Args: + Property Side Effects: Example: =cut -sub get_organism_id { - my $self=shift; - return $self->{organism_id}; +sub get_species { + my $self = shift; + return $self->get_object_row()->get_column('species'); +} +sub set_species { + my $self = shift; + my $species=shift || croak " No argument passed to set_species!!!"; + $self->get_object_row()->set_column(species => $species ) ; + } -=head2 set_organism_id +=head2 accessors get_genus, set_genus Usage: Desc: - Ret: - Args: + Property Side Effects: Example: =cut -sub set_organism_id { - my $self=shift; - $self->{organism_id}=shift; +sub get_genus { + my $self = shift; + return $self->get_object_row()->get_column("genus"); } +sub set_genus { + my $self = shift; + $self->get_object_row()->set_column(genus => shift); +} - =head2 accessors get_abbreviation, set_abbreviation - Usage: $o->set_abbreviation("S.lycopersicum"); - Desc: sets the abbreviation for the organism - + Usage: + Desc: + Property Side Effects: Example: - =cut sub get_abbreviation { - my $self=shift; - return $self->{abbreviation} || uc(substr($self->get_genus() ,0,1)) .".".$self->get_species(); - + my $self = shift; + return $self->get_object_row()->get_column("abbreviation"); } - sub set_abbreviation { - my $self=shift; - $self->{abbreviation}=shift; + my $self = shift; + $self->get_object_row()->set_column(abbreviation => shift); } -=head2 accessors get_genus, set_genus +=head2 accessors get_common_name, set_common_name - Usage: $o->set_genus("Solanum"); - Desc: sets the genus of the organism - + Usage: + Desc: + Property Side Effects: Example: =cut -sub get_genus { - my $self=shift; - return $self->{genus}; - +sub get_common_name { + my $self = shift; + return $self->get_object_row()->get_column("common_name"); } -sub set_genus { - my $self=shift; - $self->{genus}=shift; +sub set_common_name { + my $self = shift; + $self->get_object_row()->set_column(common_name => shift); } -=head2 accessors get_species, set_species - Usage: $o->set_species("lycopersicum"); - Desc: sets the species name of the organism - +=head2 accessors get_comment, set_comment + + Usage: + Desc: + Property Side Effects: Example: =cut -sub get_species { - my $self=shift; - return $self->{species}; +sub get_comment { + my $self = shift; + return $self->get_object_row()->get_column("comment"); +} +sub set_comment { + my $self = shift; + $self->get_object_row()->set_column(comment => shift); } -sub set_species { - my $self=shift; - $self->{species}=shift; -} -=head2 accessors get_common_name, set_common_name - Usage: $o->set_common_name("tomato"); - Desc: sets the common name of the organism - +=head2 accessors get_organism_id, set_organism_id + + Usage: + Desc: + Property Side Effects: Example: =cut -sub get_common_name { - my $self=shift; - return $self->{common_name}; +sub get_organism_id { + my $self = shift; + return $self->get_object_row()->get_column('organism_id'); } +sub set_organism_id { + my $self = shift; + my $organism_id=shift || croak "No argument passed to organism_id"; + #check if integer + #check if id is in the database + $self->get_object_row()->set_column(organism_id=>$organism_id); +} -sub set_common_name { - my $self=shift; - $self->{common_name}=shift; + +sub get_object_row { + my $self = shift; + return $self->{object_row}; } -=head2 accessors get_commnet, set_comment +sub set_object_row { + my $self = shift; + $self->{object_row} = shift; +} - Usage: $o->set_comment("this refers only to the cultivated tomato species"); - Desc: sets the comment field in the organism table - - Side Effects: +=head2 get_resultset + + Usage: $self->get_resultset(ModuleName::TableName) + Desc: Get a ResultSet object for source_name + Ret: a ResultSet object + Args: a source name + Side Effects: none Example: =cut -sub get_comment { - my $self=shift; - return $self->{comment}; +sub get_resultset { + my $self=shift; + my $source = shift; + return $self->get_schema()->resultset("$source"); } -sub set_comment { - my $self=shift; - $self->{comment}=shift; + +###################Functions adapted from the old the organism object + +=head2 new_with_taxon_id + + Usage: my $organism = CXGN::Chado::Organism->new_with_taxon_id($dbh, $gb_taxon_id) + Desc: create a new organism object using genbank taxon_id instead of organism_id + Ret: a new organism object + Args: + Side Effects: creates a new Bio::Chado::Schema object + Example: + +=cut + +sub new_with_taxon_id { + my $class = shift; + my $schema = shift; + + #this is for old-stype objects having only a dbh (See CXGN::Chado::Feature) + if ( $schema->isa("CXGN::DB::Connection")) { # it's a DBI object + my $dbh=$schema; + use Bio::Chado::Schema; + $schema= Bio::Chado::Schema->connect( sub { $dbh->get_actual_dbh() }, + { on_connect_do => ['SET search_path TO public'], + },); + } + + my $taxon_id = shift; + + my ($organism)= $schema->resultset("General::Db")->search( + { name => 'DB:NCBI_taxonomy' } -> + search_related('dbxrefs', { accession => $taxon_id } )-> + search_related('organism_dbxrefs')-> + search_related('organisms') + ); + my $self=CXGN::Chado::Organism->new($schema, $organism->get_column('organism_id') ); + + return $self; } -=head2 accessors get_genbank_taxon_id, set_genbank_taxon_id - Usage: $o->set_genbank_taxon_id("4081"); - Desc: sets the genbank taxon id of the organism. - this ID has to be the correct taxon id from genbank, otherwise - uploading features of this organism (add_feaure.pl) will not work! - Side Effects: - Example: +=head2 get_genbank_taxon_id + + Usage: $self->get_genbank_taxon_id + Desc: get the genbank taxon id of this organism + Ret: a string + Args: + Side Effects: none + Example: + =cut + sub get_genbank_taxon_id { - my $self=shift; - return $self->{genbank_taxon_id}; + my $self = shift; + my $schema= $self->get_schema(); + my ($db) = $schema->resultset("General::Db")->search( { name => 'DB:NCBI_taxonomy' } ); + my $db_id = $db->get_column('db_id'); + + my ($dbxref)= $schema->resultset("Organism::OrganismDbxref")->search( + { organism_id => $self->get_organism_id() })-> + search_related('dbxref', {db_id => $db_id } ) ; + my $accession = $dbxref->get_column('accession'); + return $accession; +} + + +=head2 new_with_common_name + + Usage: my $organism = CXGN::Chado::Organism->new_with_common_name($dbh, $common_name) + Desc: create a new organism object using common_name instead of organism_id + Ret: a new organism object + Args: + Side Effects: none + Example: + +=cut + + +###Need to figure out what to do with common names +sub new_with_common_name { + my $self = shift; + my $dbh = shift; + my $common_name = shift; + my $schema; + + my @organisms; + + #this returns all the organisms in the common name group + my $query = "SELECT organism_id FROM public.organism + JOIN organismgroup_member USING(organism_id) + JOIN organismgroup USING(organismgroup_id) + WHERE name ILIKE ? AND type =?"; + my $sth= $dbh->prepare($query); + $sth->execute($common_name, 'common name'); + + use Bio::Chado::Schema; + $schema= Bio::Chado::Schema->connect( sub { $dbh->get_actual_dbh() }, + { on_connect_do => ['SET search_path TO public'], + },); + while (my ($organism_id) = $sth->fetchrow_array() ) { + + my $organism= CXGN::Chado::Organism->new($schema, $organism_id); + push @organisms, $organism; + + } + + #return @organisms; + + #or maybe : + + #my @organism= $self->get_resultset('Organism::Organism')->find( +# { common_name => $common_name, +# }); + if (scalar(@organisms) > 1 ) { warn "new_with_common_name found more than one organism row for common_name $common_name!!"; } + return $organisms[0]; } -sub set_genbank_taxon_id { - my $self=shift; - $self->{genbank_taxon_id}=shift; +=head2 get_intergroup_species_name DEPRECATED see get_group_common_name + + Usage: + Ret: + Args: + Side Effects: + Example: + +=cut + +sub get_intergroup_species_name { + + my $self = shift; + warn "DEPRECATED. Replaced by get_group_common_name"; + return $self->get_group_common_name(); } + + +=head2 get_group_common_name + + Usage: my $group_common_name= $self->get_group_common_name() + Desc: The unigenes, loci and phenome are grouped by interspecific group class. + e.g. for all tomato species we have the same number of unigene, loci or phenotypes accessions. + This function get this common_name for this organism + Ret: A string + Args: + Side Effects: none + Example: my $species_intergroup= $organism->get_group_common_name() + +=cut + +sub get_group_common_name { + + my $self = shift; + my $query = "SELECT + organismgroup.name + FROM organismgroup + JOIN organismgroup_member USING (organismgroup_id) + WHERE organism_id=? AND type = ?"; + + my $sth=$self->get_dbh()->prepare($query); + $sth->execute($self->get_organism_id() , 'common name'); + + my ($common_name) = $sth->fetchrow_array(); + + return $common_name; + +} + + +############# +#The following methods need database changes of the organism and common_name FK +############# + + +=head2 get_map_data + + Usage: my $map_data = $self->get_map_data (); + Desc: Get the map link for an organism. The organism could be one of the parents. + Ret: array of [ map short_name , map_id ], [], ... + Args: + Side Effects: none + Example: my ($short_name, $map_id = $organism->get_map_data(); + +=cut + +sub get_map_data { + + my $self = shift; + + my $query = "SELECT DISTINCT + sgn.map.short_name, + sgn.map.map_id + FROM sgn.map + INNER JOIN sgn.accession ON (parent_1=accession_id or parent_2=accession_id or ancestor=accession_id) + INNER JOIN public.organism on (public.organism.organism_id = sgn.accession.chado_organism_id) + WHERE public.organism.organism_id = ?"; + + my $sth=$self->get_dbh()->prepare($query); + $sth->execute($self->get_organism_id() ); + my @map_data=(); + + while (my ($short_name, $map_id) = $sth -> fetchrow_array()) { + push @map_data, [$short_name, $map_id]; + } + return @map_data; +} + + +##################### + +=head2 get_loci_count + + Usage: my $loci_count = $self->get_loci_count(); + Desc: Get the loci data for an organism . + Ret: An integer. + Args: + Side Effects: none + Example: my $loci_count = $organism->get_loci_count(); + +=cut + +sub get_loci_count { + + my $self = shift; + + my $query = "SELECT COUNT + (phenome.locus.locus_id) + FROM phenome.locus + JOIN sgn.common_name using (common_name_id) + JOIN public.organismgroup on (common_name.common_name = public.organismgroup.name ) + JOIN public.organismgroup_member USING (organismgroup_id) + JOIN public.organism USING (organism_id) + WHERE locus.obsolete = 'f' AND public.organism.organism_id=?"; + + my $sth=$self->get_dbh()->prepare($query); + $sth->execute($self->get_organism_id() ); + + my ($locus_count) = $sth->fetchrow_array() ; + return $locus_count; +} + +=head2 get_library_list + + Usage: my $library_count = $self->get_library_list(); + Desc: Get the libraries names. + Ret: a list of library_shortnames + Args: + Side Effects: none + Example: my $lib = $organism->get_library_list(); + +=cut + +sub get_library_list { + + my $self=shift; + + my $query = "SELECT library_shortname + FROM sgn.library + JOIN public.organism on (organism.organism_id = library.chado_organism_id) + WHERE public.organism.organism_id=?"; + my $sth = $self->get_dbh()->prepare($query); + $sth->execute($self->get_organism_id() ); + + my @libraries = (); + while ( my ($library_shortname)=$sth->fetchrow_array() ) { + push @libraries, $library_shortname; + } + return @libraries; +} + +=head2 get_est_count + + Usage: my $est_count = $organism->get_est_count(); + Desc: Get the EST count for an organism. This number is only for the ESTs where status=0 and flags=0. + Ret: An integer. + Args: + Side Effects: THIS FUNCTION IS VERY SLOW. Currently not called from the organism page. + Example: my $est_n = $organism->get_ests_count(); + +=cut + +sub get_est_count { + + my $self = shift; + + my $query = "SELECT COUNT( + sgn.est.est_id) + FROM sgn.est + JOIN sgn.seqread USING (read_id) + JOIN sgn.clone USING (clone_id) + JOIN sgn.library USING (library_id) + JOIN public.organism ON (organism.organism_id = library.chado_organism_id) + WHERE sgn.est.status = 0 and sgn.est.flags = 0 and public.organism.organism_id=?"; + + my $sth = $self->get_dbh()->prepare($query); + $sth->execute($self->get_organism_id() ); + my ($est_n) = $sth->fetchrow_array() ; + return $est_n; +} + +=head2 get_phenotype_count + + Usage: my $phenotypes =$self->get_phenotype_count(); + Desc: Get the phenotypes count for an organism. + Ret: An integer or undef + Args: + Side Effects: none + Example: + +=cut + +sub get_phenotype_count { + + my $self = shift; + + my $query=" SELECT COUNT (phenome.individual.individual_id) + FROM phenome.individual + JOIN sgn.common_name using (common_name_id) + JOIN public.organismgroup on (common_name.common_name = public.organismgroup.name ) + JOIN public.organismgroup_member USING (organismgroup_id) + JOIN public.organism USING (organism_id) + WHERE individual.obsolete = 'f' AND public.organism.organism_id=?"; + + my $sth=$self->get_dbh()->prepare($query); + $sth->execute($self->get_organism_id() ); + + my $phenotypes =0; + while (my ($pheno_count) = $sth->fetchrow_array()) { + $phenotypes += $pheno_count; + } + + return $phenotypes; +} + + +########################## + =head2 get_organism_by_species - Usage: my $organism= CXGN::Chado::Organism::get_organism_by_species($species, $dbh) - Desc: finds an organism for a given species name - Ret: an organism object (or undef if no organism is found) - Args: species name and a dbh + Usage: CXGN::Chado::Oganism::get_organism_by_species($species, $schema) + Desc: + Ret: Organism object or undef + Args: species name and a schema object Side Effects: Example: =cut + sub get_organism_by_species { my $species=shift; - my $dbh=shift; - my $query="SELECT organism_id FROM public.organism WHERE species=?"; - my $sth=$dbh->prepare($query); - $sth->execute($species); - my $organism_id= $sth->fetchrow_array(); - if ($organism_id) { - my $organism= CXGN::Chado::Organism->new($dbh,$organism_id); - $organism->set_organism_id($organism_id); - return $organism; - }else { return undef ; } + my $schema= shift; + my $organism=$schema->resultset("Organism::Organism")->find( + { species => $species } + )->first(); #should be just one species... + + return $organism || undef ; } +=head2 get_organism_by_tax -#### DO NOT REMOVE -return 1; -#### + Usage: $self->get_organism_by_tax($taxon) + Desc: Find the organism row for the higher level taxon of the current organism. + Ret: Organism object or undef + Args: taxon order (e.g. order, family , tribe, etc.) + Side Effects: + Example: + +=cut + + +sub get_organism_by_tax { + my $self=shift; + my $taxon=shift; + my ($cvterm) = $self->get_resultset("Cv::Cvterm")->find( { name => $taxon } ); + if ($cvterm) { + my $type_id = $cvterm->get_column('cvterm_id'); + + my ($self_phylonode)= $self->get_resultset("Phylogeny::PhylonodeOrganism")->search( + { organism_id => $self->get_organism_id() } )->search_related('phylonode'); + if ($self_phylonode) { + my $left_idx= $self_phylonode->get_column('left_idx'); + my $right_idx=$self_phylonode->get_column('right_idx'); + my ($phylonode)=$self->get_resultset("Phylogeny::Phylonode")->search_literal( + ('left_idx < ? AND right_idx > ? AND type_id = ?' , ($left_idx, $right_idx, $type_id) )); + + if ($phylonode) { + my ($organism)= $self->get_resultset("Phylogeny::PhylonodeOrganism")->search( + { phylonode_id => $phylonode->get_column('phylonode_id') } )->search_related('organism'); + + return $organism || undef ; + } + }else { warn("NO PHYLONODE stored for organism " . $self->get_abbreviation() . "\n"); } + }else { warn("NO CVTERM FOUND for term '$taxon'!! Check your database\n"); } + return undef; +} + + + + +########### +return 1;## +########### Modified: schema/trunk/chado/lib/CXGN/DB/Connection.pm =================================================================== --- schema/trunk/chado/lib/CXGN/DB/Connection.pm 2009-09-28 22:42:49 UTC (rev 22124) +++ schema/trunk/chado/lib/CXGN/DB/Connection.pm 2009-09-29 14:40:24 UTC (rev 22125) @@ -1,7 +1,5 @@ package CXGN::DB::Connection; use strict; -use vars qw/$AUTOLOAD/; -use English; use UNIVERSAL qw/isa/; use Carp qw/cluck croak carp/; @@ -191,8 +189,6 @@ =cut -#the new() method is now defined by Class::MethodMaker above - =head2 new_no_connect Desc: Same as above, except does not connect to the database. @@ -328,19 +324,10 @@ return $self; } -=head2 new - - Desc: called by new to set up the new object's internal state - Args: same as for new - Ret : nothing - -=cut - sub _compact_backtrace { return join '/', map {join(':',(caller($_))[0,2])} 1..3; } - my $debug = CXGN::Debug->new; sub new { @@ -431,17 +418,7 @@ return shift; } -# =head2 get_dbh -# Alias for dbh method. - -# =cut - -# sub get_dbh { -# carp __PACKAGE__.': the get_dbh() method is deprecated'; -# return shift; -# } - =head2 get_actual_dbh Usage: my $dbh = $self->get_actual_dbh() @@ -457,10 +434,6 @@ shift->_dbh; } - - - - =head2 get_connection_parameters Desc: get connection parameters you can use with your own DBI::connect call. @@ -483,8 +456,6 @@ =head2 dbtype - PRIVATE - Desc: get the database type set on this connection Args: none Ret : the dbtype set on this connection thingy @@ -513,16 +484,36 @@ =head2 dbname Usage: my $n = $dbc->dbname - Desc : Ret : the name of the database we're currently connected to Args : none Side Effects: none - Example: =cut sub dbname { shift->_dbname } #keep this read-only +=head2 dbuser + + Usage: my $n = $dbc->dbname + Ret : the name of the db user for this connection + Args : none + Side Effects: none + +=cut + +sub dbuser { shift->_dbuser } #keep this read-only + +=head2 dbpass + + Usage: my $n = $dbc->dbpass + Ret : the password used for this connection + Args : none + Side Effects: none + +=cut + +sub dbpass { shift->_dbpass } #keep this read-only + =head2 dbhost Usage: my $host = $dbc->dbhost Modified: schema/trunk/chado/lib/CXGN/DB/InsertDBH.pm =================================================================== --- schema/trunk/chado/lib/CXGN/DB/InsertDBH.pm 2009-09-28 22:42:49 UTC (rev 22124) +++ schema/trunk/chado/lib/CXGN/DB/InsertDBH.pm 2009-09-29 14:40:24 UTC (rev 22125) @@ -111,7 +111,7 @@ open (my $TTY, '>', '/dev/tty') or die "what the heck - no TTY??\n"; my $un = "postgres"; - print $TTY "Halt! Who goes there? (default \"$un\"): "; + print $TTY "Database username for write access (default \"$un\"): "; use Term::ReadKey; ReadMode 'normal'; @@ -122,7 +122,7 @@ } $dbargs->{dbuser} = $un; - print $TTY 'Password for write access: '; + print $TTY 'Password: '; use Term::ReadKey; ReadMode 'noecho'; Modified: schema/trunk/chado/lib/CXGN/Debug.pm =================================================================== --- schema/trunk/chado/lib/CXGN/Debug.pm 2009-09-28 22:42:49 UTC (rev 22124) +++ schema/trunk/chado/lib/CXGN/Debug.pm 2009-09-29 14:40:24 UTC (rev 22125) @@ -1,5 +1,3 @@ - - =head1 NAME CXGN::Debug - a utility class for handling debug messages @@ -47,7 +45,6 @@ package CXGN::Debug; use CXGN::VHost; -require Apache2::RequestUtil; =head2 new() @@ -129,6 +126,8 @@ warn "$message"; if ($ENV{MOD_PERL}) { + require Apache2::RequestUtil + or die "must have Apache2::RequestUtil installed to use CXGN::Debug under mod_perl"; my $r= Apache2::Request->new(); $r->log()->debug($message); } @@ -140,3 +139,9 @@ my $self = shift; $self->debug(@_); } + + +### +1;#do not remove +### + Modified: schema/trunk/chado/lib/CXGN/VHost.pm =================================================================== --- schema/trunk/chado/lib/CXGN/VHost.pm 2009-09-28 22:42:49 UTC (rev 22124) +++ schema/trunk/chado/lib/CXGN/VHost.pm 2009-09-29 14:40:24 UTC (rev 22125) @@ -372,7 +372,56 @@ } } +=head2 get_conf_keys + Usage: my @keys = $vh->get_conf_keys(); + Desc: returns all the possible conf keys + defined for the current $vh object + Ret: a list of strings + Args: none + Side Effects: none + +=cut + +sub get_conf_keys { + my $self = shift; + + my @keys = (); + @keys = keys %{$self->{vhost_config}}; + + @keys = (@keys, keys(%{$self->{conf_object}->get_conf_hashref_single_values})); + + return @keys; + +} + +=head2 get_conf_hash + + Usage: + Desc: + Ret: + Args: + Side Effects: + Example: + +=cut + +sub get_conf_hash { + my $self = shift; + + my %hash = (); + + foreach my $k ($self... [truncated message content] |
From: <nm...@us...> - 2009-10-20 14:53:24
|
Revision: 22177 http://gmod.svn.sourceforge.net/gmod/?rev=22177&view=rev Author: nm249 Date: 2009-10-20 14:53:11 +0000 (Tue, 20 Oct 2009) Log Message: ----------- sgn gmod loading scripts now work with DBIx Class. Removed all CXGN module dependencies Modified Paths: -------------- schema/trunk/chado/bin/cxgn/load_cvterms.pl schema/trunk/chado/bin/cxgn/load_ncbi_taxonomy.pl schema/trunk/chado/bin/cxgn/load_taxonomy_cvterms.pl Removed Paths: ------------- schema/trunk/chado/lib/CXGN/ Modified: schema/trunk/chado/bin/cxgn/load_cvterms.pl =================================================================== --- schema/trunk/chado/bin/cxgn/load_cvterms.pl 2009-10-19 22:32:52 UTC (rev 22176) +++ schema/trunk/chado/bin/cxgn/load_cvterms.pl 2009-10-20 14:53:11 UTC (rev 22177) @@ -21,7 +21,8 @@ =item -p -GMOD database profile name (can provide host and DB name) Default: 'default' +GMOD database profile name (can provide host and DB name) Default: +'default' =item -v @@ -33,8 +34,9 @@ =item -n -controlled vocabulary name (e.g 'biological_process'). -optional. If not given, terms of all namespaces related with database name will be handled. +controlled vocabulary name (e.g 'biological_process'). optional. If +not given, terms of all namespaces related with database name will be +handled. =item -F @@ -43,7 +45,9 @@ =item -u -update all the terms. Without -u, the terms in the database won't be updated to the contents of the file, in terms of definitions, etc. New terms will still be added. +update all the terms. Without -u, the terms in the database won't be +updated to the contents of the file, in terms of definitions, etc. New +terms will still be added. =item -o @@ -56,9 +60,15 @@ =back -The script parses the ontology in the file and the corresponding ontology in the database, if present. It compares which terms are new in the file compared to the database and inserts them, and compares all the relationships that are new and inserts them. It removes the relationships that were not specified in the file from the database. It never removes a term entry from the database. +The script parses the ontology in the file and the corresponding +ontology in the database, if present. It compares which terms are new +in the file compared to the database and inserts them, and compares +all the relationships that are new and inserts them. It removes the +relationships that were not specified in the file from the +database. It never removes a term entry from the database. -This script works with Chado schema (see gmod.org) and accesse the following tables: +This script works with Chado schema (see gmod.org) and accesse the +following tables: =over 9 @@ -80,13 +90,13 @@ =back +Terms that are in the database but not in the file are set to +is_obsolete=1. All the terms that are present in the database are +updated (if using -u option) to reflect the term definitions that are +in the file. New terms that are in the file but not in the database +are stored. The following data are associated with each term +insert/update: - -Terms that are in the database but not in the file are set to is_obsolete=1. -All the terms that are present in the database are updated (if using -u option) to reflect the term definitions that are in the file. -New terms that are in the file but not in the database are stored. -The following data are associated with each term insert/update: - =over 7 =item Term name @@ -103,57 +113,66 @@ =item Comments -=back +=back - - =head1 AUTHOR Lukas Mueller <la...@co...> Naama Menda <nm...@co...> - -=head1 VERSION AND DATE - -Version 0.12, February 2008. - =cut +our $VERSION = '0.13'; +$VERSION = eval $VERSION; use strict; use Getopt::Std; + +use Pod::Usage; + use Bio::OntologyIO; use Bio::Ontology::OntologyI; -use CXGN::DB::InsertDBH; -use CXGN::Chado::Db; -use CXGN::Chado::Dbxref; -use CXGN::Chado::CV; -use CXGN::Chado::Cvterm; -use CXGN::Chado::Ontology; -use CXGN::Chado::Relationship; + use Bio::GMOD::Config; use Bio::GMOD::DB::Config; +use Bio::Chado::Schema; + our ($opt_d, $opt_h, $opt_H, $opt_F, $opt_n, $opt_D, $opt_v, $opt_t, $opt_u, $opt_o, $opt_p); -getopts('F:d:H:o:n:vD:tup:'); +getopts('F:d:H:o:n:vD:tup:') + or pod2usage(1); my $dbhost = $opt_H; my $dbname = $opt_D; +my ($dbh, $schema); -my $DBPROFILE = $opt_p; -$DBPROFILE ||= 'default'; -my $gmod_conf = Bio::GMOD::Config->new(); -my $db_conf = Bio::GMOD::DB::Config->new( $gmod_conf, $DBPROFILE ); +if ($opt_p) { + my $DBPROFILE = $opt_p; + $DBPROFILE ||= 'default'; + my $gmod_conf = Bio::GMOD::Config->new() if $opt_p; + my $db_conf = Bio::GMOD::DB::Config->new( $gmod_conf, $DBPROFILE ) if $opt_p; + + $dbhost ||= $db_conf->host(); + $dbname ||= $db_conf->name(); + + if (!$dbhost && !$dbname) { die "Need -D dbname and -H hostname arguments.\n"; } + + $schema= Bio::Chado::Schema->connect( $db_conf->dbh(), $db_conf->user(), $db_conf->password() ); + $dbh=$schema->storage->dbh(); +} else { + require CXGN::DB::InsertDBH; + $dbh = CXGN::DB::InsertDBH->new( { dbhost=>$dbhost, + dbname=>$dbname, + dbschema=>'public', + } ); + $schema= Bio::Chado::Schema->connect( sub { $dbh->get_actual_dbh() } ); +} -$dbhost ||= $db_conf->host(); -$dbname ||= $db_conf->name(); -if (!$dbhost && !$dbname) { die "Need -D dbname and -H hostname arguments.\n"; } - my $error = 0; # keep track of input errors (in command line switches). if (!$opt_D and !$dbname) { print STDERR "Option -D required. Must be a valid database name.\n"; @@ -165,6 +184,8 @@ if ($opt_t) { print STDERR "Trial mode - rolling back all changes at the end.\n"; } +if ($opt_u) { print STDERR "This script will UPDATE cvterms stored in your database from the input file! \n"; } +else { print STDERR "WARNING: If your databse is already population with cvterms, not running in UPDATE mode (option -u) may cause database conflicts, such as violating unique constraints!\n"; } if (!$opt_d) { $opt_d="GO"; } # the database name that Dbxrefs should refer to print STDERR "Default for -d: $opt_d (specifies the database names for Dbxref objects)\n"; @@ -184,12 +205,6 @@ if ($opt_o) { open (OUT, ">$opt_o") ||die "can't open error file $opt_o for writting.\n" ; } -my $dbh = CXGN::DB::InsertDBH->new( { dbhost=>$dbhost, - dbname=>$dbname, - #dbprofile=>$DBPROFILE, - } ); - - message( "Connected to database $dbname on host $dbhost.\n", 1); @@ -212,89 +227,98 @@ message ("$opt_n: skipping to next ontology..\n",1); next (); } + my $rel_cv; #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(); + $rel_cv= $schema->resultset("Cv::Cv")->find_or_create( { name => 'relationship' } , { key => 'cv_c1' }, ); + my @rel= $schema->resultset("Cv::Cvterm")->search( + { cv_id => $rel_cv->get_column('cv_id'), + is_relationshiptype => 1, + }); + if (!@rel) { warn "Relationship ontology must be loaded first!!\n" ; exit(0); } } - #add Typedef parsing to obo.pm! - - 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"; + ####add Typedef parsing to obo.pm!### + ####store a new cv if the ontology namespace does not exist + my $cv= $schema->resultset('Cv::Cv')->find_or_create( { name => $new_ont_name } , { key => 'cv_c1' }, ); - my $db_ont; + print STDERR "cv_id = ".($cv->get_column('cv_id') )."\n"; + print STDERR "Updating an ontology in the database...\n"; + my $db_ont = $cv; - print STDERR "Updating an ontology in the database...\n"; - $db_ont = CXGN::Chado::Ontology->new_with_name($dbh, $new_ont->name()); - my $ontology_name=$db_ont->name(); + my $ontology_name=$db_ont->get_column('name'); message("Ontology name: ".($db_ont->name())."\n", 1); my %file_relationships = (); # relationships currently defined in the file my %db_relationships = (); eval { + my $db = $schema->resultset("General::Db")->find_or_create( + { name => $opt_d }, { key => 'db_c1' }, ); + print STDERR "Getting all the terms of the new ontology...\n"; my (@all_file_terms) = $new_ont->get_all_terms(); my (@all_file_predicate_terms) = $new_ont->get_predicate_terms(); - #my (@all_file_typedefs) = $new_ont->get_all_typedefs(); + ###my (@all_file_typedefs) = $new_ont->get_all_typedefs(); message( "***found ".(scalar(@all_file_predicate_terms))." predicate terms!.\n", 1); - message( "Retrieved ".(scalar(@all_file_terms))." terms.\n", 1); #look at all predecate terms (Typedefs) - my @all_db_predicate_terms = $db_ont->get_predicate_terms(); + my @all_db_predicate_terms= $db_ont->search_related('cvterms' , { is_relationshiptype => 1} ); foreach my $t(@all_file_predicate_terms) { #look at predicate terms in file - #if (!grep (/^$t$/, @all_db_predicate_terms ) ) { #didn't find predicate term in this cv in the database - my $p_term= CXGN::Chado::Cvterm::get_cvterm_by_name($dbh, $t->name(), '1'); - my $is_rel= $p_term->get_is_relationshiptype(); - if ( ($p_term->get_cv_id() && $p_term->get_is_relationshiptype()eq '1' ) ) { #maybe it's stored with another cv_id? - message("predicate term '" .$t->name() . "' already exists with cv_id " . $p_term->get_cv_id() . "\n", 1); - }else { - my $cv = CXGN::Chado::CV->new_with_name($dbh, $new_ont_name); - my $cv_id= $cv->get_cv_id(); - #message("*!for ontology '$new_ont_name' the cv_id is $cv_id \n"); - if (!$cv_id) { - $cv->set_cv_name("relationship"); - message("*!No cv found for $new_ont_name. Using 'relationship' namespace instead\n "); - $cv_id= $cv->store(); - } + my ($p_term) = $schema->resultset('Cv::Cvterm')->search( + { name => $t->name(), + is_relationshiptype => 1, + }); + #maybe it's stored with another cv_id? + if ($p_term) { + message("predicate term '" .$t->name() . "' already exists with cv_id " . $p_term->get_column('cv_id') . "\n", 1); + }else { #need to store the predicate term under $cv + #this stores the relationship types under 'relationship' cv namespace #terms defined as '[Typedef]' in the obo file should actually be stored as relationshiptype #but with the current ontology cv namespace . #To do this we need to add to the obo parser (Bio::OntologyIO::obo.pm) #a 'get_typedefs' funciton + my $accession = $t->identifier() || $t->name(); + my $p_term_db = $schema->resultset("General::Db") + ->find_or_create( { name => $opt_d }, + { key => 'db_c1' }, + ); + my $p_term_dbxref = $schema->resultset("General::Dbxref") + ->find_or_create + ({ db_id => $p_term_db->get_column('db_id'), + accession => $accession, + version => $t->version() || '', + }, + { key => 'dbxref_c1' } , + ); + my $p_term = $schema->resultset("Cv::Cvterm") + ->find_or_create + ({ cv_id => $cv->get_column('cv_id'), + name => $t->name(), + dbxref_id => $p_term_dbxref->get_column('dbxref_id'), + definition => $t->definition(), + is_obsolete=> $t->is_obsolete(), + is_relationshiptype => 1, + }, + { key => 'cvterm_c1' }, + ); - if (($cv->get_cv_name()) eq 'relationship' ) { $p_term->set_db_name('OBO_REL'); } - else { $p_term->set_db_name($opt_d); } - - $p_term->name($t->name() ); - $p_term->identifier($t->identifier()) || $p_term->identifier($t->name() ); - $p_term->definition( $t->definition() ); - $p_term->version( $t->version() ); - my $ontology= $t->ontology()->name(); - $p_term->set_obsolete($t->is_obsolete() ); - $p_term->set_is_relationshiptype('1'); - $p_term->set_cv_id($cv_id); - $p_term->store(); message("Stored new relationshiptype '" . $t->name() . "'\n",1); } - # } } - print STDERR "Getting all the terms of the current ontology...\n"; - my @all_db_terms = $db_ont->get_all_terms(); # a list of cvterm objects - + #a list of Bio::Chado::Schema::Cvterm objects + my @all_db_terms = $schema->resultset("Cv::Cvterm")->search( + { cv_id => $db_ont->get_column('cv_id'), + is_relationshiptype => 0, + })->all(); print STDERR "Indexing terms and relationships...\n"; my %file_index = (); # index of term objects in the db with accession as key my %db_index = (); # this hash will be populated with accession => cvterm_object @@ -303,17 +327,17 @@ my $id = $t->identifier(); $id=~ s/\w+\:(.*)/$1/g; $file_index{$id} = $t; + message("Found term in file : $id\n", 1); } my $c_count = 0; # count of db terms foreach my $t (@all_db_terms) { $c_count++; - my $id = $t->identifier(); - $id=~ s/\w+\:(.*)/$1/g; + my ($id )= $t->search_related('dbxref')->first()->get_column('accession'); $db_index{$id} = $t; + message("Found term in DB: $id\n", 1); } - my %novel_terms = (); my @removed_terms = (); my @novel_relationships = (); @@ -324,17 +348,15 @@ #exit(); FILE_INDEX: foreach my $k (keys(%file_index)) { - #print STDERR "Checking $k...\n"; if (!exists($db_index{$k})) { if (!$file_index{$k}->name() ) { next FILE_INDEX; } #skip if term in file has no name. #This happens in InterPro file - which is translated from xml to obo. - + if ($opt_v) { print STDERR "Novel term: $k ".($file_index{$k}->name())."\n"; } else { print STDERR "."; } print OUT "Novel term: $k ".($file_index{$k}->name())."\n" if $opt_o; - + $novel_terms{$k}=$file_index{$k}; - } } @@ -343,24 +365,24 @@ foreach my $k (keys(%db_index)) { if (!exists($file_index{$k})) { - message( "Term not in file: $k\n",1); - + my $name = $db_index{$k}->name(); #get the name in the database - - unless( $name =~ m/obsolete.*$opt_d:$k/ ) { - my $ob_name = $name . " (obsolete " . $opt_d . ":" . $k . ")" ; #add the 'obsolete' suffix - $db_index{$k}->name($ob_name ); - message( "**modified name for $opt_d:$k - '$ob_name' \n " , 1); + my ($accession)= $db_index{$k}->search_related('dbxref')->first()->accession(); + message( "Term not in file: $name \n",1); + unless( $name =~ m/obsolete.*$opt_d:/ ) { + my $ob_name = $name . " (obsolete " . $opt_d . ":" . $accession . ")" ; #add the 'obsolete' suffix + $db_index{$k}->set_column(name => $ob_name ); + message( "*modified name for $opt_d:$name - '$ob_name' \n " , 1); } - $db_index{$k}->set_obsolete("1"); - $db_index{$k}->store(); - print STDERR " obsoleted term $k!.\n"; + $db_index{$k}->set_column(is_obsolete => 1 ); + $db_index{$k}->update(); + + print STDERR " obsoleted term $name!.\n"; push @removed_terms, $db_index{$k}; } } - print STDERR "Inserting and updating terms...\n"; my $count = 0; @@ -374,23 +396,40 @@ $u_count++; message( "updating information for term $k...\n"); if (!$file_index{$k} || !$db_index{$k} ) { message ("SKIPPING term $k! No value found\n", 1); next UPDATE; } - $db_index{$k}->name($file_index{$k}->name()); - $db_index{$k}->definition($file_index{$k}->definition()); - $db_index{$k}->comment($file_index{$k}->comment()); - $db_index{$k}->set_obsolete($file_index{$k}->is_obsolete()); - $db_index{$k}->version($file_index{$k}->version()); + $db_index{$k}->set_column(name => $file_index{$k}->name() ); + $db_index{$k}->set_column( definition => $file_index{$k}->definition() ); + $db_index{$k}->set_column(is_obsolete => $file_index{$k}->is_obsolete() ); + my $name = $db_index{$k}->name(); #changing the name of obsolete terms to "$name (obsolete $db:$accession)" #to avoid violating the cvterm unique constaint (name, cv_id, is_obsolete) - if ($db_index{$k}->get_obsolete() ) { - unless( $name =~ m/obsolete.*$opt_d:$k/ ) { - my $ob_name = $name . " (obsolete " . $opt_d . ":" . $k . ")" ; - $db_index{$k}->name($ob_name ); - print STDERR "**modified name for $opt_d:$k - '$ob_name' version: " . $db_index{$k}->version()." \n " ; + if ($db_index{$k}->is_obsolete() ) { + unless( $name =~ m/obsolete.*$opt_d:/ ) { + my ($accession) = $db_index{$k}->search_related('dbxref')->first()->accession(); + my $ob_name = $name . " (obsolete " . $opt_d . ":" . $accession . ")" ; + $db_index{$k}->set_column( name=>$ob_name ); + print STDERR "**modified name for $opt_d:$k - '$ob_name' version: " . $file_index{$k}->version() . " \n " ; } } - $db_index{$k}->store(); + $db_index{$k}->update(); + #update dbxref version + if ( $file_index{$k}->version() ) { + my ($dbxref)=$db_index{$k}->search_related('dbxref'); + $dbxref->set_column(version => $file_index{$k}->version() ); + $dbxref->update(); + } + #add comment as a cvtermprop + my ($comment_cvterm) = $schema->resultset("Cv::Cvterm")->search( { name => 'comment'} ); + if ($file_index{$k}->comment() ) { + my $cvtermprop= $schema->resultset("Cv::Cvtermprop")->find_or_create( + { cvterm_id => $db_index{$k}->get_column('cvterm_id'), + type_id => $comment_cvterm->get_column('cvterm_id'), + value => $file_index{$k}->comment(), + }, + ); + } + ############################### # deal with synonyms here... my %file_synonyms = (); foreach my $s ($file_index{$k}->get_synonyms()) { @@ -399,58 +438,43 @@ $file_synonyms{uc($s)}=1; message("...adding synonym '$s' to the database...\n"); - - $db_index{$k}->add_synonym($s); + $db_index{$k}->add_synonym($s, {'autocreate' => 1} ); } - foreach my $s ($db_index{$k}->get_synonyms()) { - if (!exists($file_synonyms{uc($s)}) ) { - message( "Note: deleting synonym '$s' from cvterm ". $db_index{$k}->get_cvterm_name(). "...\n",1); + foreach my $s ($db_index{$k}->search_related('cvtermsynonyms')) { + my $s_name= $s->get_column('synonym'); + if (!exists($file_synonyms{uc($s_name)}) ) { + message( "Note: deleting synonym '$s_name' from cvterm ". $db_index{$k}->get_column('name') . "...\n",1); $db_index{$k}->delete_synonym($s); } } #deal with secondary ids (alt_id field). # Stored in cvterm_dbxref with the field 'is_for_definition' = 0 + + #delete all cvterm dbxrefs before loading the new ones from the file + my @secondary_dbxrefs= $db_index{$k}->search_related('cvterm_dbxrefs'); + foreach (@secondary_dbxrefs) { $_->delete(); } + my %file_secondary_ids = (); foreach my $i ($file_index{$k}->get_secondary_ids()) { $file_secondary_ids{uc($i)}=1; message("adding secondary id $i to the database...\n"); - + $db_index{$k}->add_secondary_dbxref($i); } - foreach my $i ($db_index{$k}->get_secondary_dbxrefs()) { - if (!exists($file_secondary_ids{uc($i)})) { - message( "Note: deleting secondary id $i from cvterm_dbxref...\n",1); - $db_index{$k}->delete_secondary_dbxref($i); - } - } - # Definition dbxrefs. get_dblinks gets the dbxref in the definition tag + ######### + # Definition dbxrefs. get_dblinks gets the dbxref in the definition tag # and all xref_analog tags. This will store in the database cvterm_dbxrefs with #the fiels 'is_for_definition' = 1 + my %file_def_dbxrefs=(); - foreach my $r ($file_index{$k}->get_dblinks() ) { #store definition's dbxrefs in cvterm_dbxref - #my $id= $r->primary_id(); - #my $db= $r->database(); - my ($db, $id) = split /:/, $r; - my $def_dbxref= $db . ":" . $id; + #store definition's dbxrefs in cvterm_dbxref + foreach my $def_dbxref ($file_index{$k}->get_dblinks() ) { $file_def_dbxrefs{uc($def_dbxref)}=1; - message("adding definition dbxref $db:$id to cvterm_dbxref\n"); - - $db_index{$k}->add_def_dbxref($db, $id); + message("adding definition dbxref $def_dbxref to cvterm_dbxref\n"); + $db_index{$k}->add_secondary_dbxref($def_dbxref, 1); } - my @def_dbxrefs = $db_index{$k}->get_def_dbxref(); - foreach my $r (@def_dbxrefs) { - if ($r->get_dbxref_id()) { - my $db= $r->get_db_name(); - my $acc=$r->get_accession(); - my $def_dbxref=$db . ":" . $acc; - if (!exists($file_def_dbxrefs{uc($def_dbxref)})) { - message( "Note: deleting definition dbxref '$def_dbxref' from cvterm_dbxref...\n",1); - $db_index{$k}->delete_def_dbxref($r); - } - } - } } } } #finished updating existing terms.. @@ -458,38 +482,52 @@ my $n_count=0; foreach my $k (keys(%novel_terms)) { $n_count++; - my $new_term = CXGN::Chado::Cvterm->new($dbh); my $name = $novel_terms{$k}->name(); - $new_term->name($name); - $new_term->identifier(numeric_id($novel_terms{$k}->identifier())); - $new_term->definition($novel_terms{$k}->definition()); - $new_term->version($novel_terms{$k}->version()); - $new_term->set_db_name($opt_d); - $new_term->set_cv_id($cv->get_cv_id()); - $new_term->set_obsolete($novel_terms{$k}->is_obsolete()); + my $version = $novel_terms{$k}->version(); - #changing the name of obsolete terms to "$name (obsolete $db:$accession)" - #to avoid violating the cvterm unique constaint (name, cv_id, is_obsolete) - if ($novel_terms{$k}->is_obsolete() ) { + my $accession = numeric_id($novel_terms{$k}->identifier()); + message("Inserting novel term '$name' (accession = '$accession', version = '$version'\n"); + + my $new_term_dbxref = $schema->resultset("General::Dbxref")->find_or_create( + { db_id => $db->get_column('db_id'), + accession => $accession, + version => $version || '', + }, + { key => 'dbxref_c1' } , + ); + + if ($novel_terms{$k}->is_obsolete() == 1 ) { unless( $name =~ m/obsolete.*$opt_d:$k/i ) { - my $ob_name = $name . " (obsolete " . $opt_d . ":" . $k . ")" ; - $novel_terms{$k}->name($ob_name ); - $new_term->name($ob_name); - print STDERR "**modified name for $opt_d:$k - '$ob_name' \n " ; - } + my $ob_name = $name . " (obsolete " . $opt_d . ":" . $accession . ")" ; + $name = $ob_name ; + print STDERR "***modified name for $opt_d:$accession - '$ob_name' \n " ; } - message("Storing term $k...name = " . $novel_terms{$k}->name() . "\n"); - - if (!$opt_t) { + } + if (!$opt_t) { + my $new_term= $schema->resultset("Cv::Cvterm")->create( + { cv_id =>$cv->cv_id(), + name => $name, + definition => $novel_terms{$k}->definition(), + dbxref_id => $new_term_dbxref-> dbxref_id(), + is_obsolete=> $novel_terms{$k}->is_obsolete(), + } + ); + + #changing the name of obsolete terms to "$name (obsolete $db:$accession)" + #to avoid violating the cvterm unique constaint (name, cv_id, is_obsolete) + + message("Storing term $k...name = " . $novel_terms{$k}->name() . "\n"); + if ($count % 100==0) { print STDERR "."; } - $new_term->store(); - $new_term->comment($novel_terms{$k}->comment()); #store comment in cvterm_prop + my $comment = $novel_terms{$k}->comment(); + $new_term->create_cvtermprops( { comment => $comment } , { autocreate => 1 } ) if $comment; - foreach my $s ($novel_terms{$k}->get_synonyms()) { #store synonyms in cvtermsynonym + #store synonyms in cvtermsynonym + foreach my $s ($novel_terms{$k}->get_synonyms() ) { $s=~ s/\s+$//; $s =~ s/\\//g; message("...adding synonym '$s' to the database...\n"); - $new_term->add_synonym($s); #need to add a type_id to each synonym! + $new_term->add_synonym( $s, {'autocreate' => 1 } ); #need to add a type_id to each synonym! } foreach my $i ($novel_terms{$k}->get_secondary_ids()) { #store secondary ids in cvterm_dbxref @@ -498,19 +536,14 @@ $new_term->add_secondary_dbxref($i); } foreach my $r ($novel_terms{$k}->get_dblinks() ) { #store definition's dbxrefs in cvterm_dbxref - #my $id= $r->primary_id(); - #my $db= $r->database(); - my ($db, $id) = split /:/, $r; - my $def_dbxref= $db . ":" . $id; - #$file_def_dbxrefs{uc($def_dbxref)}=1; - message("adding definition dbxref $db:$id to cvterm_dbxref\n"); - - $new_term->add_def_dbxref($db, $id); + my $def_dbxref= $r; + message("adding definition dbxref $r to cvterm_dbxref\n"); + $new_term->add_secondary_dbxref($r, 1); } } - } - - + } + + ################################## message ("Updated $u_count existing terms, inserted $n_count new terms!\n",1); print STDERR "Parsing out the relationships...\n"; @@ -531,26 +564,28 @@ $file_relationships{$key} = $r; # create the hash entry for this relationship } } - print STDERR "\n"; - print STDERR "Looking at relationships in database.\n"; - + print STDERR "\nLooking at relationships in database.\n"; + # indexing the database relationships foreach my $k (keys %db_index) { - foreach my $r ($db_ont->get_relationships($db_index{$k})) { - my $s = $r->subject_term(); - my $o = $r->object_term(); - - my $key = numeric_id($s->identifier())."-".numeric_id($o->identifier()); - message("Looking at relationship in db: $key\n"); - $db_relationships{$key}=$r; + ###foreach my $r ($db_ont->get_relationships($db_index{$k})) { + foreach my $r ($db_index{$k}->search_related('cvterm_relationship_subject_ids') ) { + if ($r) { + my ($s) = $r->search_related('subject'); + my ($o) = $r->search_related('object'); + #terms might have moved to a different cv namespace + if ($s->cv_id() eq $o->cv_id() ) { + my $key = numeric_id($s->search_related('dbxref')->first()->accession)."-".numeric_id($o->search_related('dbxref')->first()->accession); + message("Looking at relationship in db: $key\n"); + $db_relationships{$key}=$r; + } + } } } - - print STDERR "Relationships not in the file...\n"; foreach my $k (keys(%db_relationships)) { - if (!(exists($file_relationships{$k}) && defined($file_relationships{$k}))) { + if (! (exists($file_relationships{$k}) && defined($file_relationships{$k})) ) { push @removed_relationships, $k; message("Deleted relationship: $k... \n",1); @@ -560,8 +595,8 @@ } print STDERR "\n"; - #message(scalar(@novel_terms). " novel terms (of ".(scalar(keys(%db_terms))).") were found and stored. \n", 1); + ##################################### my $r_count = 0; RELATIONSHIP: foreach my $r (keys(%file_relationships)) { $r_count++; @@ -570,35 +605,64 @@ elsif ($r_count % 100 == 0) { print STDERR "."; } print OUT "Novel relationship: $r\n" if $opt_o; - # create a new relationship object - my $new_rel = CXGN::Chado::Relationship->new($dbh); + #### + #convert the Bio::Ontology::OBOTerm objects to Bio::Chado::Schema::Cv::Cvterm objects + my $subject_accession = $file_relationships{$r}->subject_term()->identifier(); + my ($s_db, $s_acc) = split ':', $subject_accession; + + my ($subject_term)= $schema->resultset("General::Dbxref")->search( + { accession => $s_acc, + db_id => $db->db_id(), + } )->search_related('cvterm' , { cv_id => $cv->cv_id() } ); + - # convert the Bio::Ontology::OBOTerm objects to CXGN::Chado::Cvterm objects - my $subject_term = CXGN::Chado::Cvterm->new_with_accession($dbh, $file_relationships{$r}->subject_term()->identifier()); - if (!$subject_term->get_cvterm_id() ) { message("cvterm does not exist for subject term " . $file_relationships{$r}->subject_term()->identifier() . " Skipping...\n" ,1); next RELATIONSHIP; } - $new_rel->subject_term($subject_term); - print STDERR "subject term: " . $file_relationships{$r}->subject_term()->identifier()."\n"; + if (!$subject_term ) { + message("cvterm does not exist for subject term '$subject_accession'.Skipping..\n" ,1); + next RELATIONSHIP; + } - my $object_term = CXGN::Chado::Cvterm->new_with_accession($dbh, $file_relationships{$r}->object_term()->identifier); - if (!$object_term->get_cvterm_id() ) { message("cvterm does not exist for object term " . $file_relationships{$r}->object_term()->identifier() ,1); next RELATIONSHIP;} - $new_rel->object_term($object_term); + my $object_accession = $file_relationships{$r}->object_term()->identifier(); + my ($o_db, $o_acc) = split ':', $object_accession; + my ($object_term)= $schema->resultset("General::Dbxref")->search( + { accession => $o_acc, + db_id => $db->db_id(), + } )->search_related('cvterm', { cv_id => $cv->cv_id() } ); + + if (!$object_term ) { + message("cvterm does not exist for object term $object_accession . SKIPPING!\n",1); + next RELATIONSHIP; + } + + ############################################ push @novel_relationships, $r; 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_accession($dbh, "OBO_REL:$predicate_term_name"); - 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()) { + my $predicate_term; + my ($rel_db)= $schema->resultset('General::Db')->search( { name => 'OBO_REL' } ); + ($predicate_term) = $schema->resultset('General::Dbxref')->search( + { accession => { 'ilike' , "$predicate_term_name" }, + db_id => $rel_db->db_id(), + })->search_related('cvterm') if $rel_db; + if (!$predicate_term) { + ($predicate_term) = $schema->resultset('Cv::Cvterm')->search( + { name => { 'ilike' , $predicate_term_name } , + cv_id=> $cv->cv_id(), + } + ); + + if (!$predicate_term) { die "The predicate term $predicate_term_name does not exist in the database\n"; } } - $new_rel->predicate_term($predicate_term); if (!$opt_t) { - message("Storing relationship $r. type cv_id=" . $predicate_term->get_cv_id() ."\n" ,1); - $new_rel->store(); + message("Storing relationship $r. type cv_id=" . $predicate_term->cv_id() ."\n" ,1); + my $new_rel = $schema->resultset('Cv::CvtermRelationship')->create( + { subject_id => $subject_term->cvterm_id(), + object_id => $object_term->cvterm_id(), + type_id => $predicate_term->cvterm_id(), + } + ); } } } @@ -608,14 +672,10 @@ if ($@ || ($opt_t)) { message( "Either running as trial mode (-t) or AN ERROR OCCURRED: $@\n",1); - $dbh->rollback(); exit(0); } - else { - $dbh->commit(); - } - + else { $dbh->commit(); } } print STDERR "Done.\n"; Modified: schema/trunk/chado/bin/cxgn/load_ncbi_taxonomy.pl =================================================================== --- schema/trunk/chado/bin/cxgn/load_ncbi_taxonomy.pl 2009-10-19 22:32:52 UTC (rev 22176) +++ schema/trunk/chado/bin/cxgn/load_ncbi_taxonomy.pl 2009-10-20 14:53:11 UTC (rev 22177) @@ -11,26 +11,21 @@ =head2 Prerequisites -=over 4 +=over 3 =item 1. Load taxonomy cvterms see load_taxonomy_cvterms.pl -=item 2. A cvterm with name = 'synonym' -This is required for storing the organism synonyms as organismprops. +=item 2. Download NCBI taxonomy files -<in SGN this term is stored under a 'null' cv name. It is not hardcoded in this script, since different databases might have a 'synonym' term stored under different cv> - -=item 3. Download NCBI taxonomy files - ftp://ftp.ncbi.nih.gov/pub/taxonomy/ Save these 2 files in the same dir. of this script names.dmp nodes.dmp -=item 4. Download a taxon_id list from NCBI +=item 3. Download a taxon_id list from NCBI Optional. This filter file will include the taxons you would like to store in your tree (see option -i). Without this file the entire NCBI taxonomy will be stored in your database! @@ -121,11 +116,10 @@ =head1 VERISON AND DATE -Version 1.0, June 2009. +Version 2.0, October 2009. =head1 TODO -Add an option for updating phlonode (requires wiping out the phylonodes of this phylotree and recalulating everything) =cut @@ -134,12 +128,8 @@ #! /usr/bin/perl use strict; -use CXGN::DB::InsertDBH; -use CXGN::DB::Connection; -use CXGN::Chado::Organism; -use CXGN::Chado::Db; -use CXGN::Chado::Dbxref; + use Bio::GMOD::Config; use Bio::GMOD::DB::Config; @@ -156,39 +146,48 @@ my $infile = $opt_i; my $phylotree_name= $opt_p || 'NCBI taxonomy tree'; my $DBPROFILE = $opt_g ; -my $gmod_conf = Bio::GMOD::Config->new() if $opt_g; -my $db_conf = Bio::GMOD::DB::Config->new( $gmod_conf, $DBPROFILE ) if $opt_g; print "H= $opt_H, D= $opt_D, v=$opt_v, t=$opt_t, i=$opt_i \n"; -my $dbh; -if (!$dbhost && !$dbname) { - $dbh= CXGN::DB::Connection->new(); -} else { +my ($dbh, $schema); + +if ($opt_g) { + my $DBPROFILE = $opt_g; + $DBPROFILE ||= 'default'; + my $gmod_conf = Bio::GMOD::Config->new() ; + my $db_conf = Bio::GMOD::DB::Config->new( $gmod_conf, $DBPROFILE ) ; + + $dbhost ||= $db_conf->host(); + $dbname ||= $db_conf->name(); + + if (!$dbhost && !$dbname) { die "Need -D dbname and -H hostname arguments.\n"; } + + $schema= Bio::Chado::Schema->connect( $db_conf->dbh(), $db_conf->user(), $db_conf->password() ); + $dbh=$schema->storage->dbh(); + +}else { + require CXGN::DB::InsertDBH; $dbh = CXGN::DB::InsertDBH->new( { dbhost=>$dbhost, dbname=>$dbname, - dbschema => 'public', - #dbprofile=>$DBPROFILE, + dbschema=>'public', } ); + $schema= Bio::Chado::Schema->connect( sub { $dbh->get_actual_dbh() } ); } +if (!$schema || !$dbh) { die "No schema or dbh is avaiable! \n"; } -my $schema= Bio::Chado::Schema->connect( sub { $dbh->get_actual_dbh() }, - { on_connect_do => ['SET search_path TO public, sgn'], - },); - my $sth; my %okay_level = map { chomp; $_=>1 } grep { $_ !~ /^#/ } <DATA>; my %node = (); my %seen = (); my %seq = ( - db => 'db_db_id_seq', - organism => 'organism_organism_id_seq', - dbxref => 'dbxref_dbxref_id_seq', - organism_dbxref => 'organism_dbxref_organism_dbxref_id_seq', - phylotree=> 'phylotree_phylotree_id_seq', - phylonode=> 'phylonode_phylonode_id_seq', - phylonode_organism => 'phylonode_organism_phylonode_organism_id_seq', -); + db => 'db_db_id_seq', + organism => 'organism_organism_id_seq', + dbxref => 'dbxref_dbxref_id_seq', + organism_dbxref => 'organism_dbxref_organism_dbxref_id_seq', + phylotree=> 'phylotree_phylotree_id_seq', + phylonode=> 'phylonode_phylonode_id_seq', + phylonode_organism => 'phylonode_organism_phylonode_organism_id_seq', + ); @@ -196,16 +195,13 @@ my $db_name= 'DB:NCBI_taxonomy'; -my $db=CXGN::Chado::Db->new_with_name($dbh, $db_name); -my $db_id = $db->get_db_id(); -if (!$db_id) { - $db->set_db_name($db_name); - $db->set_url('ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id='); - $db->set_urlprefix('http://'); - print STDERR "String a new db for $db_name!\n"; - $db_id=$db->store(); -} +my $db= $schema->resultset("General::Db")->find_or_create( + { name => $db_name } ); +$db->url('ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id='); +$db->urlprefix('http://'); +$db->update(); +my $db_id = $db->get_column('db_id'); ######## @@ -225,16 +221,16 @@ #store a new phylotree for NCBI taxonomy my $tree_accession= 'taxonomy'; -my $tree_dbxref=CXGN::Chado::Dbxref->new_with_accession($dbh, $tree_accession, $db_id); -my $tree_dbxref_id= $tree_dbxref->get_dbxref_id(); -if ( !$tree_dbxref_id ) { - $tree_dbxref->set_accession($tree_accession); - $tree_dbxref->set_db_name($db_name); - print STDERR "Storing a new dbxref for $tree_accession (db_name = $db_name) !\n"; - $tree_dbxref_id=$tree_dbxref->store(); - print STDERR "the tree dbxref_id is $tree_dbxref_id!!!\n\n"; -} +my $tree_dbxref = $schema->resultset("General::Dbxref")->find_or_create( + { accession => $tree_accession, + db_id => $db_id, + } ); + +my $tree_dbxref_id = $tree_dbxref->get_column('dbxref_id'); +print STDERR "Dbxref for $tree_accession (db_name = $db_name\n"; +print STDERR "The tree dbxref_id is $tree_dbxref_id!\n\n"; + my $phylotree = $schema->resultset('Phylogeny::Phylotree')->find_or_create( { dbxref_id => $tree_dbxref_id, name => $phylotree_name, @@ -242,7 +238,7 @@ ); my $phylotree_id = $phylotree->phylotree_id(); -print STDERR "Created a new phylotee with id $phylotree_id!!!!\n\n\n"; +print STDERR "Created a new phylotee with id $phylotree_id\n\n\n"; #remove all existing phylonodes for this tree and reset the database sequence @@ -269,44 +265,45 @@ #read in the taxonomy tree open( NODE, "nodes.dmp" ); while ( my $line = <NODE> ) { - my ( $id, $parent, $level ) = split /\t\|\t/, $line; - next unless $okay_level{ $level }; - if ($infile) { next() unless exists $tax_file{$id} ; } # skip nodes not in tax_file - $node{ $id }{ 'parent_taxid' } = $parent; - $node{ $id }{ 'self_taxid' } = $id; - $node{ $id }{ 'level' } = $level; -## $node{ $id }{ 'organism_id' } = $next_organism++; #do we really need an incremented organism_id?? + my ( $id, $parent, $level ) = split /\s+\|\s+/, $line; + + next unless $okay_level{ $level }; + if ($infile) { next() unless exists $tax_file{$id} ; } # skip nodes not in tax_file + $node{ $id }{ 'parent_taxid' } = $parent; + $node{ $id }{ 'self_taxid' } = $id; + $node{ $id }{ 'level' } = $level; } + close( NODE ); open( NAME, "names.dmp" ); while ( my $line = <NAME> ) { - #next unless $line =~ /scientific name/; - my ( $id, $name ) = split /\t\|\t/, $line; - next unless $node{ $id }; #skip nodes - if ( $line =~ /scientific name/) { - $node{ $id }{ 'name' } = $name; - $node{ $id }{ 'name' } .= " Taxonomy:$id" if $seen{ $name }++; - } elsif ( $line =~ /common name/) { # genbank common names - push(@{ $node{ $id }{ 'common_name' } } , $name); - push(@{ $node{$id}{ 'synonyms' } }, $name); - - } elsif ( $line =~ /synonym/ ) { - push @{ $node{$id}{ 'synonyms' } }, $name; - } + #next unless $line =~ /scientific name/; + my ( $id, $name ) = split /\t\|\t/, $line; + next unless $node{ $id }; #skip nodes + if ( $line =~ /scientific name/) { + $node{ $id }{ 'name' } = $name; + $node{ $id }{ 'name' } .= " Taxonomy:$id" if $seen{ $name }++; + } elsif ( $line =~ /common name/) { # genbank common names + push(@{ $node{ $id }{ 'common_name' } } , $name); + push(@{ $node{$id}{ 'synonyms' } }, $name); + + } elsif ( $line =~ /synonym/ ) { + push @{ $node{$id}{ 'synonyms' } }, $name; + } } close( NAME ); foreach my $id ( keys %node ) { - if ( $node{ $id }{ 'level' } eq 'species' ) { - $node{ $id }{ 'genus' } = $node{ $node{ $id }{ 'parent_taxid' } }{ 'name' }; - $node{ $id }{ 'species' } = $node{ $id }{ 'name' }; - } - else { - $node{ $id }{ 'genus' } = $node{ $id }{ 'level' }; - $node{ $id }{ 'species' } = $node{ $id }{ 'name' }; - } + if ( $node{ $id }{ 'level' } eq 'species' ) { + $node{ $id }{ 'genus' } = $node{ $node{ $id }{ 'parent_taxid' } }{ 'name' }; + $node{ $id }{ 'species' } = $node{ $id }{ 'name' }; + } + else { + $node{ $id }{ 'genus' } = $node{ $id }{ 'level' }; + $node{ $id }{ 'species' } = $node{ $id }{ 'name' }; + } } @@ -333,100 +330,112 @@ eval { my $root_id; my $organism_id = $maxval{'organism'}; - foreach my $id ( keys %node ) { - ###### - #Store the genbank taxon_id in dbxref and in organism_dbxref - # - my $genbank_taxon_accession= $node{ $id }{ 'self_taxid' }; - my $dbxref= CXGN::Chado::Dbxref->new_with_accession($dbh, $genbank_taxon_accession, $db_id); - my $dbxref_id = $dbxref->get_dbxref_id(); - if (!$dbxref_id) { - $dbxref->set_db_name($db_name); - $dbxref->set_accession( $genbank_taxon_accession ); - $dbxref_id= $dbxref->store(); - } - - - my $organism= CXGN::Chado::Organism->new($schema); - my $abbreviation; - if ($node{ $id }{level} eq 'species' ) { + NODE: foreach my $id ( keys %node ) { + ###### + #Store the genbank taxon_id in dbxref and in organism_dbxref + # + my $genbank_taxon_accession= $node{ $id }{ 'self_taxid' }; + if (!$genbank_taxon_accession) { + print ERR "SKIPPING: No record found for genbank taxon id $id! Check your infile !\n"; + next NODE; + } + my $dbxref = $schema->resultset("General::Dbxref")->find_or_create( + { accession => $genbank_taxon_accession, + db_id => $db_id, + }); + my $dbxref_id = $dbxref->get_column('dbxref_id'); + + my $abbreviation; + if ($node{ $id }{level} eq 'species' ) { - if ( $node{ $id }{ 'species' } =~ m/(.*)\s(.*)/ ) { - my $gen=$1; - my $sp=$2; - $abbreviation= uc( substr( $gen ,0, 1 ) ) . "." . $sp; - } - } - my $common_name; - - my $c= @{ $node{$id}{'common_name'} } if (defined @{ $node{$id}{'common_name'}}); - $common_name = join("," , @{ $node{ $id }{ 'common_name' } }) if $c; - - $organism->set_genus($node{ $id }{ 'genus' } ); - $organism->set_species($node{ $id }{ 'species' } ); - $organism->set_common_name($common_name); - $organism->set_abbreviation($abbreviation ); - print STDERR "Genus= " . $organism->get_genus() . " Species= " . $organism->get_species() . "\n"; - my $existing_id = $organism->exists_in_database(); - if ($existing_id) { - $organism=CXGN::Chado::Organism->new($schema, $existing_id); - print STDERR "Organism $existing_id exists in database! ($abbreviation)\n"; - $organism->set_genus($node{ $id }{ 'genus' } ); - $organism->set_species($node{ $id }{ 'species' } ); - $organism->set_common_name($common_name); - $organism->set_abbreviation($abbreviation); - }else { - print STDERR "New organism: " . $organism->get_species() . "\n"; - print ERR "New organism: " . $organism->get_species() . "\n"; - } - - #store the organism in the organism table: - $organism->store(); - - print STDERR " COMMON_NAME= " . $organism->get_common_name() . "\n" if $common_name; - my $organism_id= $organism->get_organism_id(); - - ########################################### - #store the organism synonyms - foreach (@{$node{ $id }{synonyms} } ) { - $organism->add_synonym($_); #an organismprop. Requires to have name = 'synonym' in the cvterm table. - print STDERR $node{ $id }{name} . " LEVEL=( " . $node{ $id }{level} . ") Synonym is $_ \n" ; - } - #################################################################### - - - my $organism_dbxref = $schema->resultset('Organism::OrganismDbxref')->find_or_create( - { - organism_id => $organism_id, - dbxref_id => $dbxref_id, - }, - ); - - #get the cvterm_id of the taxonomy level - my $level= $node{ $id }{level}; - my ($level_cvterm) = $schema->resultset("Cv::Cvterm")->find( - { - name => $level, - cv_id => $schema->resultset("Cv::Cv")->find( { name => 'taxonomy' } )->get_column('cv_id'), - }, - ); - - my $level_id = $level_cvterm->get_column("cvterm_id") if $level_cvterm ; - - if (!$level_cvterm) { - print STDERR "No cvterm found for type $level! Check your cvterm table for loaded taxonomy (cv name should be 'taxonomy') \n\n"; - print ERR "No cvterm found for type $level! Check your cvterm table for loaded taxonomy (cv name should be 'taxonomy') \n\n"; - - } + if ( $node{ $id }{ 'species' } =~ m/(.*)\s(.*)/ ) { + my $gen=$1; + my $sp=$2; + $abbreviation= uc( substr( $gen ,0, 1 ) ) . "." . $sp; + } + } + my $common_name; + my $c= @{ $node{$id}{'common_name'} } if (defined @{ $node{$id}{'common_name'}}); + $common_name = join("," , @{ $node{ $id }{ 'common_name' } }) if $c; + + my $genus = $node{ $id }{ 'genus' } ; + my $species = $node{ $id }{ 'species' } ; + + my ($organism, $update, $insert); + + #this is just for checking if the organism is already stored in the database + # + #if ($species =~ m/(.*)\s(.*)/) { + # $species = $2; + # $genus = $1; + #} + $organism = $schema->resultset('Organism::Organism')->search( + { + genus => { 'ilike'=> $genus }, + species => {'ilike' => $species } + })->single(); + if (!$organism) { #create a new empty row object + $organism = $schema->resultset('Organism::Organism')->new({}); + $insert=1; + } else { $update = 1; } + + $organism->set_column(genus => $node{ $id }{ 'genus' } ); + $organism->set_column(species => $node{ $id }{ 'species' } ); + $organism->set_column(abbreviation => $abbreviation ); + $organism->set_column(common_name => $common_name ); + + if ($update) { + $organism->update(); + print STDERR "*Updating organism " . $organism->get_column('organism_id') . " (species=" . $organism->species . ")\n"; + print ERR "*Updating organism " . $organism->get_column('organism_id') . " (species=" . $organism->species . ")\n"; + } + if ($insert) { + $organism->insert(); + print STDERR "New organism" . $organism->get_column('organism_id') . " (species=" . $organism->species . ")\n"; + print ERR "New organism " . $organism->get_column('organism_id') . " (species=" . $organism->species . ")\n"; + } + my $organism_id= $organism->get_column('organism_id'); + + ########################################### + #store the organism synonyms + foreach (@{$node{ $id }{synonyms} } ) { + $organism->create_organismprops( { synonym => $_ }, { autocreate => 1} , ); + print STDERR $node{ $id }{name} . " LEVEL=( " . $node{ $id }{level} . ") Synonym is $_ \n" ; + } + #################################################################### + + my $organism_dbxref = $schema->resultset('Organism::OrganismDbxref')->find_or_create( + { + organism_id => $organism_id, + dbxref_id => $dbxref_id, + }, + ); + + #get the cvterm_id of the taxonomy level + my $level= $node{ $id }{level}; + my ($level_cvterm) = $schema->resultset("Cv::Cvterm")->find( + { + name => $level, + cv_id => $schema->resultset("Cv::Cv")->find( { name => 'taxonomy' } )->get_column('cv_id'), + }, + ); + + my $level_id = $level_cvterm->get_column("cvterm_id") if $level_cvterm ; + + if (!$level_cvterm) { + print STDERR "No cvterm found for type $level! Check your cvterm table for loaded taxonomy (cv name should be 'taxonomy') \n\n"; + print ERR "No cvterm found for type $level! Check your cvterm table for loaded taxonomy (cv name should be 'taxonomy') \n\n"; + + } #store a new phylonode_id + phylonode_organism. This is necessary for storing later the parent_phylonode_id - # and eventuay the left_idx and right_idx. - - $phylonode{ $id }{ 'phylonode_id' } = $next_phylonode_id++; - $phylonode{ $id }{ 'organism_id' } = $organism_id; - $phylonode{ $id }{ 'parent_taxid' } = $node{ $id }{ 'parent_taxid' }; - $phylonode{ $id }{ 'type_id' } = $level_id ; - - } + # and eventuay the left_idx and right_idx. + + $phylonode{ $id }{ 'phylonode_id' } = $next_phylonode_id++; + $phylonode{ $id }{ 'organism_id' } = $organism_id; + $phylonode{ $id }{ 'parent_taxid' } = $node{ $id }{ 'parent_taxid' }; + $phylonode{ $id }{ 'type_id' } = $level_id ; + + } #now that all the organisms are stored, we can sore the relationships (=phylonodes) @@ -452,7 +461,7 @@ our $ctr = 1; print STDERR "the root_id is $root_id\n"; - + walktree($root_id); print STDERR "Updating the phylonode and phylonode_organism tables\n\n"; @@ -462,7 +471,6 @@ ); - foreach (@updates) { $dbh->do( $_ ); } sub walktree { @@ -531,7 +539,7 @@ #http://www.eyesopen.com/docs/cplusprog_1_2/node220.html __DATA__ -no rank + no rank superkingdom subkingdom kingdom Modified: schema/trunk/chado/bin/cxgn/load_taxonomy_cvterms.pl =================================================================== --- schema/trunk/chado/bin/cxgn/load_taxonomy_cvterms.pl 2009-10-19 22:32:52 UTC (rev 22176) +++ schema/trunk/chado/bin/cxgn/load_taxonomy_cvterms.pl 2009-10-20 14:53:11 UTC (rev 22177) @@ -1,32 +1,84 @@ + +=head1 NAME + + load_taxonomy_cvterms.pl + +=head1 DESCRIPTION + + Usage: perl load_taxonomy_cvterms.pl -H [dbhost] -D [dbname] [-t] -g gmod_dbprofile + +populate a chado database with NCBI taxon terms + + +=head2 parameters + +=over 4 + +=item -H + +hostname for database + +=item -D + +database name + + +=item -t + +trial mode. Do not perform any store operations at all. + + +=item -g + +GMOD database profile name (can provide host and DB name) Default: 'default' + + +=back + +=cut + #!/usr/bin/perl use strict; -use CXGN::DB::Connection; -use CXGN::DB::InsertDBH; +use Bio::GMOD::Config; +use Bio::GMOD::DB::Config; + use Bio::Chado::Schema; use Getopt::Std; -our ($opt_H, $opt_D, $opt_v, $opt_t); +our ($opt_H, $opt_D, $opt_g, $opt_t); -getopts('H:vtD:'); +getopts('H:g:tD:'); my $dbhost = $opt_H; my $dbname = $opt_D; -my $dbh; +my ($dbh, $schema); -if (!$dbhost && !$dbname) { - $dbh= CXGN::DB::Connection->new(); -}else { +if ($opt_g) { + my $DBPROFILE = $opt_g; + $DBPROFILE ||= 'default'; + my $gmod_conf = Bio::GMOD::Config->new() ; + my $db_conf = Bio::GMOD::DB::Config->new( $gmod_conf, $DBPROFILE ) ; - $dbh = CXGN::DB::InsertDBH->new( { dbhost => $dbhost, - dbname => $dbname, + $dbhost ||= $db_conf->host(); + $dbname ||= $db_conf->name(); + if (!$dbhost && !$dbname) { die "Need -D dbname and -H hostname arguments.\n"; } + $schema= Bio::Chado::Schema->connect( $db_conf->dbh(), $db_conf->user(), $db_conf->password() ); + + $dbh=$schema->storage->dbh(); + +}else { + require CXGN::DB::InsertDBH; + $dbh = CXGN::DB::InsertDBH->new( { dbhost=>$dbhost, + dbname=>$dbname, + dbschema=>'public', } ); + $schema= Bio::Chado::Schema->connect( sub { $dbh->get_actual_dbh() } ); } -my $schema= Bio::Chado::Schema->connect( sub { $dbh->get_actual_dbh() }, - ); +if (!$schema || !$dbh) { die "No schema or dbh is avaiable! \n"; } eval { @@ -53,13 +105,13 @@ accession => "taxonomy:$tax", }); my $dbxref_id = $dbxref->get_column('dbxref_id'); - + my $cvterm = $schema->resultset("Cv::Cvterm")->find_or_create( { cv_id => $cv_id, name => $tax, dbxref_id => $dbxref_id, - + }); my $cvterm_id= $cvterm->get_column('cvterm_id'); print STDERR "Stored cvterm for $tax ($cvterm_id)\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sco...@us...> - 2009-11-03 22:11:20
|
Revision: 22220 http://gmod.svn.sourceforge.net/gmod/?rev=22220&view=rev Author: scottcain Date: 2009-11-03 22:11:02 +0000 (Tue, 03 Nov 2009) Log Message: ----------- Added a __DIE__ signal handler to clean up the database before the bulk loader croaks so that calling --remove_lock and --recreate_cache may become a thing of the past. Modified Paths: -------------- schema/trunk/chado/Changes schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm schema/trunk/chado/load/bin/bulk_load_gff3.PLS Modified: schema/trunk/chado/Changes =================================================================== --- schema/trunk/chado/Changes 2009-11-03 21:33:29 UTC (rev 22219) +++ schema/trunk/chado/Changes 2009-11-03 22:11:02 UTC (rev 22220) @@ -26,11 +26,19 @@ * Updated all_feature_names view to search featureprop.value and dbxref.accession and added organism_id so GBrowse can limit by organism. +* Fixed gmod_bulk_load_gff3.pl to deal correctly with the case that +mulitple organisms have the same common name. If the user tries to +use a common name that corresponds to more than one organism, it will +die gracefully. +* Fixed gmod_bulk_load_gff3.pl so that featureloc.srcfeature_id will +not be sometimes set incorrectly when there are multiple organisms +with chromosomes (or other srcfeatures) with the same name. If you have +a database that has been affected by this bug, see http://.... for a fix. +* Added a __DIE__ signal handler to gmod_bulk_load_gff3.pl so that the +databsae will be cleaned up in most cases before the loader croaks. - - Below this line are changes up until a few years ago and are included for historical purposes. --------------------------------------------------------------------------- Modified: schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm =================================================================== --- schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm 2009-11-03 21:33:29 UTC (rev 22219) +++ schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm 2009-11-03 22:11:02 UTC (rev 22220) @@ -199,6 +199,8 @@ "INSERT INTO gff_meta (name,hostname) VALUES (?,?)"; use constant DELETE_FROM_META => "DELETE FROM gff_meta WHERE name = ? AND hostname = ?"; +use constant TMP_TABLE_CLEANUP => + "DELETE FROM tmp_gff_load_cache WHERE feature_id >= ?"; my $ALLOWED_UNIQUENAME_CACHE_KEYS = "feature_id|type_id|organism_id|uniquename|validate"; @@ -553,7 +555,13 @@ ## dgg; keep - this is public; sub nextfeature { my $self = shift; - return $self->nextoid('feature',@_); + + my $fid = $self->nextoid('feature',@_); + if (!$self->first_feature_id() ) { + $self->first_feature_id( $fid ); + } + + return $fid; # my $arg = shift if defined(@_); # if (defined($arg) && $arg eq '++') { # return $self->{'nextfeature'}++; @@ -1328,23 +1336,97 @@ my ($self, %argv) = @_; my $dbh = $self->dbh; - my $select_query = $dbh->prepare(SELECT_FROM_META); - $select_query->execute(); + my $select_query = $dbh->prepare(SELECT_FROM_META) or warn "select prepare failed"; + $select_query->execute() or warn "select from meta failed"; - my $delete_query = $dbh->prepare(DELETE_FROM_META); + my $delete_query = $dbh->prepare(DELETE_FROM_META) or warn "delete prepare failed"; while (my @result = $select_query->fetchrow_array) { my ($name,$host,$time) = @result; if ($name =~ /gmod_bulk_load_gff3/) { - $delete_query->execute($name,$host); + $delete_query->execute($name,$host) or warn "removing the lock failed!"; + $dbh->commit or warn "commit failed"; } } return; } +=head2 cleanup_tmp_table +=over + +=item Usage + + $obj->cleanup_tmp_table() + +=item Function + +Called when there is an abnormal exit from a loading program. It deletes +entries in the tmp_gff_load_cache table that have feature_ids that were used +during the current session. + +=item Returns + +Nothing + +=item Arguments + +None (it needs the first feature_id, but that is stored in the object). + +=back + +=cut + +sub cleanup_tmp_table { + my $self = shift; + + my $dbh = $self->dbh; + my $first_feature = $self->first_feature_id(); + return unless $first_feature; + + my $delete_query = $dbh->prepare(TMP_TABLE_CLEANUP); + + + warn "Attempting to clean up the loader temp table (so that --recreate_cache\nwon't be needed)...\n"; + $delete_query->execute($first_feature); + + return; +} + +=head2 first_feature_id + +=over + +=item Usage + + $obj->first_feature_id() #get existing value + $obj->first_feature_id($newval) #set new value + +=item Function + +=item Returns + +value of first_feature_id (a scalar), that is, the feature_id of the first +feature parsed in the current session. + +=item Arguments + +new value of first_feature_id (to set) + +=back + +=cut + +sub first_feature_id { + my $self = shift; + my $first_feature_id = shift if defined(@_); + return $self->{'first_feature_id'} = $first_feature_id if defined($first_feature_id); + return $self->{'first_feature_id'}; +} + + =head2 initialize_ontology =over Modified: schema/trunk/chado/load/bin/bulk_load_gff3.PLS =================================================================== --- schema/trunk/chado/load/bin/bulk_load_gff3.PLS 2009-11-03 21:33:29 UTC (rev 22219) +++ schema/trunk/chado/load/bin/bulk_load_gff3.PLS 2009-11-03 22:11:02 UTC (rev 22220) @@ -590,6 +590,8 @@ or pod2usage(-verbose => 1, -exitval => 1); pod2usage(-verbose => 2, -exitval => 1) if $MANPAGE; +$SIG{__DIE__} = $SIG{INT} = 'cleanup_handler'; + my $ORGANISM_FROM_CMDLINE = $ORGANISM; unless ($DBNAME) { @@ -705,6 +707,7 @@ $chado->remove_lock(force => 1) if $REMOVE_LOCK; $chado->place_lock(); +my $lock = 1; #if we need custom ontology mapping, cache them here if ($ONTOLOGY) { @@ -1059,6 +1062,22 @@ $chado->remove_lock(); exit(0); + +sub cleanup_handler { + warn "@_\nAbnormal termination, trying to clean up...\n\n" if @_; #gets the message that the die signal sent if there is one + if ($chado && $chado->dbh->ping) { + #$chado->dbh->{AutoCommit} = 1; + $chado->cleanup_tmp_table; + if ($lock) { + warn "Trying to remove the run lock (so that --remove_lock won't be needed)...\n"; + $chado->remove_lock; #remove the lock only if we've set it + } + $chado->dbh->rollback; + print STDERR "Exiting...\n"; + } + exit(1); +} + !NO!SUBS! close OUT or die "Can't close $file: $!"; chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sco...@us...> - 2009-11-16 18:05:16
|
Revision: 22261 http://gmod.svn.sourceforge.net/gmod/?rev=22261&view=rev Author: scottcain Date: 2009-11-16 18:04:55 +0000 (Mon, 16 Nov 2009) Log Message: ----------- a few changes on the suggestion of Sven Modified Paths: -------------- schema/trunk/chado/MANIFEST schema/trunk/chado/Makefile.PL Modified: schema/trunk/chado/MANIFEST =================================================================== --- schema/trunk/chado/MANIFEST 2009-11-16 16:56:00 UTC (rev 22260) +++ schema/trunk/chado/MANIFEST 2009-11-16 18:04:55 UTC (rev 22261) @@ -146,6 +146,7 @@ install_util/src_install.PLS lib/Bio/Chado/Builder.pm lib/Bio/Chado/Config.pm +lib/Bio/Chado/LoadDBI.pm lib/Bio/GMOD/Bulkfiles.pm lib/Bio/GMOD/Bulkfiles/AcodeWriter.pm lib/Bio/GMOD/Bulkfiles/BlastWriter.pm @@ -181,7 +182,6 @@ load/etc/README load/logs/load.log load/tt2/load.conf.tt2 -load/tt2/LoadDBI.tt2 Makefile.PL MANIFEST This list of files MANIFEST.SKIP Modified: schema/trunk/chado/Makefile.PL =================================================================== --- schema/trunk/chado/Makefile.PL 2009-11-16 16:56:00 UTC (rev 22260) +++ schema/trunk/chado/Makefile.PL 2009-11-16 18:04:55 UTC (rev 22261) @@ -148,7 +148,7 @@ my $build_config = catfile $working_dir, 'build.conf'; my $load_config = catfile $working_dir, 'load', 'etc', 'load.conf'; -my $all_args = join( '|', qw[LIB RECONFIGURE DEFAULTS PREFIX INSTALLSITEMAN1DIR INSTALLSITEMAN3DIR ], keys %args ); +my $all_args = join( '|', qw[LIB RECONFIGURE DEFAULTS PREFIX INSTALLSITEMAN1DIR INSTALLSITEMAN3DIR INSTALL_BASE], keys %args ); my %env_required = map {$_=>1} qw(GMOD_ROOT CHADO_DB_NAME CHADO_DB_USERNAME); #CHADO_DB_PASSWORD is valid if undefined my $all_envs = join( '|', keys %env_required ); @@ -196,6 +196,7 @@ } @ARGV = (); push @ARGV, "PREFIX=$opts{PREFIX}" if $opts{PREFIX}; +push @ARGV, "INSTALL_BASE=$opts{INSTALL_BASE}" if $opts{INSTALL_BASE}; $O{'GMOD_ROOT'} = $opts{PREFIX} if $opts{PREFIX}; push @ARGV, "INSTALLSITEMAN1DIR=$opts{INSTALLSITEMAN1DIR}" if $opts{INSTALLSITEMAN1DIR}; push @ARGV, "INSTALLSITEMAN3DIR=$opts{INSTALLSITEMAN3DIR}" if $opts{INSTALLSITEMAN3DIR}; @@ -532,7 +533,7 @@ clean => { FILES => '$(DISTVNAME).tar$(SUFFIX) load/etc/load.conf build.conf ' . - '_build Build lib/Bio/Chado/AutoDBI.pm lib/Bio/Chado/LoadDBI.pm '.$LOCAL_TMP + '_build Build lib/Bio/Chado/AutoDBI.pm '.$LOCAL_TMP }, ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sco...@us...> - 2009-12-03 21:36:04
|
Revision: 22316 http://gmod.svn.sourceforge.net/gmod/?rev=22316&view=rev Author: scottcain Date: 2009-12-03 21:35:52 +0000 (Thu, 03 Dec 2009) Log Message: ----------- fixing version number stuff Modified Paths: -------------- schema/trunk/chado/Makefile.PL schema/trunk/chado/load/Build.PL Modified: schema/trunk/chado/Makefile.PL =================================================================== --- schema/trunk/chado/Makefile.PL 2009-12-03 21:33:46 UTC (rev 22315) +++ schema/trunk/chado/Makefile.PL 2009-12-03 21:35:52 UTC (rev 22316) @@ -515,6 +515,7 @@ 'DBIx::DBStag' => 0.09, 'GO::Parser' => 0, 'Module::Load' => 0.16, + 'Bio::Root::Version'=> 1.0069, }, 'PL_FILES' => { # 'load/bin/load_affymetrix.PLS' => 'load/bin/gmod_load_affymetrix.pl', Modified: schema/trunk/chado/load/Build.PL =================================================================== --- schema/trunk/chado/load/Build.PL 2009-12-03 21:33:46 UTC (rev 22315) +++ schema/trunk/chado/load/Build.PL 2009-12-03 21:35:52 UTC (rev 22316) @@ -3,7 +3,7 @@ use Bio::Chado::Builder; use Data::Dumper; -my $VERSION = 0.01; +my $VERSION = 1.1; my $conf = shift; my $m = Bio::Chado::Builder->new( dist_name => 'Chado', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sco...@us...> - 2009-12-09 22:09:55
|
Revision: 22352 http://gmod.svn.sourceforge.net/gmod/?rev=22352&view=rev Author: scottcain Date: 2009-12-09 22:09:14 +0000 (Wed, 09 Dec 2009) Log Message: ----------- adding the option to create a temp dir for loading files, and restoring the ability of the adaptor to remove the lock when load is interrupted by cntl-C Modified Paths: -------------- schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm schema/trunk/chado/load/bin/bulk_load_gff3.PLS Modified: schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm =================================================================== --- schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm 2009-12-09 20:18:39 UTC (rev 22351) +++ schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm 2009-12-09 22:09:14 UTC (rev 22352) @@ -3,7 +3,7 @@ use strict; use Carp qw/cluck confess/; use DBI; -use File::Temp; +use File::Temp qw/ tempdir /; use Data::Dumper; use URI::Escape; use Sys::Hostname; @@ -260,6 +260,7 @@ $self->nouniquecache( $arg{nouniquecache} ); $self->recreate_cache( $arg{recreate_cache} ); $self->save_tmpfiles( $arg{save_tmpfiles} ); + $self->random_tmp_dir( $arg{random_tmp_dir} ); $self->no_target_syn( $arg{no_target_syn} ); $self->unique_target( $arg{unique_target} ); $self->dbxref( $arg{dbxref} ); @@ -899,12 +900,17 @@ return $self->{file_handles}{$fhhame}; } else { + my $file_path = "./"; + if ($self->random_tmp_dir ) { + $file_path = tempdir( CLEANUP => $self->save_tmpfiles() ? 0 : 1 ); + } for my $key (keys %files) { $self->{file_handles}{$files{$key}} = new File::Temp( TEMPLATE => "chado-$key-XXXX", #dgg; was $keyXXXX - SUFFIX => '.dat', + SUFFIX => '.dat', UNLINK => $self->save_tmpfiles() ? 0 : 1, + DIR => $file_path, ); } return; @@ -1349,7 +1355,7 @@ if ($name =~ /gmod_bulk_load_gff3/) { $delete_query->execute($name,$host) or warn "removing the lock failed!"; - #$dbh->commit; + $dbh->commit; } } @@ -2244,6 +2250,37 @@ return $self->{'save_tmpfiles'} = $save_tmpfiles if defined($save_tmpfiles); return $self->{'save_tmpfiles'}; } +=head2 random_tmp_dir + +=over + +=item Usage + + $obj->random_tmp_dir() #get existing value + $obj->random_tmp_dir($newval) #set new value + +=item Function + +=item Returns + +value of random_tmp_dir (a scalar) + +=item Arguments + +new value of random_tmp_dir (to set) + +=back + +=cut + +sub random_tmp_dir { + my $self = shift; + my $random_tmp_dir = shift if defined(@_); + return $self->{'random_tmp_dir'} = $random_tmp_dir if defined($random_tmp_dir); + return $self->{'random_tmp_dir'}; +} + + =head2 no_target_syn =over Modified: schema/trunk/chado/load/bin/bulk_load_gff3.PLS =================================================================== --- schema/trunk/chado/load/bin/bulk_load_gff3.PLS 2009-12-09 20:18:39 UTC (rev 22351) +++ schema/trunk/chado/load/bin/bulk_load_gff3.PLS 2009-12-09 22:09:14 UTC (rev 22352) @@ -84,6 +84,8 @@ --recreate_cache Causes the uniquename cache to be recreated --remove_lock Remove the lock to allow a new process to run --save_tmpfiles Save the temp files used for loading the database + --random_tmp_dir Use a randomly generated tmp dir (the default is + to use the current directory) --no_target_syn By default, the loader adds the targetId in the synonyms list of the feature. This flag desactivate this. @@ -547,7 +549,7 @@ my ($ORGANISM, $GFFFILE,$DBPROFILE, $DBNAME, $DBUSER, $DBPASS,$DBHOST, $DBPORT, $ANALYSIS, $ANALYSIS_GROUP, $GLOBAL_ANALYSIS, $NOLOAD, $VALIDATE, $INSERTS, $NOTRANSACT, $NOSEQUENCE, $SCORE_COL, $ONTOLOGY, $SKIP_VACUUM, - $DROP_INDEX, $NOEXON, $NOUNIQUECACHE, $RECREATE_CACHE, $SAVE_TMPFILES, + $DROP_INDEX, $NOEXON, $NOUNIQUECACHE, $RECREATE_CACHE, $SAVE_TMPFILES,$RANDOM_TMP_DIR, $NO_TARGET_SYN, $UNIQUE_TARGET, $DBXREF, $FP_CV, $NO_ADDFP_CV, $MANPAGE, $DEBUG, $DELETE, $DELETE_CONFIRM, $CUSTOM_ADAPTER, $PRIVATE_SCHEMA, $USE_PUBLIC_CV, $NO_SKIP_VACUUM, $END_SQL, $REMOVE_LOCK, ); @@ -577,6 +579,7 @@ 'recreate_cache'=> \$RECREATE_CACHE, 'remove_lock' => \$REMOVE_LOCK, 'save_tmpfiles'=>\$SAVE_TMPFILES, + 'random_tmp_dir'=>\$RANDOM_TMP_DIR, 'no_target_syn'=> \$NO_TARGET_SYN, 'unique_target' => \$UNIQUE_TARGET, 'dbxref:s' => \$DBXREF, @@ -679,6 +682,7 @@ $argv{nouniquecache}= $NOUNIQUECACHE; $argv{recreate_cache}=$RECREATE_CACHE; $argv{save_tmpfiles}= $SAVE_TMPFILES; + $argv{random_tmp_dir}=$RANDOM_TMP_DIR; $argv{no_target_syn}= $NO_TARGET_SYN; $argv{unique_target}= $UNIQUE_TARGET; $argv{dbxref} = $DBXREF; @@ -1077,7 +1081,7 @@ warn "Trying to remove the run lock (so that --remove_lock won't be needed)...\n"; $chado->remove_lock; #remove the lock only if we've set it } - $chado->dbh->rollback; + #$chado->dbh->rollback; print STDERR "Exiting...\n"; } exit(1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sco...@us...> - 2009-12-16 17:15:37
|
Revision: 22422 http://gmod.svn.sourceforge.net/gmod/?rev=22422&view=rev Author: scottcain Date: 2009-12-16 17:15:06 +0000 (Wed, 16 Dec 2009) Log Message: ----------- adding a --fastafile option to gmod_bulk_load_gff3.pl Modified Paths: -------------- schema/trunk/chado/Changes schema/trunk/chado/bin/gmod_gff3_preprocessor.pl schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm schema/trunk/chado/load/bin/bulk_load_gff3.PLS schema/trunk/chado/modules/companalysis/companalysis.sql Modified: schema/trunk/chado/Changes =================================================================== --- schema/trunk/chado/Changes 2009-12-16 15:38:43 UTC (rev 22421) +++ schema/trunk/chado/Changes 2009-12-16 17:15:06 UTC (rev 22422) @@ -47,9 +47,10 @@ * Adding the ability to specify that gmod_bulk_load_gff3.pl use the system tmp directory rather than using the current working directory for writing the temporary load files. +* Added a --fastafile option to gmod_bulk_load_gff3.pl to use when +loading fasta files. - Below this line are changes up until a few years ago and are included for historical purposes. --------------------------------------------------------------------------- Modified: schema/trunk/chado/bin/gmod_gff3_preprocessor.pl =================================================================== --- schema/trunk/chado/bin/gmod_gff3_preprocessor.pl 2009-12-16 15:38:43 UTC (rev 22421) +++ schema/trunk/chado/bin/gmod_gff3_preprocessor.pl 2009-12-16 17:15:06 UTC (rev 22422) @@ -242,9 +242,9 @@ open FASTA, ">", $fasta or die "couldn't open $fasta for writing: $!\n"; - print FASTA "##gff-version 3\n"; - print FASTA; - print FASTA "\n"; #extra cr works around bug in Bio::FeatureIO::gff + #print FASTA "##gff-version 3\n"; + #print FASTA; + #print FASTA "\n"; #extra cr works around bug in Bio::FeatureIO::gff next; } elsif ($fasta_flag) { Modified: schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm =================================================================== --- schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm 2009-12-16 15:38:43 UTC (rev 22421) +++ schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm 2009-12-16 17:15:06 UTC (rev 22422) @@ -1575,16 +1575,12 @@ my $sth = $self->dbh->prepare($max_id_query); $sth->execute; my ($max_id) = $sth->fetchrow_array(); - - warn "$table $max_id"; my $curval_query = "SELECT nextval('$sequences{$table}')"; $sth = $self->dbh->prepare($curval_query); $sth->execute; my ($curval) = $sth->fetchrow_array(); - warn "$table $curval"; - if ($max_id > $curval) { my $setval_query = "SELECT setval('$sequences{$table}',$max_id)"; $sth = $self->dbh->prepare($setval_query); @@ -2544,6 +2540,41 @@ return; } +sub print_fasta { + my $self = shift; + my ($uniquename,$string) = @_; + my $dbh = $self->dbh; + my $organism_id = $self->organism_id; + + #assume that the fasta ID matches the uniquename (ie, no munging when it went into the database) + my $fid_query = "SELECT feature_id FROM feature WHERE uniquename = ? AND organism_id = ?"; + my $sth = $dbh->prepare($fid_query); + $sth->execute($uniquename,$organism_id); + + if ($sth->rows == 0) { + warn <<END; +No features where found with a unqiuename of $uniquename +and an organism_id of $organism_id. Are you sure you have the uniquename +right? It might have been changed when loaded into the database to ensure +uniqueness. Skipping this sequence... + +END + return; + } + elsif ($sth->rows > 1) { + warn "More than one feature found for $uniquename, org_id:$organism_id when trying to add sequence, skipping...\n\n"; + return; + } + + my ($feature_id) = $sth->fetchrow_array; + + my $fh = $self->file_handles('sequence'); + print $fh "UPDATE feature set residues='$string' WHERE feature_id=$feature_id;\n"; + print $fh "UPDATE feature set seqlen=length(residues) WHERE feature_id=$feature_id;\n"; + + return; +} + sub print_af { my $self = shift; my ($af_id,$f_id,$a_id,$score) = @_; Modified: schema/trunk/chado/load/bin/bulk_load_gff3.PLS =================================================================== --- schema/trunk/chado/load/bin/bulk_load_gff3.PLS 2009-12-16 15:38:43 UTC (rev 22421) +++ schema/trunk/chado/load/bin/bulk_load_gff3.PLS 2009-12-16 17:15:06 UTC (rev 22422) @@ -36,6 +36,7 @@ use warnings; use lib '/Users/cain/cvs_stuff/schema/trunk/chado/lib'; use Bio::FeatureIO; +use Bio::SeqIO; use Getopt::Long; use Data::Dumper; use Pod::Usage; @@ -58,6 +59,7 @@ --gfffile The file containing GFF3 (optional, can read from stdin) + --fastafile Fasta file to load sequence from --organism The organism for the data (use the value 'fromdata' to read from GFF organism=xxx) --dbprofile Database config profile name @@ -336,6 +338,18 @@ =over +=item Loading fasta file + +When the --fastafile is provided with an argument that is the path to +a file containing fasta sequence, the loader will attempt to update the +feature table with the sequence provided. Note that the ID provided in the +fasta description line must exactly match what is in the feature table +uniquename field. Be careful if it is possible that the uniquename of the +feature was changed to ensure uniqueness when it was loaded from the +original GFF. Also note that when loading sequence from a fasta file, +loading GFF from standard in is disabled. Sorry for any inconvenience. + + =item ##sequence-region This script does not use sequence-region directives for anything. @@ -546,7 +560,7 @@ =cut -my ($ORGANISM, $GFFFILE,$DBPROFILE, $DBNAME, $DBUSER, $DBPASS,$DBHOST, $DBPORT, +my ($ORGANISM, $GFFFILE,$FASTAFILE,$DBPROFILE, $DBNAME, $DBUSER, $DBPASS,$DBHOST, $DBPORT, $ANALYSIS, $ANALYSIS_GROUP, $GLOBAL_ANALYSIS, $NOLOAD, $VALIDATE, $INSERTS, $NOTRANSACT, $NOSEQUENCE, $SCORE_COL, $ONTOLOGY, $SKIP_VACUUM, $DROP_INDEX, $NOEXON, $NOUNIQUECACHE, $RECREATE_CACHE, $SAVE_TMPFILES,$RANDOM_TMP_DIR, @@ -557,6 +571,7 @@ GetOptions( 'organism=s' => \$ORGANISM, 'gfffile=s' => \$GFFFILE, + 'fastafile=s'=> \$FASTAFILE, 'dbprofile=s'=> \$DBPROFILE, 'dbname=s' => \$DBNAME, 'dbuser=s' => \$DBUSER, @@ -660,6 +675,7 @@ my %argv; $argv{organism} = $ORGANISM; $argv{gfffile} = $GFFFILE; + $argv{fastafile} = $FASTAFILE; $argv{dbprofile} = $DBPROFILE; $argv{dbname} = $DBNAME; $argv{dbuser} = $DBUSER; @@ -730,11 +746,11 @@ $chado->file_handles(); my $gffio; -if ($GFFFILE eq 'stdin') { +if ($GFFFILE eq 'stdin' and !$FASTAFILE) { $gffio = Bio::FeatureIO->new(-fh => \*STDIN , -format => 'gff', -validate_terms => $VALIDATE); -} else { +} elsif ($GFFFILE and $GFFFILE ne 'stdin') { $gffio = Bio::FeatureIO->new(-file => $GFFFILE, -format => 'gff', -validate_terms => $VALIDATE); @@ -755,7 +771,7 @@ $chado->organism_id($ORGANISM) or die "$ORGANISM organism not found in the database"; } -elsif ($gffio->organism) { +elsif (defined $gffio && $gffio->organism) { $ORGANISM = $gffio->organism; $chado->organism($ORGANISM); $chado->organism_id($ORGANISM) @@ -786,7 +802,8 @@ my $feature_iterator; my $itern=0; my %seen_organism; FEATURE: while(my $feature = - (defined $feature_iterator && $feature_iterator->next_feature) || $gffio->next_feature){ + (defined $feature_iterator && $feature_iterator->next_feature) + || (defined $gffio && $gffio->next_feature)){ $chado->primary_dbxref(''); my $featuretype = $feature->type->name; @@ -1052,7 +1069,7 @@ #$validate_uniquename->finish; #deal with sequence -unless ($NOSEQUENCE) { +unless ($NOSEQUENCE or !defined $gffio) { #ugh--reversed unless logic while (my $seq = $gffio->next_seq) { my $string = $seq->seq(); my $name = $seq->display_id(); @@ -1060,6 +1077,15 @@ } } +if ($FASTAFILE) { + #use SeqIO to parse the fasta file + my $in = Bio::SeqIO->new(-file => $FASTAFILE, + -format => 'fasta'); + while (my $seq = $in->next_seq) { + $chado->print_fasta($seq->display_id,$seq->seq); + } +} + $chado->flush_caches(); $chado->load_data() unless $NOLOAD; Modified: schema/trunk/chado/modules/companalysis/companalysis.sql =================================================================== --- schema/trunk/chado/modules/companalysis/companalysis.sql 2009-12-16 15:38:43 UTC (rev 22421) +++ schema/trunk/chado/modules/companalysis/companalysis.sql 2009-12-16 17:15:06 UTC (rev 22422) @@ -92,3 +92,13 @@ following semantics: * normscores are floating point numbers >= 0, * high normscores are better than low one. For most programs, it would be sufficient to make the normscore the same as this rawscore, providing these semantics are satisfied.'; COMMENT ON COLUMN analysisfeature.rawscore IS 'This is the native score generated by the program; for example, the bitscore generated by blast, sim4 or genscan scores. One should not assume that high is necessarily better than low.'; + + +CREATE TABLE analysisfeatureprop ( + analysisfeatureprop_id SERIAL PRIMARY KEY, + analysisfeature_id INTEGER NOT NULL REFERENCES analysisfeature(analysisfeature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, + type_id INTEGER NOT NULL REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, + value TEXT, + rank INTEGER NOT NULL, + CONSTRAINT analysisfeature_id_type_id_rank UNIQUE(analysisfeature_id, type_id, rank) +); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sco...@us...> - 2009-12-29 04:53:42
|
Revision: 22474 http://gmod.svn.sourceforge.net/gmod/?rev=22474&view=rev Author: scottcain Date: 2009-12-29 04:53:27 +0000 (Tue, 29 Dec 2009) Log Message: ----------- updating default schema and generated files Modified Paths: -------------- schema/trunk/chado/INSTALL.Custom schema/trunk/chado/bin/AutoDBI.PL schema/trunk/chado/doc/diagrams/companalysis.diagram.png schema/trunk/chado/doc/diagrams/companalysis.graphviz.png schema/trunk/chado/doc/diagrams/companalysis.graphviz.svg schema/trunk/chado/doc/diagrams/contact.diagram.png schema/trunk/chado/doc/diagrams/cv.diagram.png schema/trunk/chado/doc/diagrams/cv.graphviz.png schema/trunk/chado/doc/diagrams/cv.graphviz.svg schema/trunk/chado/doc/diagrams/expression.diagram.png schema/trunk/chado/doc/diagrams/expression.graphviz.png schema/trunk/chado/doc/diagrams/expression.graphviz.svg schema/trunk/chado/doc/diagrams/general.diagram.png schema/trunk/chado/doc/diagrams/general.graphviz.png schema/trunk/chado/doc/diagrams/general.graphviz.svg schema/trunk/chado/doc/diagrams/genetic.diagram.png schema/trunk/chado/doc/diagrams/genetic.graphviz.png schema/trunk/chado/doc/diagrams/genetic.graphviz.svg schema/trunk/chado/doc/diagrams/library.diagram.png schema/trunk/chado/doc/diagrams/mage.diagram.png schema/trunk/chado/doc/diagrams/map.diagram.png schema/trunk/chado/doc/diagrams/map.graphviz.png schema/trunk/chado/doc/diagrams/map.graphviz.svg schema/trunk/chado/doc/diagrams/nofuncs.diagram.png schema/trunk/chado/doc/diagrams/organism.diagram.png schema/trunk/chado/doc/diagrams/organism.graphviz.png schema/trunk/chado/doc/diagrams/organism.graphviz.svg schema/trunk/chado/doc/diagrams/phenotype.diagram.png schema/trunk/chado/doc/diagrams/phylogeny.diagram.png schema/trunk/chado/doc/diagrams/pub.diagram.png schema/trunk/chado/doc/diagrams/pub.graphviz.png schema/trunk/chado/doc/diagrams/pub.graphviz.svg schema/trunk/chado/doc/diagrams/sequence.diagram.png schema/trunk/chado/doc/diagrams/sequence.graphviz.png schema/trunk/chado/doc/diagrams/sequence.graphviz.svg schema/trunk/chado/doc/diagrams/stock.diagram.png schema/trunk/chado/doc/diagrams/www.graphviz.png schema/trunk/chado/doc/diagrams/www.graphviz.svg schema/trunk/chado/modules/audit/audit_tables.sql schema/trunk/chado/modules/companalysis/companalysis.html schema/trunk/chado/modules/default_nofuncs.sql schema/trunk/chado/modules/default_schema.sql schema/trunk/chado/modules/nofuncs.html schema/trunk/chado/modules/www/www.html schema/trunk/chado/modules/www/www.sql Modified: schema/trunk/chado/INSTALL.Custom =================================================================== --- schema/trunk/chado/INSTALL.Custom 2009-12-28 21:35:16 UTC (rev 22473) +++ schema/trunk/chado/INSTALL.Custom 2009-12-29 04:53:27 UTC (rev 22474) @@ -74,9 +74,9 @@ 9. edit bin/AutoDBI.PL Delete everything in the non-substituting HEREDOC, insert the -corresponding section from the corresponding blib/lib/Chado/AutoDBI.pm +corresponding section from the corresponding blib/lib/Bio/Chado/AutoDBI.pm -10. Regenerate modules/sequence/bridges/sofa-bridge.sql. This doesn't need +10. Regenerate modules/sequence/bridges/so-bridge.sql. This doesn't need to be done all the time, but should be done before a release. Note that the create-so-layer.pl script has addtional options for making materialized views for doing fast feature type-related queries (which haven't been tested; Modified: schema/trunk/chado/bin/AutoDBI.PL =================================================================== --- schema/trunk/chado/bin/AutoDBI.PL 2009-12-28 21:35:16 UTC (rev 22473) +++ schema/trunk/chado/bin/AutoDBI.PL 2009-12-29 04:53:27 UTC (rev 22474) @@ -502,23 +502,23 @@ # -sub feature_cvterm_pub_feature_cvterms { return shift->feature_cvterm_pub_feature_cvterm_id } +sub feature_cvterm_dbxref_feature_cvterms { return shift->feature_cvterm_dbxref_feature_cvterm_id } -sub feature_cvterm_dbxref_feature_cvterms { return shift->feature_cvterm_dbxref_feature_cvterm_id } +sub feature_cvterm_pub_feature_cvterms { return shift->feature_cvterm_pub_feature_cvterm_id } # one to many to one # one2one # -sub pubs { my $self = shift; return map $_->pub_id, $self->feature_cvterm_pub_feature_cvterm_id } +sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->feature_cvterm_dbxref_feature_cvterm_id } -sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->feature_cvterm_dbxref_feature_cvterm_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->feature_cvterm_pub_feature_cvterm_id } # one to many to many @@ -1613,12 +1613,16 @@ # + +sub stock_genotype_genotypes { return shift->stock_genotype_genotype_id } + + + sub phenotype_comparison_genotype1s { return shift->phenotype_comparison_genotype1_id } sub phenotype_comparison_genotype2s { return shift->phenotype_comparison_genotype2_id } - @@ -1644,14 +1648,10 @@ sub phenotype_comparison_genotype2s { return shift->phenotype_comparison_genotype2_id } + - -sub stock_genotype_genotypes { return shift->stock_genotype_genotype_id } - - - sub phenstatement_genotypes { return shift->phenstatement_genotype_id } @@ -1673,16 +1673,16 @@ # one to many to one +# one2one # +sub stocks { my $self = shift; return map $_->stock_id, $self->stock_genotype_genotype_id } + -# one2one # -sub stocks { my $self = shift; return map $_->stock_id, $self->stock_genotype_genotype_id } - -sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_genotype_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->phenstatement_genotype_id } @@ -1690,11 +1690,11 @@ -sub cvterms { my $self = shift; return map $_->type_id, $self->phenstatement_genotype_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->phenstatement_genotype_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->phenstatement_genotype_id } +sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_genotype_id } # one to many to many @@ -1711,7 +1711,6 @@ - # many2one # @@ -1722,6 +1721,7 @@ + @@ -1740,49 +1740,52 @@ + + # many2many # -sub phenotype_comparison_genotype1_phenotype1s { my $self = shift; return map $_->phenotype_comparison_phenotype1s, $self->phenotype_comparison_genotype1s } +sub phenotype_comparison_genotype1_environment1s { my $self = shift; return map $_->phenotype_comparison_environment1s, $self->phenotype_comparison_genotype1s } -sub phenotype_comparison_genotype1_phenotype2s { my $self = shift; return map $_->phenotype_comparison_phenotype2s, $self->phenotype_comparison_genotype1s } +sub phenotype_comparison_genotype1_environment2s { my $self = shift; return map $_->phenotype_comparison_environment2s, $self->phenotype_comparison_genotype1s } -sub phenotype_comparison_genotype2_phenotype1s { my $self = shift; return map $_->phenotype_comparison_phenotype1s, $self->phenotype_comparison_genotype2s } +sub phenotype_comparison_genotype2_environment1s { my $self = shift; return map $_->phenotype_comparison_environment1s, $self->phenotype_comparison_genotype2s } -sub phenotype_comparison_genotype2_phenotype2s { my $self = shift; return map $_->phenotype_comparison_phenotype2s, $self->phenotype_comparison_genotype2s } +sub phenotype_comparison_genotype2_environment2s { my $self = shift; return map $_->phenotype_comparison_environment2s, $self->phenotype_comparison_genotype2s } + -sub phenotype_comparison_genotype1_environment1s { my $self = shift; return map $_->phenotype_comparison_environment1s, $self->phenotype_comparison_genotype1s } +sub phenotype_comparison_genotype1_phenotype1s { my $self = shift; return map $_->phenotype_comparison_phenotype1s, $self->phenotype_comparison_genotype1s } -sub phenotype_comparison_genotype1_environment2s { my $self = shift; return map $_->phenotype_comparison_environment2s, $self->phenotype_comparison_genotype1s } +sub phenotype_comparison_genotype1_phenotype2s { my $self = shift; return map $_->phenotype_comparison_phenotype2s, $self->phenotype_comparison_genotype1s } -sub phenotype_comparison_genotype2_environment1s { my $self = shift; return map $_->phenotype_comparison_environment1s, $self->phenotype_comparison_genotype2s } +sub phenotype_comparison_genotype2_phenotype1s { my $self = shift; return map $_->phenotype_comparison_phenotype1s, $self->phenotype_comparison_genotype2s } -sub phenotype_comparison_genotype2_environment2s { my $self = shift; return map $_->phenotype_comparison_environment2s, $self->phenotype_comparison_genotype2s } +sub phenotype_comparison_genotype2_phenotype2s { my $self = shift; return map $_->phenotype_comparison_phenotype2s, $self->phenotype_comparison_genotype2s } @@ -1790,9 +1793,6 @@ - - - 1; @@ -2015,22 +2015,22 @@ -sub organism_dbxref_dbxrefs { return shift->organism_dbxref_dbxref_id } +sub feature_cvterm_dbxref_dbxrefs { return shift->feature_cvterm_dbxref_dbxref_id } -sub feature_cvterm_dbxref_dbxrefs { return shift->feature_cvterm_dbxref_dbxref_id } +sub organism_dbxref_dbxrefs { return shift->organism_dbxref_dbxref_id } -sub phylonode_dbxref_dbxrefs { return shift->phylonode_dbxref_dbxref_id } +sub biomaterial_dbxref_dbxrefs { return shift->biomaterial_dbxref_dbxref_id } -sub biomaterial_dbxref_dbxrefs { return shift->biomaterial_dbxref_dbxref_id } +sub phylonode_dbxref_dbxrefs { return shift->phylonode_dbxref_dbxref_id } # one to many to one @@ -2048,19 +2048,19 @@ -sub organisms { my $self = shift; return map $_->organism_id, $self->organism_dbxref_dbxref_id } +sub feature_cvterms { my $self = shift; return map $_->feature_cvterm_id, $self->feature_cvterm_dbxref_dbxref_id } -sub feature_cvterms { my $self = shift; return map $_->feature_cvterm_id, $self->feature_cvterm_dbxref_dbxref_id } +sub organisms { my $self = shift; return map $_->organism_id, $self->organism_dbxref_dbxref_id } -sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_dbxref_dbxref_id } +sub biomaterials { my $self = shift; return map $_->biomaterial_id, $self->biomaterial_dbxref_dbxref_id } -sub biomaterials { my $self = shift; return map $_->biomaterial_id, $self->biomaterial_dbxref_dbxref_id } +sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_dbxref_dbxref_id } # one to many to many @@ -2444,123 +2444,118 @@ -sub feature_pub_pubs { return shift->feature_pub_pub_id } +sub libraryprop_pub_pubs { return shift->libraryprop_pub_pub_id } -sub featureloc_pub_pubs { return shift->featureloc_pub_pub_id } +sub library_cvterm_pubs { return shift->library_cvterm_pub_id } -sub cell_line_library_pubs { return shift->cell_line_library_pub_id } +sub library_cvterm_pubs { return shift->library_cvterm_pub_id } - -sub cell_line_library_pubs { return shift->cell_line_library_pub_id } - - - -sub pub_relationship_subjects { return shift->pub_relationship_subject_id } +sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } - -sub pub_relationship_objects { return shift->pub_relationship_object_id } - -sub stock_cvterm_pubs { return shift->stock_cvterm_pub_id } + +sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } -sub stock_cvterm_pubs { return shift->stock_cvterm_pub_id } + +sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } -sub feature_relationship_pub_pubs { return shift->feature_relationship_pub_pub_id } + +sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } -sub cell_line_pub_pubs { return shift->cell_line_pub_pub_id } +sub featuremap_pub_pubs { return shift->featuremap_pub_pub_id } +sub pub_relationship_subjects { return shift->pub_relationship_subject_id } + -sub cell_lineprop_pub_pubs { return shift->cell_lineprop_pub_pub_id } +sub pub_relationship_objects { return shift->pub_relationship_object_id } + + - -sub cell_line_feature_pubs { return shift->cell_line_feature_pub_id } +sub phylotree_pub_pubs { return shift->phylotree_pub_pub_id } -sub cell_line_feature_pubs { return shift->cell_line_feature_pub_id } +sub stockprop_pub_pubs { return shift->stockprop_pub_pub_id } -sub phylonode_pub_pubs { return shift->phylonode_pub_pub_id } +sub cell_lineprop_pub_pubs { return shift->cell_lineprop_pub_pub_id } -sub phylotree_pub_pubs { return shift->phylotree_pub_pub_id } +sub cell_line_feature_pubs { return shift->cell_line_feature_pub_id } -sub featureprop_pub_pubs { return shift->featureprop_pub_pub_id } +sub cell_line_feature_pubs { return shift->cell_line_feature_pub_id } -sub stockprop_pub_pubs { return shift->stockprop_pub_pub_id } +sub feature_relationshipprop_pub_pubs { return shift->feature_relationshipprop_pub_pub_id } - -sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } +sub stock_cvterm_pubs { return shift->stock_cvterm_pub_id } - -sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } +sub stock_cvterm_pubs { return shift->stock_cvterm_pub_id } -sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } - - + +sub feature_cvterm_pub_pubs { return shift->feature_cvterm_pub_pub_id } + - -sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } +sub stock_pub_pubs { return shift->stock_pub_pub_id } -sub feature_cvterm_pub_pubs { return shift->feature_cvterm_pub_pub_id } +sub feature_relationship_pub_pubs { return shift->feature_relationship_pub_pub_id } -sub feature_relationshipprop_pub_pubs { return shift->feature_relationshipprop_pub_pub_id } +sub featureprop_pub_pubs { return shift->featureprop_pub_pub_id } -sub library_pub_pubs { return shift->library_pub_pub_id } +sub phylonode_pub_pubs { return shift->phylonode_pub_pub_id } @@ -2570,17 +2565,17 @@ -sub expression_pub_pubs { return shift->expression_pub_pub_id } +sub library_pub_pubs { return shift->library_pub_pub_id } -sub feature_expression_pubs { return shift->feature_expression_pub_id } +sub feature_pub_pubs { return shift->feature_pub_pub_id } -sub feature_expression_pubs { return shift->feature_expression_pub_id } +sub featureloc_pub_pubs { return shift->featureloc_pub_pub_id } @@ -2605,66 +2600,74 @@ -sub library_cvterm_pubs { return shift->library_cvterm_pub_id } +sub cell_line_library_pubs { return shift->cell_line_library_pub_id } -sub library_cvterm_pubs { return shift->library_cvterm_pub_id } +sub cell_line_library_pubs { return shift->cell_line_library_pub_id } -sub libraryprop_pub_pubs { return shift->libraryprop_pub_pub_id } +sub cell_line_pub_pubs { return shift->cell_line_pub_pub_id } -sub featuremap_pub_pubs { return shift->featuremap_pub_pub_id } +sub feature_expression_pubs { return shift->feature_expression_pub_id } -sub stock_pub_pubs { return shift->stock_pub_pub_id } +sub feature_expression_pubs { return shift->feature_expression_pub_id } + + + +sub expression_pub_pubs { return shift->expression_pub_pub_id } + # one to many to one # one2one # -sub features { my $self = shift; return map $_->feature_id, $self->feature_pub_pub_id } +sub libraryprops { my $self = shift; return map $_->libraryprop_id, $self->libraryprop_pub_pub_id } -sub featurelocs { my $self = shift; return map $_->featureloc_id, $self->featureloc_pub_pub_id } +sub cvterms { my $self = shift; return map $_->cvterm_id, $self->library_cvterm_pub_id } -sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_library_pub_id } +sub librarys { my $self = shift; return map $_->library_id, $self->library_cvterm_pub_id } -sub librarys { my $self = shift; return map $_->library_id, $self->cell_line_library_pub_id } +sub organisms { my $self = shift; return map $_->organism_id, $self->phenotype_comparison_pub_id } + + -sub cvterms { my $self = shift; return map $_->cvterm_id, $self->stock_cvterm_pub_id } +sub featuremaps { my $self = shift; return map $_->featuremap_id, $self->featuremap_pub_pub_id } + -sub stocks { my $self = shift; return map $_->stock_id, $self->stock_cvterm_pub_id } +sub phylotrees { my $self = shift; return map $_->phylotree_id, $self->phylotree_pub_pub_id } -sub feature_relationships { my $self = shift; return map $_->feature_relationship_id, $self->feature_relationship_pub_pub_id } +sub stockprops { my $self = shift; return map $_->stockprop_id, $self->stockprop_pub_pub_id } -sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_pub_pub_id } +sub cell_lineprops { my $self = shift; return map $_->cell_lineprop_id, $self->cell_lineprop_pub_pub_id } -sub cell_lineprops { my $self = shift; return map $_->cell_lineprop_id, $self->cell_lineprop_pub_pub_id } +sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_feature_pub_id } @@ -2672,62 +2675,59 @@ -sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_feature_pub_id } +sub feature_relationshipprops { my $self = shift; return map $_->feature_relationshipprop_id, $self->feature_relationshipprop_pub_pub_id } -sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_pub_pub_id } +sub cvterms { my $self = shift; return map $_->cvterm_id, $self->stock_cvterm_pub_id } -sub phylotrees { my $self = shift; return map $_->phylotree_id, $self->phylotree_pub_pub_id } +sub stocks { my $self = shift; return map $_->stock_id, $self->stock_cvterm_pub_id } -sub featureprops { my $self = shift; return map $_->featureprop_id, $self->featureprop_pub_pub_id } +sub feature_cvterms { my $self = shift; return map $_->feature_cvterm_id, $self->feature_cvterm_pub_pub_id } -sub stockprops { my $self = shift; return map $_->stockprop_id, $self->stockprop_pub_pub_id } +sub stocks { my $self = shift; return map $_->stock_id, $self->stock_pub_pub_id } - - -sub organisms { my $self = shift; return map $_->organism_id, $self->phenotype_comparison_pub_id } +sub feature_relationships { my $self = shift; return map $_->feature_relationship_id, $self->feature_relationship_pub_pub_id } - -sub feature_cvterms { my $self = shift; return map $_->feature_cvterm_id, $self->feature_cvterm_pub_pub_id } +sub featureprops { my $self = shift; return map $_->featureprop_id, $self->featureprop_pub_pub_id } -sub feature_relationshipprops { my $self = shift; return map $_->feature_relationshipprop_id, $self->feature_relationshipprop_pub_pub_id } +sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_pub_pub_id } -sub librarys { my $self = shift; return map $_->library_id, $self->library_pub_pub_id } +sub stock_relationships { my $self = shift; return map $_->stock_relationship_id, $self->stock_relationship_pub_pub_id } -sub stock_relationships { my $self = shift; return map $_->stock_relationship_id, $self->stock_relationship_pub_pub_id } +sub librarys { my $self = shift; return map $_->library_id, $self->library_pub_pub_id } -sub expressions { my $self = shift; return map $_->expression_id, $self->expression_pub_pub_id } +sub features { my $self = shift; return map $_->feature_id, $self->feature_pub_pub_id } -sub features { my $self = shift; return map $_->feature_id, $self->feature_expression_pub_id } +sub featurelocs { my $self = shift; return map $_->featureloc_id, $self->featureloc_pub_pub_id } -sub expressions { my $self = shift; return map $_->expression_id, $self->feature_expression_pub_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->phenstatement_pub_id } -sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_pub_id } +sub genotypes { my $self = shift; return map $_->genotype_id, $self->phenstatement_pub_id } @@ -2735,31 +2735,31 @@ -sub cvterms { my $self = shift; return map $_->type_id, $self->phenstatement_pub_id } +sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_pub_id } -sub genotypes { my $self = shift; return map $_->genotype_id, $self->phenstatement_pub_id } +sub librarys { my $self = shift; return map $_->library_id, $self->cell_line_library_pub_id } -sub cvterms { my $self = shift; return map $_->cvterm_id, $self->library_cvterm_pub_id } +sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_library_pub_id } -sub librarys { my $self = shift; return map $_->library_id, $self->library_cvterm_pub_id } +sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_pub_pub_id } -sub libraryprops { my $self = shift; return map $_->libraryprop_id, $self->libraryprop_pub_pub_id } +sub expressions { my $self = shift; return map $_->expression_id, $self->feature_expression_pub_id } -sub featuremaps { my $self = shift; return map $_->featuremap_id, $self->featuremap_pub_pub_id } +sub features { my $self = shift; return map $_->feature_id, $self->feature_expression_pub_id } -sub stocks { my $self = shift; return map $_->stock_id, $self->stock_pub_pub_id } +sub expressions { my $self = shift; return map $_->expression_id, $self->expression_pub_pub_id } # one to many to many @@ -2768,48 +2768,46 @@ +# one2many # + +sub phenotype_comparison_genotype1s { my $self = shift; return map $_->genotype1_id, $self->phenotype_comparison_pub_id } + + + + +sub phenotype_comparison_environment1s { my $self = shift; return map $_->environment1_id, $self->phenotype_comparison_pub_id } + + + -# one2many # - - sub phenotype_comparison_phenotype1s { my $self = shift; return map $_->phenotype1_id, $self->phenotype_comparison_pub_id } - - -sub phenotype_comparison_environment1s { my $self = shift; return map $_->environment1_id, $self->phenotype_comparison_pub_id } - - - - -sub phenotype_comparison_genotype1s { my $self = shift; return map $_->genotype1_id, $self->phenotype_comparison_pub_id } - - @@ -2826,6 +2824,8 @@ + + #many to many to one @@ -2833,6 +2833,10 @@ + + + + # many2one # @@ -2869,10 +2873,6 @@ - - - - #many to many to many @@ -3169,12 +3169,18 @@ Bio::Chado::CDBI::Analysisfeature->has_a(analysis_id => 'Bio::Chado::CDBI::Analysis'); sub Bio::Chado::CDBI::Analysisfeature::analysis { return shift->analysis_id } - + + # # Has Many # + +Bio::Chado::CDBI::Analysisfeature->has_many('analysisfeatureprop_analysisfeature_id', 'Bio::Chado::CDBI::Analysisfeatureprop' => 'analysisfeature_id'); + +sub analysisfeatureprops { return shift->analysisfeatureprop_analysisfeature_id } + # one to many to one @@ -3813,27 +3819,37 @@ # -sub feature_pub_features { return shift->feature_pub_feature_id } +sub element_features { return shift->element_feature_id } -sub feature_phenotype_features { return shift->feature_phenotype_feature_id } +sub element_features { return shift->element_feature_id } -sub studyprop_feature_features { return shift->studyprop_feature_feature_id } +sub element_features { return shift->element_feature_id } +sub feature_phenotype_features { return shift->feature_phenotype_feature_id } + + + + sub studyprop_feature_features { return shift->studyprop_feature_feature_id } +sub studyprop_feature_features { return shift->studyprop_feature_feature_id } + + + + sub library_feature_features { return shift->library_feature_feature_id } @@ -3848,21 +3864,11 @@ -sub element_features { return shift->element_feature_id } +sub feature_pub_features { return shift->feature_pub_feature_id } -sub element_features { return shift->element_feature_id } - - - - -sub element_features { return shift->element_feature_id } - - - - sub feature_expression_features { return shift->feature_expression_feature_id } @@ -3875,43 +3881,43 @@ # one2one # -sub pubs { my $self = shift; return map $_->pub_id, $self->feature_pub_feature_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->element_feature_id } -sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->feature_phenotype_feature_id } +sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->element_feature_id } -sub cvterms { my $self = shift; return map $_->type_id, $self->studyprop_feature_feature_id } +sub arraydesigns { my $self = shift; return map $_->arraydesign_id, $self->element_feature_id } -sub studyprops { my $self = shift; return map $_->studyprop_id, $self->studyprop_feature_feature_id } +sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->feature_phenotype_feature_id } -sub librarys { my $self = shift; return map $_->library_id, $self->library_feature_feature_id } +sub studyprops { my $self = shift; return map $_->studyprop_id, $self->studyprop_feature_feature_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_feature_feature_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->studyprop_feature_feature_id } -sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_feature_feature_id } +sub librarys { my $self = shift; return map $_->library_id, $self->library_feature_feature_id } -sub cvterms { my $self = shift; return map $_->type_id, $self->element_feature_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_feature_feature_id } -sub arraydesigns { my $self = shift; return map $_->arraydesign_id, $self->element_feature_id } +sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_feature_feature_id } -sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->element_feature_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->feature_pub_feature_id } @@ -4262,17 +4268,15 @@ # -sub cell_line_library_cell_lines { return shift->cell_line_library_cell_line_id } +sub cell_line_relationship_subjects { return shift->cell_line_relationship_subject_id } - - -sub cell_line_library_cell_lines { return shift->cell_line_library_cell_line_id } +sub cell_line_relationship_objects { return shift->cell_line_relationship_object_id } -sub cell_line_pub_cell_lines { return shift->cell_line_pub_cell_line_id } +sub cell_line_feature_cell_lines { return shift->cell_line_feature_cell_line_id } @@ -4282,40 +4286,42 @@ -sub cell_line_feature_cell_lines { return shift->cell_line_feature_cell_line_id } +sub cell_line_library_cell_lines { return shift->cell_line_library_cell_line_id } -sub cell_line_relationship_subjects { return shift->cell_line_relationship_subject_id } +sub cell_line_library_cell_lines { return shift->cell_line_library_cell_line_id } + + -sub cell_line_relationship_objects { return shift->cell_line_relationship_object_id } +sub cell_line_pub_cell_lines { return shift->cell_line_pub_cell_line_id } # one to many to one + # one2one # -sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_library_cell_line_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_feature_cell_line_id } -sub librarys { my $self = shift; return map $_->library_id, $self->cell_line_library_cell_line_id } +sub features { my $self = shift; return map $_->feature_id, $self->cell_line_feature_cell_line_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_pub_cell_line_id } +sub librarys { my $self = shift; return map $_->library_id, $self->cell_line_library_cell_line_id } -sub features { my $self = shift; return map $_->feature_id, $self->cell_line_feature_cell_line_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_library_cell_line_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_feature_cell_line_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_pub_cell_line_id } - # one to many to many @@ -4327,11 +4333,6 @@ #many to many to one - - - - - # many2one # @@ -4341,6 +4342,11 @@ sub cell_line_relationship_object_types { my $self = shift; return map $_->type_id, $self->cell_line_relationship_object_id } + + + + + #many to many to many @@ -4769,7 +4775,7 @@ # -sub stock_cvterm_stocks { return shift->stock_cvterm_stock_id } +sub stock_genotype_stocks { return shift->stock_genotype_stock_id } @@ -4779,7 +4785,7 @@ -sub stock_genotype_stocks { return shift->stock_genotype_stock_id } +sub stock_cvterm_stocks { return shift->stock_cvterm_stock_id } @@ -4796,15 +4802,15 @@ # one2one # -sub cvterms { my $self = shift; return map $_->cvterm_id, $self->stock_cvterm_stock_id } +sub genotypes { my $self = shift; return map $_->genotype_id, $self->stock_genotype_stock_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->stock_cvterm_stock_id } +sub cvterms { my $self = shift; return map $_->cvterm_id, $self->stock_cvterm_stock_id } -sub genotypes { my $self = shift; return map $_->genotype_id, $self->stock_genotype_stock_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->stock_cvterm_stock_id } @@ -5042,6 +5048,57 @@ 1; +########Bio::Chado::CDBI::Analysisfeatureprop######## + +package Bio::Chado::CDBI::Analysisfeatureprop; +use base 'Bio::Chado::DBI'; +use Class::DBI::Pager; +no warnings qw(redefine); + +Bio::Chado::CDBI::Analysisfeatureprop->set_up_table('analysisfeatureprop'); + +# +# Primary key accessors +# + +sub id { shift->analysisfeatureprop_id } +sub analysisfeatureprop { shift->analysisfeatureprop_id } + + + + +# +# Has A +# + +Bio::Chado::CDBI::Analysisfeatureprop->has_a(analysisfeature_id => 'Bio::Chado::CDBI::Analysisfeature'); + +sub Bio::Chado::CDBI::Analysisfeatureprop::analysisfeature { return shift->analysisfeature_id } + + +Bio::Chado::CDBI::Analysisfeatureprop->has_a(type_id => 'Bio::Chado::CDBI::Cvterm'); + +sub Bio::Chado::CDBI::Analysisfeatureprop::cvterm { return shift->type_id } + + +# +# Has Many +# + + + +# one to many to one + +# one to many to many + +#many to many to one + +#many to many to many + + + +1; + ########Bio::Chado::CDBI::Project######## package Bio::Chado::CDBI::Project; @@ -5637,24 +5694,24 @@ # +sub biomaterial_dbxref_biomaterials { return shift->biomaterial_dbxref_biomaterial_id } + + + + sub biomaterial_relationship_subjects { return shift->biomaterial_relationship_subject_id } sub biomaterial_relationship_objects { return shift->biomaterial_relationship_object_id } - - -sub biomaterial_dbxref_biomaterials { return shift->biomaterial_dbxref_biomaterial_id } - - # one to many to one - # one2one # sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->biomaterial_dbxref_biomaterial_id } + # one to many to many @@ -5662,6 +5719,7 @@ #many to many to one + # many2one # @@ -5671,7 +5729,6 @@ sub biomaterial_relationship_object_types { my $self = shift; return map $_->type_id, $self->biomaterial_relationship_object_id } - #many to many to many @@ -7553,13 +7610,9 @@ # -sub organism_dbxref_organisms { return shift->organism_dbxref_organism_id } - - - -sub phylonode_organism_organisms { return shift->phylonode_organism_organism_id } +sub phenotype_comparison_organisms { return shift->phenotype_comparison_organism_id } @@ -7570,7 +7623,6 @@ - sub phenotype_comparison_organisms { return shift->phenotype_comparison_organism_id } @@ -7581,37 +7633,40 @@ +sub organism_dbxref_organisms { return shift->organism_dbxref_organism_id } + + + -sub phenotype_comparison_organisms { return shift->phenotype_comparison_organism_id } + +sub phylonode_organism_organisms { return shift->phylonode_organism_organism_id } # one to many to one + + # one2one # -sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->organism_dbxref_organism_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->phenotype_comparison_organism_id } + -sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_organism_organism_id } +sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->organism_dbxref_organism_id } - - - -sub pubs { my $self = shift; return map $_->pub_id, $self->phenotype_comparison_organism_id } +sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_organism_organism_id } # one to many to many - - # one2many # -sub phenotype_comparison_phenotype1s { my $self = shift; return map $_->phenotype1_id, $self->phenotype_comparison_organism_id } +sub phenotype_comparison_genotype1s { my $self = shift; return map $_->genotype1_id, $self->phenotype_comparison_organism_id } @@ -7626,16 +7681,18 @@ + -sub phenotype_comparison_genotype1s { my $self = shift; return map $_->genotype1_id, $self->phenotype_comparison_organism_id } +sub phenotype_comparison_phenotype1s { my $self = shift; return map $_->phenotype1_id, $self->phenotype_comparison_organism_id } + #many to many to one @@ -8152,12 +8209,12 @@ -sub phylonode_organism_phylonodes { return shift->phylonode_organism_phylonode_id } +sub phylonode_dbxref_phylonodes { return shift->phylonode_dbxref_phylonode_id } -sub phylonode_dbxref_phylonodes { return shift->phylonode_dbxref_phylonode_id } +sub phylonode_organism_phylonodes { return shift->phylonode_organism_phylonode_id } # one to many to one @@ -8168,11 +8225,11 @@ -sub organisms { my $self = shift; return map $_->organism_id, $self->phylonode_organism_phylonode_id } +sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->phylonode_dbxref_phylonode_id } -sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->phylonode_dbxref_phylonode_id } +sub organisms { my $self = shift; return map $_->organism_id, $self->phylonode_organism_phylonode_id } # one to many to many @@ -8572,7 +8629,7 @@ # -sub expression_pub_expressions { return shift->expression_pub_expression_id } +sub feature_expression_expressions { return shift->feature_expression_expression_id } @@ -8582,7 +8639,7 @@ -sub feature_expression_expressions { return shift->feature_expression_expression_id } +sub expression_pub_expressions { return shift->expression_pub_expression_id } @@ -8594,7 +8651,7 @@ # one2one # -sub pubs { my $self = shift; return map $_->pub_id, $self->expression_pub_expression_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->feature_expression_expression_id } @@ -8602,7 +8659,7 @@ -sub pubs { my $self = shift; return map $_->pub_id, $self->feature_expression_expression_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->expression_pub_expression_id } @@ -9561,15 +9618,15 @@ # -sub cell_line_library_librarys { return shift->cell_line_library_library_id } +sub library_cvterm_librarys { return shift->library_cvterm_library_id } - -sub cell_line_library_librarys { return shift->cell_line_library_library_id } +sub library_cvterm_librarys { return shift->library_cvterm_library_id } + + - sub library_feature_librarys { return shift->library_feature_library_id } @@ -9581,23 +9638,23 @@ -sub library_cvterm_librarys { return shift->library_cvterm_library_id } +sub cell_line_library_librarys { return shift->cell_line_library_library_id } -sub library_cvterm_librarys { return shift->library_cvterm_library_id } - - + +sub cell_line_library_librarys { return shift->cell_line_library_library_id } + # one to many to one # one2one # -sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_library_library_id } +sub cvterms { my $self = shift; return map $_->cvterm_id, $self->library_cvterm_library_id } -sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_library_library_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->library_cvterm_library_id } @@ -9609,11 +9666,11 @@ -sub cvterms { my $self = shift; return map $_->cvterm_id, $self->library_cvterm_library_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_library_library_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->library_cvterm_library_id } +sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_library_library_id } # one to many to many @@ -10081,6 +10138,7 @@ + Bio::Chado::CDBI::Cvterm->has_a(cv_id => 'Bio::Chado::CDBI::Cv'); @@ -10249,6 +10307,11 @@ sub libraryprops { return shift->libraryprop_type_id } +Bio::Chado::CDBI::Cvterm->has_many('analysisfeatureprop_type_id', 'Bio::Chado::CDBI::Analysisfeatureprop' => 'type_id'); + + +sub analysisfeatureprops { return shift->analysisfeatureprop_type_id } + Bio::Chado::CDBI::Cvterm->has_many('featureprop_type_id', 'Bio::Chado::CDBI::Featureprop' => 'type_id'); @@ -10421,9 +10484,9 @@ Bio::Chado::CDBI::Cvterm->has_many('contact_type_id', 'Bio::Chado::CDBI::Contact' => 'type_id'); -sub contact_types { return shift->contact_type_id } -#sub --contact--type_id-- {} - + +sub contacts { return shift->contact_type_id } + Bio::Chado::CDBI::Cvterm->has_many('library_type_id', 'Bio::Chado::CDBI::Library' => 'type_id'); sub library_types { return shift->library_type_id } @@ -10485,30 +10548,27 @@ -sub quantification_relationship_types { return shift->quantification_relationship_type_id } - - +sub library_cvterm_cvterms { return shift->library_cvterm_cvterm_id } + - -sub biomaterial_relationship_types { return shift->biomaterial_relationship_type_id } +sub library_cvterm_cvterms { return shift->library_cvterm_cvterm_id } - -sub pub_relationship_types { return shift->pub_relationship_type_id } +sub element_types { return shift->element_type_id } -sub stock_cvterm_cvterms { return shift->stock_cvterm_cvterm_id } +sub element_types { return shift->element_type_id } -sub stock_cvterm_cvterms { return shift->stock_cvterm_cvterm_id } +sub element_types { return shift->element_type_id } @@ -10522,50 +10582,58 @@ -sub cvterm_relationship_types { return shift->cvterm_relationship_type_id } - -sub cvterm_relationship_subjects { return shift->cvterm_relationship_subject_id } - -sub cvterm_relationship_objects { return shift->cvterm_relationship_object_id } +sub pub_relationship_types { return shift->pub_relationship_type_id } -sub element_types { return shift->element_type_id } + +sub cell_line_relationship_types { return shift->cell_line_relationship_type_id } -sub element_types { return shift->element_type_id } +sub environment_cvterm_cvterms { return shift->environment_cvterm_cvterm_id } -sub element_types { return shift->element_type_id } +sub contact_relationship_types { return shift->contact_relationship_type_id } + +sub quantification_relationship_types { return shift->quantification_relationship_type_id } + + + -sub cell_line_relationship_types { return shift->cell_line_relationship_type_id } +sub stock_cvterm_cvterms { return shift->stock_cvterm_cvterm_id } + + - -sub environment_cvterm_cvterms { return shift->environment_cvterm_cvterm_id } +sub stock_cvterm_cvterms { return shift->stock_cvterm_cvterm_id } -sub contact_relationship_types { return shift->contact_relationship_type_id } + +sub biomaterial_relationship_types { return shift->biomaterial_relationship_type_id } - +sub cvterm_relationship_types { return shift->cvterm_relationship_type_id } + -sub phenstatement_types { return shift->phenstatement_type_id } +sub cvterm_relationship_subjects { return shift->cvterm_relationship_subject_id } + + +sub cvterm_relationship_objects { return shift->cvterm_relationship_object_id } @@ -10584,96 +10652,88 @@ -sub library_cvterm_cvterms { return shift->library_cvterm_cvterm_id } - - - - -sub library_cvterm_cvterms { return shift->library_cvterm_cvterm_id } +sub phenstatement_types { return shift->phenstatement_type_id } # one to many to one - - - # one2one # -sub pubs { my $self = shift; return map $_->pub_id, $self->stock_cvterm_cvterm_id } +sub librarys { my $self = shift; return map $_->library_id, $self->library_cvterm_cvterm_id } -sub stocks { my $self = shift; return map $_->stock_id, $self->stock_cvterm_cvterm_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->library_cvterm_cvterm_id } -sub features { my $self = shift; return map $_->feature_id, $self->studyprop_feature_type_id } +sub features { my $self = shift; return map $_->feature_id, $self->element_type_id } -sub studyprops { my $self = shift; return map $_->studyprop_id, $self->studyprop_feature_type_id } +sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->element_type_id } -sub features { my $self = shift; return map $_->feature_id, $self->element_type_id } +sub arraydesigns { my $self = shift; return map $_->arraydesign_id, $self->element_type_id } -sub arraydesigns { my $self = shift; return map $_->arraydesign_id, $self->element_type_id } +sub studyprops { my $self = shift; return map $_->studyprop_id, $self->studyprop_feature_type_id } -sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->element_type_id } +sub features { my $self = shift; return map $_->feature_id, $self->studyprop_feature_type_id } + sub environments { my $self = shift; return map $_->environment_id, $self->environment_cvterm_cvterm_id } + -sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_type_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->stock_cvterm_cvterm_id } -sub environments { my $self = shift; return map $_->environment_id, $self->phenstatement_type_id } +sub stocks { my $self = shift; return map $_->stock_id, $self->stock_cvterm_cvterm_id } + sub genotypes { my $self = shift; return map $_->genotype_id, $self->phenstatement_type_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->phenstatement_type_id } +sub environments { my $self = shift; return map $_->environment_id, $self->phenstatement_type_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->library_cvterm_cvterm_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->phenstatement_type_id } -sub librarys { my $self = shift; return map $_->library_id, $self->library_cvterm_cvterm_id } +sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_type_id } # one to many to many -# one2many # - -sub quantification_relationship_subjects { my $self = shift; return map $_->subject_id, $self->quantification_relationship_type_id } - - - +# one2many # + + -sub biomaterial_relationship_subjects { my $self = shift; return map $_->subject_id, $self->biomaterial_relationship_type_id } +sub pub_relationship_subjects { my $self = shift; return map $_->subject_id, $self->pub_relationship_type_id } @@ -10683,35 +10743,40 @@ -sub pub_relationship_subjects { my $self = shift; return map $_->subject_id, $self->pub_relationship_type_id } +sub cell_line_relationship_subjects { my $self = shift; return map $_->subject_id, $self->cell_line_relationship_type_id } + + +sub contact_relationship_subjects { my $self = shift; return map $_->subject_id, $self->contact_relationship_type_id } + + - -sub cell_line_relationship_subjects { my $self = shift; return map $_->subject_id, $self->cell_line_relationship_type_id } +sub quantification_relationship_subjects { my $self = shift; return map $_->subject_id, $self->quantification_relationship_type_id } + -sub contact_relationship_subjects { my $self = shift; return map $_->subject_id, $self->contact_relationship_type_id } +sub biomaterial_relationship_subjects { my $self = shift; return map $_->subject_id, $self->biomaterial_relationship_type_id } @@ -10719,8 +10784,6 @@ - - #many to many to one @@ -10886,46 +10949,41 @@ # -sub environment_cvterm_environments { return shift->environment_cvterm_environment_id } - - - - sub phenotype_comparison_environment1s { return shift->phenotype_comparison_environment1_id } sub phenotype_comparison_environment2s { return shift->phenotype_comparison_environment2_id } - + sub phenotype_comparison_environment1s { return shift->phenotype_comparison_environment1_id } + sub phenotype_comparison_environment2s { return shift->phenotype_comparison_environment2_id } - - + - sub phenotype_comparison_environment1s { return shift->phenotype_comparison_environment1_id } - sub phenotype_comparison_environment2s { return shift->phenotype_comparison_environment2_id } + + - sub phenotype_comparison_environment1s { return shift->phenotype_comparison_environment1_id } sub phenotype_comparison_environment2s { return shift->phenotype_comparison_environment2_id } + -sub phenstatement_environments { return shift->phenstatement_environment_id } +sub environment_cvterm_environments { return shift->environment_cvterm_environment_id } @@ -10943,20 +11001,21 @@ sub phenstatement_environments { return shift->phenstatement_environment_id } -# one to many to one -# one2one # -sub cvterms { my $self = shift; return map $_->cvterm_id, $self->environment_cvterm_environment_id } +sub phenstatement_environments { return shift->phenstatement_environment_id } + +# one to many to one + +# one2one # +sub cvterms { my $self = shift; return map $_->cvterm_id, $self->environment_cvterm_environment_id } -sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_environment_id } - sub cvterms { my $self = shift; return map $_->type_id, $self->phenstatement_environment_id } @@ -10969,6 +11028,10 @@ sub pubs { my $self = shift; return map $_->pub_id, $self->phenstatement_environment_id } + + +sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_environment_id } + # one to many to many @@ -10983,8 +11046,6 @@ #many to many to one - - # many2one # @@ -11009,6 +11070,8 @@ + + #many to many to many @@ -11019,20 +11082,20 @@ -sub phenotype_comparison_environment1_phenotype1s { my $self = shift; return map $_->phenotype_comparison_phenotype1s, $self->phenotype_comparison_environment1s } +sub phenotype_comparison_environment1_genotype1s { my $self = shift; return map $_->phenotype_comparison_genotype1s, $self->phenotype_comparison_environment1s } -sub phenotype_comparison_environment1_phenotype2s { my $self = shift; return map $_->phenotype_comparison_phenotype2s, $self->phenotype_comparison_environment1s } +sub phenotype_comparison_environment1_genotype2s { my $self = shift; return map $_->phenotype_comparison_genotype2s, $self->phenotype_comparison_environment1s } -sub phenotype_comparison_environment2_phenotype1s { my $self = shift; return map $_->phenotype_comparison_phenotype1s, $self->phenotype_comparison_environment2s } +sub phenotype_comparison_environment2_genotype1s { my $self = shift; return map $_->phenotype_comparison_genotype1s, $self->phenotype_comparison_environment2s } -sub phenotype_comparison_environment2_phenotype2s { my $self = shift; return map $_->phenotype_comparison_phenotype2s, $self->phenotype_comparison_environment2s } +sub phenotype_comparison_environment2_genotype2s { my $self = shift; return map $_->phenotype_comparison_genotype2s, $self->phenotype_comparison_environment2s } @@ -11044,20 +11107,20 @@ -sub phenotype_comparison_environment1_genotype1s { my $self = shift; return map $_->phenotype_comparison_genotype1s, $self->phenotype_comparison_environment1s } +sub phenotype_comparison_environment1_phenotype1s { my $self = shift; return map $_->phenotype_comparison_phenotype1s, $self->phenotype_comparison_environment1s } -sub phenotype_comparison_environment1_genotype2s { my $self = shift; return map $_->phenotype_comparison_genotype2s, $self->phenotype_comparison_environment1s } +sub phenotype_comparison_environment1_phenotype2s { my $self = shift; return map $_->phenotype_comparison_phenotype2s, $self->phenotype_comparison_environment1s } -sub phenotype_comparison_environment2_genotype1s { my $self = shift; return map $_->phenotype_comparison_genotype1s, $self->phenotype_comparison_environment2s } +sub phenotype_comparison_environment2_phenotype1s { my $self = shift; return map $_->phenotype_comparison_phenotype1s, $self->phenotype_comparison_environment2s } -sub phenotype_comparison_environment2_genotype2s { my $self = shift; return map $_->phenotype_comparison_genotype2s, $self->phenotype_comparison_environment2s } +sub phenotype_comparison_environment2_phenotype2s { my $self = shift; return map $_->phenotype_comparison_phenotype2s, $self->phenotype_comparison_environment2s } @@ -11257,22 +11320,22 @@ - - sub phenotype_comparison_phenotype1s { return shift->phenotype_comparison_phenotype1_id } sub phenotype_comparison_phenotype2s { return shift->phenotype_comparison_phenotype2_id } + + - + + sub phenotype_comparison_phenotype1s { return shift->phenotype_comparison_phenotype1_id } sub phenotype_comparison_phenotype2s { return shift->phenotype_comparison_phenotype2_id } - - + @@ -11291,15 +11354,15 @@ - sub phenstatement_phenotypes { return shift->phenstatement_phenotype_id } + + - + sub phenstatement_phenotypes { return shift->phenstatement_phenotype_id } - - + sub phenstatement_phenotypes { return shift->phenstatement_phenotype_id } @@ -11321,15 +11384,15 @@ -sub environments { my $self = shift; return map $_->environment_id, $self->phenstatement_phenotype_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->phenstatement_phenotype_id } -sub cvterms { my $self = shift; return map $_->type_id, $self->phenstatement_phenotype_id } +sub genotypes { my $self = shift; return map $_->genotype_id, $self->phenstatement_phenotype_id } -sub genotypes { my $self = shift; return map $_->genotype_id, $self->phenstatement_phenotype_id } +sub environments { my $self = shift; return map $_->environment_id, $self->phenstatement_phenotype_id } @@ -11350,7 +11413,6 @@ - # many2one # @@ -11362,6 +11424,7 @@ + @@ -11380,50 +11443,50 @@ + # many2many # -sub phenotype_comparison_phenotype1_environment1s { my $self = shift; return map $_->phenotype_comparison_environment1s, $self->phenotype_comparison_phenotype1s } +sub phenotype_comparison_phenotype1_genotype1s { my $self = shift; return map $_->phenotype_comparison_genotype1s, $self->phenotype_comparison_phenotype1s } -sub phenotype_comparison_phenotype1_environment2s { my $self = shift; return map $_->phenotype_comparison_environment2s, $self->phenotype_comparison_phenotype1s } +sub phenotype_comparison_phenotype1_genotype2s { my $self = shift; return map $_->phenotype_comparison_genotype2s, $self->phenotype_comparison_phenotype1s } -sub phenotype_comparison_phenotype2_environment1s { my $self = shift; return map $_->phenotype_comparison_environment1s, $self->phenotype_comparison_phenotype2s } +sub phenotype_comparison_phenotype2_genotype1s { my $self = shift; return map $_->phenotype_comparison_genotype1s, $self->phenotype_comparison_phenotype2s } -sub phenotype_comparison_phenotype2_environment2s { my $self = shift; return map $_->phenotype_comparison_environment2s, $self->phenotype_comparison_phenotype2s } +sub phenotype_comparison_phenotype2_genotype2s { my $self = shift; return map $_->phenotype_comparison_genotype2s, $self->phenotype_comparison_phenotype2s } - -sub phenotype_comparison_phenotype1_genotype1s { my $self = shift; return map $_->phenotype_comparison_genotype1s, $self->phenotype_comparison_phenotype1s } +sub phenotype_comparison_phenotype1_environment1s { my $self = shift; return map $_->phenotype_comparison_environment1s, $self->phenotype_comparison_phenotype1s } -sub phenotype_comparison_phenotype1_genotype2s { my $self = shift; return map $_->phenotype_comparison_genotype2s, $self->phenotype_comparison_phenotype1s } +sub phenotype_comparison_phenotype1_environment2s { my $self = shift; return map $_->phenotype_comparison_environment2s, $self->phenotype_comparison_phenotype1s } -sub phenotype_comparison_phenotype2_genotype1s { my $self = shift; return map $_->phenotype_comparison_genotype1s, $self->phenotype_comparison_phenotype2s } +sub phenotype_comparison_phenotype2_environment1s { my $self = shift; return map $_->phenotype_comparison_environment1s, $self->phenotype_comparison_phenotype2s } -sub phenotype_comparison_phenotype2_genotype2s { my $self = shift; return map $_->phenotype_comparison_genotype2s, $self->phenotype_comparison_phenotype2s } +sub phenotype_comparison_phenotype2_environment2s { my $self = shift; return map $_->phenotype_comparison_environment2s, $self->phenotype_comparison_phenotype2s } Modified: schema/trunk/chado/doc/diagrams/companalysis.diagram.png =================================================================== --- schema/trunk/chado/doc/diagrams/companalysis.diagram.png 2009-12-28 21:35:16 UTC (rev 22473) +++ schema/trunk/chado/doc/diagrams/companalysis.diagram.png 2009-12-29 04:53:27 UTC (rev 22474) @@ -1,53 +1,66 @@ \x89PNG |
From: <sco...@us...> - 2010-04-07 15:37:09
|
Revision: 23012 http://gmod.svn.sourceforge.net/gmod/?rev=23012&view=rev Author: scottcain Date: 2010-04-07 15:36:57 +0000 (Wed, 07 Apr 2010) Log Message: ----------- adding LWP::Simple to prereqs Modified Paths: -------------- schema/trunk/chado/Changes schema/trunk/chado/Makefile.PL Modified: schema/trunk/chado/Changes =================================================================== --- schema/trunk/chado/Changes 2010-04-07 15:31:10 UTC (rev 23011) +++ schema/trunk/chado/Changes 2010-04-07 15:36:57 UTC (rev 23012) @@ -52,6 +52,7 @@ * Removed the cause of the error messages at the end of ontology loading: it was a patch to correct for bad behavior that DBIx::DBStag which was fixed some time ago. +* Added gmod_bulk_pub_loader.pl contributed by SGN. Below this line are changes up until a few years ago and are included Modified: schema/trunk/chado/Makefile.PL =================================================================== --- schema/trunk/chado/Makefile.PL 2010-04-07 15:31:10 UTC (rev 23011) +++ schema/trunk/chado/Makefile.PL 2010-04-07 15:36:57 UTC (rev 23012) @@ -518,6 +518,7 @@ 'GO::Parser' => 0, 'Module::Load' => 0.16, 'Bio::Root::Version'=> 1.0069, + 'LWP::Simple' => 0, }, 'PL_FILES' => { # 'load/bin/load_affymetrix.PLS' => 'load/bin/gmod_load_affymetrix.pl', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sco...@us...> - 2010-05-18 19:02:52
|
Revision: 23231 http://gmod.svn.sourceforge.net/gmod/?rev=23231&view=rev Author: scottcain Date: 2010-05-18 19:02:40 +0000 (Tue, 18 May 2010) Log Message: ----------- updating install stuff for the make_cvtermpath script Modified Paths: -------------- schema/trunk/chado/Changes schema/trunk/chado/MANIFEST schema/trunk/chado/Makefile.PL Modified: schema/trunk/chado/Changes =================================================================== --- schema/trunk/chado/Changes 2010-05-18 18:49:10 UTC (rev 23230) +++ schema/trunk/chado/Changes 2010-05-18 19:02:40 UTC (rev 23231) @@ -53,8 +53,8 @@ it was a patch to correct for bad behavior that DBIx::DBStag which was fixed some time ago. * Added gmod_bulk_pub_loader.pl contributed by SGN. +* Added gmod_make_cvtermpath.pl contributed by SGN. - Below this line are changes up until a few years ago and are included for historical purposes. --------------------------------------------------------------------------- Modified: schema/trunk/chado/MANIFEST =================================================================== --- schema/trunk/chado/MANIFEST 2010-05-18 18:49:10 UTC (rev 23230) +++ schema/trunk/chado/MANIFEST 2010-05-18 19:02:40 UTC (rev 23231) @@ -7,6 +7,7 @@ bin/create-so-bridge.pl bin/cxgn/gmod_bulk_load_pubmed.pl bin/cxgn/gmod_load_cvterms.pl +bin/cxgn/make_cvtermpath.pl bin/cxgn/load_ncbi_taxonomy.pl bin/cxgn/load_taxonomy_cvterms.pl bin/dbi.tt2 @@ -23,8 +24,6 @@ bin/gmod_materialized_view_tool.pl bin/gmod_sort_gff3.pl bin/interactions2SIF.pl -bin/make_cvtermpath.pl -bin/make_cvtermpath.sh bin/make_partial_indexes.pl bin/pg2cdbi.pl bin/pg2cdbi_viaTT.pl Modified: schema/trunk/chado/Makefile.PL =================================================================== --- schema/trunk/chado/Makefile.PL 2010-05-18 18:49:10 UTC (rev 23230) +++ schema/trunk/chado/Makefile.PL 2010-05-18 19:02:40 UTC (rev 23231) @@ -487,6 +487,7 @@ 'bin/gmod_make_gff_from_dbxref.pl', 'bin/cxgn/gmod_load_cvterms.pl', 'bin/cxgn/gmod_bulk_load_pubmed.pl', + 'bin/cxgn/gmod_make_cvtermpath.pl', # 'bin/gmod_bulkfiles.pl', # 'bin/gmod_gff2biomart5.pl', ); @@ -583,8 +584,8 @@ log4perl.conf :: \$(PERL) \"$working_dir/install_util/log4perl.conf.pl\" '$root' -cvtermpath :: - $working_dir/bin/make_cvtermpath.sh +#cvtermpath :: +# $working_dir/bin/make_cvtermpath.sh images :: graphviz graphviz_svg diagram This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sco...@us...> - 2010-05-20 20:09:57
|
Revision: 23245 http://gmod.svn.sourceforge.net/gmod/?rev=23245&view=rev Author: scottcain Date: 2010-05-20 20:09:42 +0000 (Thu, 20 May 2010) Log Message: ----------- updating diagrams Modified Paths: -------------- schema/trunk/chado/doc/diagrams/companalysis.diagram.png schema/trunk/chado/doc/diagrams/companalysis.graphviz.png schema/trunk/chado/doc/diagrams/companalysis.graphviz.svg schema/trunk/chado/doc/diagrams/contact.diagram.png schema/trunk/chado/doc/diagrams/cv.diagram.png schema/trunk/chado/doc/diagrams/cv.graphviz.png schema/trunk/chado/doc/diagrams/cv.graphviz.svg schema/trunk/chado/doc/diagrams/expression.diagram.png schema/trunk/chado/doc/diagrams/expression.graphviz.png schema/trunk/chado/doc/diagrams/expression.graphviz.svg schema/trunk/chado/doc/diagrams/general.diagram.png schema/trunk/chado/doc/diagrams/general.graphviz.png schema/trunk/chado/doc/diagrams/general.graphviz.svg schema/trunk/chado/doc/diagrams/genetic.diagram.png schema/trunk/chado/doc/diagrams/genetic.graphviz.png schema/trunk/chado/doc/diagrams/genetic.graphviz.svg schema/trunk/chado/doc/diagrams/library.diagram.png schema/trunk/chado/doc/diagrams/mage.diagram.png schema/trunk/chado/doc/diagrams/map.diagram.png schema/trunk/chado/doc/diagrams/map.graphviz.png schema/trunk/chado/doc/diagrams/map.graphviz.svg schema/trunk/chado/doc/diagrams/nofuncs.diagram.png schema/trunk/chado/doc/diagrams/organism.diagram.png schema/trunk/chado/doc/diagrams/organism.graphviz.png schema/trunk/chado/doc/diagrams/organism.graphviz.svg schema/trunk/chado/doc/diagrams/phenotype.diagram.png schema/trunk/chado/doc/diagrams/phylogeny.diagram.png schema/trunk/chado/doc/diagrams/pub.diagram.png schema/trunk/chado/doc/diagrams/pub.graphviz.png schema/trunk/chado/doc/diagrams/pub.graphviz.svg schema/trunk/chado/doc/diagrams/sequence.diagram.png schema/trunk/chado/doc/diagrams/sequence.graphviz.png schema/trunk/chado/doc/diagrams/sequence.graphviz.svg schema/trunk/chado/doc/diagrams/stock.diagram.png schema/trunk/chado/doc/diagrams/www.diagram.png schema/trunk/chado/doc/diagrams/www.graphviz.png schema/trunk/chado/doc/diagrams/www.graphviz.svg schema/trunk/chado/modules/nofuncs.html schema/trunk/chado/modules/phylogeny/phylogeny.html Modified: schema/trunk/chado/doc/diagrams/companalysis.diagram.png =================================================================== --- schema/trunk/chado/doc/diagrams/companalysis.diagram.png 2010-05-20 18:46:34 UTC (rev 23244) +++ schema/trunk/chado/doc/diagrams/companalysis.diagram.png 2010-05-20 20:09:42 UTC (rev 23245) @@ -10,36 +10,42 @@ \x9A@\x9FW\xAD\xE9iG)Va\xC2#A\xF5\xC7\xE9T\x93\xEE4\xEDWj \xEA\xC2\xE9\xEC\xA0B2W\xC8\xDF\xF54\xA1Vz\xA0\xFE\xAB\xB8- |
From: <sco...@us...> - 2010-05-24 14:12:01
|
Revision: 23256 http://gmod.svn.sourceforge.net/gmod/?rev=23256&view=rev Author: scottcain Date: 2010-05-24 14:11:51 +0000 (Mon, 24 May 2010) Log Message: ----------- minor changes Modified Paths: -------------- schema/trunk/chado/MANIFEST schema/trunk/chado/Makefile.PL Modified: schema/trunk/chado/MANIFEST =================================================================== --- schema/trunk/chado/MANIFEST 2010-05-24 14:04:17 UTC (rev 23255) +++ schema/trunk/chado/MANIFEST 2010-05-24 14:11:51 UTC (rev 23256) @@ -7,7 +7,7 @@ bin/create-so-bridge.pl bin/cxgn/gmod_bulk_load_pubmed.pl bin/cxgn/gmod_load_cvterms.pl -bin/cxgn/make_cvtermpath.pl +bin/cxgn/gmod_make_cvtermpath.pl bin/cxgn/load_ncbi_taxonomy.pl bin/cxgn/load_taxonomy_cvterms.pl bin/dbi.tt2 Modified: schema/trunk/chado/Makefile.PL =================================================================== --- schema/trunk/chado/Makefile.PL 2010-05-24 14:04:17 UTC (rev 23255) +++ schema/trunk/chado/Makefile.PL 2010-05-24 14:11:51 UTC (rev 23256) @@ -519,7 +519,7 @@ 'DBIx::DBStag' => 0.11, 'GO::Parser' => 0, 'Module::Load' => 0.16, - 'Bio::Root::Version'=> 1.0069, + 'Bio::Root::Version'=> 1.006001, 'LWP::Simple' => 0, }, 'PL_FILES' => { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nm...@us...> - 2010-07-09 20:43:36
|
Revision: 23537 http://gmod.svn.sourceforge.net/gmod/?rev=23537&view=rev Author: nm249 Date: 2010-07-09 20:43:25 +0000 (Fri, 09 Jul 2010) Log Message: ----------- fixed messed up -p and -u options Modified Paths: -------------- schema/trunk/chado/Changes schema/trunk/chado/bin/cxgn/gmod_load_cvterms.pl Modified: schema/trunk/chado/Changes =================================================================== --- schema/trunk/chado/Changes 2010-07-09 13:44:34 UTC (rev 23536) +++ schema/trunk/chado/Changes 2010-07-09 20:43:25 UTC (rev 23537) @@ -7,8 +7,8 @@ * Made gmod_materialized_view_tool.pl able to accept all configuration parameters on the command line (this is to make it work with automatic MV creation for full text searching) (Scott). +* fixed messed up gmod_load_cvterms.pl -p and -u options (Naama) - Version 1.1 * Fixes to gmod_gff3_preprocessor.pl so that file splitting will work Modified: schema/trunk/chado/bin/cxgn/gmod_load_cvterms.pl =================================================================== --- schema/trunk/chado/bin/cxgn/gmod_load_cvterms.pl 2010-07-09 13:44:34 UTC (rev 23536) +++ schema/trunk/chado/bin/cxgn/gmod_load_cvterms.pl 2010-07-09 20:43:25 UTC (rev 23537) @@ -9,7 +9,7 @@ parameters -=over 10 +=over 13 =item -H @@ -19,21 +19,26 @@ database name [required if -p isn't used] -=item -p +=item -p -GMOD database profile name (can provide host and DB name) Default: 'default' +password (if you need to provide a password to connect to your db) +=item -r + +username (if you need to provide a username to connect to your database) + + =item -d driver name (e.g. 'Pg' for postgres). Driver name can be provided in gmod_config -=item -v +=item -g -verbose output +GMOD database profile name (can provide host, DB name, password, username, and driver) Default: 'default' =item -s -database name for linking (must be in db table) Default: GO +database name for linking (must be in db table) =item -n @@ -49,6 +54,10 @@ update all the terms. Without -u, the terms in the database won't be updated to the contents of the file, in terms of definitions, etc. New terms will still be added. +=item -v + +verbose output + =item -o outfile for writing errors and verbose messages (optional) @@ -120,7 +129,7 @@ =head1 VERSION AND DATE -Version 0.13, August 2009. +Version 0.14, July 2010. =cut @@ -138,24 +147,24 @@ use Bio::Chado::Schema; our ($opt_d, $opt_h, $opt_H, $opt_F, $opt_n, $opt_D, $opt_v, $opt_t, - $opt_u, $opt_o, $opt_p); + $opt_u, $opt_o, $opt_p, $opt_r, $opt_g); -getopts('F:d:H:o:n:vD:tu:p:s:'); +getopts('F:d:H:o:n:vD:tu:p:s:r:g:'); my $dbhost = $opt_H; my $dbname = $opt_D; my $pass = $opt_p; my $driver = $opt_d; -my $user = $opt_u; +my $user = $opt_r; my $verbose = $opt_v; -my $DBPROFILE = $opt_p ; +my $DBPROFILE = $opt_g ; print "H= $opt_H, D= $opt_D, u=$opt_u, d=$opt_d, v=$opt_v, t=$opt_t \n" if $verbose; my $port = '5432'; -my $opt_s ||= 'GO'; # the database name that Dbxrefs should refer to +my $opt_s || die " Need -s db.name argument! \n " ; # the database name that Dbxrefs should refer to if (!($opt_H and $opt_D) ) { $DBPROFILE ||= 'default'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sco...@us...> - 2010-08-10 18:01:44
|
Revision: 23651 http://gmod.svn.sourceforge.net/gmod/?rev=23651&view=rev Author: scottcain Date: 2010-08-10 18:01:31 +0000 (Tue, 10 Aug 2010) Log Message: ----------- bumping the version number after the 1.11 release, and adding to the Changes file for some commits Rob made Modified Paths: -------------- schema/trunk/chado/Changes schema/trunk/chado/Makefile.PL Modified: schema/trunk/chado/Changes =================================================================== --- schema/trunk/chado/Changes 2010-08-10 17:54:24 UTC (rev 23650) +++ schema/trunk/chado/Changes 2010-08-10 18:01:31 UTC (rev 23651) @@ -1,3 +1,8 @@ +Version 1.12 Tue Aug 10 13:59:05 EDT 2010 +* Added some error checking to gmod_fasta2gff3.pl (Rob) +* Updated Bio::Chado::Builder to detect recent versions of go-perl. They +no longer have .pl at the end of the go2fmt script name (Rob) + Version 1.11 Tue May 25 11:10:47 EDT 2010 * fixed an issue with accessing the primary_id of Bio::Annotation::DBLink objects (Naama) Modified: schema/trunk/chado/Makefile.PL =================================================================== --- schema/trunk/chado/Makefile.PL 2010-08-10 17:54:24 UTC (rev 23650) +++ schema/trunk/chado/Makefile.PL 2010-08-10 18:01:31 UTC (rev 23651) @@ -500,7 +500,7 @@ # 'INSTALLSITELIB' => '$(INSTALLSITEARCH)', 'NAME' => 'chado', # 'NAME' => 'gmod', - 'VERSION' => '1.11', + 'VERSION' => '1.12', 'PREREQ_PM' => { #'SQL::Translator' => 0.05, #'Class::DBI' => 0.94, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rb...@us...> - 2010-08-17 06:00:01
|
Revision: 23679 http://gmod.svn.sourceforge.net/gmod/?rev=23679&view=rev Author: rbuels Date: 2010-08-17 05:59:49 +0000 (Tue, 17 Aug 2010) Log Message: ----------- merged integrate_natdiv into trunk. this was a pain, svn and sourceforge have had their day. Modified Paths: -------------- schema/trunk/chado/Makefile.PL schema/trunk/chado/bin/chado-build-schema.pl schema/trunk/chado/chado-module-metadata.xml schema/trunk/chado/modules/audit/audit_tables.sql schema/trunk/chado/modules/default_nofuncs.sql schema/trunk/chado/modules/default_schema.sql schema/trunk/chado/modules/general/general.html schema/trunk/chado/modules/general/general.sql schema/trunk/chado/modules/mage/mage.html schema/trunk/chado/modules/mage/mage.sql schema/trunk/chado/modules/nofuncs.html schema/trunk/chado/modules/stock/stock.sql schema/trunk/chado/modules/www/www.html schema/trunk/chado/modules/www/www.sql Added Paths: ----------- schema/trunk/chado/modules/natural_diversity/ schema/trunk/chado/modules/natural_diversity/natural_diversity.html schema/trunk/chado/modules/natural_diversity/natural_diversity.sql schema/trunk/chado/modules/project/ schema/trunk/chado/modules/project/project.html schema/trunk/chado/modules/project/project.sql Removed Paths: ------------- schema/trunk/chado/modules/natural_diversity/natural_diversity.html schema/trunk/chado/modules/natural_diversity/natural_diversity.sql schema/trunk/chado/modules/project/project.html schema/trunk/chado/modules/project/project.sql Modified: schema/trunk/chado/Makefile.PL =================================================================== --- schema/trunk/chado/Makefile.PL 2010-08-16 19:51:34 UTC (rev 23678) +++ schema/trunk/chado/Makefile.PL 2010-08-17 05:59:49 UTC (rev 23679) @@ -611,6 +611,8 @@ make $working_dir/modules/sequence/sequence.graphviz.png \ make $working_dir/modules/www/www.graphviz.png \ make $working_dir/modules/stock/stock.graphviz.png \ + make $working_dir/modules/project/project.graphviz.png \ + make $working_dir/modules/natural_diversity/natural_diversity.graphviz.png \ make $working_dir/modules/nofuncs.graphviz.png graphviz_svg :: \ @@ -631,6 +633,8 @@ make $working_dir/modules/sequence/sequence.graphviz.svg \ make $working_dir/modules/www/www.graphviz.svg \ make $working_dir/modules/stock/stock.graphviz.svg \ + make $working_dir/modules/project/project.graphviz.svg \ + make $working_dir/modules/natural_diversity/natural_diversity.graphviz.svg \ make $working_dir/modules/nofuncs.graphviz.svg diagram :: \ @@ -651,6 +655,8 @@ make $working_dir/modules/sequence/sequence.diagram.png \ make $working_dir/modules/www/www.diagram.png \ make $working_dir/modules/stock/stock.diagram.png \ + make $working_dir/modules/project/project.diagram.png \ + make $working_dir/modules/natural_diversity/natural_diversity.diagram.png \ make $working_dir/modules/nofuncs.diagram.png @@ -673,6 +679,8 @@ make $working_dir/modules/sequence/sequence.html \ make $working_dir/modules/www/www.html \ make $working_dir/modules/stock/stock.html \ + make $working_dir/modules/project/project.html \ + make $working_dir/modules/natural_diversity/natural_diversity.html \ make $working_dir/modules/nofuncs.html tex :: \ @@ -694,6 +702,8 @@ make $working_dir/modules/sequence/sequence.tex \ make $working_dir/modules/www/www.tex \ make $working_dir/modules/stock/stock.tex \ + make $working_dir/modules/project/project.tex \ + make $working_dir/modules/natural_diversity/natural_diversity.tex \ make $working_dir/modules/nofuncs.tex %.html: %.sql Modified: schema/trunk/chado/bin/chado-build-schema.pl =================================================================== --- schema/trunk/chado/bin/chado-build-schema.pl 2010-08-16 19:51:34 UTC (rev 23678) +++ schema/trunk/chado/bin/chado-build-schema.pl 2010-08-17 05:59:49 UTC (rev 23679) @@ -10,7 +10,7 @@ my ($HELP, $OUTFILE, $INFILE, $ONLY_SQL); -my $rows_of_stuff=23; +my $rows_of_stuff=28; GetOptions( 'help' => \$HELP, Modified: schema/trunk/chado/chado-module-metadata.xml =================================================================== --- schema/trunk/chado/chado-module-metadata.xml 2010-08-16 19:51:34 UTC (rev 23678) +++ schema/trunk/chado/chado-module-metadata.xml 2010-08-17 05:59:49 UTC (rev 23679) @@ -477,14 +477,29 @@ <source type='sql' path='expression/expression.sql'/> </module> + <module id='project'> + <dependency to="cv"/> + <dependency to="contact"/> + <dependency to="pub"/> + <status code='beta'> + </status> + <description> +The project table has been moved from general to its own module and has been +expanded to provide properties, publications and contacts. + </description> + <source type='sql' path='project/project.sql'/> + </module> + + <module id='mage'> - <dependency to='sequence'/> - <dependency to='cv'/> + <dependency to='sequence'/> + <dependency to='cv'/> <dependency to='pub'/> <dependency to='general'/> - <dependency to='organism'/> - <dependency to='contact'/> - <dependency to='companalysis'/> + <dependency to='organism'/> + <dependency to='contact'/> + <dependency to='companalysis'/> + <dependency to='project'/> <status code='beta'> In use at UCLA/Allen Day </status> @@ -576,6 +591,27 @@ </component> </module> + <module id='natural-diversity'> + <dependency to='sequence'/> + <dependency to='cv'/> + <dependency to='pub'/> + <dependency to='phenotype'/> + <dependency to='organism'/> + <dependency to='genetic'/> + <dependency to='contact'/> + <dependency to='general'/> + <dependency to='stock'/> + <dependency to='project'/> + <status code='beta'> + </status> + <description> +Natural diversity module for dealing with populations, samples, genotypes, +phenotypes and results of other assays. + </description> + <source type='sql' path='natural_diversity/natural_diversity.sql'/> + </module> + + <!-- Since this is dynamically generated from a given schema, this should either be done at a later step, or if requested, dynamically generated @@ -595,6 +631,8 @@ <dependency to='organism'/> <dependency to='phylogeny'/> <dependency to='rad'/> + <dependency to='project'/> + <dependency to='natural-diversity'/> <status code='beta'> In use at...? @@ -606,5 +644,6 @@ </module> --> + </modules> </schema_metadata> Modified: schema/trunk/chado/modules/audit/audit_tables.sql =================================================================== --- schema/trunk/chado/modules/audit/audit_tables.sql 2010-08-16 19:51:34 UTC (rev 23678) +++ schema/trunk/chado/modules/audit/audit_tables.sql 2010-08-17 05:59:49 UTC (rev 23679) @@ -218,63 +218,6 @@ EXECUTE PROCEDURE audit_update_delete_dbxref (); - DROP TABLE audit_project; - CREATE TABLE audit_project ( - project_id integer, - name varchar(255), - description varchar(255), - transaction_date timestamp not null default now(), - transaction_type char(1) not null - ); - GRANT ALL on audit_project to PUBLIC; - - CREATE OR REPLACE FUNCTION audit_update_delete_project() RETURNS trigger AS - ' - DECLARE - project_id_var integer; - name_var varchar(255); - description_var varchar(255); - - transaction_type_var char; - BEGIN - project_id_var = OLD.project_id; - name_var = OLD.name; - description_var = OLD.description; - - IF TG_OP = ''DELETE'' THEN - transaction_type_var = ''D''; - ELSE - transaction_type_var = ''U''; - END IF; - - INSERT INTO audit_project ( - project_id, - name, - description, - transaction_type - ) VALUES ( - project_id_var, - name_var, - description_var, - transaction_type_var - ); - - IF TG_OP = ''DELETE'' THEN - return OLD; - ELSE - return NEW; - END IF; - END - ' - LANGUAGE plpgsql; - - DROP TRIGGER project_audit_ud ON project; - CREATE TRIGGER project_audit_ud - BEFORE UPDATE OR DELETE ON project - FOR EACH ROW - EXECUTE PROCEDURE audit_update_delete_project (); - - DROP TABLE audit_cv; CREATE TABLE audit_cv ( cv_id integer, @@ -5290,6 +5233,306 @@ EXECUTE PROCEDURE audit_update_delete_expression_image (); + DROP TABLE audit_project; + CREATE TABLE audit_project ( + project_id integer, + name varchar(255), + description varchar(255), + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_project to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_project() RETURNS trigger AS + ' + DECLARE + project_id_var integer; + name_var varchar(255); + description_var varchar(255); + + transaction_type_var char; + BEGIN + project_id_var = OLD.project_id; + name_var = OLD.name; + description_var = OLD.description; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_project ( + project_id, + name, + description, + transaction_type + ) VALUES ( + project_id_var, + name_var, + description_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER project_audit_ud ON project; + CREATE TRIGGER project_audit_ud + BEFORE UPDATE OR DELETE ON project + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_project (); + + + DROP TABLE audit_projectprop; + CREATE TABLE audit_projectprop ( + projectprop_id integer, + project_id integer, + cvterm_id integer, + value text, + rank integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_projectprop to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_projectprop() RETURNS trigger AS + ' + DECLARE + projectprop_id_var integer; + project_id_var integer; + cvterm_id_var integer; + value_var text; + rank_var integer; + + transaction_type_var char; + BEGIN + projectprop_id_var = OLD.projectprop_id; + project_id_var = OLD.project_id; + cvterm_id_var = OLD.cvterm_id; + value_var = OLD.value; + rank_var = OLD.rank; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_projectprop ( + projectprop_id, + project_id, + cvterm_id, + value, + rank, + transaction_type + ) VALUES ( + projectprop_id_var, + project_id_var, + cvterm_id_var, + value_var, + rank_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER projectprop_audit_ud ON projectprop; + CREATE TRIGGER projectprop_audit_ud + BEFORE UPDATE OR DELETE ON projectprop + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_projectprop (); + + + DROP TABLE audit_project_relationship; + CREATE TABLE audit_project_relationship ( + project_relationship_id integer, + subject_project_id integer, + object_project_id integer, + type_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_project_relationship to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_project_relationship() RETURNS trigger AS + ' + DECLARE + project_relationship_id_var integer; + subject_project_id_var integer; + object_project_id_var integer; + type_id_var integer; + + transaction_type_var char; + BEGIN + project_relationship_id_var = OLD.project_relationship_id; + subject_project_id_var = OLD.subject_project_id; + object_project_id_var = OLD.object_project_id; + type_id_var = OLD.type_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_project_relationship ( + project_relationship_id, + subject_project_id, + object_project_id, + type_id, + transaction_type + ) VALUES ( + project_relationship_id_var, + subject_project_id_var, + object_project_id_var, + type_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER project_relationship_audit_ud ON project_relationship; + CREATE TRIGGER project_relationship_audit_ud + BEFORE UPDATE OR DELETE ON project_relationship + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_project_relationship (); + + + DROP TABLE audit_project_pub; + CREATE TABLE audit_project_pub ( + project_pub_id integer, + project_id integer, + pub_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_project_pub to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_project_pub() RETURNS trigger AS + ' + DECLARE + project_pub_id_var integer; + project_id_var integer; + pub_id_var integer; + + transaction_type_var char; + BEGIN + project_pub_id_var = OLD.project_pub_id; + project_id_var = OLD.project_id; + pub_id_var = OLD.pub_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_project_pub ( + project_pub_id, + project_id, + pub_id, + transaction_type + ) VALUES ( + project_pub_id_var, + project_id_var, + pub_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER project_pub_audit_ud ON project_pub; + CREATE TRIGGER project_pub_audit_ud + BEFORE UPDATE OR DELETE ON project_pub + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_project_pub (); + + + DROP TABLE audit_project_contact; + CREATE TABLE audit_project_contact ( + project_contact_id integer, + project_id integer, + contact_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_project_contact to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_project_contact() RETURNS trigger AS + ' + DECLARE + project_contact_id_var integer; + project_id_var integer; + contact_id_var integer; + + transaction_type_var char; + BEGIN + project_contact_id_var = OLD.project_contact_id; + project_id_var = OLD.project_id; + contact_id_var = OLD.contact_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_project_contact ( + project_contact_id, + project_id, + contact_id, + transaction_type + ) VALUES ( + project_contact_id_var, + project_id_var, + contact_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER project_contact_audit_ud ON project_contact; + CREATE TRIGGER project_contact_audit_ud + BEFORE UPDATE OR DELETE ON project_contact + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_project_contact (); + + DROP TABLE audit_mageml; CREATE TABLE audit_mageml ( mageml_id integer, @@ -8157,6 +8400,68 @@ EXECUTE PROCEDURE audit_update_delete_stock_relationship (); + DROP TABLE audit_stock_relationship_cvterm; + CREATE TABLE audit_stock_relationship_cvterm ( + stock_relationship_cvterm_id integer, + stock_relatiohship_id integer, + cvterm_id integer, + pub_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_stock_relationship_cvterm to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_stock_relationship_cvterm() RETURNS trigger AS + ' + DECLARE + stock_relationship_cvterm_id_var integer; + stock_relatiohship_id_var integer; + cvterm_id_var integer; + pub_id_var integer; + + transaction_type_var char; + BEGIN + stock_relationship_cvterm_id_var = OLD.stock_relationship_cvterm_id; + stock_relatiohship_id_var = OLD.stock_relatiohship_id; + cvterm_id_var = OLD.cvterm_id; + pub_id_var = OLD.pub_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_stock_relationship_cvterm ( + stock_relationship_cvterm_id, + stock_relatiohship_id, + cvterm_id, + pub_id, + transaction_type + ) VALUES ( + stock_relationship_cvterm_id_var, + stock_relatiohship_id_var, + cvterm_id_var, + pub_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER stock_relationship_cvterm_audit_ud ON stock_relationship_cvterm; + CREATE TRIGGER stock_relationship_cvterm_audit_ud + BEFORE UPDATE OR DELETE ON stock_relationship_cvterm + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_stock_relationship_cvterm (); + + DROP TABLE audit_stock_relationship_pub; CREATE TABLE audit_stock_relationship_pub ( stock_relationship_pub_id integer, @@ -9809,3 +10114,1223 @@ EXECUTE PROCEDURE audit_update_delete_cell_line_library (); + DROP TABLE audit_nd_geolocation; + CREATE TABLE audit_nd_geolocation ( + geolocation_id integer, + description varchar(255), + latitude real, + longitude real, + geodetic_datum varchar(32), + altitude real, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_geolocation to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_geolocation() RETURNS trigger AS + ' + DECLARE + geolocation_id_var integer; + description_var varchar(255); + latitude_var real; + longitude_var real; + geodetic_datum_var varchar(32); + altitude_var real; + + transaction_type_var char; + BEGIN + geolocation_id_var = OLD.geolocation_id; + description_var = OLD.description; + latitude_var = OLD.latitude; + longitude_var = OLD.longitude; + geodetic_datum_var = OLD.geodetic_datum; + altitude_var = OLD.altitude; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_geolocation ( + geolocation_id, + description, + latitude, + longitude, + geodetic_datum, + altitude, + transaction_type + ) VALUES ( + geolocation_id_var, + description_var, + latitude_var, + longitude_var, + geodetic_datum_var, + altitude_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_geolocation_audit_ud ON nd_geolocation; + CREATE TRIGGER nd_geolocation_audit_ud + BEFORE UPDATE OR DELETE ON nd_geolocation + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_geolocation (); + + + DROP TABLE audit_nd_assay; + CREATE TABLE audit_nd_assay ( + assay_id integer, + geolocation_id integer, + type_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_assay to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_assay() RETURNS trigger AS + ' + DECLARE + assay_id_var integer; + geolocation_id_var integer; + type_id_var integer; + + transaction_type_var char; + BEGIN + assay_id_var = OLD.assay_id; + geolocation_id_var = OLD.geolocation_id; + type_id_var = OLD.type_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_assay ( + assay_id, + geolocation_id, + type_id, + transaction_type + ) VALUES ( + assay_id_var, + geolocation_id_var, + type_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_assay_audit_ud ON nd_assay; + CREATE TRIGGER nd_assay_audit_ud + BEFORE UPDATE OR DELETE ON nd_assay + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_assay (); + + + DROP TABLE audit_nd_assay_project; + CREATE TABLE audit_nd_assay_project ( + assay_project_id integer, + project_id integer, + assay_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_assay_project to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_assay_project() RETURNS trigger AS + ' + DECLARE + assay_project_id_var integer; + project_id_var integer; + assay_id_var integer; + + transaction_type_var char; + BEGIN + assay_project_id_var = OLD.assay_project_id; + project_id_var = OLD.project_id; + assay_id_var = OLD.assay_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_assay_project ( + assay_project_id, + project_id, + assay_id, + transaction_type + ) VALUES ( + assay_project_id_var, + project_id_var, + assay_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_assay_project_audit_ud ON nd_assay_project; + CREATE TRIGGER nd_assay_project_audit_ud + BEFORE UPDATE OR DELETE ON nd_assay_project + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_assay_project (); + + + DROP TABLE audit_nd_assayprop; + CREATE TABLE audit_nd_assayprop ( + assayprop_id integer, + assay_id integer, + cvterm_id integer, + value varchar(255), + rank integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_assayprop to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_assayprop() RETURNS trigger AS + ' + DECLARE + assayprop_id_var integer; + assay_id_var integer; + cvterm_id_var integer; + value_var varchar(255); + rank_var integer; + + transaction_type_var char; + BEGIN + assayprop_id_var = OLD.assayprop_id; + assay_id_var = OLD.assay_id; + cvterm_id_var = OLD.cvterm_id; + value_var = OLD.value; + rank_var = OLD.rank; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_assayprop ( + assayprop_id, + assay_id, + cvterm_id, + value, + rank, + transaction_type + ) VALUES ( + assayprop_id_var, + assay_id_var, + cvterm_id_var, + value_var, + rank_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_assayprop_audit_ud ON nd_assayprop; + CREATE TRIGGER nd_assayprop_audit_ud + BEFORE UPDATE OR DELETE ON nd_assayprop + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_assayprop (); + + + DROP TABLE audit_nd_assay_pub; + CREATE TABLE audit_nd_assay_pub ( + assay_pub_id integer, + assay_id integer, + pub_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_assay_pub to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_assay_pub() RETURNS trigger AS + ' + DECLARE + assay_pub_id_var integer; + assay_id_var integer; + pub_id_var integer; + + transaction_type_var char; + BEGIN + assay_pub_id_var = OLD.assay_pub_id; + assay_id_var = OLD.assay_id; + pub_id_var = OLD.pub_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_assay_pub ( + assay_pub_id, + assay_id, + pub_id, + transaction_type + ) VALUES ( + assay_pub_id_var, + assay_id_var, + pub_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_assay_pub_audit_ud ON nd_assay_pub; + CREATE TRIGGER nd_assay_pub_audit_ud + BEFORE UPDATE OR DELETE ON nd_assay_pub + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_assay_pub (); + + + DROP TABLE audit_nd_geolocationprop; + CREATE TABLE audit_nd_geolocationprop ( + geolocationprop_id integer, + geolocation_id integer, + cvterm_id integer, + value varchar(250), + rank integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_geolocationprop to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_geolocationprop() RETURNS trigger AS + ' + DECLARE + geolocationprop_id_var integer; + geolocation_id_var integer; + cvterm_id_var integer; + value_var varchar(250); + rank_var integer; + + transaction_type_var char; + BEGIN + geolocationprop_id_var = OLD.geolocationprop_id; + geolocation_id_var = OLD.geolocation_id; + cvterm_id_var = OLD.cvterm_id; + value_var = OLD.value; + rank_var = OLD.rank; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_geolocationprop ( + geolocationprop_id, + geolocation_id, + cvterm_id, + value, + rank, + transaction_type + ) VALUES ( + geolocationprop_id_var, + geolocation_id_var, + cvterm_id_var, + value_var, + rank_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_geolocationprop_audit_ud ON nd_geolocationprop; + CREATE TRIGGER nd_geolocationprop_audit_ud + BEFORE UPDATE OR DELETE ON nd_geolocationprop + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_geolocationprop (); + + + DROP TABLE audit_nd_protocol; + CREATE TABLE audit_nd_protocol ( + protocol_id integer, + name varchar(255), + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_protocol to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_protocol() RETURNS trigger AS + ' + DECLARE + protocol_id_var integer; + name_var varchar(255); + + transaction_type_var char; + BEGIN + protocol_id_var = OLD.protocol_id; + name_var = OLD.name; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_protocol ( + protocol_id, + name, + transaction_type + ) VALUES ( + protocol_id_var, + name_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_protocol_audit_ud ON nd_protocol; + CREATE TRIGGER nd_protocol_audit_ud + BEFORE UPDATE OR DELETE ON nd_protocol + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_protocol (); + + + DROP TABLE audit_nd_reagent; + CREATE TABLE audit_nd_reagent ( + reagent_id integer, + name varchar(80), + type_id integer, + feature_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_reagent to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_reagent() RETURNS trigger AS + ' + DECLARE + reagent_id_var integer; + name_var varchar(80); + type_id_var integer; + feature_id_var integer; + + transaction_type_var char; + BEGIN + reagent_id_var = OLD.reagent_id; + name_var = OLD.name; + type_id_var = OLD.type_id; + feature_id_var = OLD.feature_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_reagent ( + reagent_id, + name, + type_id, + feature_id, + transaction_type + ) VALUES ( + reagent_id_var, + name_var, + type_id_var, + feature_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_reagent_audit_ud ON nd_reagent; + CREATE TRIGGER nd_reagent_audit_ud + BEFORE UPDATE OR DELETE ON nd_reagent + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_reagent (); + + + DROP TABLE audit_nd_protocol_reagent; + CREATE TABLE audit_nd_protocol_reagent ( + protocol_reagent_id integer, + protocol_id integer, + reagent_id integer, + type_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_protocol_reagent to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_protocol_reagent() RETURNS trigger AS + ' + DECLARE + protocol_reagent_id_var integer; + protocol_id_var integer; + reagent_id_var integer; + type_id_var integer; + + transaction_type_var char; + BEGIN + protocol_reagent_id_var = OLD.protocol_reagent_id; + protocol_id_var = OLD.protocol_id; + reagent_id_var = OLD.reagent_id; + type_id_var = OLD.type_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_protocol_reagent ( + protocol_reagent_id, + protocol_id, + reagent_id, + type_id, + transaction_type + ) VALUES ( + protocol_reagent_id_var, + protocol_id_var, + reagent_id_var, + type_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_protocol_reagent_audit_ud ON nd_protocol_reagent; + CREATE TRIGGER nd_protocol_reagent_audit_ud + BEFORE UPDATE OR DELETE ON nd_protocol_reagent + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_protocol_reagent (); + + + DROP TABLE audit_nd_protocolprop; + CREATE TABLE audit_nd_protocolprop ( + protocolprop_id integer, + protocol_id integer, + cvterm_id integer, + value varchar(255), + rank integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_protocolprop to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_protocolprop() RETURNS trigger AS + ' + DECLARE + protocolprop_id_var integer; + protocol_id_var integer; + cvterm_id_var integer; + value_var varchar(255); + rank_var integer; + + transaction_type_var char; + BEGIN + protocolprop_id_var = OLD.protocolprop_id; + protocol_id_var = OLD.protocol_id; + cvterm_id_var = OLD.cvterm_id; + value_var = OLD.value; + rank_var = OLD.rank; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_protocolprop ( + protocolprop_id, + protocol_id, + cvterm_id, + value, + rank, + transaction_type + ) VALUES ( + protocolprop_id_var, + protocol_id_var, + cvterm_id_var, + value_var, + rank_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_protocolprop_audit_ud ON nd_protocolprop; + CREATE TRIGGER nd_protocolprop_audit_ud + BEFORE UPDATE OR DELETE ON nd_protocolprop + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_protocolprop (); + + + DROP TABLE audit_nd_assay_stock; + CREATE TABLE audit_nd_assay_stock ( + assay_stock_id integer, + assay_id integer, + stock_id integer, + type_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_assay_stock to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_assay_stock() RETURNS trigger AS + ' + DECLARE + assay_stock_id_var integer; + assay_id_var integer; + stock_id_var integer; + type_id_var integer; + + transaction_type_var char; + BEGIN + assay_stock_id_var = OLD.assay_stock_id; + assay_id_var = OLD.assay_id; + stock_id_var = OLD.stock_id; + type_id_var = OLD.type_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_assay_stock ( + assay_stock_id, + assay_id, + stock_id, + type_id, + transaction_type + ) VALUES ( + assay_stock_id_var, + assay_id_var, + stock_id_var, + type_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_assay_stock_audit_ud ON nd_assay_stock; + CREATE TRIGGER nd_assay_stock_audit_ud + BEFORE UPDATE OR DELETE ON nd_assay_stock + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_assay_stock (); + + + DROP TABLE audit_nd_assay_protocol; + CREATE TABLE audit_nd_assay_protocol ( + assay_protocol_id integer, + assay_id integer, + protocol_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_assay_protocol to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_assay_protocol() RETURNS trigger AS + ' + DECLARE + assay_protocol_id_var integer; + assay_id_var integer; + protocol_id_var integer; + + transaction_type_var char; + BEGIN + assay_protocol_id_var = OLD.assay_protocol_id; + assay_id_var = OLD.assay_id; + protocol_id_var = OLD.protocol_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_assay_protocol ( + assay_protocol_id, + assay_id, + protocol_id, + transaction_type + ) VALUES ( + assay_protocol_id_var, + assay_id_var, + protocol_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_assay_protocol_audit_ud ON nd_assay_protocol; + CREATE TRIGGER nd_assay_protocol_audit_ud + BEFORE UPDATE OR DELETE ON nd_assay_protocol + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_assay_protocol (); + + + DROP TABLE audit_nd_assay_phenotype; + CREATE TABLE audit_nd_assay_phenotype ( + assay_phenotype_id integer, + assay_id integer, + phenotype_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_assay_phenotype to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_assay_phenotype() RETURNS trigger AS + ' + DECLARE + assay_phenotype_id_var integer; + assay_id_var integer; + phenotype_id_var integer; + + transaction_type_var char; + BEGIN + assay_phenotype_id_var = OLD.assay_phenotype_id; + assay_id_var = OLD.assay_id; + phenotype_id_var = OLD.phenotype_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_assay_phenotype ( + assay_phenotype_id, + assay_id, + phenotype_id, + transaction_type + ) VALUES ( + assay_phenotype_id_var, + assay_id_var, + phenotype_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_assay_phenotype_audit_ud ON nd_assay_phenotype; + CREATE TRIGGER nd_assay_phenotype_audit_ud + BEFORE UPDATE OR DELETE ON nd_assay_phenotype + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_assay_phenotype (); + + + DROP TABLE audit_nd_assay_genotype; + CREATE TABLE audit_nd_assay_genotype ( + assay_genotype_id integer, + assay_id integer, + genotype_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_assay_genotype to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_assay_genotype() RETURNS trigger AS + ' + DECLARE + assay_genotype_id_var integer; + assay_id_var integer; + genotype_id_var integer; + + transaction_type_var char; + BEGIN + assay_genotype_id_var = OLD.assay_genotype_id; + assay_id_var = OLD.assay_id; + genotype_id_var = OLD.genotype_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_assay_genotype ( + assay_genotype_id, + assay_id, + genotype_id, + transaction_type + ) VALUES ( + assay_genotype_id_var, + assay_id_var, + genotype_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_assay_genotype_audit_ud ON nd_assay_genotype; + CREATE TRIGGER nd_assay_genotype_audit_ud + BEFORE UPDATE OR DELETE ON nd_assay_genotype + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_assay_genotype (); + + + DROP TABLE audit_nd_reagent_relationship; + CREATE TABLE audit_nd_reagent_relationship ( + reagent_relationship_id integer, + subject_reagent_id integer, + object_reagent_id integer, + type_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_reagent_relationship to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_reagent_relationship() RETURNS trigger AS + ' + DECLARE + reagent_relationship_id_var integer; + subject_reagent_id_var integer; + object_reagent_id_var integer; + type_id_var integer; + + transaction_type_var char; + BEGIN + reagent_relationship_id_var = OLD.reagent_relationship_id; + subject_reagent_id_var = OLD.subject_reagent_id; + object_reagent_id_var = OLD.object_reagent_id; + type_id_var = OLD.type_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_reagent_relationship ( + reagent_relationship_id, + subject_reagent_id, + object_reagent_id, + type_id, + transaction_type + ) VALUES ( + reagent_relationship_id_var, + subject_reagent_id_var, + object_reagent_id_var, + type_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_reagent_relationship_audit_ud ON nd_reagent_relationship; + CREATE TRIGGER nd_reagent_relationship_audit_ud + BEFORE UPDATE OR DELETE ON nd_reagent_relationship + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_reagent_relationship (); + + + DROP TABLE audit_nd_reagentprop; + CREATE TABLE audit_nd_reagentprop ( + reagentprop_id integer, + reagent_id integer, + cvterm_id integer, + value varchar(255), + rank integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_reagentprop to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_reagentprop() RETURNS trigger AS + ' + DECLARE + reagentprop_id_var integer; + reagent_id_var integer; + cvterm_id_var integer; + value_var varchar(255); + rank_var integer; + + transaction_type_var char; + BEGIN + reagentprop_id_var = OLD.reagentprop_id; + reagent_id_var = OLD.reagent_id; + cvterm_id_var = OLD.cvterm_id; + value_var = OLD.value; + rank_var = OLD.rank; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_reagentprop ( + reagentprop_id, + reagent_id, + cvterm_id, + value, + rank, + transaction_type + ) VALUES ( + reagentprop_id_var, + reagent_id_var, + cvterm_id_var, + value_var, + rank_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_reagentprop_audit_ud ON nd_reagentprop; + CREATE TRIGGER nd_reagentprop_audit_ud + BEFORE UPDATE OR DELETE ON nd_reagentprop + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_reagentprop (); + + + DROP TABLE audit_nd_assay_stockprop; + CREATE TABLE audit_nd_assay_stockprop ( + assay_stockprop_id integer, + assay_stock_id integer, + cvterm_id integer, + value varchar(255), + rank integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_assay_stockprop to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_assay_stockprop() RETURNS trigger AS + ' + DECLARE + assay_stockprop_id_var integer; + assay_stock_id_var integer; + cvterm_id_var integer; + value_var varchar(255); + rank_var integer; + + transaction_type_var char; + BEGIN + assay_stockprop_id_var = OLD.assay_stockprop_id; + assay_stock_id_var = OLD.assay_stock_id; + cvterm_id_var = OLD.cvterm_id; + value_var = OLD.value; + rank_var = OLD.rank; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_assay_stockprop ( + assay_stockprop_id, + assay_stock_id, + cvterm_id, + value, + rank, + transaction_type + ) VALUES ( + assay_stockprop_id_var, + assay_stock_id_var, + cvterm_id_var, + value_var, + rank_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_assay_stockprop_audit_ud ON nd_assay_stockprop; + CREATE TRIGGER nd_assay_stockprop_audit_ud + BEFORE UPDATE OR DELETE ON nd_assay_stockprop + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_assay_stockprop (); + + + DROP TABLE audit_nd_assay_stock_dbxref; + CREATE TABLE audit_nd_assay_stock_dbxref ( + assay_stock_dbxref_id integer, + assay_stock_id integer, + dbxref_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_assay_stock_dbxref to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_assay_stock_dbxref() RETURNS trigger AS + ' + DECLARE + assay_stock_dbxref_id_var integer; + assay_stock_id_var integer; + dbxref_id_var integer; + + transaction_type_var char; + BEGIN + assay_stock_dbxref_id_var = OLD.assay_stock_dbxref_id; + assay_stock_id_var = OLD.assay_stock_id; + dbxref_id_var = OLD.dbxref_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_assay_stock_dbxref ( + assay_stock_dbxref_id, + assay_stock_id, + dbxref_id, + transaction_type + ) VALUES ( + assay_stock_dbxref_id_var, + assay_stock_id_var, + dbxref_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_assay_stock_dbxref_audit_ud ON nd_assay_stock_dbxref; + CREATE TRIGGER nd_assay_stock_dbxref_audit_ud + BEFORE UPDATE OR DELETE ON nd_assay_stock_dbxref + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_assay_stock_dbxref (); + + + DROP TABLE audit_nd_assay_dbxref; + CREATE TABLE audit_nd_assay_dbxref ( + assay_dbxref_id integer, + assay_id integer, + dbxref_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_assay_dbxref to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_assay_dbxref() RETURNS trigger AS + ' + DECLARE + assay_dbxref_id_var integer; + assay_id_var integer; + dbxref_id_var integer; + + transaction_type_var char; + BEGIN + assay_dbxref_id_var = OLD.assay_dbxref_id; + assay_id_var = OLD.assay_id; + dbxref_id_var = OLD.dbxref_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_assay_dbxref ( + assay_dbxref_id, + assay_id, + dbxref_id, + transaction_type + ) VALUES ( + assay_dbxref_id_var, + assay_id_var, + dbxref_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_assay_dbxref_audit_ud ON nd_assay_dbxref; + CREATE TRIGGER nd_assay_dbxref_audit_ud + BEFORE UPDATE OR DELETE ON nd_assay_dbxref + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_assay_dbxref (); + + + DROP TABLE audit_nd_assay_contact; + CREATE TABLE audit_nd_assay_contact ( + assay_contact_id integer, + assay_id integer, + contact_id integer, + transaction_date timestamp not null default now(), + transaction_type char(1) not null + ); + GRANT ALL on audit_nd_assay_contact to PUBLIC; + + CREATE OR REPLACE FUNCTION audit_update_delete_nd_assay_contact() RETURNS trigger AS + ' + DECLARE + assay_contact_id_var integer; + assay_id_var integer; + contact_id_var integer; + + transaction_type_var char; + BEGIN + assay_contact_id_var = OLD.assay_contact_id; + assay_id_var = OLD.assay_id; + contact_id_var = OLD.contact_id; + + IF TG_OP = ''DELETE'' THEN + transaction_type_var = ''D''; + ELSE + transaction_type_var = ''U''; + END IF; + + INSERT INTO audit_nd_assay_contact ( + assay_contact_id, + assay_id, + contact_id, + transaction_type + ) VALUES ( + assay_contact_id_var, + assay_id_var, + contact_id_var, + transaction_type_var + ); + + IF TG_OP = ''DELETE'' THEN + return OLD; + ELSE + return NEW; + END IF; + END + ' + LANGUAGE plpgsql; + + DROP TRIGGER nd_assay_contact_audit_ud ON nd_assay_contact; + CREATE TRIGGER nd_assay_contact_audit_ud + BEFORE UPDATE OR DELETE ON nd_assay_contact + FOR EACH ROW + EXECUTE PROCEDURE audit_update_delete_nd_assay_contact (); + + Modified: schema/trunk/chado/modules/default_nofuncs.sql =================================================================== --- schema/trunk/chado/modules/default_nofuncs.sql 2010-08-16 19:51:34 UTC (rev 23678) +++ schema/trunk/chado/modules/default_nofuncs.sql 2010-08-17 05:59:49 UTC (rev 23679) @@ -67,19 +67,6 @@ COMMENT ON COLUMN dbxref.accession IS 'The local part of the identifier. Guaranteed by the db authority to be unique for that db.'; --- ================================================ --- TABLE: project --- ================================================ - -create table project ( - project_id serial not null, - primary key (project_id), - name varchar(255) not null, - description varchar(255) not null, - constraint project_c1 unique (name) -); - -COMMENT ON TABLE project IS NULL; -- $Id: cv.sql,v 1.37 2007-02-28 15:08:48 briano Exp $ -- ========================================== -- Chado cv module @@ -2192,6 +2179,92 @@ ); create index expression_image_idx1 on expression_image (expression_id); create index expression_image_idx2 on expression_image (eimage_id); +-- ================================================================= +-- Dependencies: +-- +-- :import cvterm from cv +-- :import pub from pub +-- :import contact from contact +-- ================================================================= + + +-- ================================================ +-- TABLE: project +-- ================================================ + +create table project ( + project_id serial not null, + primary key (project_id), + name varchar(255) not null, + description varchar(255) not null, + constraint project_c1 unique (name) +); + +COMMENT ON TABLE project IS NULL; + +-- ================================================ +-- TABLE: projectprop +-- ================================================ + +CREATE TABLE projectprop ( + projectprop_id serial NOT NULL, + PRIMARY KEY (projectprop_id), + project_id integer NOT NULL, + FOREIGN KEY (project_id) REFERENCES project (project_id) ON DELETE CASCADE, + cvterm_id integer NOT NULL, + FOREIGN KEY (cvterm_id) REFERENCES cvterm (cvterm_id) ON DELETE CASCADE, + value text, + rank integer not null default 0, + CONSTRAINT projectprop_c1 UNIQUE (project_id, cvterm_id, rank) +); + +-- ================================================ +-- TABLE: project_relationship +-- ================================================ + +CREATE TABLE project_relationship ( + project_relationship_id serial NOT NULL, + PRIMARY KEY (project_relationship_id), + subject_project_id integer NOT NULL, + FOREIGN KEY (subject_project_id) REFERENCES project (project_id) ON DELETE CASCADE, + object_project_id integer NOT NULL, + FOREIGN KEY (object_project_id) REFERENCES project (project_id) ON DELETE CASCADE, + type_id integer NOT NULL, + FOREIGN KEY (type_id) REFERENCES cvterm (cvterm_id) ON DELETE RESTRICT, + CONSTRAINT project_relationship_c1 UNIQUE (subject_project_id, object_project_id, type_id) +); +COMMENT ON TABLE project_relationship IS 'A project can be composed of several smaller scale projects'; +COMMENT ON COLUMN project_relationship.type_id IS 'The type of relationship being stated, such as "is part of".'; + + +create table project_pub ( + project_pub_id serial not null, + primary key (project_pub_id), + project_id int not null, + foreign key (project_id) references project (project_id) on delete cascade INITIALLY DEFERRED, + pub_id int not null, + foreign key (pub_id) references pub (pub_id) on delete cascade INITIALLY DEFERRED, + constraint project_pub_c1 unique (project_id,pub_id) +); +create index project_pub_idx1 on project_pub (project_id); +create index project_pub_idx2 on project_pub (pub_id); + +COMMENT ON TABLE project_pub IS 'Linking project(s) to publication(s)'; + + +create table project_contact ( + project_contact_id serial not null, + primary key (project_contact_id), + project_id int not null, + foreign key (project_id) references project (project_id) on delete cascade INITIALLY DEFERRED, + contact_id int not null, + foreign key (contact_id) references contact (contact_id) on delete cascade INITIALLY DEFERRED, + constraint project_contact_c1 unique (project_id,contact_id) +); +create index project_contact_idx1 on project_contact (project_id); +create index project_contact_idx2 on project_contact (contact_id); + +COMMENT ON TABLE project_contact IS 'Linking project(s) to contact(s)'; -- $Id: mage.sql,v 1.3 2008-03-19 18:32:51 scottcain Exp $ -- ========================================== -- Chado mage module @@ -2206,7 +2279,7 @@ -- :import contact from contact -- :import dbxref from general -- :import tableinfo from general --- :import project from general +-- :import project from project -- :import analysis from companalysis -- ================================================================= @@ -3028,6 +3101,7 @@ -- :import dbxref from general -- :import organism from organism -- :import genotype from genetic +-- :import contact from contact -- ================================================ -- TABLE: stock @@ -3038,7 +3112,7 @@ primary key (stock_id), dbxref_id int, foreign key (dbxref_id) references dbxref (dbxref_id) on delete set null INITIALLY DEFERRED, - organism_id int not null, + organism_id int, foreign key (organism_id) references organism (organism_id) on delete cascade INITIALLY DEFERRED, name varchar(255), uniquename text not null, @@ -3057,7 +3131,7 @@ COMMENT ON TABLE stock IS 'Any stock can be globally identified by the combination of organism, uniquename and stock type. A stock is the physical entities, either living or preserved, held by collections. Stocks belong to a collection; they have IDs, type, organism, description and may have a genotype.'; COMMENT ON COLUMN stock.dbxref_id IS 'The dbxref_id is an optional primary stable identifier for this stock. Secondary indentifiers and external dbxrefs go in table: stock_dbxref.'; -COMMENT ON COLUMN stock.organism_id IS 'The organism_id is the organism to which the stock belongs. This column is mandatory.'; +COMMENT ON COLUMN stock.organism_id IS 'The organism_id is the organism to which the stock belongs. This column should only be left blank if the organism cannot be determined.'; COMMENT ON COLUMN stock.type_id IS 'The type_id foreign key links to a controlled vocabulary of s... [truncated message content] |
From: <sco...@us...> - 2010-08-25 20:48:24
|
Revision: 23700 http://gmod.svn.sourceforge.net/gmod/?rev=23700&view=rev Author: scottcain Date: 2010-08-25 20:47:26 +0000 (Wed, 25 Aug 2010) Log Message: ----------- updating diagrams and docs for the addition of the natdiv module Modified Paths: -------------- schema/trunk/chado/doc/diagrams/general.diagram.png schema/trunk/chado/doc/diagrams/general.graphviz.png schema/trunk/chado/doc/diagrams/general.graphviz.svg schema/trunk/chado/doc/diagrams/nofuncs.diagram.png schema/trunk/chado/doc/diagrams/stock.diagram.png schema/trunk/chado/modules/nofuncs.html Added Paths: ----------- schema/trunk/chado/doc/diagrams/natural_diversity.diagram.png schema/trunk/chado/doc/diagrams/natural_diversity.graphviz.png schema/trunk/chado/doc/diagrams/natural_diversity.graphviz.svg Modified: schema/trunk/chado/doc/diagrams/general.diagram.png =================================================================== --- schema/trunk/chado/doc/diagrams/general.diagram.png 2010-08-25 20:26:10 UTC (rev 23699) +++ schema/trunk/chado/doc/diagrams/general.diagram.png 2010-08-25 20:47:26 UTC (rev 23700) @@ -1,78 +1,65 @@ \x89PNG |
From: <sco...@us...> - 2010-10-21 19:27:06
|
Revision: 24016 http://gmod.svn.sourceforge.net/gmod/?rev=24016&view=rev Author: scottcain Date: 2010-10-21 19:26:53 +0000 (Thu, 21 Oct 2010) Log Message: ----------- updating diagrams and audit tables Modified Paths: -------------- schema/trunk/chado/doc/diagrams/natural_diversity.diagram.png schema/trunk/chado/doc/diagrams/natural_diversity.graphviz.png schema/trunk/chado/doc/diagrams/natural_diversity.graphviz.svg schema/trunk/chado/doc/diagrams/nofuncs.diagram.png schema/trunk/chado/doc/diagrams/stock.diagram.png schema/trunk/chado/modules/audit/audit_tables.sql Modified: schema/trunk/chado/doc/diagrams/natural_diversity.diagram.png =================================================================== (Binary files differ) Modified: schema/trunk/chado/doc/diagrams/natural_diversity.graphviz.png =================================================================== (Binary files differ) Modified: schema/trunk/chado/doc/diagrams/natural_diversity.graphviz.svg =================================================================== --- schema/trunk/chado/doc/diagrams/natural_diversity.graphviz.svg 2010-10-21 18:47:50 UTC (rev 24015) +++ schema/trunk/chado/doc/diagrams/natural_diversity.graphviz.svg 2010-10-21 19:26:53 UTC (rev 24016) @@ -44,7 +44,7 @@ <polyline style="fill:none;stroke:black;" points="37,-445 217,-445 "/> <text text-anchor="start" x="45" y="-427.9" style="font-family:Times New Roman;font-size:14.00;">- nd_geolocationprop_id</text> <text text-anchor="start" x="45" y="-410.9" style="font-family:Times New Roman;font-size:14.00;">- nd_geolocation_id</text> -<text text-anchor="start" x="45" y="-393.9" style="font-family:Times New Roman;font-size:14.00;">- cvterm_id</text> +<text text-anchor="start" x="45" y="-393.9" style="font-family:Times New Roman;font-size:14.00;">- type_id</text> <text text-anchor="start" x="45" y="-376.9" style="font-family:Times New Roman;font-size:14.00;">- value</text> <text text-anchor="start" x="45" y="-359.9" style="font-family:Times New Roman;font-size:14.00;">- rank</text> </g> @@ -74,7 +74,7 @@ <polyline style="fill:none;stroke:black;" points="709,-843 889,-843 "/> <text text-anchor="start" x="717" y="-825.9" style="font-family:Times New Roman;font-size:14.00;">- nd_experimentprop_id</text> <text text-anchor="start" x="717" y="-808.9" style="font-family:Times New Roman;font-size:14.00;">- nd_experiment_id</text> -<text text-anchor="start" x="717" y="-791.9" style="font-family:Times New Roman;font-size:14.00;">- cvterm_id</text> +<text text-anchor="start" x="717" y="-791.9" style="font-family:Times New Roman;font-size:14.00;">- type_id</text> <text text-anchor="start" x="717" y="-774.9" style="font-family:Times New Roman;font-size:14.00;">- value</text> <text text-anchor="start" x="717" y="-757.9" style="font-family:Times New Roman;font-size:14.00;">- rank</text> </g> @@ -212,7 +212,7 @@ <polyline style="fill:none;stroke:black;" points="578,-94 734,-94 "/> <text text-anchor="start" x="586" y="-76.9" style="font-family:Times New Roman;font-size:14.00;">- nd_protocolprop_id</text> <text text-anchor="start" x="586" y="-59.9" style="font-family:Times New Roman;font-size:14.00;">- nd_protocol_id</text> -<text text-anchor="start" x="586" y="-42.9" style="font-family:Times New Roman;font-size:14.00;">- cvterm_id</text> +<text text-anchor="start" x="586" y="-42.9" style="font-family:Times New Roman;font-size:14.00;">- type_id</text> <text text-anchor="start" x="586" y="-25.9" style="font-family:Times New Roman;font-size:14.00;">- value</text> <text text-anchor="start" x="586" y="-8.9" style="font-family:Times New Roman;font-size:14.00;">- rank</text> </g> @@ -263,7 +263,7 @@ <polyline style="fill:none;stroke:black;" points="1181,-153 1336,-153 "/> <text text-anchor="start" x="1188.5" y="-135.9" style="font-family:Times New Roman;font-size:14.00;">- nd_reagentprop_id</text> <text text-anchor="start" x="1188.5" y="-118.9" style="font-family:Times New Roman;font-size:14.00;">- nd_reagent_id</text> -<text text-anchor="start" x="1188.5" y="-101.9" style="font-family:Times New Roman;font-size:14.00;">- cvterm_id</text> +<text text-anchor="start" x="1188.5" y="-101.9" style="font-family:Times New Roman;font-size:14.00;">- type_id</text> <text text-anchor="start" x="1188.5" y="-84.9" style="font-family:Times New Roman;font-size:14.00;">- value</text> <text text-anchor="start" x="1188.5" y="-67.9" style="font-family:Times New Roman;font-size:14.00;">- rank</text> </g> @@ -279,7 +279,7 @@ <polyline style="fill:none;stroke:black;" points="58,-131 281,-131 "/> <text text-anchor="start" x="65.5" y="-113.9" style="font-family:Times New Roman;font-size:14.00;">- nd_experiment_stockprop_id</text> <text text-anchor="start" x="65.5" y="-96.9" style="font-family:Times New Roman;font-size:14.00;">- nd_experiment_stock_id</text> -<text text-anchor="start" x="65.5" y="-79.9" style="font-family:Times New Roman;font-size:14.00;">- cvterm_id</text> +<text text-anchor="start" x="65.5" y="-79.9" style="font-family:Times New Roman;font-size:14.00;">- type_id</text> <text text-anchor="start" x="65.5" y="-62.9" style="font-family:Times New Roman;font-size:14.00;">- value</text> <text text-anchor="start" x="65.5" y="-45.9" style="font-family:Times New Roman;font-size:14.00;">- rank</text> </g> Modified: schema/trunk/chado/doc/diagrams/nofuncs.diagram.png =================================================================== --- schema/trunk/chado/doc/diagrams/nofuncs.diagram.png 2010-10-21 18:47:50 UTC (rev 24015) +++ schema/trunk/chado/doc/diagrams/nofuncs.diagram.png 2010-10-21 19:26:53 UTC (rev 24016) @@ -1,3652 +1,3880 @@ \x89PNG |
From: <sco...@us...> - 2010-11-10 18:04:36
|
Revision: 24118 http://gmod.svn.sourceforge.net/gmod/?rev=24118&view=rev Author: scottcain Date: 2010-11-10 18:04:22 +0000 (Wed, 10 Nov 2010) Log Message: ----------- updating default schema for changes to nd schema, gff-bridge, and addition of cvprop table Modified Paths: -------------- schema/trunk/chado/bin/AutoDBI.PL schema/trunk/chado/modules/audit/audit_tables.sql schema/trunk/chado/modules/cv/cv.html schema/trunk/chado/modules/default_nofuncs.sql schema/trunk/chado/modules/default_schema.sql schema/trunk/chado/modules/natural_diversity/natural_diversity.html schema/trunk/chado/modules/nofuncs.html Modified: schema/trunk/chado/bin/AutoDBI.PL =================================================================== --- schema/trunk/chado/bin/AutoDBI.PL 2010-11-10 16:48:42 UTC (rev 24117) +++ schema/trunk/chado/bin/AutoDBI.PL 2010-11-10 18:04:22 UTC (rev 24118) @@ -42,7 +42,7 @@ # This is how you normally connect with Class DBI's connection pooling but # its very fragile for me on FC2. I'm replacing it with the db_Main method below -#Bio::Chado::DBI->set_db('Main', 'dbi:Pg:dbname=chado', 'cain', ''); +#Bio::Chado::DBI->set_db('Main', 'dbi:Pg:dbname=chado_test', 'cain', ''); my $db_options = { __PACKAGE__->_default_attributes }; __PACKAGE__->_remember_handle('Main'); # so dbi_commit works @@ -502,23 +502,23 @@ # -sub feature_cvterm_pub_feature_cvterms { return shift->feature_cvterm_pub_feature_cvterm_id } +sub feature_cvterm_dbxref_feature_cvterms { return shift->feature_cvterm_dbxref_feature_cvterm_id } -sub feature_cvterm_dbxref_feature_cvterms { return shift->feature_cvterm_dbxref_feature_cvterm_id } +sub feature_cvterm_pub_feature_cvterms { return shift->feature_cvterm_pub_feature_cvterm_id } # one to many to one # one2one # -sub pubs { my $self = shift; return map $_->pub_id, $self->feature_cvterm_pub_feature_cvterm_id } +sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->feature_cvterm_dbxref_feature_cvterm_id } -sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->feature_cvterm_dbxref_feature_cvterm_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->feature_cvterm_pub_feature_cvterm_id } # one to many to many @@ -611,15 +611,15 @@ # + sub element_arraydesigns { return shift->element_arraydesign_id } - - + - sub element_arraydesigns { return shift->element_arraydesign_id } + + - sub element_arraydesigns { return shift->element_arraydesign_id } @@ -628,11 +628,11 @@ # one2one # -sub cvterms { my $self = shift; return map $_->type_id, $self->element_arraydesign_id } +sub features { my $self = shift; return map $_->feature_id, $self->element_arraydesign_id } -sub features { my $self = shift; return map $_->feature_id, $self->element_arraydesign_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->element_arraydesign_id } @@ -1733,22 +1733,19 @@ # -sub phenstatement_genotypes { return shift->phenstatement_genotype_id } +sub phenotype_comparison_genotype1s { return shift->phenotype_comparison_genotype1_id } - - -sub phenstatement_genotypes { return shift->phenstatement_genotype_id } +sub phenotype_comparison_genotype2s { return shift->phenotype_comparison_genotype2_id } -sub phenstatement_genotypes { return shift->phenstatement_genotype_id } +sub phenotype_comparison_genotype1s { return shift->phenotype_comparison_genotype1_id } - - -sub phenstatement_genotypes { return shift->phenstatement_genotype_id } + +sub phenotype_comparison_genotype2s { return shift->phenotype_comparison_genotype2_id } @@ -1758,6 +1755,7 @@ sub phenotype_comparison_genotype2s { return shift->phenotype_comparison_genotype2_id } + @@ -1769,37 +1767,43 @@ -sub phenotype_comparison_genotype1s { return shift->phenotype_comparison_genotype1_id } - +sub stock_genotype_genotypes { return shift->stock_genotype_genotype_id } + + -sub phenotype_comparison_genotype2s { return shift->phenotype_comparison_genotype2_id } +sub phenstatement_genotypes { return shift->phenstatement_genotype_id } -sub phenotype_comparison_genotype1s { return shift->phenotype_comparison_genotype1_id } +sub phenstatement_genotypes { return shift->phenstatement_genotype_id } + + -sub phenotype_comparison_genotype2s { return shift->phenotype_comparison_genotype2_id } +sub phenstatement_genotypes { return shift->phenstatement_genotype_id } + + +sub phenstatement_genotypes { return shift->phenstatement_genotype_id } + sub nd_experiment_genotype_genotypes { return shift->nd_experiment_genotype_genotype_id } +# one to many to one -sub stock_genotype_genotypes { return shift->stock_genotype_genotype_id } - -# one to many to one - + + # one2one # -sub cvterms { my $self = shift; return map $_->type_id, $self->phenstatement_genotype_id } +sub stocks { my $self = shift; return map $_->stock_id, $self->stock_genotype_genotype_id } @@ -1811,19 +1815,15 @@ -sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_genotype_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->phenstatement_genotype_id } - - - - -sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_genotype_genotype_id } +sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_genotype_id } -sub stocks { my $self = shift; return map $_->stock_id, $self->stock_genotype_genotype_id } +sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_genotype_genotype_id } # one to many to many @@ -1840,43 +1840,38 @@ #many to many to one - - - - # many2one # -sub phenotype_comparison_genotype1_organisms { my $self = shift; return map $_->organism_id, $self->phenotype_comparison_genotype1_id } +sub phenotype_comparison_genotype1_pubs { my $self = shift; return map $_->pub_id, $self->phenotype_comparison_genotype1_id } -sub phenotype_comparison_genotype2_organisms { my $self = shift; return map $_->organism_id, $self->phenotype_comparison_genotype2_id } +sub phenotype_comparison_genotype2_pubs { my $self = shift; return map $_->pub_id, $self->phenotype_comparison_genotype2_id } + + -sub phenotype_comparison_genotype1_pubs { my $self = shift; return map $_->pub_id, $self->phenotype_comparison_genotype1_id } +sub phenotype_comparison_genotype1_organisms { my $self = shift; return map $_->organism_id, $self->phenotype_comparison_genotype1_id } -sub phenotype_comparison_genotype2_pubs { my $self = shift; return map $_->pub_id, $self->phenotype_comparison_genotype2_id } +sub phenotype_comparison_genotype2_organisms { my $self = shift; return map $_->organism_id, $self->phenotype_comparison_genotype2_id } + + #many to many to many - - - - - # many2many # @@ -1925,6 +1920,11 @@ + + + + + 1; @@ -2138,85 +2138,85 @@ -sub organism_dbxref_dbxrefs { return shift->organism_dbxref_dbxref_id } +sub element_dbxrefs { return shift->element_dbxref_id } -sub nd_experiment_dbxref_dbxrefs { return shift->nd_experiment_dbxref_dbxref_id } +sub element_dbxrefs { return shift->element_dbxref_id } -sub phylonode_dbxref_dbxrefs { return shift->phylonode_dbxref_dbxref_id } +sub element_dbxrefs { return shift->element_dbxref_id } -sub biomaterial_dbxref_dbxrefs { return shift->biomaterial_dbxref_dbxref_id } +sub feature_cvterm_dbxref_dbxrefs { return shift->feature_cvterm_dbxref_dbxref_id } -sub element_dbxrefs { return shift->element_dbxref_id } +sub nd_experiment_stock_dbxref_dbxrefs { return shift->nd_experiment_stock_dbxref_dbxref_id } -sub element_dbxrefs { return shift->element_dbxref_id } +sub biomaterial_dbxref_dbxrefs { return shift->biomaterial_dbxref_dbxref_id } -sub element_dbxrefs { return shift->element_dbxref_id } +sub nd_experiment_dbxref_dbxrefs { return shift->nd_experiment_dbxref_dbxref_id } -sub feature_cvterm_dbxref_dbxrefs { return shift->feature_cvterm_dbxref_dbxref_id } +sub organism_dbxref_dbxrefs { return shift->organism_dbxref_dbxref_id } -sub nd_experiment_stock_dbxref_dbxrefs { return shift->nd_experiment_stock_dbxref_dbxref_id } +sub phylonode_dbxref_dbxrefs { return shift->phylonode_dbxref_dbxref_id } # one to many to one # one2one # -sub organisms { my $self = shift; return map $_->organism_id, $self->organism_dbxref_dbxref_id } +sub features { my $self = shift; return map $_->feature_id, $self->element_dbxref_id } -sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_dbxref_dbxref_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->element_dbxref_id } -sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_dbxref_dbxref_id } +sub arraydesigns { my $self = shift; return map $_->arraydesign_id, $self->element_dbxref_id } -sub biomaterials { my $self = shift; return map $_->biomaterial_id, $self->biomaterial_dbxref_dbxref_id } +sub feature_cvterms { my $self = shift; return map $_->feature_cvterm_id, $self->feature_cvterm_dbxref_dbxref_id } -sub cvterms { my $self = shift; return map $_->type_id, $self->element_dbxref_id } +sub nd_experiment_stocks { my $self = shift; return map $_->nd_experiment_stock_id, $self->nd_experiment_stock_dbxref_dbxref_id } -sub features { my $self = shift; return map $_->feature_id, $self->element_dbxref_id } +sub biomaterials { my $self = shift; return map $_->biomaterial_id, $self->biomaterial_dbxref_dbxref_id } -sub arraydesigns { my $self = shift; return map $_->arraydesign_id, $self->element_dbxref_id } +sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_dbxref_dbxref_id } -sub feature_cvterms { my $self = shift; return map $_->feature_cvterm_id, $self->feature_cvterm_dbxref_dbxref_id } +sub organisms { my $self = shift; return map $_->organism_id, $self->organism_dbxref_dbxref_id } -sub nd_experiment_stocks { my $self = shift; return map $_->nd_experiment_stock_id, $self->nd_experiment_stock_dbxref_dbxref_id } +sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_dbxref_dbxref_id } # one to many to many @@ -2617,149 +2617,144 @@ # -sub pub_relationship_subjects { return shift->pub_relationship_subject_id } - -sub pub_relationship_objects { return shift->pub_relationship_object_id } - - +sub feature_cvterm_pub_pubs { return shift->feature_cvterm_pub_pub_id } + -sub library_cvterm_pubs { return shift->library_cvterm_pub_id } +sub feature_relationship_pub_pubs { return shift->feature_relationship_pub_pub_id } -sub library_cvterm_pubs { return shift->library_cvterm_pub_id } + +sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } -sub library_pub_pubs { return shift->library_pub_pub_id } + +sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } - -sub cell_line_library_pubs { return shift->cell_line_library_pub_id } +sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } + + - -sub cell_line_library_pubs { return shift->cell_line_library_pub_id } - - - -sub phenstatement_pubs { return shift->phenstatement_pub_id } +sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } -sub phenstatement_pubs { return shift->phenstatement_pub_id } +sub libraryprop_pub_pubs { return shift->libraryprop_pub_pub_id } -sub phenstatement_pubs { return shift->phenstatement_pub_id } +sub library_cvterm_pubs { return shift->library_cvterm_pub_id } -sub phenstatement_pubs { return shift->phenstatement_pub_id } +sub library_cvterm_pubs { return shift->library_cvterm_pub_id } -sub feature_cvterm_pub_pubs { return shift->feature_cvterm_pub_pub_id } +sub cell_line_pub_pubs { return shift->cell_line_pub_pub_id } -sub featuremap_pub_pubs { return shift->featuremap_pub_pub_id } +sub cell_line_library_pubs { return shift->cell_line_library_pub_id } -sub feature_pub_pubs { return shift->feature_pub_pub_id } +sub cell_line_library_pubs { return shift->cell_line_library_pub_id } -sub libraryprop_pub_pubs { return shift->libraryprop_pub_pub_id } +sub stockprop_pub_pubs { return shift->stockprop_pub_pub_id } -sub cell_lineprop_pub_pubs { return shift->cell_lineprop_pub_pub_id } +sub project_pub_pubs { return shift->project_pub_pub_id } -sub stock_cvterm_pubs { return shift->stock_cvterm_pub_id } +sub library_pub_pubs { return shift->library_pub_pub_id } -sub stock_cvterm_pubs { return shift->stock_cvterm_pub_id } +sub featuremap_pub_pubs { return shift->featuremap_pub_pub_id } -sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } +sub pub_relationship_subjects { return shift->pub_relationship_subject_id } + +sub pub_relationship_objects { return shift->pub_relationship_object_id } + - -sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } +sub feature_relationshipprop_pub_pubs { return shift->feature_relationshipprop_pub_pub_id } - -sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } +sub nd_experiment_pub_pubs { return shift->nd_experiment_pub_pub_id } - -sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } +sub stock_relationship_pub_pubs { return shift->stock_relationship_pub_pub_id } -sub stock_relationship_pub_pubs { return shift->stock_relationship_pub_pub_id } +sub phylonode_pub_pubs { return shift->phylonode_pub_pub_id } -sub feature_relationship_pub_pubs { return shift->feature_relationship_pub_pub_id } +sub phenstatement_pubs { return shift->phenstatement_pub_id } -sub phylotree_pub_pubs { return shift->phylotree_pub_pub_id } +sub phenstatement_pubs { return shift->phenstatement_pub_id } -sub stockprop_pub_pubs { return shift->stockprop_pub_pub_id } +sub phenstatement_pubs { return shift->phenstatement_pub_id } -sub featureloc_pub_pubs { return shift->featureloc_pub_pub_id } +sub phenstatement_pubs { return shift->phenstatement_pub_id } -sub feature_relationshipprop_pub_pubs { return shift->feature_relationshipprop_pub_pub_id } +sub stock_pub_pubs { return shift->stock_pub_pub_id } -sub phylonode_pub_pubs { return shift->phylonode_pub_pub_id } +sub phylotree_pub_pubs { return shift->phylotree_pub_pub_id } @@ -2769,22 +2764,27 @@ -sub cell_line_pub_pubs { return shift->cell_line_pub_pub_id } +sub cell_line_feature_pubs { return shift->cell_line_feature_pub_id } -sub feature_expression_pubs { return shift->feature_expression_pub_id } +sub cell_line_feature_pubs { return shift->cell_line_feature_pub_id } +sub cell_lineprop_pub_pubs { return shift->cell_lineprop_pub_pub_id } + + + + sub feature_expression_pubs { return shift->feature_expression_pub_id } -sub nd_experiment_pub_pubs { return shift->nd_experiment_pub_pub_id } +sub feature_expression_pubs { return shift->feature_expression_pub_id } @@ -2794,136 +2794,136 @@ -sub cell_line_feature_pubs { return shift->cell_line_feature_pub_id } +sub stock_cvterm_pubs { return shift->stock_cvterm_pub_id } -sub cell_line_feature_pubs { return shift->cell_line_feature_pub_id } +sub stock_cvterm_pubs { return shift->stock_cvterm_pub_id } -sub project_pub_pubs { return shift->project_pub_pub_id } +sub feature_pub_pubs { return shift->feature_pub_pub_id } -sub stock_pub_pubs { return shift->stock_pub_pub_id } +sub featureloc_pub_pubs { return shift->featureloc_pub_pub_id } # one to many to one - # one2one # -sub cvterms { my $self = shift; return map $_->cvterm_id, $self->library_cvterm_pub_id } +sub feature_cvterms { my $self = shift; return map $_->feature_cvterm_id, $self->feature_cvterm_pub_pub_id } -sub librarys { my $self = shift; return map $_->library_id, $self->library_cvterm_pub_id } +sub feature_relationships { my $self = shift; return map $_->feature_relationship_id, $self->feature_relationship_pub_pub_id } + + -sub librarys { my $self = shift; return map $_->library_id, $self->library_pub_pub_id } +sub organisms { my $self = shift; return map $_->organism_id, $self->phenotype_comparison_pub_id } + -sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_library_pub_id } +sub libraryprops { my $self = shift; return map $_->libraryprop_id, $self->libraryprop_pub_pub_id } -sub librarys { my $self = shift; return map $_->library_id, $self->cell_line_library_pub_id } +sub cvterms { my $self = shift; return map $_->cvterm_id, $self->library_cvterm_pub_id } -sub cvterms { my $self = shift; return map $_->type_id, $self->phenstatement_pub_id } +sub librarys { my $self = shift; return map $_->library_id, $self->library_cvterm_pub_id } -sub environments { my $self = shift; return map $_->environment_id, $self->phenstatement_pub_id } +sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_pub_pub_id } -sub genotypes { my $self = shift; return map $_->genotype_id, $self->phenstatement_pub_id } +sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_library_pub_id } -sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_pub_id } +sub librarys { my $self = shift; return map $_->library_id, $self->cell_line_library_pub_id } -sub feature_cvterms { my $self = shift; return map $_->feature_cvterm_id, $self->feature_cvterm_pub_pub_id } +sub stockprops { my $self = shift; return map $_->stockprop_id, $self->stockprop_pub_pub_id } -sub featuremaps { my $self = shift; return map $_->featuremap_id, $self->featuremap_pub_pub_id } +sub projects { my $self = shift; return map $_->project_id, $self->project_pub_pub_id } -sub features { my $self = shift; return map $_->feature_id, $self->feature_pub_pub_id } +sub librarys { my $self = shift; return map $_->library_id, $self->library_pub_pub_id } -sub libraryprops { my $self = shift; return map $_->libraryprop_id, $self->libraryprop_pub_pub_id } +sub featuremaps { my $self = shift; return map $_->featuremap_id, $self->featuremap_pub_pub_id } + -sub cell_lineprops { my $self = shift; return map $_->cell_lineprop_id, $self->cell_lineprop_pub_pub_id } +sub feature_relationshipprops { my $self = shift; return map $_->feature_relationshipprop_id, $self->feature_relationshipprop_pub_pub_id } -sub cvterms { my $self = shift; return map $_->cvterm_id, $self->stock_cvterm_pub_id } +sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_pub_pub_id } -sub stocks { my $self = shift; return map $_->stock_id, $self->stock_cvterm_pub_id } +sub stock_relationships { my $self = shift; return map $_->stock_relationship_id, $self->stock_relationship_pub_pub_id } -sub organisms { my $self = shift; return map $_->organism_id, $self->phenotype_comparison_pub_id } +sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_pub_pub_id } - - - -sub stock_relationships { my $self = shift; return map $_->stock_relationship_id, $self->stock_relationship_pub_pub_id } +sub environments { my $self = shift; return map $_->environment_id, $self->phenstatement_pub_id } -sub feature_relationships { my $self = shift; return map $_->feature_relationship_id, $self->feature_relationship_pub_pub_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->phenstatement_pub_id } -sub phylotrees { my $self = shift; return map $_->phylotree_id, $self->phylotree_pub_pub_id } +sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_pub_id } -sub stockprops { my $self = shift; return map $_->stockprop_id, $self->stockprop_pub_pub_id } +sub genotypes { my $self = shift; return map $_->genotype_id, $self->phenstatement_pub_id } -sub featurelocs { my $self = shift; return map $_->featureloc_id, $self->featureloc_pub_pub_id } +sub stocks { my $self = shift; return map $_->stock_id, $self->stock_pub_pub_id } -sub feature_relationshipprops { my $self = shift; return map $_->feature_relationshipprop_id, $self->feature_relationshipprop_pub_pub_id } +sub phylotrees { my $self = shift; return map $_->phylotree_id, $self->phylotree_pub_pub_id } -sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_pub_pub_id } +sub featureprops { my $self = shift; return map $_->featureprop_id, $self->featureprop_pub_pub_id } -sub featureprops { my $self = shift; return map $_->featureprop_id, $self->featureprop_pub_pub_id } +sub features { my $self = shift; return map $_->feature_id, $self->cell_line_feature_pub_id } -sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_pub_pub_id } +sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_feature_pub_id } -sub expressions { my $self = shift; return map $_->expression_id, $self->feature_expression_pub_id } +sub cell_lineprops { my $self = shift; return map $_->cell_lineprop_id, $self->cell_lineprop_pub_pub_id } @@ -2931,7 +2931,7 @@ -sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_pub_pub_id } +sub expressions { my $self = shift; return map $_->expression_id, $self->feature_expression_pub_id } @@ -2939,70 +2939,70 @@ -sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_feature_pub_id } +sub stocks { my $self = shift; return map $_->stock_id, $self->stock_cvterm_pub_id } -sub features { my $self = shift; return map $_->feature_id, $self->cell_line_feature_pub_id } +sub cvterms { my $self = shift; return map $_->cvterm_id, $self->stock_cvterm_pub_id } -sub projects { my $self = shift; return map $_->project_id, $self->project_pub_pub_id } +sub features { my $self = shift; return map $_->feature_id, $self->feature_pub_pub_id } -sub stocks { my $self = shift; return map $_->stock_id, $self->stock_pub_pub_id } +sub featurelocs { my $self = shift; return map $_->featureloc_id, $self->featureloc_pub_pub_id } # one to many to many +# one2many # + +sub phenotype_comparison_environment1s { my $self = shift; return map $_->environment1_id, $self->phenotype_comparison_pub_id } + + + + +sub phenotype_comparison_phenotype1s { my $self = shift; return map $_->phenotype1_id, $self->phenotype_comparison_pub_id } + + + + +sub phenotype_comparison_genotype1s { my $self = shift; return map $_->genotype1_id, $self->phenotype_comparison_pub_id } + + -# one2many # - -sub phenotype_comparison_environment1s { my $self = shift; return map $_->environment1_id, $self->phenotype_comparison_pub_id } - - - - -sub phenotype_comparison_genotype1s { my $self = shift; return map $_->genotype1_id, $self->phenotype_comparison_pub_id } - - - - -sub phenotype_comparison_phenotype1s { my $self = shift; return map $_->phenotype1_id, $self->phenotype_comparison_pub_id } - - @@ -3023,15 +3023,9 @@ #many to many to one -# many2one # -sub pub_relationship_subject_types { my $self = shift; return map $_->type_id, $self->pub_relationship_subject_id } - -sub pub_relationship_object_types { my $self = shift; return map $_->type_id, $self->pub_relationship_object_id } - - @@ -3045,9 +3039,15 @@ +# many2one # +sub pub_relationship_subject_types { my $self = shift; return map $_->type_id, $self->pub_relationship_subject_id } + +sub pub_relationship_object_types { my $self = shift; return map $_->type_id, $self->pub_relationship_object_id } + + @@ -3911,9 +3911,9 @@ sub Bio::Chado::CDBI::Nd_Reagentprop::nd_reagent { return shift->nd_reagent_id } -Bio::Chado::CDBI::Nd_Reagentprop->has_a(cvterm_id => 'Bio::Chado::CDBI::Cvterm'); +Bio::Chado::CDBI::Nd_Reagentprop->has_a(type_id => 'Bio::Chado::CDBI::Cvterm'); -sub Bio::Chado::CDBI::Nd_Reagentprop::cvterm { return shift->cvterm_id } +sub Bio::Chado::CDBI::Nd_Reagentprop::cvterm { return shift->type_id } # @@ -3934,6 +3934,57 @@ 1; +########Bio::Chado::CDBI::Stock_Dbxrefprop######## + +package Bio::Chado::CDBI::Stock_Dbxrefprop; +use base 'Bio::Chado::DBI'; +use Class::DBI::Pager; +no warnings qw(redefine); + +Bio::Chado::CDBI::Stock_Dbxrefprop->set_up_table('stock_dbxrefprop'); + +# +# Primary key accessors +# + +sub id { shift->stock_dbxrefprop_id } +sub stock_dbxrefprop { shift->stock_dbxrefprop_id } + + + + +# +# Has A +# + +Bio::Chado::CDBI::Stock_Dbxrefprop->has_a(stock_dbxref_id => 'Bio::Chado::CDBI::Stock_Dbxref'); + +sub Bio::Chado::CDBI::Stock_Dbxrefprop::stock_dbxref { return shift->stock_dbxref_id } + + +Bio::Chado::CDBI::Stock_Dbxrefprop->has_a(type_id => 'Bio::Chado::CDBI::Cvterm'); + +sub Bio::Chado::CDBI::Stock_Dbxrefprop::cvterm { return shift->type_id } + + +# +# Has Many +# + + + +# one to many to one + +# one to many to many + +#many to many to one + +#many to many to many + + + +1; + ########Bio::Chado::CDBI::Nd_Experiment_Project######## package Bio::Chado::CDBI::Nd_Experiment_Project; @@ -4170,11 +4221,6 @@ # -sub feature_pub_features { return shift->feature_pub_feature_id } - - - - sub studyprop_feature_features { return shift->studyprop_feature_feature_id } @@ -4185,98 +4231,103 @@ -sub feature_phenotype_features { return shift->feature_phenotype_feature_id } +sub element_features { return shift->element_feature_id } -sub feature_expression_features { return shift->feature_expression_feature_id } +sub element_features { return shift->element_feature_id } - -sub feature_expression_features { return shift->feature_expression_feature_id } - - - sub element_features { return shift->element_feature_id } -sub element_features { return shift->element_feature_id } +sub feature_phenotype_features { return shift->feature_phenotype_feature_id } -sub element_features { return shift->element_feature_id } + +sub library_feature_features { return shift->library_feature_feature_id } + + + +sub cell_line_feature_features { return shift->cell_line_feature_feature_id } -sub library_feature_features { return shift->library_feature_feature_id } +sub cell_line_feature_features { return shift->cell_line_feature_feature_id } +sub feature_expression_features { return shift->feature_expression_feature_id } + + + -sub cell_line_feature_features { return shift->cell_line_feature_feature_id } + +sub feature_expression_features { return shift->feature_expression_feature_id } -sub cell_line_feature_features { return shift->cell_line_feature_feature_id } +sub feature_pub_features { return shift->feature_pub_feature_id } # one to many to one # one2one # -sub pubs { my $self = shift; return map $_->pub_id, $self->feature_pub_feature_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->studyprop_feature_feature_id } -sub cvterms { my $self = shift; return map $_->type_id, $self->studyprop_feature_feature_id } +sub studyprops { my $self = shift; return map $_->studyprop_id, $self->studyprop_feature_feature_id } -sub studyprops { my $self = shift; return map $_->studyprop_id, $self->studyprop_feature_feature_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->element_feature_id } -sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->feature_phenotype_feature_id } +sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->element_feature_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->feature_expression_feature_id } +sub arraydesigns { my $self = shift; return map $_->arraydesign_id, $self->element_feature_id } -sub expressions { my $self = shift; return map $_->expression_id, $self->feature_expression_feature_id } +sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->feature_phenotype_feature_id } -sub cvterms { my $self = shift; return map $_->type_id, $self->element_feature_id } +sub librarys { my $self = shift; return map $_->library_id, $self->library_feature_feature_id } -sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->element_feature_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_feature_feature_id } -sub arraydesigns { my $self = shift; return map $_->arraydesign_id, $self->element_feature_id } +sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_feature_feature_id } -sub librarys { my $self = shift; return map $_->library_id, $self->library_feature_feature_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->feature_expression_feature_id } -sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_feature_feature_id } +sub expressions { my $self = shift; return map $_->expression_id, $self->feature_expression_feature_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_feature_feature_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->feature_pub_feature_id } # one to many to many @@ -4619,6 +4670,11 @@ # +sub cell_line_pub_cell_lines { return shift->cell_line_pub_cell_line_id } + + + + sub cell_line_library_cell_lines { return shift->cell_line_library_cell_line_id } @@ -4637,11 +4693,6 @@ -sub cell_line_pub_cell_lines { return shift->cell_line_pub_cell_line_id } - - - - sub cell_line_feature_cell_lines { return shift->cell_line_feature_cell_line_id } @@ -4654,6 +4705,10 @@ # one2one # +sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_pub_cell_line_id } + + + sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_library_cell_line_id } @@ -4663,10 +4718,6 @@ -sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_pub_cell_line_id } - - - sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_feature_cell_line_id } @@ -4686,6 +4737,7 @@ + # many2one # @@ -4697,7 +4749,6 @@ - #many to many to many @@ -4783,6 +4834,7 @@ # # Has A # + Bio::Chado::CDBI::Stock_Dbxref->has_a(stock_id => 'Bio::Chado::CDBI::Stock'); @@ -4797,7 +4849,12 @@ # # Has Many # + +Bio::Chado::CDBI::Stock_Dbxref->has_many('stock_dbxrefprop_stock_dbxref_id', 'Bio::Chado::CDBI::Stock_Dbxrefprop' => 'stock_dbxref_id'); + +sub stock_dbxrefprops { return shift->stock_dbxrefprop_stock_dbxref_id } + # one to many to one @@ -5129,68 +5186,68 @@ # -sub stock_cvterm_stocks { return shift->stock_cvterm_stock_id } + +sub nd_experiment_stock_stocks { return shift->nd_experiment_stock_stock_id } + + + +sub nd_experiment_stock_stocks { return shift->nd_experiment_stock_stock_id } -sub stock_cvterm_stocks { return shift->stock_cvterm_stock_id } +sub stock_genotype_stocks { return shift->stock_genotype_stock_id } -sub nd_experiment_stock_stocks { return shift->nd_experiment_stock_stock_id } +sub stock_pub_stocks { return shift->stock_pub_stock_id } -sub nd_experiment_stock_stocks { return shift->nd_experiment_stock_stock_id } +sub stockcollection_stock_stocks { return shift->stockcollection_stock_stock_id } -sub stock_genotype_stocks { return shift->stock_genotype_stock_id } +sub stock_cvterm_stocks { return shift->stock_cvterm_stock_id } - -sub stockcollection_stock_stocks { return shift->stockcollection_stock_stock_id } - - - -sub stock_pub_stocks { return shift->stock_pub_stock_id } +sub stock_cvterm_stocks { return shift->stock_cvterm_stock_id } # one to many to one # one2one # -sub cvterms { my $self = shift; return map $_->cvterm_id, $self->stock_cvterm_stock_id } +sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_stock_stock_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->stock_cvterm_stock_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->nd_experiment_stock_stock_id } -sub cvterms { my $self = shift; return map $_->type_id, $self->nd_experiment_stock_stock_id } +sub genotypes { my $self = shift; return map $_->genotype_id, $self->stock_genotype_stock_id } -sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_stock_stock_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->stock_pub_stock_id } -sub genotypes { my $self = shift; return map $_->genotype_id, $self->stock_genotype_stock_id } +sub stockcollections { my $self = shift; return map $_->stockcollection_id, $self->stockcollection_stock_stock_id } -sub stockcollections { my $self = shift; return map $_->stockcollection_id, $self->stockcollection_stock_stock_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->stock_cvterm_stock_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->stock_pub_stock_id } +sub cvterms { my $self = shift; return map $_->cvterm_id, $self->stock_cvterm_stock_id } # one to many to many @@ -5536,11 +5593,19 @@ # -sub nd_experiment_project_projects { return shift->nd_experiment_project_project_id } +sub project_relationship_subject_projects { return shift->project_relationship_subject_project_id } + +sub project_relationship_object_projects { return shift->project_relationship_object_project_id } + +sub project_pub_projects { return shift->project_pub_project_id } + + + + sub project_contact_projects { return shift->project_contact_project_id } @@ -5551,22 +5616,15 @@ -sub project_relationship_subject_projects { return shift->project_relationship_subject_project_id } +sub nd_experiment_project_projects { return shift->nd_experiment_project_project_id } - -sub project_relationship_object_projects { return shift->project_relationship_object_project_id } - - - -sub project_pub_projects { return shift->project_pub_project_id } - - # one to many to one + # one2one # -sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_project_project_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->project_pub_project_id } @@ -5577,9 +5635,8 @@ sub assays { my $self = shift; return map $_->assay_id, $self->assay_project_project_id } - -sub pubs { my $self = shift; return map $_->pub_id, $self->project_pub_project_id } +sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_project_project_id } # one to many to many @@ -5591,9 +5648,6 @@ #many to many to one - - - # many2one # @@ -5604,6 +5658,9 @@ + + + #many to many to many @@ -5983,9 +6040,9 @@ sub Bio::Chado::CDBI::Nd_Protocolprop::nd_protocol { return shift->nd_protocol_id } -Bio::Chado::CDBI::Nd_Protocolprop->has_a(cvterm_id => 'Bio::Chado::CDBI::Cvterm'); +Bio::Chado::CDBI::Nd_Protocolprop->has_a(type_id => 'Bio::Chado::CDBI::Cvterm'); -sub Bio::Chado::CDBI::Nd_Protocolprop::cvterm { return shift->cvterm_id } +sub Bio::Chado::CDBI::Nd_Protocolprop::cvterm { return shift->type_id } # @@ -6249,12 +6306,12 @@ # - -sub nd_experiment_project_nd_experiments { return shift->nd_experiment_project_nd_experiment_id } +sub nd_experiment_phenotype_nd_experiments { return shift->nd_experiment_phenotype_nd_experiment_id } + + - -sub nd_experiment_stock_nd_experiments { return shift->nd_experiment_stock_nd_experiment_id } +sub nd_experiment_contact_nd_experiments { return shift->nd_experiment_contact_nd_experiment_id } @@ -6264,7 +6321,7 @@ -sub nd_experiment_phenotype_nd_experiments { return shift->nd_experiment_phenotype_nd_experiment_id } +sub nd_experiment_stock_nd_experiments { return shift->nd_experiment_stock_nd_experiment_id } @@ -6279,19 +6336,19 @@ -sub nd_experiment_genotype_nd_experiments { return shift->nd_experiment_genotype_nd_experiment_id } +sub nd_experiment_pub_nd_experiments { return shift->nd_experiment_pub_nd_experiment_id } -sub nd_experiment_contact_nd_experiments { return shift->nd_experiment_contact_nd_experiment_id } +sub nd_experiment_genotype_nd_experiments { return shift->nd_experiment_genotype_nd_experiment_id } -sub nd_experiment_pub_nd_experiments { return shift->nd_experiment_pub_nd_experiment_id } - - + +sub nd_experiment_project_nd_experiments { return shift->nd_experiment_project_nd_experiment_id } + # one to many to one # one to many to many @@ -7132,6 +7189,57 @@ 1; +########Bio::Chado::CDBI::Cvprop######## + +package Bio::Chado::CDBI::Cvprop; +use base 'Bio::Chado::DBI'; +use Class::DBI::Pager; +no warnings qw(redefine); + +Bio::Chado::CDBI::Cvprop->set_up_table('cvprop'); + +# +# Primary key accessors +# + +sub id { shift->cvprop_id } +sub cvprop { shift->cvprop_id } + + + + +# +# Has A +# + +Bio::Chado::CDBI::Cvprop->has_a(cv_id => 'Bio::Chado::CDBI::Cv'); + +sub Bio::Chado::CDBI::Cvprop::cv { return shift->cv_id } + + +Bio::Chado::CDBI::Cvprop->has_a(type_id => 'Bio::Chado::CDBI::Cvterm'); + +sub Bio::Chado::CDBI::Cvprop::cvterm { return shift->type_id } + + +# +# Has Many +# + + + +# one to many to one + +# one to many to many + +#many to many to one + +#many to many to many + + + +1; + ########Bio::Chado::CDBI::Studyfactor######## package Bio::Chado::CDBI::Studyfactor; @@ -8109,9 +8217,9 @@ sub Bio::Chado::CDBI::Nd_Experiment_Stockprop::nd_experiment_stock { return shift->nd_experiment_stock_id } -Bio::Chado::CDBI::Nd_Experiment_Stockprop->has_a(cvterm_id => 'Bio::Chado::CDBI::Cvterm'); +Bio::Chado::CDBI::Nd_Experiment_Stockprop->has_a(type_id => 'Bio::Chado::CDBI::Cvterm'); -sub Bio::Chado::CDBI::Nd_Experiment_Stockprop::cvterm { return shift->cvterm_id } +sub Bio::Chado::CDBI::Nd_Experiment_Stockprop::cvterm { return shift->type_id } # @@ -8725,14 +8833,14 @@ + +sub phylonode_organism_organisms { return shift->phylonode_organism_organism_id } + + + sub organism_dbxref_organisms { return shift->organism_dbxref_organism_id } - - - -sub phylonode_organism_organisms { return shift->phylonode_organism_organism_id } - # one to many to one @@ -8744,11 +8852,11 @@ -sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->organism_dbxref_organism_id } +sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_organism_organism_id } -sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_organism_organism_id } +sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->organism_dbxref_organism_id } # one to many to many @@ -8769,7 +8877,7 @@ -sub phenotype_comparison_genotype1s { my $self = shift; return map $_->genotype1_id, $self->phenotype_comparison_organism_id } +sub phenotype_comparison_phenotype1s { my $self = shift; return map $_->phenotype1_id, $self->phenotype_comparison_organism_id } @@ -8779,7 +8887,7 @@ -sub phenotype_comparison_phenotype1s { my $self = shift; return map $_->phenotype1_id, $self->phenotype_comparison_organism_id } +sub phenotype_comparison_genotype1s { my $self = shift; return map $_->genotype1_id, $self->phenotype_comparison_organism_id } @@ -8990,24 +9098,24 @@ + sub nd_protocol_reagent_reagents { return shift->nd_protocol_reagent_reagent_id } - - + - sub nd_protocol_reagent_reagents { return shift->nd_protocol_reagent_reagent_id } - + + # one to many to one # one2one # -sub cvterms { my $self = shift; return map $_->type_id, $self->nd_protocol_reagent_reagent_id } +sub nd_protocols { my $self = shift; return map $_->nd_protocol_id, $self->nd_protocol_reagent_reagent_id } -sub nd_protocols { my $self = shift; return map $_->nd_protocol_id, $self->nd_protocol_reagent_reagent_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->nd_protocol_reagent_reagent_id } # one to many to many @@ -9240,11 +9348,11 @@ # one2one # -sub cvterms { my $self = shift; return map $_->type_id, $self->studyprop_feature_studyprop_id } +sub features { my $self = shift; return map $_->feature_id, $self->studyprop_feature_studyprop_id } -sub features { my $self = shift; return map $_->feature_id, $self->studyprop_feature_studyprop_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->studyprop_feature_studyprop_id } # one to many to many @@ -9462,7 +9570,7 @@ # -sub phylonode_dbxref_phylonodes { return shift->phylonode_dbxref_phylonode_id } +sub phylonode_organism_phylonodes { return shift->phylonode_organism_phylonode_id } @@ -9472,14 +9580,14 @@ -sub phylonode_organism_phylonodes { return shift->phylonode_organism_phylonode_id } +sub phylonode_dbxref_phylonodes { return shift->phylonode_dbxref_phylonode_id } # one to many to one # one2one # -sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->phylonode_dbxref_phylonode_id } +sub organisms { my $self = shift; return map $_->organism_id, $self->phylonode_organism_phylonode_id } @@ -9487,7 +9595,7 @@ -sub organisms { my $self = shift; return map $_->organism_id, $self->phylonode_organism_phylonode_id } +sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->phylonode_dbxref_phylonode_id } # one to many to many @@ -9887,7 +9995,7 @@ # -sub feature_expression_expressions { return shift->feature_expression_expression_id } +sub expression_image_expressions { return shift->expression_image_expression_id } @@ -9897,7 +10005,7 @@ -sub expression_image_expressions { return shift->expression_image_expression_id } +sub feature_expression_expressions { return shift->feature_expression_expression_id } @@ -9909,15 +10017,15 @@ # one2one # -sub pubs { my $self = shift; return map $_->pub_id, $self->feature_expression_expression_id } +sub eimages { my $self = shift; return map $_->eimage_id, $self->expression_image_expression_id } -sub features { my $self = shift; return map $_->feature_id, $self->feature_expression_expression_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->feature_expression_expression_id } -sub eimages { my $self = shift; return map $_->eimage_id, $self->expression_image_expression_id } +sub features { my $self = shift; return map $_->feature_id, $self->feature_expression_expression_id } @@ -10607,6 +10715,7 @@ # Has A # + # @@ -10618,6 +10727,11 @@ sub cvtermpaths { return shift->cvtermpath_cv_id } +Bio::Chado::CDBI::Cv->has_many('cvprop_cv_id', 'Bio::Chado::CDBI::Cvprop' => 'cv_id'); + + +sub cvprops { return shift->cvprop_cv_id } + Bio::Chado::CDBI::Cv->has_many('cvterm_cv_id', 'Bio::Chado::CDBI::Cvterm' => 'cv_id'); @@ -10763,6 +10877,11 @@ # +sub library_feature_librarys { return shift->library_feature_library_id } + + + + sub library_cvterm_librarys { return shift->library_cvterm_library_id } @@ -10773,7 +10892,7 @@ -sub library_pub_librarys { return shift->library_pub_library_id } +sub cell_line_library_librarys { return shift->cell_line_library_library_id } @@ -10783,19 +10902,14 @@ -sub cell_line_library_librarys { return shift->cell_line_library_library_id } +sub library_pub_librarys { return shift->library_pub_library_id } - - -sub library_feature_librarys { return shift->library_feature_library_id } - - # one to many to one # one2one # -sub cvterms { my $self = shift; return map $_->cvterm_id, $self->library_cvterm_library_id } +sub features { my $self = shift; return map $_->feature_id, $self->library_feature_library_id } @@ -10803,19 +10917,19 @@ -sub pubs { my $self = shift; return map $_->pub_id, $self->library_pub_library_id } +sub cvterms { my $self = shift; return map $_->cvterm_id, $self->library_cvterm_library_id } -sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_library_library_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_library_library_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_library_library_id } +sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_library_library_id } -sub features { my $self = shift; return map $_->feature_id, $self->library_feature_library_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->library_pub_library_id } # one to many to many @@ -10934,7 +11048,10 @@ -sub project_contact_contacts { return shift->project_contact_contact_id } +sub contact_relationship_subjects { return shift->contact_relationship_subject_id } + + +sub contact_relationship_objects { return shift->contact_relationship_object_id } @@ -10944,22 +11061,19 @@ -sub contact_relationship_subjects { return shift->contact_relationship_subject_id } - - -sub contact_relationship_objects { return shift->contact_relationship_object_id } +sub project_contact_contacts { return shift->project_contact_contact_id } # one to many to one + # one2one # -sub projects { my $self = shift; return map $_->project_id, $self->project_contact_contact_id } +sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_contact_contact_id } -sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_contact_contact_id } +sub projects { my $self = shift; return map $_->project_id, $self->project_contact_contact_id } - # one to many to many @@ -10968,8 +11082,6 @@ #many to many to one - - # many2one # @@ -10979,6 +11091,8 @@ sub contact_relationship_object_types { my $self = shift; return map $_->type_id, $self->contact_relationship_object_id } + + #many to many to many @@ -11304,9 +11418,9 @@ sub Bio::Chado::CDBI::Nd_Geolocationprop::nd_geolocation { return shift->nd_geolocation_id } -Bio::Chado::CDBI::Nd_Geolocationprop->has_a(cvterm_id => 'Bio::Chado::CDBI::Cvterm'); +Bio::Chado::CDBI::Nd_Geolocationprop->has_a(type_id => 'Bio::Chado::CDBI::Cvterm'); -sub Bio::Chado::CDBI::Nd_Geolocationprop::cvterm { return shift->cvterm_id } +sub Bio::Chado::CDBI::Nd_Geolocationprop::cvterm { return shift->type_id } # @@ -11355,9 +11469,9 @@ sub Bio::Chado::CDBI::Projectprop::project { return shift->project_id } -Bio::Chado::CDBI::Projectprop->has_a(cvterm_id => 'Bio::Chado::CDBI::Cvterm'); +Bio::Chado::CDBI::Projectprop->has_a(type_id => 'Bio::Chado::CDBI::Cvterm'); -sub Bio::Chado::CDBI::Projectprop::cvterm { return shift->cvterm_id } +sub Bio::Chado::CDBI::Projectprop::cvterm { return shift->type_id } # @@ -11406,9 +11520,9 @@ sub Bio::Chado::CDBI::Nd_Experimentprop::nd_experiment { return shift->nd_experiment_id } -Bio::Chado::CDBI::Nd_Experimentprop->has_a(cvterm_id => 'Bio::Chado::CDBI::Cvterm'); +Bio::Chado::CDBI::Nd_Experimentprop->has_a(type_id => 'Bio::Chado::CDBI::Cvterm'); -sub Bio::Chado::CDBI::Nd_Experimentprop::cvterm { return shift->cvterm_id } +sub Bio::Chado::CDBI::Nd_Experimentprop::cvterm { return shift->type_id } # @@ -11825,6 +11939,8 @@ + + Bio::Chado::CDBI::Cvterm->has_a(cv_id => 'Bio::Chado::CDBI::Cv'); @@ -11941,11 +12057,16 @@ sub protocols { return shift->protocol_type_id } -Bio::Chado::CDBI::Cvterm->has_many('nd_reagentprop_cvterm_id', 'Bio::Chado::CDBI::Nd_Reagentprop' => 'cvterm_id'); +Bio::Chado::CDBI::Cvterm->has_many('nd_reagentprop_type_id', 'Bio::Chado::CDBI::Nd_Reagentprop' => 'type_id'); -sub nd_reagentprops { return shift->nd_reagentprop_cvterm_id } +sub nd_reagentprops { return shift->nd_reagentprop_type_id } +Bio::Chado::CDBI::Cvterm->has_many('stock_dbxrefprop_type_id', 'Bio::Chado::CDBI::Stock_Dbxrefprop' => 'type_id'); + + +sub stock_dbxrefprops { return shift->stock_dbxrefprop_type_id } + Bio::Chado::CDBI::Cvterm->has_many('feature_type_id', 'Bio::Chado::CDBI::Feature' => 'type_id'); sub feature_types { return shift->feature_type_id } @@ -12013,10 +12134,10 @@ sub phylonode_relationships { return shift->phylonode_relationship_type_id } -Bio::Chado::CDBI::Cvterm->has_many('nd_protocolprop_cvterm_id', 'Bio::Chado::CDBI::Nd_Protocolprop' => 'cvterm_id'); +Bio::Chado::CDBI::Cvterm->has_many('nd_protocolprop_type_id', 'Bio::Chado::CDBI::Nd_Protocolprop' => 'type_id'); -sub nd_protocolprops { return shift->nd_protocolprop_cvterm_id } +sub nd_protocolprops { return shift->nd_protocolprop_type_id } Bio::Chado::CDBI::Cvterm->has_many('nd_protocol_reagent_type_id', 'Bio::Chado::CDBI::Nd_Protocol_Reagent' => 'type_id'); @@ -12057,6 +12178,11 @@ Bio::Chado::CDBI::Cvterm->has_many('pub_relationship_type_id', 'Bio::Chado::CDBI::Pub_Relationship' => 'type_id'); +Bio::Chado::CDBI::Cvterm->has_many('cvprop_type_id', 'Bio::Chado::CDBI::Cvprop' => 'type_id'); + + +sub cvprops { return shift->cvprop_type_id } + Bio::Chado::CDBI::Cvterm->has_many('studyfactor_type_id', 'Bio::Chado::CDBI::Studyfactor' => 'type_id'); @@ -12101,10 +12227,10 @@ sub expressionprops { return shift->expressionprop_type_id } -Bio::Chado::CDBI::Cvterm->has_many('nd_experiment_stockprop_cvterm_id', 'Bio::Chado::CDBI::Nd_Experiment_Stockprop' => 'cvterm_id'); +Bio::Chado::CDBI::Cvterm->has_many('nd_experiment_stockprop_type_id', 'Bio::Chado::CDBI::Nd_Experiment_Stockprop' => 'type_id'); -sub nd_experiment_stockprops { return shift->nd_experiment_stockprop_cvterm_id } +sub nd_experiment_stockprops { return shift->nd_experiment_stockprop_type_id } Bio::Chado::CDBI::Cvterm->has_many('acquisitionprop_type_id', 'Bio::Chado::CDBI::Acquisitionprop' => 'type_id'); @@ -12216,20 +12342,20 @@ Bio::Chado::CDBI::Cvterm->has_many('nd_reagent_relationship_type_id', 'Bio::Chado::CDBI::Nd_Reagent_Relationship' => 'type_id'); -Bio::Chado::CDBI::Cvterm->has_many('nd_geolocationprop_cvterm_id', 'Bio::Chado::CDBI::Nd_Geolocationprop' => 'cvterm_id'); +Bio::Chado::CDBI::Cvterm->has_many('nd_geolocationprop_type_id', 'Bio::Chado::CDBI::Nd_Geolocationprop' => 'type_id'); -sub nd_geolocationprops { return shift->nd_geolocationprop_cvterm_id } +sub nd_geolocationprops { return shift->nd_geolocationprop_type_id } -Bio::Chado::CDBI::Cvterm->has_many('projectprop_cvterm_id', 'Bio::Chado::CDBI::Projectprop' => 'cvterm_id'); +Bio::Chado::CDBI::Cvterm->has_many('projectprop_type_id', 'Bio::Chado::CDBI::Projectprop' => 'type_id'); -sub projectprops { return shift->projectprop_cvterm_id } +sub projectprops { return shift->projectprop_type_id } -Bio::Chado::CDBI::Cvterm->has_many('nd_experimentprop_cvterm_id', 'Bio::Chado::CDBI::Nd_Experimentprop' => 'cvterm_id'); +Bio::Chado::CDBI::Cvterm->has_many('nd_experimentprop_type_id', 'Bio::Chado::CDBI::Nd_Experimentprop' => 'type_id'); -sub nd_experimentprops { return shift->nd_experimentprop_cvterm_id } +sub nd_experimentprops { return shift->nd_experimentprop_type_id } Bio::Chado::CDBI::Cvterm->has_many('phenotype_cvterm_cvterm_id', 'Bio::Chado::CDBI::Phenotype_Cvterm' => 'cvterm_id'); @@ -12288,125 +12414,133 @@ -sub pub_relationship_types { return shift->pub_relationship_type_id } +sub nd_reagent_relationship_types { return shift->nd_reagent_relationship_type_id } +sub studyprop_feature_types { return shift->studyprop_feature_type_id } + + -sub nd_reagent_relationship_types { return shift->nd_reagent_relationship_type_id } + +sub studyprop_feature_types { return shift->studyprop_feature_type_id } -sub library_cvterm_cvterms { return shift->library_cvterm_cvterm_id } + +sub element_types { return shift->element_type_id } + + + +sub element_types { return shift->element_type_id } -sub library_cvterm_cvterms { return shift->library_cvterm_cvterm_id } +sub element_types { return shift->element_type_id } -sub phenstatement_types { return shift->phenstatement_type_id } +sub contact_relationship_types { return shift->contact_relationship_type_id } + -sub phenstatement_types { return shift->phenstatement_type_id } +sub nd_experiment_types { return shift->nd_experiment_type_id } -sub phenstatement_types { return shift->phenstatement_type_id } - - - -sub phenstatement_types { return shift->phenstatement_type_id } +sub project_relationship_types { return shift->project_relationship_type_id } -sub studyprop_feature_types { return shift->studyprop_feature_type_id } +sub nd_protocol_reagent_types { return shift->nd_protocol_reagent_type_id } -sub studyprop_feature_types { return shift->studyprop_feature_type_id } +sub nd_protocol_reagent_types { return shift->nd_protocol_reagent_type_id } -sub stock_cvterm_cvterms { return shift->stock_cvterm_cvterm_id } +sub library_cvterm_cvterms { return shift->library_cvterm_cvterm_id } -sub stock_cvterm_cvterms { return shift->stock_cvterm_cvterm_id } +sub library_cvterm_cvterms { return shift->library_cvterm_cvterm_id } - -sub cell_line_relationship_types { return shift->cell_line_relationship_type_id } +sub nd_experiment_stock_types { return shift->nd_experiment_stock_type_id } -sub cvterm_relationship_types { return shift->cvterm_relationship_type_id } - -sub cvterm_relationship_subjects { return shift->cvterm_relationship_subject_id } - - -sub cvterm_relationship_objects { return shift->cvterm_relationship_object_id } +sub nd_experiment_stock_types { return shift->nd_experiment_stock_type_id } -sub nd_experiment_stock_types { return shift->nd_experiment_stock_type_id } + +sub pub_relationship_types { return shift->pub_relationship_type_id } -sub nd_experiment_stock_types { return shift->nd_experiment_stock_type_id } + +sub cell_line_relationship_types { return shift->cell_line_relationship_type_id } -sub quantification_relationship_types { return shift->quantification_relationship_type_id } +sub biomaterial_relationship_types { return shift->biomaterial_relationship_type_id } - -sub nd_protocol_reagent_types { return shift->nd_protocol_reagent_type_id } +sub phenstatement_types { return shift->phenstatement_type_id } + + - -sub nd_protocol_reagent_types { return shift->nd_protocol_reagent_type_id } +sub phenstatement_types { return shift->phenstatement_type_id } -sub nd_experiment_types { return shift->nd_experiment_type_id } +sub phenstatement_types { return shift->phenstatement_type_id } -sub element_types { return shift->element_type_id } +sub phenstatement_types { return shift->phenstatement_type_id } -sub element_types { return shift->element_type_id } + +sub quantification_relationship_types { return shift->quantification_relationship_type_id } +sub cvterm_relationship_types { return shift->cvterm_relationship_type_id } + -sub element_types { return shift->element_type_id } +sub cvterm_relationship_subjects { return shift->cvterm_relationship_subject_id } + + +sub cvterm_relationship_objects { return shift->cvterm_relationship_object_id } @@ -12416,106 +12550,98 @@ - -sub project_relationship_types { return shift->project_relationship_type_id } +sub stock_cvterm_cvterms { return shift->stock_cvterm_cvterm_id } -sub contact_relationship_types { return shift->contact_relationship_type_id } +sub stock_cvterm_cvterms { return shift->stock_cvterm_cvterm_id } - - - - -sub biomaterial_relationship_types { return shift->biomaterial_relationship_type_id } - - # one to many to one - # one2one # -sub pubs { my $self = shift; return map $_->pub_id, $self->library_cvterm_cvterm_id } +sub features { my $self = shift; return map $_->feature_id, $self->studyprop_feature_type_id } -sub librarys { my $self = shift; return map $_->library_id, $self->library_cvterm_cvterm_id } +sub studyprops { my $self = shift; return map $_->studyprop_id, $self->studyprop_feature_type_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->phenstatement_type_id } +sub features { my $self = shift; return map $_->feature_id, $self->element_type_id } -sub environments { my $self = shift; return map $_->environment_id, $self->phenstatement_type_id } +sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->element_type_id } -sub genotypes { my $self = shift; return map $_->genotype_id, $self->phenstatement_type_id } +sub arraydesigns { my $self = shift; return map $_->arraydesign_id, $self->element_type_id } + -sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_type_id } +sub nd_geolocations { my $self = shift; return map $_->nd_geolocation_id, $self->nd_experiment_type_id } + -sub studyprops { my $self = shift; return map $_->studyprop_id, $self->studyprop_feature_type_id } +sub nd_protocols { my $self = shift; return map $_->nd_protocol_id, $self->nd_protocol_reagent_type_id } -sub features { my $self = shift; return map $_->feature_id, $self->studyprop_feature_type_id } +sub nd_reagents { my $self = shift; return map $_->reagent_id, $self->nd_protocol_reagent_type_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->stock_cvterm_cvterm_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->library_cvterm_cvterm_id } -sub stocks { my $self = shift; return map $_->stock_id, $self->stock_cvterm_cvterm_id } +sub librarys { my $self = shift; return map $_->library_id, $self->library_cvterm_cvterm_id } - -sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_stock_type_id } +sub stocks { my $self = shift; return map $_->stock_id, $self->nd_experiment_stock_type_id } -sub stocks { my $self = shift; return map $_->stock_id, $self->nd_experiment_stock_type_id } +sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_stock_type_id } + + -sub nd_reagents { my $self = shift; return map $_->reagent_id, $self->nd_protocol_reagent_type_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->phenstatement_type_id } -sub nd_protocols { my $self = shift; return map $_->nd_protocol_id, $self->nd_protocol_reagent_type_id } +sub environments { my $self = shift; return map $_->environment_id, $self->phenstatement_type_id } -sub nd_geolocations { my $self = shift; return map $_->nd_geolocation_id, $self->nd_experiment_type_id } +sub phenotypes { my $self = shift; return... [truncated message content] |
From: <rb...@us...> - 2010-11-15 18:21:59
|
Revision: 24160 http://gmod.svn.sourceforge.net/gmod/?rev=24160&view=rev Author: rbuels Date: 2010-11-15 18:21:45 +0000 (Mon, 15 Nov 2010) Log Message: ----------- remove old log4perl installation from the build process, finally making the build run successfully as non-root Modified Paths: -------------- schema/trunk/chado/Makefile.PL Removed Paths: ------------- schema/trunk/chado/install_util/log4perl.conf.PLS Modified: schema/trunk/chado/Makefile.PL =================================================================== --- schema/trunk/chado/Makefile.PL 2010-11-15 01:10:39 UTC (rev 24159) +++ schema/trunk/chado/Makefile.PL 2010-11-15 18:21:45 UTC (rev 24160) @@ -515,7 +515,6 @@ 'XML::Simple' => 2.09, 'XML::Twig' => 0, 'Bio::Chado::Schema'=> 0, #can this load without a db? probably - 'Log::Log4perl' => 0.39, 'DBIx::DBStag' => 0.11, 'GO::Parser' => 0, 'Module::Load' => 0.16, @@ -530,7 +529,6 @@ 'load/bin/bulk_load_gff3.PLS' => 'load/bin/gmod_bulk_load_gff3.pl', 'install_util/conf_install.PLS' => 'install_util/conf_install.pl', 'install_util/src_install.PLS' => 'install_util/src_install.pl', - 'install_util/log4perl.conf.PLS' => 'install_util/log4perl.conf.pl', }, EXE_FILES => \@exe_files, ($] >= 5.005 ? ## Add these new keywords supported since 5.005 @@ -556,7 +554,7 @@ sub MY::install { package MY; my $inherited = shift->SUPER::install(@_); - $inherited =~ s/doc_install/doc_install conf_install src_install log4perl.conf/; + $inherited =~ s/doc_install/doc_install conf_install src_install/; $inherited; } @@ -582,9 +580,6 @@ src_install :: \$(PERL) \"$working_dir/install_util/src_install.pl\" '$root' -log4perl.conf :: - \$(PERL) \"$working_dir/install_util/log4perl.conf.pl\" '$root' - #cvtermpath :: # $working_dir/bin/make_cvtermpath.sh Deleted: schema/trunk/chado/install_util/log4perl.conf.PLS =================================================================== --- schema/trunk/chado/install_util/log4perl.conf.PLS 2010-11-15 01:10:39 UTC (rev 24159) +++ schema/trunk/chado/install_util/log4perl.conf.PLS 2010-11-15 18:21:45 UTC (rev 24160) @@ -1,83 +0,0 @@ -#!perl -use Config; -use File::Basename qw(&basename &dirname); -use Cwd; - -$origdir = cwd; -chdir dirname($0); -$file = basename($0, '.PL','.PLS'); -$file .= $^O eq 'VMS' ? '.com' : '.pl'; - -open OUT,">$file" or die "Can't create $file: $!"; - -print "Extracting $file (with variable substitutions)\n"; - -print OUT "$Config{startperl}\n"; - -print OUT <<'!NO!SUBS!'; -use strict; -use Cwd; -use FindBin '$Bin'; - -foreach (@ARGV) { - $_ =~ s/^\'(.*)\'$/$1/; -} - -my %options = map {split /=/} @ARGV; -my $gmod_root = $options{GMOD_ROOT}; -my $log_dir = "$gmod_root/logs"; - -if (! (-e $log_dir)) { - mkdir($log_dir, 0777) or die "unable to make $log_dir directory"; -} - -my $conf_text = qq( -log4perl.logger.SQL.Translator.Producer.Turnkey = DEBUG, Producer_Turnkey -log4perl.appender.Producer_Turnkey = Log::Log4perl::Appender::File -log4perl.appender.Producer_Turnkey.filename = $log_dir/debug_log -log4perl.appender.Producer_Turnkey.layout = Log::Log4perl::Layout::PatternLayout -log4perl.appender.Producer_Turnkey.layout.ConversionPattern =%c - [%d{HH:mm}] %M() in file .../%F{2} (line %L) says: %m%n - -log4perl.logger.Turnkey.Request = DEBUG, Turnkey_Request -log4perl.appender.Turnkey_Request = Log::Log4perl::Appender::File -log4perl.appender.Turnkey_Request.filename = $log_dir/debug_log -log4perl.appender.Turnkey_Request.layout = Log::Log4perl::Layout::PatternLayout -log4perl.appender.Turnkey_Request.layout.ConversionPattern =%c - [%d{HH:mm}] %M() in file .../%F{2} (line %L) says: %m%n - -log4perl.logger.Turnkey.Util.WebXML = DEBUG, Turnkey_Util_WebXML -log4perl.appender.Turnkey_Util_WebXML = Log::Log4perl::Appender::File -log4perl.appender.Turnkey_Util_WebXML.filename = $log_dir/debug_log -log4perl.appender.Turnkey_Util_WebXML.layout = Log::Log4perl::Layout::PatternLayout -log4perl.appender.Turnkey_Util_WebXML.layout.ConversionPattern =%c - [%d{HH:mm}] %M() in file .../%F{2} (line %L) says: %m%n - -log4perl.logger.Turnkey.Render = DEBUG, Turnkey_Render -log4perl.appender.Turnkey_Render = Log::Log4perl::Appender::File -log4perl.appender.Turnkey_Render.filename = $log_dir/debug_log -log4perl.appender.Turnkey_Render.layout = Log::Log4perl::Layout::PatternLayout -log4perl.appender.Turnkey_Render.layout.ConversionPattern =%c - [%d{HH:mm}] %M() in file .../%F{2} (line %L) says: %m%n -); - -if (-e '/etc/log4perl.conf') { - warn "\n\nYou appear to already have a log4perl.conf file in /etc\n"; - warn "Append the contents of ./log4perl.conf to your /etc/log4perl.conf.\n"; - - open OUT, ">log4perl.conf" or die "unable to open log4perl.conf for writing: $!\n"; - print OUT $conf_text; - close OUT; - chmod (0666, "log4perl.conf"); - -} else { - warn "Installing log4perl.conf in /etc...\n"; - open CONF, ">/etc/log4perl.conf" or die "unable to open /etc/log4perl.conf: $!\n"; - print CONF $conf_text; - close CONF; -} - -exit(0); - -!NO!SUBS! -close OUT or die "Can't close $file: $!"; -chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; -exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; -chdir $origdir; - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rb...@us...> - 2011-03-24 00:24:54
|
Revision: 24718 http://gmod.svn.sourceforge.net/gmod/?rev=24718&view=rev Author: rbuels Date: 2011-03-24 00:24:43 +0000 (Thu, 24 Mar 2011) Log Message: ----------- remove bin/cxgn dir, moving scripts in there into the root. no need for a subdir now, none of those scripts depend on CXGN::* modules any longer Modified Paths: -------------- schema/trunk/chado/Makefile.PL Added Paths: ----------- schema/trunk/chado/bin/gmod_bulk_load_pubmed.pl schema/trunk/chado/bin/gmod_load_cvterms.pl schema/trunk/chado/bin/gmod_make_cvtermpath.pl schema/trunk/chado/bin/load_ncbi_taxonomy.pl schema/trunk/chado/bin/load_taxonomy_cvterms.pl Removed Paths: ------------- schema/trunk/chado/bin/cxgn/gmod_bulk_load_pubmed.pl schema/trunk/chado/bin/cxgn/gmod_load_cvterms.pl schema/trunk/chado/bin/cxgn/gmod_make_cvtermpath.pl schema/trunk/chado/bin/cxgn/load_ncbi_taxonomy.pl schema/trunk/chado/bin/cxgn/load_taxonomy_cvterms.pl Modified: schema/trunk/chado/Makefile.PL =================================================================== --- schema/trunk/chado/Makefile.PL 2011-03-23 23:10:49 UTC (rev 24717) +++ schema/trunk/chado/Makefile.PL 2011-03-24 00:24:43 UTC (rev 24718) @@ -485,9 +485,9 @@ 'bin/gmod_extract_dbxref_from_gff.pl', 'bin/gmod_gff3_preprocessor.pl', 'bin/gmod_make_gff_from_dbxref.pl', - 'bin/cxgn/gmod_load_cvterms.pl', - 'bin/cxgn/gmod_bulk_load_pubmed.pl', - 'bin/cxgn/gmod_make_cvtermpath.pl', + 'bin/gmod_load_cvterms.pl', + 'bin/gmod_bulk_load_pubmed.pl', + 'bin/gmod_make_cvtermpath.pl', # 'bin/gmod_bulkfiles.pl', # 'bin/gmod_gff2biomart5.pl', ); Deleted: schema/trunk/chado/bin/cxgn/gmod_bulk_load_pubmed.pl =================================================================== --- schema/trunk/chado/bin/cxgn/gmod_bulk_load_pubmed.pl 2011-03-23 23:10:49 UTC (rev 24717) +++ schema/trunk/chado/bin/cxgn/gmod_bulk_load_pubmed.pl 2011-03-24 00:24:43 UTC (rev 24718) @@ -1,485 +0,0 @@ - -=head1 NAME - -gmod_bulk_load_pubmed.pl - -=head1 DESCRIPTION - - Usage: perl gmod_bulk_load_pubmed.pl -H [dbhost] -D [dbname] [-vt] -i file - - -parameters - -=over 6 - -=item -H - -hostname for database - -=item -D - -database name - -=item -i - -input file [required] - -=item -v - -verbose output - -=item -t - -trial mode. Do not perform any store operations at all. - -=item -g - -GMOD database profile name (can provide host and DB name) Default: 'default' - -=back - -=head2 If not using a GMOD database profile (option -g) then you must provide the following parameters - -=over 3 - -=item -u - -user name - -=item -d - -database driver name (i.e. 'Pg' for postgres) - -=item -p - -password for youe user to connect to the database - - -=back - -The script stores pubmed entries in the database. -Existing ones are ignored. -Input file should contain a list of pubmed ids. Then a new Publication object (Bio::Chado::Schema::Pub::Pub) with accession= PMID, -the publication specs are fetched from Entrez (using eUtils) which sets the different fields in the Publication object. When the publication is stored, a new dbxref is stored first (see Chado General module) - -=head2 This script works with Chado schema and accesse the following tables: - -=over 5 - -=item pub - -=item pubauthor - -=item pubprop - -=item dbxref - -=item pub_dbxref - - -=back - - -=head1 AUTHOR - -Naama Menda <nm...@co...> - -=head1 VERSION AND DATE - -Version 1.1, April 2010. - -=cut - - -#! /usr/bin/perl -use strict; - - -use Bio::GMOD::Config; -use Bio::GMOD::DB::Config; - -use Bio::Chado::Schema; -use XML::Twig; -use LWP::Simple qw/ get /; - -use Getopt::Std; - -our ($opt_H, $opt_D, $opt_v, $opt_t, $opt_i, $opt_g, $opt_p, $opt_d, $opt_u); - -getopts('H:D:i:p:g:p:d:u:tv'); - -our $publication; - - -my $dbhost = $opt_H; -my $dbname = $opt_D; -my $infile = $opt_i; -my $pass = $opt_p; -my $driver = $opt_d; -my $user = $opt_u; - -my $DBPROFILE = $opt_g ; - -print "H= $opt_H, D= $opt_D, u=$opt_u, d=$opt_d, v=$opt_v, t=$opt_t, i=$opt_i \n"; - -my $port; -my ($dbh, $schema); - -if ($opt_g) { - my $DBPROFILE = $opt_g; - $DBPROFILE ||= 'default'; - my $gmod_conf = Bio::GMOD::Config->new() ; - my $db_conf = Bio::GMOD::DB::Config->new( $gmod_conf, $DBPROFILE ) ; - - $dbhost ||= $db_conf->host(); - $dbname ||= $db_conf->name(); - $driver = $db_conf->driver(); - - - $port= $db_conf->port(); - - $user= $db_conf->user(); - $pass= $db_conf->password(); -} - -if (!$dbhost && !$dbname) { die "Need -D dbname and -H hostname arguments.\n"; } -if (!$driver) { die "Need -d (dsn) driver, or provide one in -g gmod_conf\n"; } -if (!$user) { die "Need -u user_name, or provide one in -g gmod_conf\n"; } -#if (!$pass) { die "Need -p password, or provide one in -g gmod_conf\n"; } - -my $dsn = "dbi:$driver:dbname=$dbname"; -$dsn .= ";host=$dbhost"; -$dsn .= ";port=$port"; - -$schema= Bio::Chado::Schema->connect($dsn, $user, $pass||'', { AutoCommit=>0 }); - -$dbh=$schema->storage->dbh(); - -if (!$schema || !$dbh) { die "No schema or dbh is avaiable! \n"; } - -print STDOUT "Connected to database $dbname on host $dbhost.\n"; -##################################################################################################### - -my $sth; - -my %seq = ( - db => 'db_db_id_seq', - dbxref => 'dbxref_dbxref_id_seq', - pub => 'pub_pub_id_seq', - pub_dbxref => 'pub_dbxref_pub_dbxref_id_seq', - pubauthor => 'pubauthor_pubauthor_id_seq', - pubprop => 'pubprop_pubprop_id_seq', - cv => 'cv_cv_id_seq', - cvterm => 'cvterm_cvterm_id_seq', - ); - -open (INFILE, "<$infile") || die "can't open file $infile"; # -open (ERR, ">$infile.err") || die "Can't open the error ($infile.err) file for writing.\n"; -my $exists_count=0; -my $pubmed_count=0; - -my %maxval=(); - -eval { - - #Fetch last database ids of relevant tables for resetting in case of rollback - - foreach my $key( keys %seq) { - my $id_column= $key . "_id"; - my $table = $key; - my $query = "SELECT max($id_column) FROM $table"; - $sth=$dbh->prepare($query); - $sth->execute(); - my ($next) = $sth->fetchrow_array(); - $maxval{$key}= $next; - } - - #db name for pubmed ids - my $db= $schema->resultset("General::Db")->find_or_create( - { name => 'PMID' } ); - my $db_id = $db->get_column('db_id'); - - #cvterm_name for 'journal' . Currently this software does not support other types. All PubMed publications are stored with this default 'journal' type_id - my $journal_cvterm = $schema->resultset('Cv::Cvterm')->create_with( - {name=>'journal', cv=>'publication'}); - - while (my $line = <INFILE>) { - - $publication = undef; - - chomp $line; - my $pmid; - if ( $line=~ m/(\[PMID: )(\d+)(.*)/ ) { - $pmid= $2; - }else { $pmid=$line;} - if (!$pmid) { next(); } - - #add a dbxref - my $dbxref = $schema->resultset("General::Dbxref")->find_or_create( - { accession => $pmid, - db_id => $db_id, - }); - - ## - # new Bio::Chado::Schema::Pub::Pub object - my $pub_dbxref = $dbxref->find_related ('pub_dbxrefs', {}, { key=> 'pub_dbxref_c1' }, ); - $publication= $pub_dbxref->find_related('pub', {}, { key=> 'pub_c1'}, ) if $pub_dbxref; - - if(!($publication)) { #publication does not exist in our database - $pubmed_count++; - $publication = $schema->resultset('Pub::Pub')->new( {} ) ; - - my $message= fetch_pubmed($pmid); - - if ($message) { message($message,1); } - print STDOUT "storing new publication. pubmed id = $pmid\n"; - #### - #extract the abstract and uniquename assigned in Pubmed.pm - my $abstract = $publication->uniquename(); - print STDOUT "The abstract is $abstract \n\n\n"; - my (@authors) = split /-----/ , $publication->title(); - my $title = shift(@authors); - print STDOUT "The title is $title\n\n"; - $publication->title($title) ; - - - #remove the abstract from the uniquename field - $publication->set_column(uniquename => $pmid . ":" . $title ) ; - $publication->type_id( $journal_cvterm->cvterm_id() ); - - #store the publication in the pub table - $publication->insert(); - - #store a pubprop for the abstract - # - my $pubprop = create_pubprops($publication, { 'abstract'=>$abstract }, { autocreate => 1 } ); - - ## Add pub_dbxref - $publication->find_or_create_related('pub_dbxrefs' , - { dbxref_id => $dbxref->dbxref_id } ); - ## - - ##Add the authors - my $rank =1; - foreach (@authors) { - my ($surname, $givennames)= split /\|/, $_; - print STDOUT "Author: Surname=$surname, givennames = $givennames \n"; - - $surname =~ s/^\s+|\s+$//g; - $givennames =~ s/^\s+|\s+$//g; - $publication->find_or_create_related( 'pubauthors' , - { - surname => $surname, - givennames => $givennames, - rank => $rank++, - } - ); - } - - #publication exists, do nothing - }else { - $exists_count++; - print STDOUT "Publication $pmid is already stored in the database. Skipping..\n"; - } - } -}; - - -if($@) { - print $@; - print"Failed; rolling back.\n"; - - foreach my $key ( keys %seq ) { - my $value= $seq{$key}; - my $maxvalue= $maxval{$key} || 0; - if ($maxvalue) { $dbh->do("SELECT setval ('$value', $maxvalue, true)") ; } - else { $dbh->do("SELECT setval ('$value', 1, false)"); } - } - $dbh->rollback(); -}else{ - print"Succeeded.\n"; - print "Inserted $pubmed_count new publications!\n"; - print "$exists_count publication already exist in the database\n"; - - if($opt_t) { - print STDOUT "Rolling back!\n"; - foreach my $key ( keys %seq ) { - my $value= $seq{$key}; - my $maxvalue= $maxval{$key} || 0; - - if ($maxvalue) { $dbh->do("SELECT setval ('$value', $maxvalue, true)") ; } - else { $dbh->do("SELECT setval ('$value', 1, false)"); } - } - $dbh->rollback(); - }else { - print STDOUT "Committing...\n"; - $dbh->commit(); - } -} - -close ERR; -close INFILE; - - -sub message { - my $message=shift; - my $err=shift; - if ($opt_v) { - print STDOUT $message. "\n"; - } - print ERR "$message \n" if $err; -} - - - -sub sanitize { - my $string = shift; - $string =~ s/^\s+//; #remove leading spaces - $string =~ s/\s+$//; #remove trailing spaces - return $string; -} - - -sub create_pubprops { - my ($self, $props, $opts) = @_; - - # process opts - $opts ||= {}; - $opts->{cv_name} = 'publication' - unless defined $opts->{cv_name}; - - return Bio::Chado::Schema::Util->create_properties - ( properties => $props, - options => $opts, - row => $self, - prop_relation_name => 'pubprops', - ); -} - -sub reset_sequences { - my %seq=@_; - my %maxval=@_; - #reset sequences - foreach my $key ( keys %seq ) { - my $value= $seq{$key}; - my $maxvalue= $maxval{$key} || 0; - #print STDERR "$key: $value, $maxvalue \n"; - if ($maxvalue) { $dbh->do("SELECT setval ('$value', $maxvalue, true)") ; } - else { $dbh->do("SELECT setval ('$value', 1, false)"); } - } -} - - -sub fetch_pubmed { - - my $accession=shift; - my $pub_xml = get("http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=$accession&rettype=xml&retmode=text"); - - eval { - my $twig=XML::Twig->new( - twig_roots => - { - 'Article/ArticleTitle' => \&title, - 'JournalIssue/Volume' => \&volume, - 'JournalIssue/Issue' => \&issue, - 'DateCompleted/Year' => \&pyear, - 'PubDate/Year' => \&pyear, - 'Pagination/MedlinePgn' => \&pages, - 'Journal/Title' => \&journal_name, - #'PublicationTypeList/PublicationType' => \&pub_type, - 'Abstract/AbstractText' => \&abstract, - Author => \&author, - }, - twig_handlers => - { }, - pretty_print => 'indented', # output will be nicely formatted - ); - - $twig->parse($pub_xml ); # build it - - }; - if($@) { - my $message= "Error in transaction or NCBI server seems to be down. Please check your input for accession $accession or try again later.\n $@"; - return $message; - }else { return undef ; } - -} - -########################################## -#Functions for parsing the XML -########################################## - -sub title { - - my ($twig, $elt)= @_; - $publication->title($elt->text) ; - $twig->purge; -} - - - -sub volume { - my ($twig, $elt)= @_; - $publication->volume($elt->text) ; - $twig->purge; -} - - -sub issue { - my ($twig, $elt)= @_; - $publication->issue($elt->text) ; - - $twig->purge; -} - - -sub pyear { - my ($twig, $elt)= @_; - my $pyear = $elt->text; - $publication->pyear($pyear); - - $twig->purge; -} - - -sub pages { - my ($twig, $elt)= @_; - $publication->pages($elt->text) ; - - $twig->purge; -} - - - -sub journal_name { - my ($twig, $elt)= @_; - $publication->series_name($elt->text) ; - - $twig->purge; -} - -sub abstract { - my ($twig, $elt)= @_; - $publication->uniquename($elt->text) ; - - $twig->purge -} - -sub author { - my ($twig, $elt)= @_; - - my $lastname=$elt->children_text('LastName'); - my $initials=$elt->children_text('Initials'); - #sometimes the firstname has no initials but full first name 'ForName'.. - - if (!$initials) { $initials=$elt->children_text('ForeName') || $elt->children_text('FirstName') ; } - - - my $author_data= $lastname ."|" . $initials ; - - #append the authors to the 'title' field. - #Then extract the list and store in pubprop - $publication->title($publication->title() . "-----" . $author_data) ; - - $twig->purge -} Deleted: schema/trunk/chado/bin/cxgn/gmod_load_cvterms.pl =================================================================== --- schema/trunk/chado/bin/cxgn/gmod_load_cvterms.pl 2011-03-23 23:10:49 UTC (rev 24717) +++ schema/trunk/chado/bin/cxgn/gmod_load_cvterms.pl 2011-03-24 00:24:43 UTC (rev 24718) @@ -1,783 +0,0 @@ -#!/usr/bin/env perl - -=head1 NAME - -load_cvterms.pl - -=head1 SYNOPSIS - -Usage: perl load_cvterms.pl -H dbhost -D dbname [-vdntuFo] file - -parameters - -=over 8 - -=item -g - -GMOD database profile name (can provide host, DB name, password, username, and driver) Default: 'default' - -=item -s - -database name for linking (must be in db table, e.g. GO ) - -=item -n - -controlled vocabulary name (e.g 'biological_process'). -optional. If not given, terms of all namespaces related with database name will be handled. - -=item -F - -File format. Can be obo or go_flat and others supported by -L<Bio::OntologyIO>. Default: obo - -=item -u - -update all the terms. Without -u, the terms in the database won't be updated to the contents of the file, in terms of definitions, etc. New terms will still be added. - -=item -v - -verbose output - -=item -o - -outfile for writing errors and verbose messages (optional) - -=item -t - -trial mode. Don't perform any store operations at all. -(trial mode cannot test inserting associated data for new terms) - -=back - - -The following options are required if not using GMOD profile - - -=over 5 - -=item -H - -hostname for database [required if -p isn't used] - -=item -D - -database name [required if -p isn't used] - -=item -p - -password (if you need to provide a password to connect to your db) - -=item -r - -username (if you need to provide a username to connect to your database) - - -=item -d - -driver name (e.g. 'Pg' for postgres). Driver name can be provided in gmod_config - -=back - - -The script parses the ontology in the file and the corresponding ontology in the database, if present. It compares which terms are new in the file compared to the database and inserts them, and compares all the relationships that are new and inserts them. It removes the relationships that were not specified in the file from the database. It never removes a term entry from the database. - -This script works with Chado schema (see gmod.org) and accesse the following tables: - -=over 9 - -=item db - -=item dbxref - -=item cv - -=item cvterm - -=item cvterm_relationship - -=item cvtermsynonym - -=item cvterm_dbxref - -=item cvtermprop - -=back - - - -Terms that are in the database but not in the file are set to is_obsolete=1. -All the terms that are present in the database are updated (if using -u option) to reflect the term definitions that are in the file. -New terms that are in the file but not in the database are stored. -The following data are associated with each term insert/update: - -=over 7 - -=item Term name - -=item Term definition - -=item Relationships with other terms - -=item Synonyms - -=item Secondary ids - -=item Definition dbxrefs - -=item Comments - -=back - - - -=head1 AUTHOR - -Lukas Mueller <la...@co...> - -Naama Menda <nm...@co...> - - -=head1 VERSION AND DATE - -Version 0.15, September 2010. - -=cut - - -use strict; - -use Getopt::Std; -use Pod::Usage; - -use Bio::OntologyIO; -use Bio::Ontology::OntologyI; - -use Bio::GMOD::Config; -use Bio::GMOD::DB::Config; - -use Bio::Chado::Schema; - -our ($opt_d, $opt_h, $opt_H, $opt_F, $opt_n, $opt_D, $opt_v, $opt_t, - $opt_u, $opt_o, $opt_p, $opt_r, $opt_g, $opt_s); - -getopts('F:d:H:o:n:vD:tp:us:r:g:') - or pod2usage(); - -my $dbhost = $opt_H; -my $dbname = $opt_D; -my $pass = $opt_p; -my $driver = $opt_d; -my $user = $opt_r; -my $verbose = $opt_v; - -my $DBPROFILE = $opt_g ; - -print "H= $opt_H, D= $opt_D, u=$opt_u, d=$opt_d, v=$opt_v, t=$opt_t \n" if $verbose; - -my $port = '5432'; - -if (!$opt_s) { die " Need -s db.name argument! (e.g. GO , PO, etc.\n " ; } # the database name that Dbxrefs should refer to - -if (!($opt_H and $opt_D) ) { - $DBPROFILE ||= 'default'; - my $gmod_conf = Bio::GMOD::Config->new() ; - my $db_conf = Bio::GMOD::DB::Config->new( $gmod_conf, $DBPROFILE ) ; - - $dbhost ||= $db_conf->host(); - $dbname ||= $db_conf->name(); - $driver ||= $db_conf->driver(); - - - $port= $db_conf->port() || '5432'; - - $user= $db_conf->user(); - $pass= $db_conf->password(); -} - -if (!$dbhost && !$dbname) { die "Need -D dbname and -H hostname arguments.\n"; } -if (!$driver) { die "Need -d (dsn) driver, or provide one in -g gmod_conf\n"; } -if (!$user) { die "Need -r user_name, or provide one in -g gmod_conf\n"; } - - -my $dsn = "dbi:$driver:dbname=$dbname"; -$dsn .= ";host=$dbhost"; -$dsn .= ";port=$port"; - -my $schema= Bio::Chado::Schema->connect($dsn, $user, $pass||'', { AutoCommit=>0 }); - -my $dbh=$schema->storage->dbh(); - -if (!$schema || !$dbh) { die "No schema or dbh is avaiable! \n"; } - -####################### - -my $error = 0; # keep track of input errors (in command line switches). - -if (!$opt_F) { $opt_F="obo"; } - -if ($opt_t) { - print STDERR "Trial mode - rolling back all changes at the end.\n"; -} -if ($opt_u) { print STDERR "This script will UPDATE cvterms stored in your database from the input file! \n"; } -else { print STDERR "WARNING: If your databse is already population with cvterms, not running in UPDATE mode (option -u) may cause database conflicts, such as violating unique constraints!\n"; } - -print STDERR "Default for -s: $opt_s (specifies the database names for Dbxref objects)\n"; - -print STDERR "Default for -F: File format set to $opt_F\n"; - -my $file = shift; - -if (!$file) { - print STDERR "A file is required as a command line argument.\n"; - $error=1; -} - - -die "Some required command lines parameters not set. Aborting.\n" if $error; - -if ($opt_o) { open (OUT, ">$opt_o") ||die "can't open error file $opt_o for writting.\n" ; } - - -message( "Connected to database $dbname on host $dbhost.\n", 1); - - -print STDERR "Parsing the ontology $file...\n"; -my $parser = Bio::OntologyIO->new( -file => $file, -format=>$opt_F ); -my $default_ont; - -my @onts = (); -while( my $ont = $parser->next_ontology() ) { - $default_ont = $ont if !$default_ont; - push @onts, $ont; -} -message("Default namespace is " . $default_ont->name . " \n" , 1); -my $default_cv= $schema->resultset('Cv::Cv')->find_or_create( { name => $default_ont->name } , { key => 'cv_c1' }, ); - -foreach my $new_ont(@onts) { - my $new_ont_name=$new_ont->name(); - message("....found namespace '$new_ont_name' \n", 1); - - if ($opt_n && ( $opt_n ne $new_ont_name) ) { - message ("$opt_n: skipping to next ontology..\n",1); - next (); - } - my $rel_cv; - #check if relationship ontology is already loaded: - if ($new_ont_name ne 'relationship') { - $rel_cv= $schema->resultset("Cv::Cv")->find_or_create( { name => 'relationship' } , { key => 'cv_c1' }, ); - my @rel= $schema->resultset("Cv::Cvterm")->search( - { cv_id => $rel_cv->get_column('cv_id'), - is_relationshiptype => 1, - }); - if (!@rel) { - warn "Relationship ontology must be loaded first!!\n" ; - exit(0); - } - } - ####add Typedef parsing to obo.pm!### - ####store a new cv if the ontology namespace does not exist - my $cv= $schema->resultset('Cv::Cv')->find_or_create( { name => $new_ont_name } , { key => 'cv_c1' }, ); - - print STDERR "cv_id = ".($cv->get_column('cv_id') )."\n"; - print STDERR "Updating an ontology in the database...\n"; - my $db_ont = $cv; - my $ontology_name=$db_ont->get_column('name'); - message("Ontology name: ".($db_ont->name())."\n", 1); - my %file_relationships = (); # relationships currently defined in the file - my %db_relationships = (); - - eval { - my $db = $schema->resultset("General::Db")->find_or_create( - { name => $opt_s }, { key => 'db_c1' }, ); - - print STDERR "Getting all the terms of the new ontology...\n"; - my (@all_file_terms) = $new_ont->get_all_terms(); - my (@all_file_predicate_terms) = $new_ont->get_predicate_terms(); - ###my (@all_file_typedefs) = $new_ont->get_all_typedefs(); - message( "***found ".(scalar(@all_file_predicate_terms))." predicate terms!.\n", 1); - message( "Retrieved ".(scalar(@all_file_terms))." terms.\n", 1); - - #look at all predecate terms (Typedefs) - my @all_db_predicate_terms= $db_ont->search_related('cvterms' , { is_relationshiptype => 1} ); - foreach my $t(@all_file_predicate_terms) { #look at predicate terms in file - my ($p_term) = $schema->resultset('Cv::Cvterm')->search( - { 'lower(name)' => { 'like' , lc( $t->name() ) }, - is_relationshiptype => 1, - }); - #maybe it's stored with another cv_id? - if ($p_term) { - message("predicate term '" .$t->name() . "' already exists with cv_id " . $p_term->get_column('cv_id') . "\n", 1); - }else { #the predicate term will be stored at the time of storing a term with that relationship, using the term's cv_id - - #this stores the relationship types under 'relationship' cv namespace - #terms defined as '[Typedef]' in the obo file should actually be stored as relationshiptype - #but with the current ontology cv namespace . - #To do this we need to add to the obo parser (Bio::OntologyIO::obo.pm) - #a 'get_typedefs' funciton - my $accession = $t->identifier() || $t->name(); - message("Predicate term $accession will be stored later if used as a relationship in an ontology term\n",1); - } - } - print STDERR "Getting all the terms of the current ontology...\n"; - - #a list of Bio::Chado::Schema::Cvterm objects - my @all_db_terms = $schema->resultset("Cv::Cvterm")->search( - { cv_id => $db_ont->get_column('cv_id'), - is_relationshiptype => 0, - })->all(); - print STDERR "Indexing terms and relationships...\n"; - my %file_index = (); # index of term objects in the db with accession as key - my %db_index = (); # this hash will be populated with accession => cvterm_object - my $db_namespace ; - foreach my $t (@all_file_terms) { - my ($prefix, $id) = split (/\:/, $t->identifier()); #=~ s/\w+\:(.*)/$1/g; - $db_namespace = $prefix if !$db_namespace; - $file_index{$id} = $t if ($db_namespace eq $prefix) ; - message("Found term in file : $prefix:$id\n", 1); - } - my $c_count = 0; # count of db terms - foreach my $t (@all_db_terms) { - $c_count++; - my ($id )= $t->search_related('dbxref')->first()->get_column('accession'); - $db_index{$id} = $t; - message("Found term in DB: $id\n", 1); - } - my %novel_terms = (); - my @removed_terms = (); - my @novel_relationships = (); - my @removed_relationships = (); - - print STDERR "Determining which terms are new...\n"; - - FILE_INDEX: foreach my $k (keys(%file_index)) { - if (!exists($db_index{$k})) { - if (!$file_index{$k}->name() ) { next FILE_INDEX; } #skip if term in file has no name. - #This happens in InterPro file - which is translated from xml to obo. - if ($opt_v) { print STDERR "Novel term: $k ".($file_index{$k}->name())."\n"; } - else { print STDERR "."; } - print OUT "Novel term: $k ".($file_index{$k}->name())."\n" if $opt_o; - $novel_terms{$k}=$file_index{$k}; - } - } - print STDERR "Determine which terms are not in the file anymore...\n - These terms will be set to obsolete in the database\n"; - foreach my $k (keys(%db_index)) { - if (!exists($file_index{$k})) { - my $name = $db_index{$k}->name(); #get the name in the database - message( "Term not in file: $name \n",1); - unless( $name =~ m/obsolete.*$opt_s:/ ) { - my $ob_name = $name . " (obsolete " . $opt_s . ":" . $name . ")" ; #add the 'obsolete' suffix - $db_index{$k}->set_column(name => $ob_name ); - message( "**modified name for $opt_s:$name - '$ob_name' \n " , 1); - } - $db_index{$k}->set_column(is_obsolete => 1 ); - $db_index{$k}->update(); - - print STDERR " obsoleted term $name!.\n"; - push @removed_terms, $db_index{$k}; - } - } - print STDERR "Inserting and updating terms...\n"; - - my $count = 0; - my $u_count=0; - if ($opt_u) { - UPDATE: foreach my $k (keys(%file_index)) { - $count++; - if (!exists($novel_terms{$k})) { - #update the term if run with -u option. - $u_count++; - message( "updating information for term $k...\n"); - if (!$file_index{$k} || !$db_index{$k} ) { - message ("SKIPPING term $k! No value found\n", 1); next UPDATE; - } - my $name = $file_index{$k}->name(); - $db_index{$k}->set_column(name => $name ); - $db_index{$k}->set_column( definition => $file_index{$k}->definition() ); - $db_index{$k}->set_column(is_obsolete => $file_index{$k}->is_obsolete() ); - - #changing the name of obsolete terms to "$name (obsolete $db:$accession)" - #to avoid violating the cvterm unique constaint (name, cv_id, is_obsolete) - if ($db_index{$k}->is_obsolete() ) { - unless( $name =~ m/obsolete.*$opt_s:$k/ ) { - my $ob_name = $name . " (obsolete " . $opt_s . ":" . $k . ")" ; - $db_index{$k}->set_column( name=>$ob_name ); - print STDERR "**modified name for $opt_s:$k - '$ob_name' version: " . $file_index{$k}->version() . " \n " ; - } - } - #a term might be updated to a name which already exists in the database, - #but would also be updated later on - my ($existing_name) = $schema->resultset("Cv::Cvterm")->search( - { - name => $name, - is_obsolete => $db_index{$k}->is_obsolete, - cv_id => $db_index{$k}->cv_id, - } )->single; - #if a term already exists, update it now from the file index - #to avoid violating the unique constraint - if ($existing_name && $file_index{$existing_name->dbxref->accession} ) { - my $existing_accession = $existing_name->dbxref->accession; - - #update here only if the existing accession is different than $k - if ( $existing_accession ne $k ) { - message("Updating term $existing_accession with name " . $file_index{$existing_accession}->name . "\n" , 1); - $db_index{$existing_accession}->update( - { - name => $file_index{$existing_accession}->name, - definition => $file_index{$existing_accession}->definition, - is_obsolete => $file_index{$existing_accession}->is_obsolete, - }); - } - } - # now we can update the original term without conflicts - message("UPDATING term $k with name " . $file_index{$k}->name . "\n" , 1); - $db_index{$k}->update(); - - #update dbxref version - if ( $file_index{$k}->version() ) { - my ($dbxref)=$db_index{$k}->search_related('dbxref'); - $dbxref->set_column(version => $file_index{$k}->version() ); - $dbxref->update(); - } - #add comment as a cvtermprop - my ($comment_cvterm) = $schema->resultset("Cv::Cvterm")->search( { name => 'comment'} ); - if ($file_index{$k}->comment() ) { - my $cvtermprop= $schema->resultset("Cv::Cvtermprop")->find_or_create( - { cvterm_id => $db_index{$k}->get_column('cvterm_id'), - type_id => $comment_cvterm->get_column('cvterm_id'), - value => $file_index{$k}->comment(), - }, - ); - } - ############################### - # deal with synonyms here... - my %file_synonyms = (); - foreach my $s ($file_index{$k}->get_synonyms()) { - $s=~ s/\s+$//; - $s =~ s/\\//g; - $file_synonyms{uc($s)}=1; - - message("...adding synonym '$s' to the database...\n"); - $db_index{$k}->add_synonym($s); - } - foreach my $s ($db_index{$k}->search_related('cvtermsynonyms')) { - my $s_name= $s->get_column('synonym'); - if (!exists($file_synonyms{uc($s_name)}) ) { - message( "Note: deleting synonym ' " . $s->synonym() . "' from cvterm ". $db_index{$k}->get_column('name') . "...\n",1); - $db_index{$k}->delete_synonym($s_name); - } - } - #deal with secondary ids (alt_id field). - # Stored in cvterm_dbxref with the field 'is_for_definition' = 0 - - #delete all cvterm dbxrefs before loading the new ones from the file - my @secondary_dbxrefs= $db_index{$k}->search_related('cvterm_dbxrefs'); - foreach (@secondary_dbxrefs) { $_->delete(); } - - my %file_secondary_ids = (); - foreach my $i ($file_index{$k}->get_secondary_ids()) { - $file_secondary_ids{uc($i)}=1; - message("adding secondary id $i to the database...\n"); - - $db_index{$k}->add_secondary_dbxref($i); - } - ######### - # Definition dbxrefs. get_dblinks gets the dbxref in the definition tag - # and all xref_analog tags. This will store in the database cvterm_dbxrefs with - #the field 'is_for_definition' = 1 - my %file_def_dbxrefs=(); - #store definition's dbxrefs in cvterm_dbxref - foreach my $dblink ($file_index{$k}->get_dbxrefs() ) { - my $def_dbxref = $dblink->database() . ':' . $dblink->primary_id(); - $file_def_dbxrefs{uc($def_dbxref)}=1; - message("adding definition dbxref $def_dbxref to cvterm_dbxref\n"); - $db_index{$k}->add_secondary_dbxref($def_dbxref, 1); - } - } - } - message("DONE UPDATING existing terms! \n",1); - } #finished updating existing terms.. - #now insert the new ones: - my $n_count=0; - foreach my $k (keys(%novel_terms)) { - $n_count++; - my $name = $novel_terms{$k}->name(); - my $version = $novel_terms{$k}->version(); - my $accession = numeric_id($novel_terms{$k}->identifier()); - message("Inserting novel term '$name' (accession = '$accession', version = '$version' ) \n"); - #write a special case for interpro domains - #those have accession IPR000xxxx - # - #There's a potential issue with updating cvterms which have been moved to another cv namespace. - #In such cases, a dbxref is found, but we cannot store a new cvterm with the same dbxref_id (see cvterm_c2). - # A new dbxref will be created to overcome this problem - my $new_term_dbxref = $schema->resultset("General::Dbxref")->find( - { db_id => $db->get_column('db_id'), - accession => $accession, - version => $version || '', - }, - { key => 'dbxref_c1' } , - ); - if ($new_term_dbxref) { $version = $version+1 ; } - - $new_term_dbxref = $schema->resultset("General::Dbxref")->create( - { db_id => $db->get_column('db_id'), - accession => $accession, - version => $version || '', - }, - { key => 'dbxref_c1' } , - ); - - if ($novel_terms{$k}->is_obsolete() == 1 ) { - unless( $name =~ m/obsolete.*$opt_s:$k/i ) { - my $ob_name = $name . " (obsolete " . $opt_s . ":" . $k . ")" ; - $name = $ob_name ; - print STDERR "**modified name for $opt_s:$k - '$ob_name' \n " ; - } - } - if (!$opt_t) { - my ($existing_term) = $schema->resultset("Cv::Cvterm")->search( - { cv_id =>$cv->cv_id(), - name => $name, - is_obsolete=> $novel_terms{$k}->is_obsolete(), - }); - if ($existing_term) { message("TERM $k has name $name, which also exists for term id " . $existing_term->cvterm_id . " with accession " . $existing_term->dbxref->accession . "\n\n",1); } - my $new_term= $schema->resultset("Cv::Cvterm")->create( - { cv_id =>$cv->cv_id(), - name => $name, - definition => $novel_terms{$k}->definition(), - dbxref_id => $new_term_dbxref-> dbxref_id(), - is_obsolete=> $novel_terms{$k}->is_obsolete(), - }); - - #changing the name of obsolete terms to "$name (obsolete $db:$accession)" - #to avoid violating the cvterm unique constaint (name, cv_id, is_obsolete) - - message("Storing term $k...name = " . $novel_terms{$k}->name() . "\n"); - - if ($count % 100==0) { print STDERR "."; } - my $comment = $novel_terms{$k}->comment(); - $new_term->create_cvtermprops( { comment => $comment } , { autocreate => 1 } ) if $comment; - #store synonyms in cvtermsynonym - foreach my $s ($novel_terms{$k}->get_synonyms() ) { - $s=~ s/\s+$//; - $s =~ s/\\//g; - message("...adding synonym '$s' to the database...\n"); - $new_term->add_synonym($s); #need to add a type_id to each synonym! - } - - foreach my $i ($novel_terms{$k}->get_secondary_ids()) { #store secondary ids in cvterm_dbxref - message("adding secondary dbxref '$i' to cvterm_dbxref\n"); - - $new_term->add_secondary_dbxref($i); - } - foreach my $r ($novel_terms{$k}->get_dbxrefs() ) { #store definition's dbxrefs in cvterm_dbxref - my $def_dbxref= $r->database() . ':' . $r->primary_id(); - message("adding definition dbxref $def_dbxref to cvterm_dbxref\n"); - $new_term->add_secondary_dbxref($def_dbxref, 1); - } - } - } - - ################################## - message ("Updated $u_count existing terms, inserted $n_count new terms!\n",1); - - print STDERR "Parsing out the relationships...\n"; - print STDERR "Looking at relationships in file.\n"; - - my $t_count = 0; # count of terms in the file - foreach my $t (@all_file_terms) { - $t_count++; - my $id = numeric_id($t->identifier()); - my @all_relationships = $new_ont->get_relationships($t); - message("Retrieved accession: $id\n"); - foreach my $r (@all_relationships) { - my $s = $r->subject_term(); - my $o = $r->object_term(); - my ($s_db_name, undef) = split (/\:/ , $s->identifier); - my ($o_db_name, undef) = split (/\:/, $o->identifier); - if ($s_db_name ne $o_db_name) { - print "*********************************************subject $s_db_name != object $o_db_name. Skipping!!\n"; - next(); - } - my $key = numeric_id($s->identifier())."-".numeric_id($o->identifier()); - message("Looking at relationship in file: $key\n" ); - if ($t_count % 100==0) { message("."); } - $file_relationships{$key} = $r; # create the hash entry for this relationship - } - } - print STDERR "\nLooking at relationships in database.\n"; - - # indexing the database relationships - foreach my $k (keys %db_index) { - ###foreach my $r ($db_ont->get_relationships($db_index{$k})) { - foreach my $r ($db_index{$k}->search_related('cvterm_relationship_subjects') ) { - if ($r) { - my ($s) = $r->search_related('subject'); - my ($o) = $r->search_related('object'); - #terms might have moved to a different cv namespace - if ($s->cv_id() eq $o->cv_id() ) { - my $key = numeric_id($s->search_related('dbxref')->first()->accession)."-".numeric_id($o->search_related('dbxref')->first()->accession); - message("Looking at relationship in db: $key\n"); - $db_relationships{$key}=$r; - } - } - } - } - print STDERR "Relationships not in the file...\n"; - - foreach my $k (keys(%db_relationships)) { - if (! (exists($file_relationships{$k}) && defined($file_relationships{$k})) ) { - push @removed_relationships, $k; - message("Deleted relationship: $k... \n",1); - - $db_relationships{$k}->delete(); - print STDERR "gone.\n"; - } - } - print STDERR "\n"; - ##################################### - my $r_count = 0; - RELATIONSHIP: foreach my $r (keys(%file_relationships)) { - $r_count++; - if (!exists($db_relationships{$r})) { - if ($opt_v) { print STDERR "Novel relationship: $r\n"; } - elsif ($r_count % 100 == 0) { print STDERR "."; } - print OUT "Novel relationship: $r\n" if $opt_o; - #### - #convert the Bio::Ontology::OBOTerm objects to Bio::Chado::Schema::Cv::Cvterm objects - my $subject_accession = $file_relationships{$r}->subject_term()->identifier(); - - my ($s_db, $s_acc) = split ':', $subject_accession; - my ($subject_dbxref)= $schema->resultset("Cv::Cvterm")->search()-> - search_related( - 'dbxref', - { accession => $s_acc, - db_id => $db->db_id(), - } )->single; - if (!$subject_dbxref ) { - message("dbxref does not exist for subject term '$s_acc'.Skipping..\n" ,1); - next RELATIONSHIP; - } - my ($subject_term)= $schema->resultset('Cv::Cvterm')->find( - { cv_id => $cv->cv_id(), - dbxref_id => $subject_dbxref->dbxref_id(), - }); - - if (!$subject_term ) { - message("cvterm does not exist for subject term '$subject_accession'.Skipping..\n" ,1); - next RELATIONSHIP; - } - my $object_accession = $file_relationships{$r}->object_term()->identifier(); - my ($o_db, $o_acc) = split ':', $object_accession; - my ($object_dbxref)= $schema->resultset("Cv::Cvterm")->search()-> - search_related( - 'dbxref', - { accession => $o_acc, - db_id => $db->db_id(), - } )->single; - - if (!$object_dbxref ) { - message("dbxref does not exist for object term $o_acc . SKIPPING!\n",1); - next RELATIONSHIP; - } - my ($object_term)= $schema->resultset('Cv::Cvterm')->find( - { cv_id => $cv->cv_id(), - dbxref_id => $object_dbxref->dbxref_id(), - }); - if (!$object_term ) { - message("cvterm does not exist for object term $object_accession . SKIPPING!\n",1); - next RELATIONSHIP; - } - ############################################ - push @novel_relationships, $r; - my $predicate_term_name = $file_relationships{$r}->predicate_term()->name(); - - my $predicate_term; - my ($rel_db)= $schema->resultset('General::Db')->search( { name => 'OBO_REL' } ); - ($predicate_term) = $schema->resultset('General::Dbxref')->search( - { 'lower(accession)' => { 'like' , lc($predicate_term_name) }, - db_id => $rel_db->db_id(), - })->search_related('cvterm') if $rel_db; - # this is not a relationship_ontology term - if (!$predicate_term) { - my ($predicate_dbxref) = $schema->resultset('General::Db')->search( { name => $opt_s } )->search_related('dbxrefs', { accession => $predicate_term_name }); - ($predicate_term) = $schema->resultset("Cv::Cvterm")->find( - { dbxref_id => $predicate_dbxref->dbxref_id } ) if $predicate_dbxref; - # cvterm has a relationshiptype term with the dbxref_id of $predicate_term_name - if ($predicate_term) { - die("predicate term $predicate_term_name (cvterm id = " . $predicate_term->cvterm_id . " is not stored as relationshiptype in your database!!\n") if $predicate_term->is_relationshiptype !=1 ; - # this happens when the predicate term is stored with the wrong cv - #(e.g. GO predicate terms should have the cv_id of the - # default namespace of the ontology (gene_ontology) - # and not of one of the 3 components ) - $predicate_term->update( { cv_id => $default_cv->cv_id } ) ; - } else { # no cvterm exists with this dbxref, create a new one - $predicate_term = $schema->resultset('Cv::Cvterm')->create_with( - { name => $predicate_term_name, - cv => $default_cv, - db => $opt_s, - dbxref => $predicate_term_name, - }); - $predicate_term->is_relationshiptype(1); - $predicate_term->update; - message("Stored new relationshiptype '" . $predicate_term_name . "'\n",1); - } - if (!$predicate_term) { - die "The predicate term $predicate_term_name does not exist in the database\n"; - } - } - if (!$opt_t) { - message("Storing relationship $r. type cv_id=" . $predicate_term->cv_id() ."\n" ,1); - my $new_rel = $schema->resultset('Cv::CvtermRelationship')->create( - { subject_id => $subject_term->cvterm_id(), - object_id => $object_term->cvterm_id(), - type_id => $predicate_term->cvterm_id(), - } - ); - } - } - } - message($ontology_name." : ". scalar(@novel_relationships)." novel relationships among ".(scalar(keys(%file_relationships)))." were found and stored.\n", 1); - }; - - if ($@ || ($opt_t)) { - message( "Either running as trial mode (-t) or AN ERROR OCCURRED: $@\n",1); - $dbh->rollback(); - exit(0); - } - else { - message("Committing! \n If you are using cvtermpath you should now run gmod_make_cvtermpath.pl . See the perldoc for more info. \n\n", 1); - $dbh->commit(); - } -} - -print STDERR "Done.\n"; - - - -sub recursive_children { - my $ont = shift; - my $node = shift; - - my @children = $ont -> get_child_terms($node); - - foreach my $child (@children) { - print STDERR "CHILD: ".($child->name())."\n"; - recursive_children($ont, $child); - } -} - - -sub message { - my $message = shift; - my $default=shift; - if ($opt_v || $default) { print STDOUT "$message"; } - print OUT "$message" if $opt_o; -} - -sub numeric_id { - my $id = shift; - $id =~ s/.*\:(.*)$/$1/g; - return $id; -} Deleted: schema/trunk/chado/bin/cxgn/gmod_make_cvtermpath.pl =================================================================== --- schema/trunk/chado/bin/cxgn/gmod_make_cvtermpath.pl 2011-03-23 23:10:49 UTC (rev 24717) +++ schema/trunk/chado/bin/cxgn/gmod_make_cvtermpath.pl 2011-03-24 00:24:43 UTC (rev 24718) @@ -1,400 +0,0 @@ -#!/usr/bin/perl - -=pod - -=head1 NAME - -gmod_make_cvtermpath.pl - -=head1 USAGE - - perl gmod_make_cvtermpath.pl -H [dbhost] -D [dbname] [-vt] -c cvname - perl gmod_make_cvtermpath.pl -g [GMODConf_profile] -c cvname - -=head2 Parameters - -=over 5 - - -=item -c - -Name of ontology (cv.name) to compute the transitive closure on. (Required) - -=item -v - -Verbose output - -=item -t - -Trial mode. Do not perform any store operations at all. (Not implemented) - -=item -o - -outfile for writing errors and verbose messages (optional) - -=item -g - -GMOD database profile name (can provide host and DB name) Default: 'default' - -=back - -=head2 If not using a GMOD database profile (option -g) then you must provide the following parameters - -=over 5 - -=item -D - -Database name - -=item -H - -Hostname - - -=item -d - -Database driver name (e.g. 'Pg' for postgres) - -=item -u - -[Optional- if default user is not used] -Database user name - -=item -p - -[Optional- if you need a password to connect to your database] -Password for your user to connect to the database - - -=back - -=head1 DESCRIPTION - -This script calculates the transitive closure on the ontology terms in the cvterm -table. As this is a computationaly intensive operation, doing so on a large -cv like the Gene Ontology can take several hours. For more information on what -a transative closure is, please see: - - http://www.geneontology.org/GO.database.shtml#graphs - -=head1 AUTHOR - -Naama Menda <nm...@co...> - -=head1 VERSION AND DATE - -Version 1.2, Feb. 2011. - -=cut - - -use strict; - -use DBI; -use Bio::OntologyIO; -use Bio::Ontology::TermFactory; - -use Bio::Chado::Schema; -########## -use Bio::GMOD::Config; -use Bio::GMOD::DB::Config; -use Getopt::Std; - -our ($opt_H, $opt_D, $opt_v, $opt_t, $opt_g, $opt_p, $opt_d, $opt_u, $opt_c, $opt_o); - -getopts('H:D:c:p:g:p:d:u:o:tv'); - - -my $dbhost = $opt_H; -my $dbname = $opt_D; -my $pass = $opt_p; -my $driver = $opt_d; -my $user = $opt_u; -my $cvname = $opt_c; -my $verbose = $opt_v; - -my $DBPROFILE = $opt_g ; - -print "H= $opt_H, D= $opt_D, u=$opt_u, d=$opt_d, v=$opt_v, t=$opt_t , cvname = $opt_c \n" if $verbose; - -my $port = '5432'; - -if (!($opt_H and $opt_D) ) { - my $DBPROFILE = $opt_g; - $DBPROFILE ||= 'default'; - my $gmod_conf = Bio::GMOD::Config->new() ; - my $db_conf = Bio::GMOD::DB::Config->new( $gmod_conf, $DBPROFILE ) ; - - $dbhost ||= $db_conf->host(); - $dbname ||= $db_conf->name(); - $driver = $db_conf->driver(); - - $port= $db_conf->port(); - - $user= $db_conf->user(); - $pass= $db_conf->password(); -} - -if (!$dbhost && !$dbname) { die "Need -D dbname and -H hostname arguments.\n"; } -if (!$driver) { die "Need -d (dsn) driver, or provide one in -g gmod_conf\n"; } -if (!$user) { die "Need -u user_name, or provide one in -g gmod_conf\n"; } - -#we can allow blank passwords -#if (!$pass) { die "Need -p password, or provide one in -g gmod_conf\n"; } -if (!$cvname) { die "Need to provide -c cv.name ! \n" ; } - -my $dsn = "dbi:$driver:dbname=$dbname"; -$dsn .= ";host=$dbhost"; -$dsn .= ";port=$port"; - -my $schema= Bio::Chado::Schema->connect($dsn, $user, $pass||'', { AutoCommit=>0 }); - -my $db=$schema->storage->dbh(); - -if (!$schema || !$db) { die "No schema or dbh is avaiable! \n"; } - -print STDOUT "Connected to database $dbname on host $dbhost.\n" if $verbose; -########## - - -if ($opt_o) { open (OUT, ">$opt_o") ||die "can't open error file $opt_o for writting.\n" ; } - -#die "USAGE: $0 <dbhost> <dbname> <cvname>" unless $dbhost and $dbname and $cvname; - - -my %type; -my %subject; -my %object; -my %black; -my %root; -our %leaf; -my %sot; - -my $sth_type = $db->prepare("select cvterm_id from cvterm where cv_id = (select cv_id from cv where name ilike 'Relationship')"); -$sth_type->execute; -while(my $type_id = $sth_type->fetchrow){ - $type{$type_id}++; -} - -my %cvterm; -my $sth_cvterm = $db->prepare("select cvterm_id from cvterm"); -$sth_cvterm->execute; -while(my $cvterm_id = $sth_cvterm->fetchrow_array){ - $cvterm{$cvterm_id}++; -} - - - -my $cv_id; -warn "select cv_id from cv where name = '$cvname'" if $verbose; -my $sth_cv = $db->prepare("select cv_id from cv where name = '$cvname'"); -$sth_cv->execute; -while(my $cv = $sth_cv->fetchrow_hashref){ - $cv_id = $cv->{cv_id}; -} - -die "no cv_id for '$cvname'" unless defined $cv_id; - -############## - -#delete existing cvtermpath rows -$schema->resultset("Cv::Cvtermpath")->search({cv_id => $cv_id} )->delete(); -####### - -my $sth_cvterm_relationship = $db->prepare("select subject_id,type_id,object_id from cvterm_relationship,cvterm where cvterm_relationship.subject_id = cvterm.cvterm_id and cvterm.cv_id = $cv_id"); -$sth_cvterm_relationship->execute; -while(my $cvterm_relationship = $sth_cvterm_relationship->fetchrow_hashref){ - $subject{$cvterm_relationship->{subject_id}}++; - $object{$cvterm_relationship->{object_id}}++; - - #hash of subject-object-type. Stores all the relationships defined in cvterm_relationship table. - $sot{$cvterm_relationship->{subject_id}}{$cvterm_relationship->{object_id}}{$cvterm_relationship->{type_id}}++; -} - -#populate hash of roots (terms without parents (objects)) and hash of leaves (terms without child terms (subjects)) -foreach my $cvterm (keys %cvterm){ - $root{$cvterm}++ if(!$subject{$cvterm} and $object{$cvterm}); - $leaf{$cvterm}++ if( $subject{$cvterm} and !$object{$cvterm}); -} - -my %leafbak = %leaf; -%sot = (); - -# this is a hash for storing the already-processed leaves for a given type term. -our %seen ; - - -while(keys %leaf){ - foreach my $l (keys %leaf){ - foreach my $type (keys %type){ - #add the leaf-type term to the seen list. - $seen{$l}{$type}++; - #sending the leaf as an arrayref to the recurse fuction. Distance starts with 1 - recurse([$l],$type,1); - } - delete $leaf{$l}; - message("DELETED leaf $l ! number of leaves is now : " .(scalar(keys(%leaf))) . "\n" ) ; - } - message("DONE recursing leaves \n"); -} -message("DONE FIRST LEAF RECURSIION! About to create the transitive path.\n"); - -%leaf = %leafbak; -%seen = (); - - -while(keys %leaf){ - foreach my $le (sort keys %leaf){ - $seen{$le}{0}++; - #calling recurse with leaf $le - recurse([$le],0,1); - #deleting the leaf from the list - delete $leaf{$le}; - message("Deleted leaf $le! after deleting number of leaves is : " .(scalar(keys(%leaf))) . "\n"); - } - message("FINISHED RECURSING for the transitive path (type = IS_A) \n"); -} - - -sub recurse { - my($subjects,$type,$dist) = @_; - - # start with the last subject - my $subject = $subjects->[-1]; - #get the parents for the subject with this type (defaults to IS_A) - my @objects = objects($subject,$type); - - #if there are no parents for this path, exit the loop (and the next leaf will be sent here again) - if(!@objects){ - $leaf{$subject}++ ; - return; - } - my $path; - - # foreach parent construct a path with each child - foreach my $object (@objects){ - my $tdist = $dist; - # loop through the child terms - foreach my $s (@$subjects){ - #next if the path was seen (subject-object-type-distance) - next if $sot{$s}{$object}{$type}{$tdist}; - if (exists($sot{$s}{$object}) && exists($sot{$object}{$s})) { - die " YOU HAVE A CYCLE IN YOUR ONTOLOGY for $s, $object ($type, $tdist) C8-( \n" ; - } - $sot{$s}{$object}{$type}{$tdist}++; - - print $tdist,"\t"x$dist,"\t",$s,"\t" , $object,"\t" ,$type||'transitive',"\n"; - - # if type is defined , create a path using it (see the first looping through %leaf keys) - if($type){ - - $path = $schema->resultset("Cv::Cvtermpath")->find_or_create( - { - subject_id => $s, - object_id => $object, - type_id => $type, - cv_id => $cv_id, - pathdistance => $tdist - }, { key => 'cvtermpath_c1' } , ); - message( "Inserting ($s,$object,$type,$cv_id , $tdist) into cvtermpath...path_id = " . $path->cvtermpath_id(). "\n" ); - my $ttdist = -1 * $tdist; - - $path = $schema->resultset("Cv::Cvtermpath")->find_or_create( - { - subject_id => $object, - object_id => $subject, - type_id => $type, - cv_id => $cv_id, - pathdistance => $ttdist - }, { key => 'cvtermpath_c1' } , ); - message( "Inserting ($object,$subject,$type,$cv_id , $ttdist) into cvtermpath...path_id = " . $path->cvtermpath_id() . "\n" ); - } else { # if type exists (see second looping through %leaf keys) create a path using the is_a type - message("No type defined! Using default IS_A relationship\n"); - my $is_a = $schema->resultset("Cv::Cvterm")->search({ name => 'is_a' })->first(); - - $path = $schema->resultset("Cv::Cvtermpath")->find_or_create( - { - subject_id => $s, - object_id => $object, - type_id => $is_a->cvterm_id(), - cv_id => $cv_id, - pathdistance => $tdist - }, { key => 'cvtermpath_c1' } , ); - message("Inserting ($s,$object, $type, " . $is_a->cv_id() . " , $tdist) into cvtermpath...path_id = " . $path->cvtermpath_id() . "\n" ); - - $path = $schema->resultset("Cv::Cvtermpath")->find_or_create( - { - subject_id => $object, - object_id => $subject, - type_id => $is_a->cvterm_id(), - cv_id => $cv_id, - pathdistance => -$tdist - }, { key => 'cvtermpath_c1' } , ); - message( "Inserting ($object,$subject, " . $is_a->cvterm_id() . " ,$cv_id , -$tdist) into cvtermpath... path_id = " . $path->cvtermpath_id() . "\n" ); - } - $tdist--; - } - $tdist = $dist; - # recurse with arrayref of subjects and the object, increment the pathdistance - recurse([@$subjects,$object],$type,$dist+1); - - $db->commit(); - } - -} - -#------------------- - -sub objects { - my($subject,$type) = @_; - - my @cvterm_rel; - if($type){ - - @cvterm_rel = $schema->resultset("Cv::CvtermRelationship")->search( - { subject_id => $subject, - type_id => $type , - } - ); - - } else { - - @cvterm_rel = $schema->resultset("Cv::CvtermRelationship")->search( - { subject_id => $subject } - ); - } - my @objects = map ($_->object_id, @cvterm_rel) ; - return @objects; -} - - -sub subjects { - my($object,$type) = @_; - - my @cvterm_rel; - if($type){ - - @cvterm_rel = $schema->resultset("Cv::CvtermRelationship")->search( - { object_id => $object, - type_id => $type , - } - ); - - } else { - - @cvterm_rel = $schema->resultset("Cv::CvtermRelationship")->search( - { object_id => $object } - ); - } - my @subjects = map ($_->subject_id, @cvterm_rel) ; - - return @subjects; -} - - -sub message { - my $message = shift; - my $default=shift; - if ($opt_v || $default) { print STDOUT "$message"; } - print OUT "$message" if $opt_o; -} Deleted: schema/trunk/chado/bin/cxgn/load_ncbi_taxonomy.pl =================================================================== --- schema/trunk/chado/bin/cxgn/load_ncbi_taxonomy.pl 2011-03-23 23:10:49 UTC (rev 24717) +++ schema/trunk/chado/bin/cxgn/load_ncbi_taxonomy.pl 2011-03-24 00:24:43 UTC (rev 24718) @@ -1,618 +0,0 @@ - -=head1 NAME - - load_ncbi_taxonomy.pl - -=head1 DESCRIPTION - - Usage: perl load_ncbi_taxonomy.pl -H [dbhost] -D [dbname] [-vt] -i file - -populate a chado database with organism information (see the organism module and phylogeny module) - -=head2 Prerequisites - -=over 3 - -=item 1. Load taxonomy cvterms - -see load_taxonomy_cvterms.pl - -=item 2. Download NCBI taxonomy files - -ftp://ftp.ncbi.nih.gov/pub/taxonomy/ - -Save these 2 files in the same dir. of this script - names.dmp - nodes.dmp - -=item 3. Download a taxon_id list from NCBI - -Optional. This filter file will include the taxons you would like to store in your tree (see option -i). -Without this file the entire NCBI taxonomy will be stored in your database! - -=back - - -=head2 parameters - -=over 9 - -=item -H - -hostname for database - -=item -D - -database name - -=item -i - -input file [optional] - -List taxonomy ids to be stored. The rest of the taxons in the name and node files will be excluded. -http://www.ncbi.nlm.nih.gov/sites/entrez?db=Taxonomy -and search by taxid (e.g. txis4070[Subtree] ) - -=item p [optional] - -phylotree name - -name you phylotree. Default = 'NCBI taxonomy tree' - -=item -v - -verbose output - -=item -t - -trial mode. Do not perform any store operations at all. - - -=item -g - -GMOD database profile name (can provide host and DB name) Default: 'default' - -=item -u - -username. Override username in gmod_config - -=item -d - -driver. Override driver name in gmod_config - -=item -s - -password. Override password in gmod_config - - -=back - - -The script stores ncbi taxonomy in chado organism and phylogeny modules -This script works with SGN's public schema (chado compatible) and accesse the following tables: - -=over 7 - -=item db (DB:NCBI_taxonomy) - -=item dbxref (genbank taxon ids will be stored in the accession field) - -=item organism - -=item organism_dbxref - -=item phylotree - -=item phylonode - -=item phylonode_organism - - - -=back - - -For storing phylonodes a new phylotree will be stored with the name 'NCBI taxonomy tree'. -Each organism will get a phylonode id and will be stored in a tmp table, since each phylonode (except for the root) has a parent_phylonode_id, which is an internal foreign key. -Next each phylonode will get a left and right indexes, which are calculated by walking down the entire tree structure (see article by Aaron Mackey: http://www.oreillynet.com/pub/a/network/2002/11/27/bioconf.html?page=2). -Only after each phylonode will have calculated indexes, the phylonode table will be populated from the tmp table. - - -=head1 AUTHOR - -Adapted from GMOD load_taxonomy.pl: -#$Id: load_taxonomy.pl,v 1.1 2006/04/17 05:22:22 allenday Exp $ -#download from ftp://ftp.ncbi.nih.gov/pub/taxonomy/ - -by -Naama Menda <nm...@co...> - -=head1 VERISON AND DATE - -Version 2.0, October 2009. - -=head1 TODO - - - -=cut - - -#! /usr/bin/perl - -use strict; - - -use Bio::GMOD::Config; -use Bio::GMOD::DB::Config; - -use Bio::Chado::Schema; - -use Getopt::Std; - -our ($opt_H, $opt_D, $opt_v, $opt_t, $opt_i, $opt_p, $opt_g, $opt_u, $opt_s, $opt_d); - -getopts('H:D:i:p:g:u:s:d:tv'); - -my $dbhost = $opt_H; -my $dbname = $opt_D; -my $infile = $opt_i; -my $phylotree_name= $opt_p || 'NCBI taxonomy tree'; -my $user = $opt_u; -my $pass = $opt_s; -my $driver = $opt_d; -my $port; - -my $DBPROFILE = $opt_g ; - - -print "H= $opt_H, D= $opt_D, v=$opt_v, t=$opt_t, i=$opt_i \n"; - -my ($dbh, $schema); - -################ - -if (!($opt_H and $opt_D) ) { - $DBPROFILE ||= 'default'; - my $gmod_conf = Bio::GMOD::Config->new() ; - my $db_conf = Bio::GMOD::DB::Config->new( $gmod_conf, $DBPROFILE ) ; - - $dbhost ||= $db_conf->host(); - $dbname ||= $db_conf->name(); - $driver ||= $db_conf->driver(); - - - $port= $db_conf->port(); - - $user= $db_conf->user(); - $pass= $db_conf->password(); -} - -################### - -if (!$dbhost && !$dbname) { die "Need -D dbname and -H hostname arguments.\n"; } - -my $dsn = "dbi:$driver:dbname=$dbname"; -$dsn .= ";host=$dbhost"; -$dsn .= ";port=$port" if $port; - -$schema= Bio::Chado::Schema->connect( $dsn, $user, $pass, { AutoCommit=>0 }); -$dbh=$schema->storage->dbh(); - - -if (!$schema || !$d... [truncated message content] |
From: <sco...@us...> - 2011-04-22 20:33:17
|
Revision: 24842 http://gmod.svn.sourceforge.net/gmod/?rev=24842&view=rev Author: scottcain Date: 2011-04-22 20:33:05 +0000 (Fri, 22 Apr 2011) Log Message: ----------- starting towards a more organized migration path between schemas Modified Paths: -------------- schema/trunk/chado/modules/default_nofuncs.sql schema/trunk/chado/modules/default_schema.sql Added Paths: ----------- schema/trunk/chado/schemas/ schema/trunk/chado/schemas/1.0/ schema/trunk/chado/schemas/1.0/default_schema.sql schema/trunk/chado/schemas/1.1/ schema/trunk/chado/schemas/1.1/default_schema.sql schema/trunk/chado/schemas/1.1-1.0/ schema/trunk/chado/schemas/1.1-1.0/diff schema/trunk/chado/schemas/1.1-1.0/diff.sql schema/trunk/chado/schemas/1.11/ schema/trunk/chado/schemas/1.11/default_schema.sql schema/trunk/chado/schemas/1.11-1.0/ schema/trunk/chado/schemas/1.11-1.0/diff schema/trunk/chado/schemas/1.11-1.0/diff.sql schema/trunk/chado/schemas/1.11-1.1/ schema/trunk/chado/schemas/1.11-1.1/diff schema/trunk/chado/schemas/1.11-1.1/diff.sql schema/trunk/chado/schemas/1.12/ schema/trunk/chado/schemas/1.12-1.0/ schema/trunk/chado/schemas/1.12-1.1/ schema/trunk/chado/schemas/1.12-1.11/ Modified: schema/trunk/chado/modules/default_nofuncs.sql =================================================================== --- schema/trunk/chado/modules/default_nofuncs.sql 2011-04-21 22:40:58 UTC (rev 24841) +++ schema/trunk/chado/modules/default_nofuncs.sql 2011-04-22 20:33:05 UTC (rev 24842) @@ -365,7 +365,7 @@ foreign key (cv_id) references cv (cv_id) INITIALLY DEFERRED, type_id int not null, foreign key (type_id) references cvterm (cvterm_id) INITIALLY DEFERRED, - value text not null default '', + value text, rank int not null default 0, constraint cvprop_c1 unique (cv_id,type_id,rank) ); @@ -1264,13 +1264,15 @@ CREATE TABLE gencode_codon_aa ( gencode_id INTEGER NOT NULL REFERENCES gencode(gencode_id), codon CHAR(3) NOT NULL, - aa CHAR(1) NOT NULL + aa CHAR(1) NOT NULL, + CONSTRAINT gencode_codon_unique UNIQUE( gencode_id, codon ) ); CREATE INDEX gencode_codon_aa_i1 ON gencode_codon_aa(gencode_id,codon,aa); CREATE TABLE gencode_startcodon ( gencode_id INTEGER NOT NULL REFERENCES gencode(gencode_id), - codon CHAR(3) + codon CHAR(3), + CONSTRAINT gencode_startcodon_unique UNIQUE( gencode_id, codon ) ); SET search_path = public,pg_catalog; -- $Id: companalysis.sql,v 1.37 2007-03-23 15:18:02 scottcain Exp $ @@ -3326,8 +3328,10 @@ foreign key (cvterm_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, pub_id int not null, foreign key (pub_id) references pub (pub_id) on delete cascade INITIALLY DEFERRED, - constraint stock_cvterm_c1 unique (stock_id,cvterm_id,pub_id) -); + is_not boolean not null default false, + rank integer not null default 0, + constraint stock_cvterm_c1 unique (stock_id,cvterm_id,pub_id,rank) + ); create index stock_cvterm_idx1 on stock_cvterm (stock_id); create index stock_cvterm_idx2 on stock_cvterm (cvterm_id); create index stock_cvterm_idx3 on stock_cvterm (pub_id); @@ -3336,6 +3340,46 @@ -- ================================================ +-- TABLE: stock_cvtermprop +-- ================================================ + +create table stock_cvtermprop ( + stock_cvtermprop_id serial not null, + primary key (stock_cvtermprop_id), + stock_cvterm_id int not null, + foreign key (stock_cvterm_id) references stock_cvterm (stock_cvterm_id) on delete cascade, + type_id int not null, + foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, + value text null, + rank int not null default 0, + constraint stock_cvtermprop_c1 unique (stock_cvterm_id,type_id,rank) +); +create index stock_cvtermprop_idx1 on stock_cvtermprop (stock_cvterm_id); +create index stock_cvtermprop_idx2 on stock_cvtermprop (type_id); + +COMMENT ON TABLE stock_cvtermprop IS 'Extensible properties for +stock to cvterm associations. Examples: GO evidence codes; +qualifiers; metadata such as the date on which the entry was curated +and the source of the association. See the stockprop table for +meanings of type_id, value and rank.'; + +COMMENT ON COLUMN stock_cvtermprop.type_id IS 'The name of the +property/slot is a cvterm. The meaning of the property is defined in +that cvterm. cvterms may come from the OBO evidence code cv.'; + +COMMENT ON COLUMN stock_cvtermprop.value IS 'The value of the +property, represented as text. Numeric values are converted to their +text representation. This is less efficient than using native database +types, but is easier to query.'; + +COMMENT ON COLUMN stock_cvtermprop.rank IS 'Property-Value +ordering. Any stock_cvterm can have multiple values for any particular +property type - these are ordered in a list using rank, counting from +zero. For properties that are single-valued rather than multi-valued, +the default 0 value should be used.'; + + +-- ================================================ -- TABLE: stock_genotype -- ================================================ @@ -3914,7 +3958,7 @@ constraint nd_experimentprop_c1 unique (nd_experiment_id,type_id,rank) ); -create table nd_experiment_pub ( +CREATE TABLE nd_experiment_pub ( nd_experiment_pub_id serial PRIMARY KEY not null, nd_experiment_id int not null, foreign key (nd_experiment_id) references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED, Modified: schema/trunk/chado/modules/default_schema.sql =================================================================== --- schema/trunk/chado/modules/default_schema.sql 2011-04-21 22:40:58 UTC (rev 24841) +++ schema/trunk/chado/modules/default_schema.sql 2011-04-22 20:33:05 UTC (rev 24842) @@ -416,7 +416,7 @@ foreign key (cv_id) references cv (cv_id) INITIALLY DEFERRED, type_id int not null, foreign key (type_id) references cvterm (cvterm_id) INITIALLY DEFERRED, - value text not null default '', + value text, rank int not null default 0, constraint cvprop_c1 unique (cv_id,type_id,rank) ); @@ -1901,13 +1901,15 @@ CREATE TABLE gencode_codon_aa ( gencode_id INTEGER NOT NULL REFERENCES gencode(gencode_id), codon CHAR(3) NOT NULL, - aa CHAR(1) NOT NULL + aa CHAR(1) NOT NULL, + CONSTRAINT gencode_codon_unique UNIQUE( gencode_id, codon ) ); CREATE INDEX gencode_codon_aa_i1 ON gencode_codon_aa(gencode_id,codon,aa); CREATE TABLE gencode_startcodon ( gencode_id INTEGER NOT NULL REFERENCES gencode(gencode_id), - codon CHAR(3) + codon CHAR(3), + CONSTRAINT gencode_startcodon_unique UNIQUE( gencode_id, codon ) ); SET search_path = public,pg_catalog; -- @@ -35905,8 +35907,10 @@ foreign key (cvterm_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, pub_id int not null, foreign key (pub_id) references pub (pub_id) on delete cascade INITIALLY DEFERRED, - constraint stock_cvterm_c1 unique (stock_id,cvterm_id,pub_id) -); + is_not boolean not null default false, + rank integer not null default 0, + constraint stock_cvterm_c1 unique (stock_id,cvterm_id,pub_id,rank) + ); create index stock_cvterm_idx1 on stock_cvterm (stock_id); create index stock_cvterm_idx2 on stock_cvterm (cvterm_id); create index stock_cvterm_idx3 on stock_cvterm (pub_id); @@ -35915,6 +35919,46 @@ -- ================================================ +-- TABLE: stock_cvtermprop +-- ================================================ + +create table stock_cvtermprop ( + stock_cvtermprop_id serial not null, + primary key (stock_cvtermprop_id), + stock_cvterm_id int not null, + foreign key (stock_cvterm_id) references stock_cvterm (stock_cvterm_id) on delete cascade, + type_id int not null, + foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, + value text null, + rank int not null default 0, + constraint stock_cvtermprop_c1 unique (stock_cvterm_id,type_id,rank) +); +create index stock_cvtermprop_idx1 on stock_cvtermprop (stock_cvterm_id); +create index stock_cvtermprop_idx2 on stock_cvtermprop (type_id); + +COMMENT ON TABLE stock_cvtermprop IS 'Extensible properties for +stock to cvterm associations. Examples: GO evidence codes; +qualifiers; metadata such as the date on which the entry was curated +and the source of the association. See the stockprop table for +meanings of type_id, value and rank.'; + +COMMENT ON COLUMN stock_cvtermprop.type_id IS 'The name of the +property/slot is a cvterm. The meaning of the property is defined in +that cvterm. cvterms may come from the OBO evidence code cv.'; + +COMMENT ON COLUMN stock_cvtermprop.value IS 'The value of the +property, represented as text. Numeric values are converted to their +text representation. This is less efficient than using native database +types, but is easier to query.'; + +COMMENT ON COLUMN stock_cvtermprop.rank IS 'Property-Value +ordering. Any stock_cvterm can have multiple values for any particular +property type - these are ordered in a list using rank, counting from +zero. For properties that are single-valued rather than multi-valued, +the default 0 value should be used.'; + + +-- ================================================ -- TABLE: stock_genotype -- ================================================ @@ -37085,7 +37129,7 @@ constraint nd_experimentprop_c1 unique (nd_experiment_id,type_id,rank) ); -create table nd_experiment_pub ( +CREATE TABLE nd_experiment_pub ( nd_experiment_pub_id serial PRIMARY KEY not null, nd_experiment_id int not null, foreign key (nd_experiment_id) references nd_experiment (nd_experiment_id) on delete cascade INITIALLY DEFERRED, Added: schema/trunk/chado/schemas/1.0/default_schema.sql =================================================================== --- schema/trunk/chado/schemas/1.0/default_schema.sql (rev 0) +++ schema/trunk/chado/schemas/1.0/default_schema.sql 2011-04-22 20:33:05 UTC (rev 24842) @@ -0,0 +1,6381 @@ +-- $Id: default_schema.sql,v 1.53 2008-03-28 16:05:24 scottcain Exp $ +-- ========================================== +-- Chado general module +-- +-- ================================================ +-- TABLE: tableinfo +-- ================================================ + +create table tableinfo ( + tableinfo_id serial not null, + primary key (tableinfo_id), + name varchar(30) not null, + primary_key_column varchar(30) null, + is_view int not null default 0, + view_on_table_id int null, + superclass_table_id int null, + is_updateable int not null default 1, + modification_date date not null default now(), + constraint tableinfo_c1 unique (name) +); + +COMMENT ON TABLE tableinfo IS NULL; + +-- ================================================ +-- TABLE: db +-- ================================================ + +create table db ( + db_id serial not null, + primary key (db_id), + name varchar(255) not null, +-- contact_id int, +-- foreign key (contact_id) references contact (contact_id) on delete cascade INITIALLY DEFERRED, + description varchar(255) null, + urlprefix varchar(255) null, + url varchar(255) null, + constraint db_c1 unique (name) +); + +COMMENT ON TABLE db IS 'A database authority. Typical databases in +bioinformatics are FlyBase, GO, UniProt, NCBI, MGI, etc. The authority +is generally known by this shortened form, which is unique within the +bioinformatics and biomedical realm. To Do - add support for URIs, +URNs (e.g. LSIDs). We can do this by treating the URL as a URI - +however, some applications may expect this to be resolvable - to be +decided.'; + +-- ================================================ +-- TABLE: dbxref +-- ================================================ + +create table dbxref ( + dbxref_id serial not null, + primary key (dbxref_id), + db_id int not null, + foreign key (db_id) references db (db_id) on delete cascade INITIALLY DEFERRED, + accession varchar(255) not null, + version varchar(255) not null default '', + description text, + constraint dbxref_c1 unique (db_id,accession,version) +); +create index dbxref_idx1 on dbxref (db_id); +create index dbxref_idx2 on dbxref (accession); +create index dbxref_idx3 on dbxref (version); + +COMMENT ON TABLE dbxref IS 'A unique, global, public, stable identifier. Not necessarily an external reference - can reference data items inside the particular chado instance being used. Typically a row in a table can be uniquely identified with a primary identifier (called dbxref_id); a table may also have secondary identifiers (in a linking table <T>_dbxref). A dbxref is generally written as <DB>:<ACCESSION> or as <DB>:<ACCESSION>:<VERSION>.'; + +COMMENT ON COLUMN dbxref.accession IS 'The local part of the identifier. Guaranteed by the db authority to be unique for that db.'; + +-- ================================================ +-- TABLE: project +-- ================================================ + +create table project ( + project_id serial not null, + primary key (project_id), + name varchar(255) not null, + description varchar(255) not null, + constraint project_c1 unique (name) +); + +COMMENT ON TABLE project IS NULL; +CREATE VIEW db_dbxref_count AS + SELECT db.name,count(*) AS num_dbxrefs FROM db INNER JOIN dbxref USING (db_id) GROUP BY db.name; +COMMENT ON VIEW db_dbxref_count IS 'per-db dbxref counts'; + +CREATE OR REPLACE FUNCTION store_db (VARCHAR) + RETURNS INT AS +'DECLARE + v_name ALIAS FOR $1; + + v_db_id INTEGER; + BEGIN + SELECT INTO v_db_id db_id + FROM db + WHERE name=v_name; + IF NOT FOUND THEN + INSERT INTO db + (name) + VALUES + (v_name); + RETURN currval(''db_db_id_seq''); + END IF; + RETURN v_db_id; + END; +' LANGUAGE 'plpgsql'; + +CREATE OR REPLACE FUNCTION store_dbxref (VARCHAR,VARCHAR) + RETURNS INT AS +'DECLARE + v_dbname ALIAS FOR $1; + v_accession ALIAS FOR $1; + + v_db_id INTEGER; + v_dbxref_id INTEGER; + BEGIN + SELECT INTO v_db_id + store_db(v_dbname); + SELECT INTO v_dbxref_id dbxref_id + FROM dbxref + WHERE db_id=v_db_id AND + accession=v_accession; + IF NOT FOUND THEN + INSERT INTO dbxref + (db_id,accession) + VALUES + (v_db_id,v_accession); + RETURN currval(''dbxref_dbxref_id_seq''); + END IF; + RETURN v_dbxref_id; + END; +' LANGUAGE 'plpgsql'; + +-- $Id: default_schema.sql,v 1.53 2008-03-28 16:05:24 scottcain Exp $ +-- ========================================== +-- Chado cv module +-- +-- ================================================================= +-- Dependencies: +-- +-- :import dbxref from general +-- ================================================================= + +-- ================================================ +-- TABLE: cv +-- ================================================ +create table cv ( + cv_id serial not null, + primary key (cv_id), + name varchar(255) not null, + definition text, + constraint cv_c1 unique (name) +); + +COMMENT ON TABLE cv IS 'A controlled vocabulary or ontology. A cv is +composed of cvterms (AKA terms, classes, types, universals - relations +and properties are also stored in cvterm) and the relationships +between them.'; + +COMMENT ON COLUMN cv.name IS 'The name of the ontology. This +corresponds to the obo-format -namespace-. cv names uniquely identify +the cv. In OBO file format, the cv.name is known as the namespace.'; + +COMMENT ON COLUMN cv.definition IS 'A text description of the criteria for +membership of this ontology.'; + +-- ================================================ +-- TABLE: cvterm +-- ================================================ +create table cvterm ( + cvterm_id serial not null, + primary key (cvterm_id), + cv_id int not null, + foreign key (cv_id) references cv (cv_id) on delete cascade INITIALLY DEFERRED, + name varchar(1024) not null, + definition text, + dbxref_id int not null, + foreign key (dbxref_id) references dbxref (dbxref_id) on delete set null INITIALLY DEFERRED, + is_obsolete int not null default 0, + is_relationshiptype int not null default 0, + constraint cvterm_c1 unique (name,cv_id,is_obsolete), + constraint cvterm_c2 unique (dbxref_id) +); +create index cvterm_idx1 on cvterm (cv_id); +create index cvterm_idx2 on cvterm (name); +create index cvterm_idx3 on cvterm (dbxref_id); + +COMMENT ON TABLE cvterm IS 'A term, class, universal or type within an +ontology or controlled vocabulary. This table is also used for +relations and properties. cvterms constitute nodes in the graph +defined by the collection of cvterms and cvterm_relationships.'; + +COMMENT ON COLUMN cvterm.cv_id IS 'The cv or ontology or namespace to which +this cvterm belongs.'; + +COMMENT ON COLUMN cvterm.name IS 'A concise human-readable name or +label for the cvterm. Uniquely identifies a cvterm within a cv.'; + +COMMENT ON COLUMN cvterm.definition IS 'A human-readable text +definition.'; + +COMMENT ON COLUMN cvterm.dbxref_id IS 'Primary identifier dbxref - The +unique global OBO identifier for this cvterm. Note that a cvterm may +have multiple secondary dbxrefs - see also table: cvterm_dbxref.'; + +COMMENT ON COLUMN cvterm.is_obsolete IS 'Boolean 0=false,1=true; see +GO documentation for details of obsoletion. Note that two terms with +different primary dbxrefs may exist if one is obsolete.'; + +COMMENT ON COLUMN cvterm.is_relationshiptype IS 'Boolean +0=false,1=true relations or relationship types (also known as Typedefs +in OBO format, or as properties or slots) form a cv/ontology in +themselves. We use this flag to indicate whether this cvterm is an +actual term/class/universal or a relation. Relations may be drawn from +the OBO Relations ontology, but are not exclusively drawn from there.'; + +COMMENT ON INDEX cvterm_c1 IS 'A name can mean different things in +different contexts; for example "chromosome" in SO and GO. A name +should be unique within an ontology or cv. A name may exist twice in a +cv, in both obsolete and non-obsolete forms - these will be for +different cvterms with different OBO identifiers; so GO documentation +for more details on obsoletion. Note that occasionally multiple +obsolete terms with the same name will exist in the same cv. If this +is a possibility for the ontology under consideration (e.g. GO) then the +ID should be appended to the name to ensure uniqueness.'; + +COMMENT ON INDEX cvterm_c2 IS 'The OBO identifier is globally unique.'; + +-- ================================================ +-- TABLE: cvterm_relationship +-- ================================================ +create table cvterm_relationship ( + cvterm_relationship_id serial not null, + primary key (cvterm_relationship_id), + type_id int not null, + foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, + subject_id int not null, + foreign key (subject_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, + object_id int not null, + foreign key (object_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, + constraint cvterm_relationship_c1 unique (subject_id,object_id,type_id) +); +create index cvterm_relationship_idx1 on cvterm_relationship (type_id); +create index cvterm_relationship_idx2 on cvterm_relationship (subject_id); +create index cvterm_relationship_idx3 on cvterm_relationship (object_id); + +COMMENT ON TABLE cvterm_relationship IS 'A relationship linking two +cvterms. Each cvterm_relationship constitutes an edge in the graph +defined by the collection of cvterms and cvterm_relationships. The +meaning of the cvterm_relationship depends on the definition of the +cvterm R refered to by type_id. However, in general the definitions +are such that the statement "all SUBJs REL some OBJ" is true. The +cvterm_relationship statement is about the subject, not the +object. For example "insect wing part_of thorax".'; + +COMMENT ON COLUMN cvterm_relationship.subject_id IS 'The subject of +the subj-predicate-obj sentence. The cvterm_relationship is about the +subject. In a graph, this typically corresponds to the child node.'; + +COMMENT ON COLUMN cvterm_relationship.object_id IS 'The object of the +subj-predicate-obj sentence. The cvterm_relationship refers to the +object. In a graph, this typically corresponds to the parent node.'; + +COMMENT ON COLUMN cvterm_relationship.type_id IS 'The nature of the +relationship between subject and object. Note that relations are also +housed in the cvterm table, typically from the OBO relationship +ontology, although other relationship types are allowed.'; + +-- ================================================ +-- TABLE: cvtermpath +-- ================================================ +create table cvtermpath ( + cvtermpath_id serial not null, + primary key (cvtermpath_id), + type_id int, + foreign key (type_id) references cvterm (cvterm_id) on delete set null INITIALLY DEFERRED, + subject_id int not null, + foreign key (subject_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, + object_id int not null, + foreign key (object_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, + cv_id int not null, + foreign key (cv_id) references cv (cv_id) on delete cascade INITIALLY DEFERRED, + pathdistance int, + constraint cvtermpath_c1 unique (subject_id,object_id,type_id,pathdistance) +); +create index cvtermpath_idx1 on cvtermpath (type_id); +create index cvtermpath_idx2 on cvtermpath (subject_id); +create index cvtermpath_idx3 on cvtermpath (object_id); +create index cvtermpath_idx4 on cvtermpath (cv_id); + +COMMENT ON TABLE cvtermpath IS 'The reflexive transitive closure of +the cvterm_relationship relation.'; + +COMMENT ON COLUMN cvtermpath.type_id IS 'The relationship type that +this is a closure over. If null, then this is a closure over ALL +relationship types. If non-null, then this references a relationship +cvterm - note that the closure will apply to both this relationship +AND the OBO_REL:is_a (subclass) relationship.'; + +COMMENT ON COLUMN cvtermpath.cv_id IS 'Closures will mostly be within +one cv. If the closure of a relationship traverses a cv, then this +refers to the cv of the object_id cvterm.'; + +COMMENT ON COLUMN cvtermpath.pathdistance IS 'The number of steps +required to get from the subject cvterm to the object cvterm, counting +from zero (reflexive relationship).'; + +-- ================================================ +-- TABLE: cvtermsynonym +-- ================================================ +create table cvtermsynonym ( + cvtermsynonym_id serial not null, + primary key (cvtermsynonym_id), + cvterm_id int not null, + foreign key (cvterm_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, + synonym varchar(1024) not null, + type_id int, + foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, + constraint cvtermsynonym_c1 unique (cvterm_id,synonym) +); +create index cvtermsynonym_idx1 on cvtermsynonym (cvterm_id); + +COMMENT ON TABLE cvtermsynonym IS 'A cvterm actually represents a +distinct class or concept. A concept can be refered to by different +phrases or names. In addition to the primary name (cvterm.name) there +can be a number of alternative aliases or synonyms. For example, "T +cell" as a synonym for "T lymphocyte".'; + +COMMENT ON COLUMN cvtermsynonym.type_id IS 'A synonym can be exact, +narrower, or broader than.'; + + +-- ================================================ +-- TABLE: cvterm_dbxref +-- ================================================ +create table cvterm_dbxref ( + cvterm_dbxref_id serial not null, + primary key (cvterm_dbxref_id), + cvterm_id int not null, + foreign key (cvterm_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, + dbxref_id int not null, + foreign key (dbxref_id) references dbxref (dbxref_id) on delete cascade INITIALLY DEFERRED, + is_for_definition int not null default 0, + constraint cvterm_dbxref_c1 unique (cvterm_id,dbxref_id) +); +create index cvterm_dbxref_idx1 on cvterm_dbxref (cvterm_id); +create index cvterm_dbxref_idx2 on cvterm_dbxref (dbxref_id); + +COMMENT ON TABLE cvterm_dbxref IS 'In addition to the primary +identifier (cvterm.dbxref_id) a cvterm can have zero or more secondary +identifiers/dbxrefs, which may refer to records in external +databases. The exact semantics of cvterm_dbxref are not fixed. For +example: the dbxref could be a pubmed ID that is pertinent to the +cvterm, or it could be an equivalent or similar term in another +ontology. For example, GO cvterms are typically linked to InterPro +IDs, even though the nature of the relationship between them is +largely one of statistical association. The dbxref may be have data +records attached in the same database instance, or it could be a +"hanging" dbxref pointing to some external database. NOTE: If the +desired objective is to link two cvterms together, and the nature of +the relation is known and holds for all instances of the subject +cvterm then consider instead using cvterm_relationship together with a +well-defined relation.'; + +COMMENT ON COLUMN cvterm_dbxref.is_for_definition IS 'A +cvterm.definition should be supported by one or more references. If +this column is true, the dbxref is not for a term in an external database - +it is a dbxref for provenance information for the definition.'; + + +-- ================================================ +-- TABLE: cvtermprop +-- ================================================ +create table cvtermprop ( + cvtermprop_id serial not null, + primary key (cvtermprop_id), + cvterm_id int not null, + foreign key (cvterm_id) references cvterm (cvterm_id) on delete cascade, + type_id int not null, + foreign key (type_id) references cvterm (cvterm_id) on delete cascade, + value text not null default '', + rank int not null default 0, + + unique(cvterm_id, type_id, value, rank) +); +create index cvtermprop_idx1 on cvtermprop (cvterm_id); +create index cvtermprop_idx2 on cvtermprop (type_id); + +COMMENT ON TABLE cvtermprop IS 'Additional extensible properties can be attached to a cvterm using this table. Corresponds to -AnnotationProperty- in W3C OWL format.'; + +COMMENT ON COLUMN cvtermprop.type_id IS 'The name of the property or slot is a cvterm. The meaning of the property is defined in that cvterm.'; + +COMMENT ON COLUMN cvtermprop.value IS 'The value of the property, represented as text. Numeric values are converted to their text representation.'; + +COMMENT ON COLUMN cvtermprop.rank IS 'Property-Value ordering. Any +cvterm can have multiple values for any particular property type - +these are ordered in a list using rank, counting from zero. For +properties that are single-valued rather than multi-valued, the +default 0 value should be used.'; + + +-- ================================================ +-- TABLE: dbxrefprop +-- ================================================ +create table dbxrefprop ( + dbxrefprop_id serial not null, + primary key (dbxrefprop_id), + dbxref_id int not null, + foreign key (dbxref_id) references dbxref (dbxref_id) INITIALLY DEFERRED, + type_id int not null, + foreign key (type_id) references cvterm (cvterm_id) INITIALLY DEFERRED, + value text not null default '', + rank int not null default 0, + constraint dbxrefprop_c1 unique (dbxref_id,type_id,rank) +); +create index dbxrefprop_idx1 on dbxrefprop (dbxref_id); +create index dbxrefprop_idx2 on dbxrefprop (type_id); + +COMMENT ON TABLE dbxrefprop IS 'Metadata about a dbxref. Note that this is not defined in the dbxref module, as it depends on the cvterm table. This table has a structure analagous to cvtermprop.'; + + +CREATE OR REPLACE VIEW cv_root AS + SELECT + cv_id, + cvterm_id AS root_cvterm_id + FROM cvterm + WHERE + cvterm_id NOT IN ( SELECT subject_id FROM cvterm_relationship) AND + is_obsolete=0; + +COMMENT ON VIEW cv_root IS 'the roots of a cv are the set of terms +which have no parents (terms that are not the subject of a +relation). Most cvs will have a single root, some may have >1. All +will have at least 1'; + +CREATE OR REPLACE VIEW cv_leaf AS + SELECT + cv_id, + cvterm_id + FROM cvterm + WHERE + cvterm_id NOT IN ( SELECT object_id FROM cvterm_relationship); + +COMMENT ON VIEW cv_leaf IS 'the leaves of a cv are the set of terms +which have no children (terms that are not the object of a +relation). All cvs will have at least 1 leaf'; + +CREATE OR REPLACE VIEW common_ancestor_cvterm AS + SELECT + p1.subject_id AS cvterm1_id, + p2.subject_id AS cvterm2_id, + p1.object_id AS ancestor_cvterm_id, + p1.pathdistance AS pathdistance1, + p2.pathdistance AS pathdistance2, + p1.pathdistance + p2.pathdistance + AS total_pathdistance + FROM + cvtermpath AS p1, + cvtermpath AS p2 + WHERE + p1.object_id = p2.object_id; + +COMMENT ON VIEW common_ancestor_cvterm IS 'The common ancestor of any +two terms is the intersection of both terms ancestors. Two terms can +have multiple common ancestors. Use total_pathdistance to get the +least common ancestor'; + +CREATE OR REPLACE VIEW common_descendant_cvterm AS + SELECT + p1.object_id AS cvterm1_id, + p2.object_id AS cvterm2_id, + p1.subject_id AS ancestor_cvterm_id, + p1.pathdistance AS pathdistance1, + p2.pathdistance AS pathdistance2, + p1.pathdistance + p2.pathdistance + AS total_pathdistance + FROM + cvtermpath AS p1, + cvtermpath AS p2 + WHERE + p1.subject_id = p2.subject_id; + +COMMENT ON VIEW common_descendant_cvterm IS 'The common descendant of +any two terms is the intersection of both terms descendants. Two terms +can have multiple common descendants. Use total_pathdistance to get +the least common ancestor'; + +CREATE OR REPLACE VIEW stats_paths_to_root AS + SELECT + subject_id AS cvterm_id, + count(DISTINCT cvtermpath_id) AS total_paths, + avg(pathdistance) AS avg_distance, + min(pathdistance) AS min_distance, + max(pathdistance) AS max_distance + FROM cvtermpath INNER JOIN cv_root ON (object_id=root_cvterm_id) + GROUP BY cvterm_id; + +COMMENT ON VIEW stats_paths_to_root IS 'per-cvterm statistics on its +placement in the DAG relative to the root. There may be multiple paths +from any term to the root. This gives the total number of paths, and +the average minimum and maximum distances. Here distance is defined by +cvtermpath.pathdistance'; +CREATE VIEW cv_cvterm_count AS + SELECT cv.name,count(*) AS num_terms_excl_obs FROM cv INNER JOIN cvterm USING (cv_id) WHERE is_obsolete=0 GROUP BY cv.name; +COMMENT ON VIEW cv_cvterm_count IS 'per-cv terms counts (excludes obsoletes)'; + +CREATE VIEW cv_cvterm_count_with_obs AS + SELECT cv.name,count(*) AS num_terms_incl_obs FROM cv INNER JOIN cvterm USING (cv_id) GROUP BY cv.name; +COMMENT ON VIEW cv_cvterm_count_with_obs IS 'per-cv terms counts (includes obsoletes)'; + +CREATE VIEW cv_link_count AS + SELECT cv.name AS cv_name, + relation.name AS relation_name, + relation_cv.name AS relation_cv_name, + count(*) AS num_links + FROM cv + INNER JOIN cvterm ON (cvterm.cv_id=cv.cv_id) + INNER JOIN cvterm_relationship ON (cvterm.cvterm_id=subject_id) + INNER JOIN cvterm AS relation ON (type_id=relation.cvterm_id) + INNER JOIN cv AS relation_cv ON (relation.cv_id=relation_cv.cv_id) + GROUP BY cv.name,relation.name,relation_cv.name; + +COMMENT ON VIEW cv_link_count IS 'per-cv summary of number of +links (cvterm_relationships) broken down by +relationship_type. num_links is the total # of links of the specified +type in which the subject_id of the link is in the named cv'; + +CREATE VIEW cv_path_count AS + SELECT cv.name AS cv_name, + relation.name AS relation_name, + relation_cv.name AS relation_cv_name, + count(*) AS num_paths + FROM cv + INNER JOIN cvterm ON (cvterm.cv_id=cv.cv_id) + INNER JOIN cvtermpath ON (cvterm.cvterm_id=subject_id) + INNER JOIN cvterm AS relation ON (type_id=relation.cvterm_id) + INNER JOIN cv AS relation_cv ON (relation.cv_id=relation_cv.cv_id) + GROUP BY cv.name,relation.name,relation_cv.name; + +COMMENT ON VIEW cv_path_count IS 'per-cv summary of number of +paths (cvtermpaths) broken down by relationship_type. num_paths is the +total # of paths of the specified type in which the subject_id of the +path is in the named cv. See also: cv_distinct_relations'; + +CREATE OR REPLACE FUNCTION _get_all_subject_ids(integer) RETURNS SETOF cvtermpath AS +' +DECLARE + root alias for $1; + cterm cvtermpath%ROWTYPE; + cterm2 cvtermpath%ROWTYPE; +BEGIN + + FOR cterm IN SELECT * FROM cvterm_relationship WHERE object_id = root LOOP + RETURN NEXT cterm; + FOR cterm2 IN SELECT * FROM _get_all_subject_ids(cterm.subject_id) LOOP + RETURN NEXT cterm2; + END LOOP; + END LOOP; + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +---arg: parent term id +---return: all children term id and their parent term id with relationship type id +CREATE OR REPLACE FUNCTION get_all_subject_ids(integer) RETURNS SETOF cvtermpath AS +' +DECLARE + root alias for $1; + cterm cvtermpath%ROWTYPE; + exist_c int; +BEGIN + + SELECT INTO exist_c count(*) FROM cvtermpath WHERE object_id = root and pathdistance <= 0; + IF (exist_c > 0) THEN + FOR cterm IN SELECT * FROM cvtermpath WHERE object_id = root and pathdistance > 0 LOOP + RETURN NEXT cterm; + END LOOP; + ELSE + FOR cterm IN SELECT * FROM _get_all_subject_ids(root) LOOP + RETURN NEXT cterm; + END LOOP; + END IF; + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +CREATE OR REPLACE FUNCTION get_graph_below(integer) RETURNS SETOF cvtermpath AS +' +DECLARE + root alias for $1; + cterm cvtermpath%ROWTYPE; + cterm2 cvtermpath%ROWTYPE; + +BEGIN + + FOR cterm IN SELECT * FROM cvterm_relationship WHERE object_id = root LOOP + RETURN NEXT cterm; + FOR cterm2 IN SELECT * FROM get_all_subject_ids(cterm.subject_id) LOOP + RETURN NEXT cterm2; + END LOOP; + END LOOP; + RETURN; +END; +' +LANGUAGE 'plpgsql'; + + +CREATE OR REPLACE FUNCTION get_graph_above(integer) RETURNS SETOF cvtermpath AS +' +DECLARE + leaf alias for $1; + cterm cvtermpath%ROWTYPE; + cterm2 cvtermpath%ROWTYPE; + +BEGIN + + FOR cterm IN SELECT * FROM cvterm_relationship WHERE subject_id = leaf LOOP + RETURN NEXT cterm; + FOR cterm2 IN SELECT * FROM get_all_object_ids(cterm.object_id) LOOP + RETURN NEXT cterm2; + END LOOP; + END LOOP; + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +CREATE OR REPLACE FUNCTION _get_all_object_ids(integer) RETURNS SETOF cvtermpath AS +' +DECLARE + leaf alias for $1; + cterm cvtermpath%ROWTYPE; + cterm2 cvtermpath%ROWTYPE; +BEGIN + + FOR cterm IN SELECT * FROM cvterm_relationship WHERE subject_id = leaf LOOP + RETURN NEXT cterm; + FOR cterm2 IN SELECT * FROM _get_all_object_ids(cterm.object_id) LOOP + RETURN NEXT cterm2; + END LOOP; + END LOOP; + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +---arg: child term id +---return: all parent term id and their childrent term id with relationship type id +CREATE OR REPLACE FUNCTION get_all_object_ids(integer) RETURNS SETOF cvtermpath AS +' +DECLARE + leaf alias for $1; + cterm cvtermpath%ROWTYPE; + exist_c int; +BEGIN + + + SELECT INTO exist_c count(*) FROM cvtermpath WHERE object_id = leaf and pathdistance <= 0; + IF (exist_c > 0) THEN + FOR cterm IN SELECT * FROM cvtermpath WHERE subject_id = leaf AND pathdistance > 0 LOOP + RETURN NEXT cterm; + END LOOP; + ELSE + FOR cterm IN SELECT * FROM _get_all_object_ids(leaf) LOOP + RETURN NEXT cterm; + END LOOP; + END IF; + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +---arg: sql statement which must be in the form of select cvterm_id from ... +---return: a set of cvterm ids that includes what is in sql statement and their children (subject ids) +CREATE OR REPLACE FUNCTION get_it_sub_cvterm_ids(text) RETURNS SETOF cvterm AS +' +DECLARE + query alias for $1; + cterm cvterm%ROWTYPE; + cterm2 cvterm%ROWTYPE; +BEGIN + FOR cterm IN EXECUTE query LOOP + RETURN NEXT cterm; + FOR cterm2 IN SELECT subject_id as cvterm_id FROM get_all_subject_ids(cterm.cvterm_id) LOOP + RETURN NEXT cterm2; + END LOOP; + END LOOP; + RETURN; +END; +' +LANGUAGE 'plpgsql'; +--- example: select * from fill_cvtermpath(7); where 7 is cv_id for an ontology +--- fill path from the node to its children and their children +CREATE OR REPLACE FUNCTION _fill_cvtermpath4node(INTEGER, INTEGER, INTEGER, INTEGER, INTEGER) RETURNS INTEGER AS +' +DECLARE + origin alias for $1; + child_id alias for $2; + cvid alias for $3; + typeid alias for $4; + depth alias for $5; + cterm cvterm_relationship%ROWTYPE; + exist_c int; + +BEGIN + + --- RAISE NOTICE ''depth=% root=%'', depth,child_id; + --- not check type_id as it may be null and not very meaningful in cvtermpath when pathdistance > 1 + SELECT INTO exist_c count(*) FROM cvtermpath WHERE cv_id = cvid AND object_id = origin AND subject_id = child_id AND pathdistance = depth; + + IF (exist_c = 0) THEN + INSERT INTO cvtermpath (object_id, subject_id, cv_id, type_id, pathdistance) VALUES(origin, child_id, cvid, typeid, depth); + END IF; + FOR cterm IN SELECT * FROM cvterm_relationship WHERE object_id = child_id LOOP + PERFORM _fill_cvtermpath4node(origin, cterm.subject_id, cvid, cterm.type_id, depth+1); + END LOOP; + RETURN 1; +END; +' +LANGUAGE 'plpgsql'; + + +CREATE OR REPLACE FUNCTION _fill_cvtermpath4root(INTEGER, INTEGER) RETURNS INTEGER AS +' +DECLARE + rootid alias for $1; + cvid alias for $2; + ttype int; + cterm cvterm_relationship%ROWTYPE; + child cvterm_relationship%ROWTYPE; + +BEGIN + + SELECT INTO ttype cvterm_id FROM cvterm WHERE (name = ''isa'' OR name = ''is_a''); + PERFORM _fill_cvtermpath4node(rootid, rootid, cvid, ttype, 0); + FOR cterm IN SELECT * FROM cvterm_relationship WHERE object_id = rootid LOOP + PERFORM _fill_cvtermpath4root(cterm.subject_id, cvid); + -- RAISE NOTICE ''DONE for term, %'', cterm.subject_id; + END LOOP; + RETURN 1; +END; +' +LANGUAGE 'plpgsql'; + +CREATE OR REPLACE FUNCTION fill_cvtermpath(INTEGER) RETURNS INTEGER AS +' +DECLARE + cvid alias for $1; + root cvterm%ROWTYPE; + +BEGIN + + DELETE FROM cvtermpath WHERE cv_id = cvid; + + FOR root IN SELECT DISTINCT t.* from cvterm t LEFT JOIN cvterm_relationship r ON (t.cvterm_id = r.subject_id) INNER JOIN cvterm_relationship r2 ON (t.cvterm_id = r2.object_id) WHERE t.cv_id = cvid AND r.subject_id is null LOOP + PERFORM _fill_cvtermpath4root(root.cvterm_id, root.cv_id); + END LOOP; + RETURN 1; +END; +' +LANGUAGE 'plpgsql'; + +CREATE OR REPLACE FUNCTION fill_cvtermpath(cv.name%TYPE) RETURNS INTEGER AS +' +DECLARE + cvname alias for $1; + cv_id int; + rtn int; +BEGIN + + SELECT INTO cv_id cv.cv_id from cv WHERE cv.name = cvname; + SELECT INTO rtn fill_cvtermpath(cv_id); + RETURN rtn; +END; +' +LANGUAGE 'plpgsql'; + +CREATE OR REPLACE FUNCTION _fill_cvtermpath4node2detect_cycle(INTEGER, INTEGER, INTEGER, INTEGER, INTEGER) RETURNS INTEGER AS +' +DECLARE + origin alias for $1; + child_id alias for $2; + cvid alias for $3; + typeid alias for $4; + depth alias for $5; + cterm cvterm_relationship%ROWTYPE; + exist_c int; + ccount int; + ecount int; + rtn int; +BEGIN + + EXECUTE ''SELECT * FROM tmpcvtermpath p1, tmpcvtermpath p2 WHERE p1.subject_id=p2.object_id AND p1.object_id=p2.subject_id AND p1.object_id = ''|| origin || '' AND p2.subject_id = '' || child_id || ''AND '' || depth || ''> 0''; + GET DIAGNOSTICS ccount = ROW_COUNT; + IF (ccount > 0) THEN + --RAISE EXCEPTION ''FOUND CYCLE: node % on cycle path'',origin; + RETURN origin; + END IF; + + EXECUTE ''SELECT * FROM tmpcvtermpath WHERE cv_id = '' || cvid || '' AND object_id = '' || origin || '' AND subject_id = '' || child_id || '' AND '' || origin || ''<>'' || child_id; + GET DIAGNOSTICS ecount = ROW_COUNT; + IF (ecount > 0) THEN + --RAISE NOTICE ''FOUND TWICE (node), will check root obj % subj %'',origin, child_id; + SELECT INTO rtn _fill_cvtermpath4root2detect_cycle(child_id, cvid); + IF (rtn > 0) THEN + RETURN rtn; + END IF; + END IF; + + EXECUTE ''SELECT * FROM tmpcvtermpath WHERE cv_id = '' || cvid || '' AND object_id = '' || origin || '' AND subject_id = '' || child_id || '' AND pathdistance = '' || depth; + GET DIAGNOSTICS exist_c = ROW_COUNT; + IF (exist_c = 0) THEN + EXECUTE ''INSERT INTO tmpcvtermpath (object_id, subject_id, cv_id, type_id, pathdistance) VALUES('' || origin || '', '' || child_id || '', '' || cvid || '', '' || typeid || '', '' || depth || '')''; + END IF; + + FOR cterm IN SELECT * FROM cvterm_relationship WHERE object_id = child_id LOOP + --RAISE NOTICE ''DOING for node, % %'', origin, cterm.subject_id; + SELECT INTO rtn _fill_cvtermpath4node2detect_cycle(origin, cterm.subject_id, cvid, cterm.type_id, depth+1); + IF (rtn > 0) THEN + RETURN rtn; + END IF; + END LOOP; + RETURN 0; +END; +' +LANGUAGE 'plpgsql'; + + +CREATE OR REPLACE FUNCTION _fill_cvtermpath4root2detect_cycle(INTEGER, INTEGER) RETURNS INTEGER AS +' +DECLARE + rootid alias for $1; + cvid alias for $2; + ttype int; + ccount int; + cterm cvterm_relationship%ROWTYPE; + child cvterm_relationship%ROWTYPE; + rtn int; +BEGIN + + SELECT INTO ttype cvterm_id FROM cvterm WHERE (name = ''isa'' OR name = ''is_a''); + SELECT INTO rtn _fill_cvtermpath4node2detect_cycle(rootid, rootid, cvid, ttype, 0); + IF (rtn > 0) THEN + RETURN rtn; + END IF; + FOR cterm IN SELECT * FROM cvterm_relationship WHERE object_id = rootid LOOP + EXECUTE ''SELECT * FROM tmpcvtermpath p1, tmpcvtermpath p2 WHERE p1.subject_id=p2.object_id AND p1.object_id=p2.subject_id AND p1.object_id='' || rootid || '' AND p1.subject_id='' || cterm.subject_id; + GET DIAGNOSTICS ccount = ROW_COUNT; + IF (ccount > 0) THEN + --RAISE NOTICE ''FOUND TWICE (root), will check root obj % subj %'',rootid,cterm.subject_id; + SELECT INTO rtn _fill_cvtermpath4node2detect_cycle(rootid, cterm.subject_id, cvid, ttype, 0); + IF (rtn > 0) THEN + RETURN rtn; + END IF; + ELSE + SELECT INTO rtn _fill_cvtermpath4root2detect_cycle(cterm.subject_id, cvid); + IF (rtn > 0) THEN + RETURN rtn; + END IF; + END IF; + END LOOP; + RETURN 0; +END; +' +LANGUAGE 'plpgsql'; + +CREATE OR REPLACE FUNCTION get_cycle_cvterm_id(INTEGER, INTEGER) RETURNS INTEGER AS +' +DECLARE + cvid alias for $1; + rootid alias for $2; + rtn int; +BEGIN + + CREATE TEMP TABLE tmpcvtermpath(object_id int, subject_id int, cv_id int, type_id int, pathdistance int); + CREATE INDEX tmp_cvtpath1 ON tmpcvtermpath(object_id, subject_id); + + SELECT INTO rtn _fill_cvtermpath4root2detect_cycle(rootid, cvid); + IF (rtn > 0) THEN + DROP TABLE tmpcvtermpath; + RETURN rtn; + END IF; + DROP TABLE tmpcvtermpath; + RETURN 0; +END; +' +LANGUAGE 'plpgsql'; + +CREATE OR REPLACE FUNCTION get_cycle_cvterm_ids(INTEGER) RETURNS SETOF INTEGER AS +' +DECLARE + cvid alias for $1; + root cvterm%ROWTYPE; + rtn int; +BEGIN + + + FOR root IN SELECT DISTINCT t.* from cvterm t WHERE cv_id = cvid LOOP + SELECT INTO rtn get_cycle_cvterm_id(cvid,root.cvterm_id); + IF (rtn > 0) THEN + RETURN NEXT rtn; + END IF; + END LOOP; + RETURN; +END; +' +LANGUAGE 'plpgsql'; + +CREATE OR REPLACE FUNCTION get_cycle_cvterm_id(INTEGER) RETURNS INTEGER AS +' +DECLARE + cvid alias for $1; + root cvterm%ROWTYPE; + rtn int; +BEGIN + + CREATE TEMP TABLE tmpcvtermpath(object_id int, subject_id int, cv_id int, type_id int, pathdistance int); + CREATE INDEX tmp_cvtpath1 ON tmpcvtermpath(object_id, subject_id); + + FOR root IN SELECT DISTINCT t.* from cvterm t LEFT JOIN cvterm_relationship r ON (t.cvterm_id = r.subject_id) INNER JOIN cvterm_relationship r2 ON (t.cvterm_id = r2.object_id) WHERE t.cv_id = cvid AND r.subject_id is null LOOP + SELECT INTO rtn _fill_cvtermpath4root2detect_cycle(root.cvterm_id, root.cv_id); + IF (rtn > 0) THEN + DROP TABLE tmpcvtermpath; + RETURN rtn; + END IF; + END LOOP; + DROP TABLE tmpcvtermpath; + RETURN 0; +END; +' +LANGUAGE 'plpgsql'; + +CREATE OR REPLACE FUNCTION get_cycle_cvterm_id(cv.name%TYPE) RETURNS INTEGER AS +' +DECLARE + cvname alias for $1; + cv_id int; + rtn int; +BEGIN + + SELECT INTO cv_id cv.cv_id from cv WHERE cv.name = cvname; + SELECT INTO rtn get_cycle_cvterm_id(cv_id); + + RETURN rtn; +END; +' +LANGUAGE 'plpgsql'; +-- $Id: default_schema.sql,v 1.53 2008-03-28 16:05:24 scottcain Exp $ +-- ========================================== +-- Chado pub module +-- +-- ================================================================= +-- Dependencies: +-- +-- :import cvterm from cv +-- :import dbxref from general +-- ================================================================= + +-- ================================================ +-- TABLE: pub +-- ================================================ + +create table pub ( + pub_id serial not null, + primary key (pub_id), + title text, + volumetitle text, + volume varchar(255), + series_name varchar(255), + issue varchar(255), + pyear varchar(255), + pages varchar(255), + miniref varchar(255), + uniquename text not null, + type_id int not null, + foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, + is_obsolete boolean default 'false', + publisher varchar(255), + pubplace varchar(255), + constraint pub_c1 unique (uniquename) +); +CREATE INDEX pub_idx1 ON pub (type_id); + +COMMENT ON TABLE pub IS 'A documented provenance artefact - publications, +documents, personal communication.'; +COMMENT ON COLUMN pub.title IS 'Descriptive general heading.'; +COMMENT ON COLUMN pub.volumetitle IS 'Title of part if one of a series.'; +COMMENT ON COLUMN pub.series_name IS 'Full name of (journal) series.'; +COMMENT ON COLUMN pub.pages IS 'Page number range[s], e.g. 457--459, viii + 664pp, lv--lvii.'; +COMMENT ON COLUMN pub.type_id IS 'The type of the publication (book, journal, poem, graffiti, etc). Uses pub cv.'; + +-- ================================================ +-- TABLE: pub_relationship +-- ================================================ + +create table pub_relationship ( + pub_relationship_id serial not null, + primary key (pub_relationship_id), + subject_id int not null, + foreign key (subject_id) references pub (pub_id) on delete cascade INITIALLY DEFERRED, + object_id int not null, + foreign key (object_id) references pub (pub_id) on delete cascade INITIALLY DEFERRED, + type_id int not null, + foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, + + constraint pub_relationship_c1 unique (subject_id,object_id,type_id) +); +create index pub_relationship_idx1 on pub_relationship (subject_id); +create index pub_relationship_idx2 on pub_relationship (object_id); +create index pub_relationship_idx3 on pub_relationship (type_id); + +COMMENT ON TABLE pub_relationship IS 'Handle relationships between +publications, e.g. when one publication makes others obsolete, when one +publication contains errata with respect to other publication(s), or +when one publication also appears in another pub.'; + +-- ================================================ +-- TABLE: pub_dbxref +-- ================================================ + +create table pub_dbxref ( + pub_dbxref_id serial not null, + primary key (pub_dbxref_id), + pub_id int not null, + foreign key (pub_id) references pub (pub_id) on delete cascade INITIALLY DEFERRED, + dbxref_id int not null, + foreign key (dbxref_id) references dbxref (dbxref_id) on delete cascade INITIALLY DEFERRED, + is_current boolean not null default 'true', + constraint pub_dbxref_c1 unique (pub_id,dbxref_id) +); +create index pub_dbxref_idx1 on pub_dbxref (pub_id); +create index pub_dbxref_idx2 on pub_dbxref (dbxref_id); + +COMMENT ON TABLE pub_dbxref IS 'Handle links to repositories, +e.g. Pubmed, Biosis, zoorec, OCLC, Medline, ISSN, coden...'; + + +-- ================================================ +-- TABLE: pubauthor +-- ================================================ + +create table pubauthor ( + pubauthor_id serial not null, + primary key (pubauthor_id), + pub_id int not null, + foreign key (pub_id) references pub (pub_id) on delete cascade INITIALLY DEFERRED, + rank int not null, + editor boolean default 'false', + surname varchar(100) not null, + givennames varchar(100), + suffix varchar(100), + + constraint pubauthor_c1 unique (pub_id, rank) +); +create index pubauthor_idx2 on pubauthor (pub_id); + +COMMENT ON TABLE pubauthor IS 'An author for a publication. Note the denormalisation (hence lack of _ in table name) - this is deliberate as it is in general too hard to assign IDs to authors.'; +COMMENT ON COLUMN pubauthor.givennames IS 'First name, initials'; +COMMENT ON COLUMN pubauthor.suffix IS 'Jr., Sr., etc'; +COMMENT ON COLUMN pubauthor.rank IS 'Order of author in author list for this pub - order is important.'; +COMMENT ON COLUMN pubauthor.editor IS 'Indicates whether the author is an editor for linked publication. Note: this is a boolean field but does not follow the normal chado convention for naming booleans.'; + + +-- ================================================ +-- TABLE: pubprop +-- ================================================ + +create table pubprop ( + pubprop_id serial not null, + primary key (pubprop_id), + pub_id int not null, + foreign key (pub_id) references pub (pub_id) on delete cascade INITIALLY DEFERRED, + type_id int not null, + foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, + value text not null, + rank integer, + + constraint pubprop_c1 unique (pub_id,type_id,rank) +); +create index pubprop_idx1 on pubprop (pub_id); +create index pubprop_idx2 on pubprop (type_id); + +COMMENT ON TABLE pubprop IS 'Property-value pairs for a pub. Follows standard chado pattern.'; +-- $Id: default_schema.sql,v 1.53 2008-03-28 16:05:24 scottcain Exp $ +-- ========================================== +-- Chado organism module +-- +-- ============ +-- DEPENDENCIES +-- ============ +-- :import cvterm from cv +-- :import dbxref from general +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +-- ================================================ +-- TABLE: organism +-- ================================================ + +create table organism ( + organism_id serial not null, + primary key (organism_id), + abbreviation varchar(255) null, + genus varchar(255) not null, + species varchar(255) not null, + common_name varchar(255) null, + comment text null, + constraint organism_c1 unique (genus,species) +); + +COMMENT ON TABLE organism IS 'The organismal taxonomic +classification. Note that phylogenies are represented using the +phylogeny module, and taxonomies can be represented using the cvterm +module or the phylogeny module.'; + +COMMENT ON COLUMN organism.species IS 'A type of organism is always +uniquely identified by genus and species. When mapping from the NCBI +taxonomy names.dmp file, this column must be used where it +is present, as the common_name column is not always unique (e.g. environmental +samples). If a particular strain or subspecies is to be represented, +this is appended onto the species name. Follows standard NCBI taxonomy +pattern.'; + +-- ================================================ +-- TABLE: organism_dbxref +-- ================================================ + +create table organism_dbxref ( + organism_dbxref_id serial not null, + primary key (organism_dbxref_id), + organism_id int not null, + foreign key (organism_id) references organism (organism_id) on delete cascade INITIALLY DEFERRED, + dbxref_id int not null, + foreign key (dbxref_id) references dbxref (dbxref_id) on delete cascade INITIALLY DEFERRED, + constraint organism_dbxref_c1 unique (organism_id,dbxref_id) +); +create index organism_dbxref_idx1 on organism_dbxref (organism_id); +create index organism_dbxref_idx2 on organism_dbxref (dbxref_id); + +-- ================================================ +-- TABLE: organismprop +-- ================================================ + +create table organismprop ( + organismprop_id serial not null, + primary key (organismprop_id), + organism_id int not null, + foreign key (organism_id) references organism (organism_id) on delete cascade INITIALLY DEFERRED, + type_id int not null, + foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, + value text null, + rank int not null default 0, + constraint organismprop_c1 unique (organism_id,type_id,rank) +); +create index organismprop_idx1 on organismprop (organism_id); +create index organismprop_idx2 on organismprop (type_id); + +COMMENT ON TABLE organismprop IS 'Tag-value properties - follows standard chado model.'; + + +CREATE OR REPLACE FUNCTION get_organism_id(VARCHAR,VARCHAR) RETURNS INT + AS ' + SELECT organism_id + FROM organism + WHERE genus=$1 + AND species=$2 + ' LANGUAGE 'sql'; + +CREATE OR REPLACE FUNCTION get_organism_id(VARCHAR) RETURNS INT + AS ' +SELECT organism_id + FROM organism + WHERE genus=substring($1,1,position('' '' IN $1)-1) + AND species=substring($1,position('' '' IN $1)+1) + ' LANGUAGE 'sql'; + +CREATE OR REPLACE FUNCTION get_organism_id_abbrev(VARCHAR) RETURNS INT + AS ' +SELECT organism_id + FROM organism + WHERE substr(genus,1,1)=substring($1,1,1) + AND species=substring($1,position('' '' IN $1)+1) + ' LANGUAGE 'sql'; + +CREATE OR REPLACE FUNCTION store_organism (VARCHAR,VARCHAR,VARCHAR) + RETURNS INT AS +'DECLARE + v_genus ALIAS FOR $1; + v_species ALIAS FOR $2; + v_common_name ALIAS FOR $3; + + v_organism_id INTEGER; + BEGIN + SELECT INTO v_organism_id organism_id + FROM organism + WHERE genus=v_genus AND + species=v_species; + IF NOT FOUND THEN + INSERT INTO organism + (genus,species,common_name) + VALUES + (v_genus,v_species,v_common_name); + RETURN currval(''organism_organism_id_seq''); + ELSE + UPDATE organism + SET common_name=v_common_name + WHERE organism_id = v_organism_id; + END IF; + RETURN v_organism_id; + END; +' LANGUAGE 'plpgsql'; + +-- $Id: default_schema.sql,v 1.53 2008-03-28 16:05:24 scottcain Exp $ +-- ========================================== +-- Chado sequence module +-- +-- ================================================================= +-- Dependencies: +-- +-- :import cvterm from cv +-- :import pub from pub +-- :import organism from organism +-- :import dbxref from general +-- ================================================================= + +-- ================================================ +-- TABLE: feature +-- ================================================ + +create table feature ( + feature_id serial not null, + primary key (feature_id), + dbxref_id int, + foreign key (dbxref_id) references dbxref (dbxref_id) on delete set null INITIALLY DEFERRED, + organism_id int not null, + foreign key (organism_id) references organism (organism_id) on delete cascade INITIALLY DEFERRED, + name varchar(255), + uniquename text not null, + residues text, + seqlen int, + md5checksum char(32), + type_id int not null, + foreign key (type_id) references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED, + is_analysis boolean not null default 'false', + is_obsolete boolean not null default 'false', + timeaccessioned timestamp not null default current_timestamp, + timelastmodified timestamp not null default current_timestamp, + constraint feature_c1 unique (organism_id,uniquename,type_id) +); +create sequence feature_uniquename_seq; +create index feature_name_ind1 on feature(name); +create index feature_idx1 on feature (dbxref_id); +create index feature_idx2 on feature (organism_id); +create index feature_idx3 on feature (type_id); +create index feature_idx4 on feature (uniquename); +create index feature_idx5 on feature (lower(name)); + +COMMENT ON TABLE feature IS 'A feature is a biological sequence or a +section of a biological sequence, or a collection of such +sections. Examples include genes, exons, transcripts, regulatory +regions, polypeptides, protein domains, chromosome sequences, sequence +variations, cross-genome match regions such as hits and HSPs and so +on; see the Sequence Ontology for more. The combination of +organism_id, uniquename and type_id should be unique.'; + +COMMENT ON COLUMN feature.dbxref_id IS 'An optional primary public stable +identifier for this feature. Secondary identifiers and external +dbxrefs go in the table feature_dbxref.'; + +COMMENT ON COLUMN feature.organism_id IS 'The organism to which this feature +belongs. This column is mandatory.'; + +COMMENT ON COLUMN feature.name IS 'The optional human-readable common name for +a feature, for display purposes.'; + +COMMENT ON COLUMN feature.uniquename IS 'The unique name for a feature; may +not be necessarily be particularly human-readable, although this is +preferred. This name must be unique for this type of feature within +this organism.'; + +COMMENT ON COLUMN feature.residues IS 'A sequence of alphabetic characters +representing biological residues (nucleic acids, amino acids). This +column does not need to be manifested for all features; it is optional +for features such as exons where the residues can be derived from the +featureloc. It is recommended that the value for this column be +manifested for features which may may non-contiguous sublocations (e.g. +transcripts), since derivation at query time is non-trivial. For +expressed sequence, the DNA sequence should be used rather than the +RNA sequence.'; + +COMMENT ON COLUMN feature.seqlen IS 'The length of the residue feature. See +column:residues. This column is partially redundant with the residues +column, and also with featureloc. This column is required because the +location may be unknown and the residue sequence may not be +manifested, yet it may be desirable to store and query the length of +the feature. The seqlen should always be manifested where the length +of the sequence is known.'; + +COMMENT ON COLUMN feature.md5checksum IS 'The 32-character checksum of the sequence, +calculated using the MD5 algorithm. This is practically guaranteed to +be unique for any feature. This column thus acts as a unique +identifier on the mathematical sequence.'; + +COMMENT ON COLUMN feature.type_id IS 'A required reference to a table:cvterm +giving the feature type. This will typically be a Sequence Ontology +identifier. This column is thus used to subclass the feature table.'; + +COMMENT ON COLUMN feature.is_analysis IS 'Boolean indicating whether this +feature is annotated or the result of an automated analysi... [truncated message content] |
From: <sco...@us...> - 2011-06-21 21:47:55
|
Revision: 25044 http://gmod.svn.sourceforge.net/gmod/?rev=25044&view=rev Author: scottcain Date: 2011-06-21 21:47:46 +0000 (Tue, 21 Jun 2011) Log Message: ----------- adding functionality to add a new organism at install time Modified Paths: -------------- schema/trunk/chado/MANIFEST schema/trunk/chado/Makefile.PL schema/trunk/chado/lib/Bio/Chado/Builder.pm schema/trunk/chado/load/tt2/load.conf.tt2 Modified: schema/trunk/chado/MANIFEST =================================================================== --- schema/trunk/chado/MANIFEST 2011-06-21 21:33:54 UTC (rev 25043) +++ schema/trunk/chado/MANIFEST 2011-06-21 21:47:46 UTC (rev 25044) @@ -5,6 +5,7 @@ bin/config.PLS bin/create-bridge-sql.pl bin/create-so-bridge.pl +bin/gmod_add_organism.pl bin/gmod_bulk_load_pubmed.pl bin/gmod_load_cvterms.pl bin/gmod_make_cvtermpath.pl Modified: schema/trunk/chado/Makefile.PL =================================================================== --- schema/trunk/chado/Makefile.PL 2011-06-21 21:33:54 UTC (rev 25043) +++ schema/trunk/chado/Makefile.PL 2011-06-21 21:47:46 UTC (rev 25044) @@ -423,6 +423,7 @@ db_password => $DBPASS, db_host => $DBHOST, db_port => $DBPORT, + db_organism => $DBORGANISM, local_tmp => $LOCAL_TMP, working_dir => $working_dir, external_ddl => $external, @@ -488,6 +489,7 @@ 'bin/gmod_load_cvterms.pl', 'bin/gmod_bulk_load_pubmed.pl', 'bin/gmod_make_cvtermpath.pl', + 'bin/gmod_add_organism.pl', # 'bin/gmod_bulkfiles.pl', # 'bin/gmod_gff2biomart5.pl', ); Modified: schema/trunk/chado/lib/Bio/Chado/Builder.pm =================================================================== --- schema/trunk/chado/lib/Bio/Chado/Builder.pm 2011-06-21 21:33:54 UTC (rev 25043) +++ schema/trunk/chado/lib/Bio/Chado/Builder.pm 2011-06-21 21:47:46 UTC (rev 25044) @@ -27,7 +27,9 @@ Calls the psql command and pipes in the contents of the load/etc/initialize.sql file. Put any insert statements that -your data load needs here. +your data load needs here. Also executes gmod_add_organism.pl +if the common_name provided in the perl Makefile.PL step isn't +present in the database. =item ncbi() @@ -82,6 +84,18 @@ system( $sys_call ) == 0 or croak "Error executing '$sys_call': $?"; + $m->log->debug("Checking for organism"); + + my $db_org = $conf->{'database'}{'db_organism'}; + + if ($db_org and ($db_org ne 'none')) { + my $result = `bin/gmod_add_organism.pl --name_only --common_name $db_org`; + unless ($result) { + print "Adding $db_org to the database...\n"; + system('bin/gmod_add_organism.pl','--common_name',$db_org); + } + } + $m->log->info("leaving ACTION_prepdb"); } Modified: schema/trunk/chado/load/tt2/load.conf.tt2 =================================================================== --- schema/trunk/chado/load/tt2/load.conf.tt2 2011-06-21 21:33:54 UTC (rev 25043) +++ schema/trunk/chado/load/tt2/load.conf.tt2 2011-06-21 21:47:46 UTC (rev 25044) @@ -6,6 +6,7 @@ <db_password>[% db_password %]</db_password> <db_host>[% db_host %]</db_host> <db_port>[% db_port %]</db_port> + <db_organism>[% db_organism %]</db_organism> </database> <build> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sco...@us...> - 2011-07-18 17:10:08
|
Revision: 25095 http://gmod.svn.sourceforge.net/gmod/?rev=25095&view=rev Author: scottcain Date: 2011-07-18 17:09:52 +0000 (Mon, 18 Jul 2011) Log Message: ----------- Several items: * Removed the dependency on Log::Log4perl * updated the schema for the next release * updated the so-bridge for new SO terms Modified Paths: -------------- schema/trunk/chado/Changes schema/trunk/chado/Makefile.PL schema/trunk/chado/bin/AutoDBI.PL schema/trunk/chado/bin/create_so_bridge_command schema/trunk/chado/lib/Bio/Chado/Builder.pm schema/trunk/chado/load/Build.PL schema/trunk/chado/load/bin/load_affyxls.pl schema/trunk/chado/modules/audit/audit_tables.sql schema/trunk/chado/modules/cv/cv.html schema/trunk/chado/modules/cv/cv.sql schema/trunk/chado/modules/default_nofuncs.sql schema/trunk/chado/modules/default_schema.sql schema/trunk/chado/modules/genetic/genetic.html schema/trunk/chado/modules/natural_diversity/natural_diversity.html schema/trunk/chado/modules/nofuncs.html schema/trunk/chado/modules/phenotype/phenotype.html schema/trunk/chado/modules/sequence/bridges/so-bridge.sql Modified: schema/trunk/chado/Changes =================================================================== --- schema/trunk/chado/Changes 2011-07-14 15:25:29 UTC (rev 25094) +++ schema/trunk/chado/Changes 2011-07-18 17:09:52 UTC (rev 25095) @@ -1,4 +1,4 @@ -Version 1.12 Tue Aug 10 13:59:05 EDT 2010 +Version 1.2 Tue Aug 10 13:59:05 EDT 2010 * Added some error checking to gmod_fasta2gff3.pl (Rob) * Updated Bio::Chado::Builder to detect recent versions of go-perl. They no longer have .pl at the end of the go2fmt script name (Rob) @@ -14,6 +14,9 @@ a loaded cv. (Scott) * Removed the "DB:" prefix from all of the names of databases that go into the db table. (Scott) +* Removed the dependency on Log::Log4perl (it was overkill for what it +was being used for) (Scott) +* Bumped the version to 1.2 because of the new schema module. (Scott) Version 1.11 Tue May 25 11:10:47 EDT 2010 * fixed an issue with accessing the primary_id of Modified: schema/trunk/chado/Makefile.PL =================================================================== --- schema/trunk/chado/Makefile.PL 2011-07-14 15:25:29 UTC (rev 25094) +++ schema/trunk/chado/Makefile.PL 2011-07-18 17:09:52 UTC (rev 25095) @@ -502,7 +502,7 @@ # 'INSTALLSITELIB' => '$(INSTALLSITEARCH)', 'NAME' => 'chado', # 'NAME' => 'gmod', - 'VERSION' => '1.12', + 'VERSION' => '1.2', 'PREREQ_PM' => { #'SQL::Translator' => 0.05, #'Class::DBI' => 0.94, Modified: schema/trunk/chado/bin/AutoDBI.PL =================================================================== --- schema/trunk/chado/bin/AutoDBI.PL 2011-07-14 15:25:29 UTC (rev 25094) +++ schema/trunk/chado/bin/AutoDBI.PL 2011-07-18 17:09:52 UTC (rev 25095) @@ -42,7 +42,7 @@ # This is how you normally connect with Class DBI's connection pooling but # its very fragile for me on FC2. I'm replacing it with the db_Main method below -#Bio::Chado::DBI->set_db('Main', 'dbi:Pg:dbname=chado_test', 'cain', ''); +#Bio::Chado::DBI->set_db('Main', 'dbi:Pg:dbname=chado', 'cain', ''); my $db_options = { __PACKAGE__->_default_attributes }; __PACKAGE__->_remember_handle('Main'); # so dbi_commit works @@ -657,6 +657,57 @@ 1; +########Bio::Chado::CDBI::Stock_Cvtermprop######## + +package Bio::Chado::CDBI::Stock_Cvtermprop; +use base 'Bio::Chado::DBI'; +use Class::DBI::Pager; +no warnings qw(redefine); + +Bio::Chado::CDBI::Stock_Cvtermprop->set_up_table('stock_cvtermprop'); + +# +# Primary key accessors +# + +sub id { shift->stock_cvtermprop_id } +sub stock_cvtermprop { shift->stock_cvtermprop_id } + + + + +# +# Has A +# + +Bio::Chado::CDBI::Stock_Cvtermprop->has_a(stock_cvterm_id => 'Bio::Chado::CDBI::Stock_Cvterm'); + +sub Bio::Chado::CDBI::Stock_Cvtermprop::stock_cvterm { return shift->stock_cvterm_id } + + +Bio::Chado::CDBI::Stock_Cvtermprop->has_a(type_id => 'Bio::Chado::CDBI::Cvterm'); + +sub Bio::Chado::CDBI::Stock_Cvtermprop::cvterm { return shift->type_id } + + +# +# Has Many +# + + + +# one to many to one + +# one to many to many + +#many to many to one + +#many to many to many + + + +1; + ########Bio::Chado::CDBI::Cell_Line_Dbxref######## package Bio::Chado::CDBI::Cell_Line_Dbxref; @@ -1671,6 +1722,57 @@ 1; +########Bio::Chado::CDBI::Genotypeprop######## + +package Bio::Chado::CDBI::Genotypeprop; +use base 'Bio::Chado::DBI'; +use Class::DBI::Pager; +no warnings qw(redefine); + +Bio::Chado::CDBI::Genotypeprop->set_up_table('genotypeprop'); + +# +# Primary key accessors +# + +sub id { shift->genotypeprop_id } +sub genotypeprop { shift->genotypeprop_id } + + + + +# +# Has A +# + +Bio::Chado::CDBI::Genotypeprop->has_a(genotype_id => 'Bio::Chado::CDBI::Genotype'); + +sub Bio::Chado::CDBI::Genotypeprop::genotype { return shift->genotype_id } + + +Bio::Chado::CDBI::Genotypeprop->has_a(type_id => 'Bio::Chado::CDBI::Cvterm'); + +sub Bio::Chado::CDBI::Genotypeprop::cvterm { return shift->type_id } + + +# +# Has Many +# + + + +# one to many to one + +# one to many to many + +#many to many to one + +#many to many to many + + + +1; + ########Bio::Chado::CDBI::Genotype######## package Bio::Chado::CDBI::Genotype; @@ -1694,17 +1796,28 @@ # Has A # + +Bio::Chado::CDBI::Genotype->has_a(type_id => 'Bio::Chado::CDBI::Cvterm'); + +sub Bio::Chado::CDBI::Genotype::cvterm { return shift->type_id } + + # # Has Many # +Bio::Chado::CDBI::Genotype->has_many('genotypeprop_genotype_id', 'Bio::Chado::CDBI::Genotypeprop' => 'genotype_id'); + + +sub genotypeprops { return shift->genotypeprop_genotype_id } + Bio::Chado::CDBI::Genotype->has_many('nd_experiment_genotype_genotype_id', 'Bio::Chado::CDBI::Nd_Experiment_Genotype' => 'genotype_id'); Bio::Chado::CDBI::Genotype->has_many('stock_genotype_genotype_id', 'Bio::Chado::CDBI::Stock_Genotype' => 'genotype_id'); @@ -1733,29 +1846,37 @@ # -sub phenotype_comparison_genotype1s { return shift->phenotype_comparison_genotype1_id } +sub phenstatement_genotypes { return shift->phenstatement_genotype_id } + + -sub phenotype_comparison_genotype2s { return shift->phenotype_comparison_genotype2_id } +sub phenstatement_genotypes { return shift->phenstatement_genotype_id } -sub phenotype_comparison_genotype1s { return shift->phenotype_comparison_genotype1_id } +sub phenstatement_genotypes { return shift->phenstatement_genotype_id } + + - -sub phenotype_comparison_genotype2s { return shift->phenotype_comparison_genotype2_id } +sub phenstatement_genotypes { return shift->phenstatement_genotype_id } + +sub nd_experiment_genotype_genotypes { return shift->nd_experiment_genotype_genotype_id } + + + sub phenotype_comparison_genotype1s { return shift->phenotype_comparison_genotype1_id } + sub phenotype_comparison_genotype2s { return shift->phenotype_comparison_genotype2_id } - @@ -1767,63 +1888,55 @@ +sub phenotype_comparison_genotype1s { return shift->phenotype_comparison_genotype1_id } + -sub stock_genotype_genotypes { return shift->stock_genotype_genotype_id } - - - -sub phenstatement_genotypes { return shift->phenstatement_genotype_id } +sub phenotype_comparison_genotype2s { return shift->phenotype_comparison_genotype2_id } - - -sub phenstatement_genotypes { return shift->phenstatement_genotype_id } - -sub phenstatement_genotypes { return shift->phenstatement_genotype_id } +sub phenotype_comparison_genotype1s { return shift->phenotype_comparison_genotype1_id } - - -sub phenstatement_genotypes { return shift->phenstatement_genotype_id } +sub phenotype_comparison_genotype2s { return shift->phenotype_comparison_genotype2_id } -sub nd_experiment_genotype_genotypes { return shift->nd_experiment_genotype_genotype_id } +sub stock_genotype_genotypes { return shift->stock_genotype_genotype_id } # one to many to one - - - - # one2one # -sub stocks { my $self = shift; return map $_->stock_id, $self->stock_genotype_genotype_id } +sub environments { my $self = shift; return map $_->environment_id, $self->phenstatement_genotype_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->phenstatement_genotype_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->phenstatement_genotype_id } -sub environments { my $self = shift; return map $_->environment_id, $self->phenstatement_genotype_id } +sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_genotype_id } -sub cvterms { my $self = shift; return map $_->type_id, $self->phenstatement_genotype_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->phenstatement_genotype_id } -sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_genotype_id } +sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_genotype_genotype_id } + + + + -sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_genotype_genotype_id } +sub stocks { my $self = shift; return map $_->stock_id, $self->stock_genotype_genotype_id } # one to many to many @@ -1840,19 +1953,13 @@ #many to many to one -# many2one # -sub phenotype_comparison_genotype1_pubs { my $self = shift; return map $_->pub_id, $self->phenotype_comparison_genotype1_id } - -sub phenotype_comparison_genotype2_pubs { my $self = shift; return map $_->pub_id, $self->phenotype_comparison_genotype2_id } - - - +# many2one # sub phenotype_comparison_genotype1_organisms { my $self = shift; return map $_->organism_id, $self->phenotype_comparison_genotype1_id } @@ -1863,15 +1970,25 @@ + +sub phenotype_comparison_genotype1_pubs { my $self = shift; return map $_->pub_id, $self->phenotype_comparison_genotype1_id } + +sub phenotype_comparison_genotype2_pubs { my $self = shift; return map $_->pub_id, $self->phenotype_comparison_genotype2_id } + + #many to many to many + + + + # many2many # @@ -1896,6 +2013,7 @@ + @@ -1920,11 +2038,6 @@ - - - - - 1; @@ -2138,85 +2251,85 @@ -sub element_dbxrefs { return shift->element_dbxref_id } +sub nd_experiment_stock_dbxref_dbxrefs { return shift->nd_experiment_stock_dbxref_dbxref_id } -sub element_dbxrefs { return shift->element_dbxref_id } +sub phylonode_dbxref_dbxrefs { return shift->phylonode_dbxref_dbxref_id } -sub element_dbxrefs { return shift->element_dbxref_id } +sub feature_cvterm_dbxref_dbxrefs { return shift->feature_cvterm_dbxref_dbxref_id } -sub feature_cvterm_dbxref_dbxrefs { return shift->feature_cvterm_dbxref_dbxref_id } +sub biomaterial_dbxref_dbxrefs { return shift->biomaterial_dbxref_dbxref_id } -sub nd_experiment_stock_dbxref_dbxrefs { return shift->nd_experiment_stock_dbxref_dbxref_id } +sub organism_dbxref_dbxrefs { return shift->organism_dbxref_dbxref_id } -sub biomaterial_dbxref_dbxrefs { return shift->biomaterial_dbxref_dbxref_id } +sub nd_experiment_dbxref_dbxrefs { return shift->nd_experiment_dbxref_dbxref_id } -sub nd_experiment_dbxref_dbxrefs { return shift->nd_experiment_dbxref_dbxref_id } +sub element_dbxrefs { return shift->element_dbxref_id } -sub organism_dbxref_dbxrefs { return shift->organism_dbxref_dbxref_id } +sub element_dbxrefs { return shift->element_dbxref_id } -sub phylonode_dbxref_dbxrefs { return shift->phylonode_dbxref_dbxref_id } +sub element_dbxrefs { return shift->element_dbxref_id } # one to many to one # one2one # -sub features { my $self = shift; return map $_->feature_id, $self->element_dbxref_id } +sub nd_experiment_stocks { my $self = shift; return map $_->nd_experiment_stock_id, $self->nd_experiment_stock_dbxref_dbxref_id } -sub cvterms { my $self = shift; return map $_->type_id, $self->element_dbxref_id } +sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_dbxref_dbxref_id } -sub arraydesigns { my $self = shift; return map $_->arraydesign_id, $self->element_dbxref_id } +sub feature_cvterms { my $self = shift; return map $_->feature_cvterm_id, $self->feature_cvterm_dbxref_dbxref_id } -sub feature_cvterms { my $self = shift; return map $_->feature_cvterm_id, $self->feature_cvterm_dbxref_dbxref_id } +sub biomaterials { my $self = shift; return map $_->biomaterial_id, $self->biomaterial_dbxref_dbxref_id } -sub nd_experiment_stocks { my $self = shift; return map $_->nd_experiment_stock_id, $self->nd_experiment_stock_dbxref_dbxref_id } +sub organisms { my $self = shift; return map $_->organism_id, $self->organism_dbxref_dbxref_id } -sub biomaterials { my $self = shift; return map $_->biomaterial_id, $self->biomaterial_dbxref_dbxref_id } +sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_dbxref_dbxref_id } -sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_dbxref_dbxref_id } +sub features { my $self = shift; return map $_->feature_id, $self->element_dbxref_id } -sub organisms { my $self = shift; return map $_->organism_id, $self->organism_dbxref_dbxref_id } +sub arraydesigns { my $self = shift; return map $_->arraydesign_id, $self->element_dbxref_id } -sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_dbxref_dbxref_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->element_dbxref_id } # one to many to many @@ -2566,7 +2679,10 @@ sub studys { return shift->study_pub_id } Bio::Chado::CDBI::Pub->has_many('stock_cvterm_pub_id', 'Bio::Chado::CDBI::Stock_Cvterm' => 'pub_id'); - + + +sub stock_cvterms { return shift->stock_cvterm_pub_id } + Bio::Chado::CDBI::Pub->has_many('cell_line_cvterm_pub_id', 'Bio::Chado::CDBI::Cell_Line_Cvterm' => 'pub_id'); @@ -2618,103 +2734,90 @@ -sub feature_cvterm_pub_pubs { return shift->feature_cvterm_pub_pub_id } +sub featureprop_pub_pubs { return shift->featureprop_pub_pub_id } -sub feature_relationship_pub_pubs { return shift->feature_relationship_pub_pub_id } +sub feature_relationshipprop_pub_pubs { return shift->feature_relationshipprop_pub_pub_id } - -sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } +sub feature_relationship_pub_pubs { return shift->feature_relationship_pub_pub_id } - -sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } +sub feature_expression_pubs { return shift->feature_expression_pub_id } -sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } - - - - - -sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } +sub feature_expression_pubs { return shift->feature_expression_pub_id } -sub libraryprop_pub_pubs { return shift->libraryprop_pub_pub_id } +sub expression_pub_pubs { return shift->expression_pub_pub_id } +sub pub_relationship_subjects { return shift->pub_relationship_subject_id } + -sub library_cvterm_pubs { return shift->library_cvterm_pub_id } +sub pub_relationship_objects { return shift->pub_relationship_object_id } + + - -sub library_cvterm_pubs { return shift->library_cvterm_pub_id } +sub phylotree_pub_pubs { return shift->phylotree_pub_pub_id } -sub cell_line_pub_pubs { return shift->cell_line_pub_pub_id } +sub feature_cvterm_pub_pubs { return shift->feature_cvterm_pub_pub_id } -sub cell_line_library_pubs { return shift->cell_line_library_pub_id } +sub phylonode_pub_pubs { return shift->phylonode_pub_pub_id } -sub cell_line_library_pubs { return shift->cell_line_library_pub_id } +sub featureloc_pub_pubs { return shift->featureloc_pub_pub_id } -sub stockprop_pub_pubs { return shift->stockprop_pub_pub_id } +sub featuremap_pub_pubs { return shift->featuremap_pub_pub_id } -sub project_pub_pubs { return shift->project_pub_pub_id } +sub feature_pub_pubs { return shift->feature_pub_pub_id } -sub library_pub_pubs { return shift->library_pub_pub_id } +sub phenstatement_pubs { return shift->phenstatement_pub_id } -sub featuremap_pub_pubs { return shift->featuremap_pub_pub_id } +sub phenstatement_pubs { return shift->phenstatement_pub_id } -sub pub_relationship_subjects { return shift->pub_relationship_subject_id } - -sub pub_relationship_objects { return shift->pub_relationship_object_id } - - +sub phenstatement_pubs { return shift->phenstatement_pub_id } - - -sub feature_relationshipprop_pub_pubs { return shift->feature_relationshipprop_pub_pub_id } - -sub nd_experiment_pub_pubs { return shift->nd_experiment_pub_pub_id } +sub phenstatement_pubs { return shift->phenstatement_pub_id } @@ -2724,52 +2827,55 @@ -sub phylonode_pub_pubs { return shift->phylonode_pub_pub_id } +sub stock_pub_pubs { return shift->stock_pub_pub_id } -sub phenstatement_pubs { return shift->phenstatement_pub_id } + +sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } - -sub phenstatement_pubs { return shift->phenstatement_pub_id } +sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } + + - -sub phenstatement_pubs { return shift->phenstatement_pub_id } + +sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } -sub phenstatement_pubs { return shift->phenstatement_pub_id } + +sub phenotype_comparison_pubs { return shift->phenotype_comparison_pub_id } -sub stock_pub_pubs { return shift->stock_pub_pub_id } +sub stockprop_pub_pubs { return shift->stockprop_pub_pub_id } -sub phylotree_pub_pubs { return shift->phylotree_pub_pub_id } +sub cell_line_pub_pubs { return shift->cell_line_pub_pub_id } -sub featureprop_pub_pubs { return shift->featureprop_pub_pub_id } +sub cell_line_library_pubs { return shift->cell_line_library_pub_id } -sub cell_line_feature_pubs { return shift->cell_line_feature_pub_id } +sub cell_line_library_pubs { return shift->cell_line_library_pub_id } -sub cell_line_feature_pubs { return shift->cell_line_feature_pub_id } +sub nd_experiment_pub_pubs { return shift->nd_experiment_pub_pub_id } @@ -2779,147 +2885,139 @@ -sub feature_expression_pubs { return shift->feature_expression_pub_id } +sub cell_line_feature_pubs { return shift->cell_line_feature_pub_id } -sub feature_expression_pubs { return shift->feature_expression_pub_id } +sub cell_line_feature_pubs { return shift->cell_line_feature_pub_id } -sub expression_pub_pubs { return shift->expression_pub_pub_id } +sub libraryprop_pub_pubs { return shift->libraryprop_pub_pub_id } -sub stock_cvterm_pubs { return shift->stock_cvterm_pub_id } +sub library_cvterm_pubs { return shift->library_cvterm_pub_id } -sub stock_cvterm_pubs { return shift->stock_cvterm_pub_id } +sub library_cvterm_pubs { return shift->library_cvterm_pub_id } -sub feature_pub_pubs { return shift->feature_pub_pub_id } +sub project_pub_pubs { return shift->project_pub_pub_id } -sub featureloc_pub_pubs { return shift->featureloc_pub_pub_id } +sub library_pub_pubs { return shift->library_pub_pub_id } # one to many to one # one2one # -sub feature_cvterms { my $self = shift; return map $_->feature_cvterm_id, $self->feature_cvterm_pub_pub_id } +sub featureprops { my $self = shift; return map $_->featureprop_id, $self->featureprop_pub_pub_id } -sub feature_relationships { my $self = shift; return map $_->feature_relationship_id, $self->feature_relationship_pub_pub_id } +sub feature_relationshipprops { my $self = shift; return map $_->feature_relationshipprop_id, $self->feature_relationshipprop_pub_pub_id } - - -sub organisms { my $self = shift; return map $_->organism_id, $self->phenotype_comparison_pub_id } +sub feature_relationships { my $self = shift; return map $_->feature_relationship_id, $self->feature_relationship_pub_pub_id } - -sub libraryprops { my $self = shift; return map $_->libraryprop_id, $self->libraryprop_pub_pub_id } +sub features { my $self = shift; return map $_->feature_id, $self->feature_expression_pub_id } -sub cvterms { my $self = shift; return map $_->cvterm_id, $self->library_cvterm_pub_id } +sub expressions { my $self = shift; return map $_->expression_id, $self->feature_expression_pub_id } -sub librarys { my $self = shift; return map $_->library_id, $self->library_cvterm_pub_id } +sub expressions { my $self = shift; return map $_->expression_id, $self->expression_pub_pub_id } - -sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_pub_pub_id } - -sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_library_pub_id } +sub phylotrees { my $self = shift; return map $_->phylotree_id, $self->phylotree_pub_pub_id } -sub librarys { my $self = shift; return map $_->library_id, $self->cell_line_library_pub_id } +sub feature_cvterms { my $self = shift; return map $_->feature_cvterm_id, $self->feature_cvterm_pub_pub_id } -sub stockprops { my $self = shift; return map $_->stockprop_id, $self->stockprop_pub_pub_id } +sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_pub_pub_id } -sub projects { my $self = shift; return map $_->project_id, $self->project_pub_pub_id } +sub featurelocs { my $self = shift; return map $_->featureloc_id, $self->featureloc_pub_pub_id } -sub librarys { my $self = shift; return map $_->library_id, $self->library_pub_pub_id } - - - sub featuremaps { my $self = shift; return map $_->featuremap_id, $self->featuremap_pub_pub_id } - -sub feature_relationshipprops { my $self = shift; return map $_->feature_relationshipprop_id, $self->feature_relationshipprop_pub_pub_id } +sub features { my $self = shift; return map $_->feature_id, $self->feature_pub_pub_id } -sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_pub_pub_id } +sub environments { my $self = shift; return map $_->environment_id, $self->phenstatement_pub_id } -sub stock_relationships { my $self = shift; return map $_->stock_relationship_id, $self->stock_relationship_pub_pub_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->phenstatement_pub_id } -sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_pub_pub_id } +sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_pub_id } -sub environments { my $self = shift; return map $_->environment_id, $self->phenstatement_pub_id } +sub genotypes { my $self = shift; return map $_->genotype_id, $self->phenstatement_pub_id } -sub cvterms { my $self = shift; return map $_->type_id, $self->phenstatement_pub_id } +sub stock_relationships { my $self = shift; return map $_->stock_relationship_id, $self->stock_relationship_pub_pub_id } -sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_pub_id } +sub stocks { my $self = shift; return map $_->stock_id, $self->stock_pub_pub_id } + -sub genotypes { my $self = shift; return map $_->genotype_id, $self->phenstatement_pub_id } +sub organisms { my $self = shift; return map $_->organism_id, $self->phenotype_comparison_pub_id } + + -sub stocks { my $self = shift; return map $_->stock_id, $self->stock_pub_pub_id } +sub stockprops { my $self = shift; return map $_->stockprop_id, $self->stockprop_pub_pub_id } -sub phylotrees { my $self = shift; return map $_->phylotree_id, $self->phylotree_pub_pub_id } +sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_pub_pub_id } -sub featureprops { my $self = shift; return map $_->featureprop_id, $self->featureprop_pub_pub_id } +sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_library_pub_id } -sub features { my $self = shift; return map $_->feature_id, $self->cell_line_feature_pub_id } +sub librarys { my $self = shift; return map $_->library_id, $self->cell_line_library_pub_id } -sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_feature_pub_id } +sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_pub_pub_id } @@ -2927,84 +3025,84 @@ -sub features { my $self = shift; return map $_->feature_id, $self->feature_expression_pub_id } +sub features { my $self = shift; return map $_->feature_id, $self->cell_line_feature_pub_id } -sub expressions { my $self = shift; return map $_->expression_id, $self->feature_expression_pub_id } +sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_feature_pub_id } -sub expressions { my $self = shift; return map $_->expression_id, $self->expression_pub_pub_id } +sub libraryprops { my $self = shift; return map $_->libraryprop_id, $self->libraryprop_pub_pub_id } -sub stocks { my $self = shift; return map $_->stock_id, $self->stock_cvterm_pub_id } +sub cvterms { my $self = shift; return map $_->cvterm_id, $self->library_cvterm_pub_id } -sub cvterms { my $self = shift; return map $_->cvterm_id, $self->stock_cvterm_pub_id } +sub librarys { my $self = shift; return map $_->library_id, $self->library_cvterm_pub_id } -sub features { my $self = shift; return map $_->feature_id, $self->feature_pub_pub_id } +sub projects { my $self = shift; return map $_->project_id, $self->project_pub_pub_id } -sub featurelocs { my $self = shift; return map $_->featureloc_id, $self->featureloc_pub_pub_id } +sub librarys { my $self = shift; return map $_->library_id, $self->library_pub_pub_id } # one to many to many -# one2many # - -sub phenotype_comparison_environment1s { my $self = shift; return map $_->environment1_id, $self->phenotype_comparison_pub_id } - - - - -sub phenotype_comparison_phenotype1s { my $self = shift; return map $_->phenotype1_id, $self->phenotype_comparison_pub_id } - - - - -sub phenotype_comparison_genotype1s { my $self = shift; return map $_->genotype1_id, $self->phenotype_comparison_pub_id } - - +# one2many # + +sub phenotype_comparison_environment1s { my $self = shift; return map $_->environment1_id, $self->phenotype_comparison_pub_id } + + + + +sub phenotype_comparison_phenotype1s { my $self = shift; return map $_->phenotype1_id, $self->phenotype_comparison_pub_id } + + + + +sub phenotype_comparison_genotype1s { my $self = shift; return map $_->genotype1_id, $self->phenotype_comparison_pub_id } + + @@ -3018,8 +3116,6 @@ - - #many to many to one @@ -3029,9 +3125,15 @@ +# many2one # +sub pub_relationship_subject_types { my $self = shift; return map $_->type_id, $self->pub_relationship_subject_id } + +sub pub_relationship_object_types { my $self = shift; return map $_->type_id, $self->pub_relationship_object_id } + + @@ -3039,15 +3141,9 @@ -# many2one # -sub pub_relationship_subject_types { my $self = shift; return map $_->type_id, $self->pub_relationship_subject_id } - -sub pub_relationship_object_types { my $self = shift; return map $_->type_id, $self->pub_relationship_object_id } - - @@ -3067,8 +3163,6 @@ - - #many to many to many @@ -3107,8 +3201,6 @@ - - 1; @@ -3689,6 +3781,52 @@ 1; +########Bio::Chado::CDBI::Chadoprop######## + +package Bio::Chado::CDBI::Chadoprop; +use base 'Bio::Chado::DBI'; +use Class::DBI::Pager; +no warnings qw(redefine); + +Bio::Chado::CDBI::Chadoprop->set_up_table('chadoprop'); + +# +# Primary key accessors +# + +sub id { shift->chadoprop_id } +sub chadoprop { shift->chadoprop_id } + + + + +# +# Has A +# + +Bio::Chado::CDBI::Chadoprop->has_a(type_id => 'Bio::Chado::CDBI::Cvterm'); + +sub Bio::Chado::CDBI::Chadoprop::cvterm { return shift->type_id } + + +# +# Has Many +# + + + +# one to many to one + +# one to many to many + +#many to many to one + +#many to many to many + + + +1; + ########Bio::Chado::CDBI::Feature_Cvtermprop######## package Bio::Chado::CDBI::Feature_Cvtermprop; @@ -4221,27 +4359,22 @@ # -sub studyprop_feature_features { return shift->studyprop_feature_feature_id } +sub feature_expression_features { return shift->feature_expression_feature_id } -sub studyprop_feature_features { return shift->studyprop_feature_feature_id } +sub feature_expression_features { return shift->feature_expression_feature_id } -sub element_features { return shift->element_feature_id } - - - -sub element_features { return shift->element_feature_id } - - +sub library_feature_features { return shift->library_feature_feature_id } + -sub element_features { return shift->element_feature_id } +sub feature_pub_features { return shift->feature_pub_feature_id } @@ -4252,11 +4385,11 @@ -sub library_feature_features { return shift->library_feature_feature_id } +sub studyprop_feature_features { return shift->studyprop_feature_feature_id } -sub cell_line_feature_features { return shift->cell_line_feature_feature_id } +sub studyprop_feature_features { return shift->studyprop_feature_feature_id } @@ -4266,68 +4399,73 @@ -sub feature_expression_features { return shift->feature_expression_feature_id } +sub cell_line_feature_features { return shift->cell_line_feature_feature_id } +sub element_features { return shift->element_feature_id } + + + -sub feature_expression_features { return shift->feature_expression_feature_id } +sub element_features { return shift->element_feature_id } + + - -sub feature_pub_features { return shift->feature_pub_feature_id } +sub element_features { return shift->element_feature_id } # one to many to one # one2one # -sub cvterms { my $self = shift; return map $_->type_id, $self->studyprop_feature_feature_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->feature_expression_feature_id } -sub studyprops { my $self = shift; return map $_->studyprop_id, $self->studyprop_feature_feature_id } +sub expressions { my $self = shift; return map $_->expression_id, $self->feature_expression_feature_id } -sub cvterms { my $self = shift; return map $_->type_id, $self->element_feature_id } +sub librarys { my $self = shift; return map $_->library_id, $self->library_feature_feature_id } -sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->element_feature_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->feature_pub_feature_id } -sub arraydesigns { my $self = shift; return map $_->arraydesign_id, $self->element_feature_id } +sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->feature_phenotype_feature_id } -sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->feature_phenotype_feature_id } +sub studyprops { my $self = shift; return map $_->studyprop_id, $self->studyprop_feature_feature_id } -sub librarys { my $self = shift; return map $_->library_id, $self->library_feature_feature_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->studyprop_feature_feature_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_feature_feature_id } +sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_feature_feature_id } -sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_feature_feature_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_feature_feature_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->feature_expression_feature_id } +sub arraydesigns { my $self = shift; return map $_->arraydesign_id, $self->element_feature_id } -sub expressions { my $self = shift; return map $_->expression_id, $self->feature_expression_feature_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->element_feature_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->feature_pub_feature_id } +sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->element_feature_id } # one to many to many @@ -4685,11 +4823,8 @@ -sub cell_line_relationship_subjects { return shift->cell_line_relationship_subject_id } +sub cell_line_feature_cell_lines { return shift->cell_line_feature_cell_line_id } - -sub cell_line_relationship_objects { return shift->cell_line_relationship_object_id } - @@ -4698,8 +4833,11 @@ -sub cell_line_feature_cell_lines { return shift->cell_line_feature_cell_line_id } +sub cell_line_relationship_subjects { return shift->cell_line_relationship_subject_id } + +sub cell_line_relationship_objects { return shift->cell_line_relationship_object_id } + # one to many to one @@ -4709,21 +4847,21 @@ +sub librarys { my $self = shift; return map $_->library_id, $self->cell_line_library_cell_line_id } + + + sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_library_cell_line_id } -sub librarys { my $self = shift; return map $_->library_id, $self->cell_line_library_cell_line_id } +sub features { my $self = shift; return map $_->feature_id, $self->cell_line_feature_cell_line_id } - sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_feature_cell_line_id } - -sub features { my $self = shift; return map $_->feature_id, $self->cell_line_feature_cell_line_id } - # one to many to many @@ -4738,6 +4876,8 @@ + + # many2one # @@ -4747,8 +4887,6 @@ sub cell_line_relationship_object_types { my $self = shift; return map $_->type_id, $self->cell_line_relationship_object_id } - - #many to many to many @@ -5158,7 +5296,10 @@ Bio::Chado::CDBI::Stock->has_many('stock_genotype_stock_id', 'Bio::Chado::CDBI::Stock_Genotype' => 'stock_id'); Bio::Chado::CDBI::Stock->has_many('stock_cvterm_stock_id', 'Bio::Chado::CDBI::Stock_Cvterm' => 'stock_id'); - + + +sub stock_cvterms { return shift->stock_cvterm_stock_id } + Bio::Chado::CDBI::Stock->has_many('stock_relationship_subject_id', 'Bio::Chado::CDBI::Stock_Relationship' => 'subject_id'); @@ -5187,7 +5328,7 @@ -sub nd_experiment_stock_stocks { return shift->nd_experiment_stock_stock_id } +sub stockcollection_stock_stocks { return shift->stockcollection_stock_stock_id } @@ -5196,34 +5337,24 @@ -sub stock_genotype_stocks { return shift->stock_genotype_stock_id } - - - -sub stock_pub_stocks { return shift->stock_pub_stock_id } - - +sub nd_experiment_stock_stocks { return shift->nd_experiment_stock_stock_id } - - -sub stockcollection_stock_stocks { return shift->stockcollection_stock_stock_id } - -sub stock_cvterm_stocks { return shift->stock_cvterm_stock_id } +sub stock_pub_stocks { return shift->stock_pub_stock_id } -sub stock_cvterm_stocks { return shift->stock_cvterm_stock_id } +sub stock_genotype_stocks { return shift->stock_genotype_stock_id } # one to many to one # one2one # -sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_stock_stock_id } +sub stockcollections { my $self = shift; return map $_->stockcollection_id, $self->stockcollection_stock_stock_id } @@ -5231,7 +5362,7 @@ -sub genotypes { my $self = shift; return map $_->genotype_id, $self->stock_genotype_stock_id } +sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_stock_stock_id } @@ -5239,16 +5370,8 @@ -sub stockcollections { my $self = shift; return map $_->stockcollection_id, $self->stockcollection_stock_stock_id } +sub genotypes { my $self = shift; return map $_->genotype_id, $self->stock_genotype_stock_id } - - -sub pubs { my $self = shift; return map $_->pub_id, $self->stock_cvterm_stock_id } - - - -sub cvterms { my $self = shift; return map $_->cvterm_id, $self->stock_cvterm_stock_id } - # one to many to many @@ -5256,8 +5379,6 @@ - - #many to many to one @@ -5265,8 +5386,6 @@ - - #many to many to many @@ -5274,8 +5393,6 @@ - - 1; @@ -5601,7 +5718,12 @@ -sub project_pub_projects { return shift->project_pub_project_id } + +sub assay_project_projects { return shift->assay_project_project_id } + + + +sub nd_experiment_project_projects { return shift->nd_experiment_project_project_id } @@ -5611,12 +5733,7 @@ - -sub assay_project_projects { return shift->assay_project_project_id } - - - -sub nd_experiment_project_projects { return shift->nd_experiment_project_project_id } +sub project_pub_projects { return shift->project_pub_project_id } # one to many to one @@ -5624,19 +5741,19 @@ # one2one # -sub pubs { my $self = shift; return map $_->pub_id, $self->project_pub_project_id } +sub assays { my $self = shift; return map $_->assay_id, $self->assay_project_project_id } -sub contacts { my $self = shift; return map $_->contact_id, $self->project_contact_project_id } +sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_project_project_id } -sub assays { my $self = shift; return map $_->assay_id, $self->assay_project_project_id } +sub contacts { my $self = shift; return map $_->contact_id, $self->project_contact_project_id } -sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_project_project_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->project_pub_project_id } # one to many to many @@ -6311,7 +6428,7 @@ -sub nd_experiment_contact_nd_experiments { return shift->nd_experiment_contact_nd_experiment_id } +sub nd_experiment_stock_nd_experiments { return shift->nd_experiment_stock_nd_experiment_id } @@ -6321,34 +6438,34 @@ -sub nd_experiment_stock_nd_experiments { return shift->nd_experiment_stock_nd_experiment_id } +sub nd_experiment_contact_nd_experiments { return shift->nd_experiment_contact_nd_experiment_id } -sub nd_experiment_protocol_nd_experiments { return shift->nd_experiment_protocol_nd_experiment_id } + +sub nd_experiment_project_nd_experiments { return shift->nd_experiment_project_nd_experiment_id } + + + +sub nd_experiment_genotype_nd_experiments { return shift->nd_experiment_genotype_nd_experiment_id } -sub nd_experiment_dbxref_nd_experiments { return shift->nd_experiment_dbxref_nd_experiment_id } +sub nd_experiment_protocol_nd_experiments { return shift->nd_experiment_protocol_nd_experiment_id } -sub nd_experiment_pub_nd_experiments { return shift->nd_experiment_pub_nd_experiment_id } +sub nd_experiment_dbxref_nd_experiments { return shift->nd_experiment_dbxref_nd_experiment_id } -sub nd_experiment_genotype_nd_experiments { return shift->nd_experiment_genotype_nd_experiment_id } +sub nd_experiment_pub_nd_experiments { return shift->nd_experiment_pub_nd_experiment_id } - - - -sub nd_experiment_project_nd_experiments { return shift->nd_experiment_project_nd_experiment_id } - # one to many to one # one to many to many @@ -7155,23 +7272,23 @@ # +sub assay_project_assays { return shift->assay_project_assay_id } + + + + sub study_assay_assays { return shift->study_assay_assay_id } - - -sub assay_project_assays { return shift->assay_project_assay_id } - - # one to many to one # one2one # -sub studys { my $self = shift; return map $_->study_id, $self->study_assay_assay_id } +sub projects { my $self = shift; return map $_->project_id, $self->assay_project_assay_id } -sub projects { my $self = shift; return map $_->project_id, $self->assay_project_assay_id } +sub studys { my $self = shift; return map $_->study_id, $self->study_assay_assay_id } # one to many to many @@ -7423,6 +7540,11 @@ # + +Bio::Chado::CDBI::Nd_Protocol->has_a(type_id => 'Bio::Chado::CDBI::Cvterm'); + +sub Bio::Chado::CDBI::Nd_Protocol::cvterm { return shift->type_id } + # @@ -7435,7 +7557,7 @@ sub nd_protocolprops { return shift->nd_protocolprop_nd_protocol_id } Bio::Chado::CDBI::Nd_Protocol->has_many('nd_protocol_reagent_nd_protocol_id', 'Bio::Chado::CDBI::Nd_Protocol_Reagent' => 'nd_protocol_id'); - + Bio::Chado::CDBI::Nd_Protocol->has_many('nd_experiment_protocol_nd_protocol_id', 'Bio::Chado::CDBI::Nd_Experiment_Protocol' => 'nd_protocol_id'); @@ -7446,6 +7568,11 @@ # + +sub nd_experiment_protocol_nd_protocols { return shift->nd_experiment_protocol_nd_protocol_id } + + + sub nd_protocol_reagent_nd_protocols { return shift->nd_protocol_reagent_nd_protocol_id } @@ -7454,24 +7581,19 @@ sub nd_protocol_reagent_nd_protocols { return shift->nd_protocol_reagent_nd_protocol_id } - - - -sub nd_experiment_protocol_nd_protocols { return shift->nd_experiment_protocol_nd_protocol_id } - # one to many to one # one2one # -sub cvterms { my $self = shift; return map $_->type_id, $self->nd_protocol_reagent_nd_protocol_id } +sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_protocol_nd_protocol_id } -sub nd_reagents { my $self = shift; return map $_->reagent_id, $self->nd_protocol_reagent_nd_protocol_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->nd_protocol_reagent_nd_protocol_id } -sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_protocol_nd_protocol_id } +sub nd_reagents { my $self = shift; return map $_->reagent_id, $self->nd_protocol_reagent_nd_protocol_id } # one to many to many @@ -7652,6 +7774,7 @@ # # Has A # + Bio::Chado::CDBI::Stock_Cvterm->has_a(stock_id => 'Bio::Chado::CDBI::Stock'); @@ -7671,7 +7794,12 @@ # # Has Many # - + +Bio::Chado::CDBI::Stock_Cvterm->has_many('stock_cvtermprop_stock_cvterm_id', 'Bio::Chado::CDBI::Stock_Cvtermprop' => 'stock_cvterm_id'); + + +sub stock_cvtermprops { return shift->stock_cvtermprop_stock_cvterm_id } + # one to many to one @@ -8811,12 +8939,17 @@ -sub phenotype_comparison_organisms { return shift->phenotype_comparison_organism_id } +sub phylonode_organism_organisms { return shift->phylonode_organism_organism_id } +sub organism_dbxref_organisms { return shift->organism_dbxref_organism_id } + + + + sub phenotype_comparison_organisms { return shift->phenotype_comparison_organism_id } @@ -8828,40 +8961,36 @@ - sub phenotype_comparison_organisms { return shift->phenotype_comparison_organism_id } -sub phylonode_organism_organisms { return shift->phylonode_organism_organism_id } + +sub phenotype_comparison_organisms { return shift->phenotype_comparison_organism_id } - - -sub organism_dbxref_organisms { return shift->organism_dbxref_organism_id } - - # one to many to one # one2one # -sub pubs { my $self = shift; return map $_->pub_id, $self->phenotype_comparison_organism_id } +sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_organism_organism_id } + +sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->organism_dbxref_organism_id } + -sub phylonodes { my $self = shift; return map $_->phylonode_id, $self->phylonode_organism_organism_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->phenotype_comparison_organism_id } - -sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->organism_dbxref_organism_id } - # one to many to many + # one2many # @@ -8882,6 +9011,7 @@ + @@ -8891,8 +9021,6 @@ - - #many to many to one @@ -9098,24 +9226,24 @@ - sub nd_protocol_reagent_reagents { return shift->nd_protocol_reagent_reagent_id } + + - + sub nd_protocol_reagent_reagents { return shift->nd_protocol_reagent_reagent_id } - - + # one to many to one # one2one # -sub nd_protocols { my $self = shift; return map $_->nd_protocol_id, $self->nd_protocol_reagent_reagent_id } +sub cvterms { my $self = shift; return map $_->type_id, $self->nd_protocol_reagent_reagent_id } -sub cvterms { my $self = shift; return map $_->type_id, $self->nd_protocol_reagent_reagent_id } +sub nd_protocols { my $self = shift; return map $_->nd_protocol_id, $self->nd_protocol_reagent_reagent_id } # one to many to many @@ -9575,12 +9703,12 @@ -sub phylonode_pub_phylonodes { return shift->phylonode_pub_phylonode_id } +sub phylonode_dbxref_phylonodes { return shift->phylonode_dbxref_phylonode_id } -sub phylonode_dbxref_phylonodes { return shift->phylonode_dbxref_phylonode_id } +sub phylonode_pub_phylonodes { return shift->phylonode_pub_phylonode_id } # one to many to one @@ -9591,11 +9719,11 @@ -sub pubs { my $self = shift; return map $_->pub_id, $self->phylonode_pub_phylonode_id } +sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->phylonode_dbxref_phylonode_id } -sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->phylonode_dbxref_phylonode_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->phylonode_pub_phylonode_id } # one to many to many @@ -9995,7 +10123,7 @@ # -sub expression_image_expressions { return shift->expression_image_expression_id } +sub feature_expression_expressions { return shift->feature_expression_expression_id } @@ -10005,19 +10133,19 @@ -sub feature_expression_expressions { return shift->feature_expression_expression_id } +sub expression_pub_expressions { return shift->expression_pub_expression_id } -sub expression_pub_expressions { return shift->expression_pub_expression_id } +sub expression_image_expressions { return shift->expression_image_expression_id } # one to many to one # one2one # -sub eimages { my $self = shift; return map $_->eimage_id, $self->expression_image_expression_id } +sub features { my $self = shift; return map $_->feature_id, $self->feature_expression_expression_id } @@ -10025,11 +10153,11 @@ -sub features { my $self = shift; return map $_->feature_id, $self->feature_expression_expression_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->expression_pub_expression_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->expression_pub_expression_id } +sub eimages { my $self = shift; return map $_->eimage_id, $self->expression_image_expression_id } # one to many to many @@ -10882,7 +11010,12 @@ -sub library_cvterm_librarys { return shift->library_cvterm_library_id } + +sub cell_line_library_librarys { return shift->cell_line_library_library_id } + + + +sub cell_line_library_librarys { return shift->cell_line_library_library_id } @@ -10892,16 +11025,11 @@ -sub cell_line_library_librarys { return shift->cell_line_library_library_id } +sub library_cvterm_librarys { return shift->library_cvterm_library_id } - -sub cell_line_library_librarys { return shift->cell_line_library_library_id } - - - sub library_pub_librarys { return shift->library_pub_library_id } @@ -10913,19 +11041,19 @@ -sub pubs { my $self = shift; return map $_->pub_id, $self->library_cvterm_library_id } +sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_library_library_id } -sub cvterms { my $self = shift; return map $_->cvterm_id, $self->library_cvterm_library_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_library_library_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->cell_line_library_library_id } +sub cvterms { my $self = shift; return map $_->cvterm_id, $self->library_cvterm_library_id } -sub cell_lines { my $self = shift; return map $_->cell_line_id, $self->cell_line_library_library_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->library_cvterm_library_id } @@ -11941,6 +12069,11 @@ + + + + + Bio::Chado::CDBI::Cvterm->has_a(cv_id => 'Bio::Chado::CDBI::Cv'); @@ -11978,6 +12111,11 @@ sub arraydesign_substratetypes { return shift->arraydesign_substratetype_id } #sub --arraydesign--substratetype_id-- {} +Bio::Chado::CDBI::Cvterm->has_many('stock_cvtermprop_type_id', 'Bio::Chado::CDBI::Stock_Cvtermprop' => 'type_id'); + + +sub stock_cvtermprops { return shift->stock_cvtermprop_type_id } + Bio::Chado::CDBI::Cvterm->has_many('biomaterial_relationship_type_id', 'Bio::Chado::CDBI::Biomaterial_Relationship' => 'type_id'); Bio::Chado::CDBI::Cvterm->has_many('cell_line_relationship_type_id', 'Bio::Chado::CDBI::Cell_Line_Relationship' => 'type_id'); @@ -12015,6 +12153,16 @@ Bio::Chado::CDBI::Cvterm->has_many('cvterm_relationship_object_id', 'Bio::Chado::CDBI::Cvterm_Relationship' => 'object_id'); +Bio::Chado::CDBI::Cvterm->has_many('genotypeprop_type_id', 'Bio::Chado::CDBI::Genotypeprop' => 'type_id'); + + +sub genotypeprops { return shift->genotypeprop_type_id } + +Bio::Chado::CDBI::Cvterm->has_many('genotype_type_id', 'Bio::Chado::CDBI::Genotype' => 'type_id'); + +sub genotype_types { return shift->genotype_type_id } +#sub --genotype--type_id-- {} + Bio::Chado::CDBI::Cvterm->has_many('assayprop_type_id', 'Bio::Chado::CDBI::Assayprop' => 'type_id'); @@ -12047,6 +12195,11 @@ sub acquisition_relationships { return shift->acquisition_relationship_type_id } +Bio::Chado::CDBI::Cvterm->has_many('chadoprop_type_id', 'Bio::Chado::CDBI::Chadoprop' => 'type_id'); + + +sub chadoprops { return shift->chadoprop_type_id } + Bio::Chado::CDBI::Cvterm->has_many('feature_cvtermprop_type_id', 'Bio::Chado::CDBI::Feature_Cvtermprop' => 'type_id'); @@ -12193,8 +12346,16 @@ sub phylonodeprops { return shift->phylonodeprop_type_id } +Bio::Chado::CDBI::Cvterm->has_many('nd_protocol_type_id', 'Bio::Chado::CDBI::Nd_Protocol' => 'type_id'); + +sub nd_protocol_types { return shift->nd_protocol_type_id } +#sub --nd_protocol--type_id-- {} + Bio::Chado::CDBI::Cvterm->has_many('stock_cvterm_cvterm_id', 'Bio::Chado::CDBI::Stock_Cvterm' => 'cvterm_id'); - + + +sub stock_cvterms { return shift->stock_cvterm_cvterm_id } + Bio::Chado::CDBI::Cvterm->has_many('cell_line_cvterm_cvterm_id', 'Bio::Chado::CDBI::Cell_Line_Cvterm' => 'cvterm_id'); @@ -12335,9 +12496,9 @@ Bio::Chado::CDBI::Cvterm->has_many('contact_type_id', 'Bio::Chado::CDBI::Contact' => 'type_id'); - -sub contacts { return shift->contact_type_id } - +sub contact_types { return shift->contact_type_id } +#sub --contact--type_id-- {} + Bio::Chado::CDBI::Cvterm->has_many('nd_experiment_stock_type_id', 'Bio::Chado::CDBI::Nd_Experiment_Stock' => 'type_id'); Bio::Chado::CDBI::Cvterm->has_many('nd_reagent_relationship_type_id', 'Bio::Chado::CDBI::Nd_Reagent_Relationship' => 'type_id'); @@ -12412,47 +12573,32 @@ # +sub contact_relationship_types { return shift->contact_relationship_type_id } + - -sub nd_reagent_relationship_types { return shift->nd_reagent_relationship_type_id } + - -sub studyprop_feature_types { return shift->studyprop_feature_type_id } +sub environment_cvterm_cvterms { return shift->environment_cvterm_cvterm_id } -sub studyprop_feature_types { return shift->studyprop_feature_type_id } - - - -sub element_types { return shift->element_type_id } +sub pub_relationship_types { return shift->pub_relationship_type_id } -sub element_types { return shift->element_type_id } - - - - -sub element_types { return shift->element_type_id } +sub nd_experiment_stock_types { return shift->nd_experiment_stock_type_id } -sub contact_relationship_types { return shift->contact_relationship_type_id } - - +sub nd_experiment_stock_types { return shift->nd_experiment_stock_type_id } - - -sub nd_experiment_types { return shift->nd_experiment_type_id } - @@ -12461,72 +12607,71 @@ -sub nd_protocol_reagent_types { return shift->nd_protocol_reagent_type_id } +sub phenstatement_types { return shift->phenstatement_type_id } -sub nd_protocol_reagent_types { return shift->nd_protocol_reagent_type_id } +sub phenstatement_types { return shift->phenstatement_type_id } -sub library_cvterm_cvterms { return shift->library_cvterm_cvterm_id } +sub phenstatement_types { return shift->phenstatement_type_id } -sub library_cvterm_cvterms { return shift->library_cvterm_cvterm_id } +sub phenstatement_types { return shift->phenstatement_type_id } -sub nd_experiment_stock_types { return shift->nd_experiment_stock_type_id } +sub biomaterial_relationship_types { return shift->biomaterial_relationship_type_id } + + - -sub nd_experiment_stock_types { return shift->nd_experiment_stock_type_id } +sub nd_experiment_types { return shift->nd_experiment_type_id } -sub pub_relationship_types { return shift->pub_relationship_type_id } +sub nd_reagent_relationship_types { return shift->nd_reagent_relationship_type_id } - -sub cell_line_relationship_types { return shift->cell_line_relationship_type_id } +sub studyprop_feature_types { return shift->studyprop_feature_type_id } -sub biomaterial_relationship_types { return shift->biomaterial_relationship_type_id } - - +sub studyprop_feature_types { return shift->studyprop_feature_type_id } + -sub phenstatement_types { return shift->phenstatement_type_id } +sub cvterm_relationship_types { return shift->cvterm_relationship_type_id } - - +sub cvterm_relationship_subjects { return shift->cvterm_relationship_subject_id } + -sub phenstatement_types { return shift->phenstatement_type_id } +sub cvterm_relationship_objects { return shift->cvterm_relationship_object_id } -sub phenstatement_types { return shift->phenstatement_type_id } +sub library_cvterm_cvterms { return shift->library_cvterm_cvterm_id } - -sub phenstatement_types { return shift->phenstatement_type_id } +sub library_cvterm_cvterms { return shift->library_cvterm_cvterm_id } + + - sub quantification_relationship_types { return shift->quantification_relationship_type_id } @@ -12534,27 +12679,33 @@ -sub cvterm_relationship_types { return shift->cvterm_relationship_type_id } - -sub cvterm_relationship_subjects { return shift->cvterm_relationship_subject_id } - +sub nd_protocol_reagent_types { return shift->nd_protocol_reagent_type_id } + + -sub cvterm_relationship_objects { return shift->cvterm_relationship_object_id } + +sub nd_protocol_reagent_types { return shift->nd_protocol_reagent_type_id } -sub environment_cvterm_cvterms { return shift->environment_cvterm_cvterm_id } + +sub cell_line_relationship_types { return shift->cell_line_relationship_type_id } -sub stock_cvterm_cvterms { return shift->stock_cvterm_cvterm_id } +sub element_types { return shift->element_type_id } -sub stock_cvterm_cvterms { return shift->stock_cvterm_cvterm_id } + +sub element_types { return shift->element_type_id } + + + +sub element_types { return shift->element_type_id } # one to many to one @@ -12562,85 +12713,77 @@ # one2one # -sub features { my $self = shift; return map $_->feature_id, $self->studyprop_feature_type_id } +sub environments { my $self = shift; return map $_->environment_id, $self->environment_cvterm_cvterm_id } - -sub studyprops { my $self = shift; return map $_->studyprop_id, $self->studyprop_feature_type_id } - -sub features { my $self = shift; return map $_->feature_id, $self->element_type_id } +sub stocks { my $self = shift; return map $_->stock_id, $self->nd_experiment_stock_type_id } -sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->element_type_id } +sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_stock_type_id } - -sub arraydesigns { my $self = shift; return map $_->arraydesign_id, $self->element_type_id } - - -sub nd_geolocations { my $self = shift; return map $_->nd_geolocation_id, $self->nd_experiment_type_id } +sub environments { my $self = shift; return map $_->environment_id, $self->phenstatement_type_id } - -sub nd_protocols { my $self = shift; return map $_->nd_protocol_id, $self->nd_protocol_reagent_type_id } +sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_type_id } -sub nd_reagents { my $self = shift; return map $_->reagent_id, $self->nd_protocol_reagent_type_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->phenstatement_type_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->library_cvterm_cvterm_id } +sub genotypes { my $self = shift; return map $_->genotype_id, $self->phenstatement_type_id } + -sub librarys { my $self = shift; return map $_->library_id, $self->library_cvterm_cvterm_id } +sub nd_geolocations { my $self = shift; return map $_->nd_geolocation_id, $self->nd_experiment_type_id } + -sub stocks { my $self = shift; return map $_->stock_id, $self->nd_experiment_stock_type_id } +sub features { my $self = shift; return map $_->feature_id, $self->studyprop_feature_type_id } -sub nd_experiments { my $self = shift; return map $_->nd_experiment_id, $self->nd_experiment_stock_type_id } +sub studyprops { my $self = shift; return map $_->studyprop_id, $self->studyprop_feature_type_id } - - - -sub pubs { my $self = shift; return map $_->pub_id, $self->phenstatement_type_id } +sub librarys { my $self = shift; return map $_->library_id, $self->library_cvterm_cvterm_id } -sub environments { my $self = shift; return map $_->environment_id, $self->phenstatement_type_id } +sub pubs { my $self = shift; return map $_->pub_id, $self->library_cvterm_cvterm_id } + -sub phenotypes { my $self = shift; return map $_->phenotype_id, $self->phenstatement_type_id } +sub nd_reagents { my $self = shift; return map $_->reagent_id, $self->nd_protocol_reagent_type_id } -sub genotypes { my $self = shift; return map $_->genotype_id, $self->phenstatement_type_id } +sub nd_protocols { my $self = shift; return map $_->nd_protocol_id, $self->nd_protocol_reagent_type_id } -sub environments { my $self = shift; return map $_->environment_id, $self->environment_cvterm_cvterm_id } +sub features { my $self = shift; return map $_->feature_id, $self->element_type_id } -sub stocks { my $self = shift; return map $_->stock_id, $self->stock_cvterm_cvterm_id } +sub arraydesigns { my $self = shift; return map $_->arraydesign_id, $self->element_type_id } -sub pubs { my $self = shift; return map $_->pub_id, $self->stock_cvterm_cvterm_id } +sub dbxrefs { my $self = shift; return map $_->dbxref_id, $self->element_type_id } # one to many to many @@ -12650,27 +12793,24 @@ -sub nd_reagent_relati... [truncated message content] |
From: <sco...@us...> - 2011-07-27 20:54:59
|
Revision: 25103 http://gmod.svn.sourceforge.net/gmod/?rev=25103&view=rev Author: scottcain Date: 2011-07-27 20:54:48 +0000 (Wed, 27 Jul 2011) Log Message: ----------- added an "allow_external_parent" option that will allow GFF files to refer to Parent features that are already in the database, rather than in the same GFF file, which is not allowed by the GFF spec. Modified Paths: -------------- schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm schema/trunk/chado/load/bin/bulk_load_gff3.PLS Modified: schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm =================================================================== --- schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm 2011-07-27 14:41:07 UTC (rev 25102) +++ schema/trunk/chado/lib/Bio/GMOD/DB/Adapter.pm 2011-07-27 20:54:48 UTC (rev 25103) @@ -268,6 +268,7 @@ $self->{'addpropertycv'}= $arg{addpropertycv}; # dgg $self->private_schema( $arg{private_schema} ); $self->use_public_cv( $arg{use_public_cv} ); + $self->allow_external_parent($arg{allow_external_parent}); $self->{const}{source_success} = 1; #flag to indicate GFF_source is in db table @@ -1079,7 +1080,42 @@ return $self->{'fp_cv'}; } +=head2 allow_external_parent +=over + +=item Usage + + $obj->allow_external_parent() #get existing value + $obj->allow_external_parent($newval) #set new value + +=item Function + +Flag to allow the GFF parser to look in the database for +a Parent ID, which is not allowed by the GFF3 spec. + +=item Returns + +value of allow_external_parent (a scalar) + +=item Arguments + +new value of allow_external_parent (to set) + +=back + +=cut + +sub allow_external_parent { + my $self = shift; + my $allow_external_parent = shift if defined(@_); + + return $self->{'allow_external_parent'} = $allow_external_parent if defined($allow_external_parent); + return $self->{'allow_external_parent'}; +} + + + =head2 recreate_cache =over @@ -4395,6 +4431,14 @@ ? $self->modified_uniquename(orig_id => $orig_pname, organism_id => $organism_id) : $orig_pname; my $parent = $self->cache('feature',$pname); + + if (!$parent and $self->allow_external_parent() ) { + #the uniquename_cache method returns the feature_id when called with "validate" + $parent = $self->uniquename_cache( validate => 1, + organism_id => $organism_id, + uniquename => $pname); + } + confess "\nno parent $orig_pname ($pname);\nyou probably need to rerun the loader with the --recreate_cache option\n\n" unless $parent; $self->cache('parent',$self->nextfeature,$parent); Modified: schema/trunk/chado/load/bin/bulk_load_gff3.PLS =================================================================== --- schema/trunk/chado/load/bin/bulk_load_gff3.PLS 2011-07-27 14:41:07 UTC (rev 25102) +++ schema/trunk/chado/load/bin/bulk_load_gff3.PLS 2011-07-27 20:54:48 UTC (rev 25103) @@ -125,6 +125,9 @@ --use_public_cv When loading into a non-public schema, load any cv and cvterm data into the public schema --end_sql SQL code to execute after the data load is complete + --allow_external_parent + Allow Parent tags to refer to IDs outside the current + GFF file Note that all of the arguments that begin 'db' as well as organism can be provided by default by Bio::GMOD::Config, which was installed when @@ -537,13 +540,25 @@ created before the parts and the parts must refer to the parent with the Parent tag. +=item External Parent IDs + +The GFF3 specification states that IDs are only valid within a single +GFF file, so you can't have Parent tags that refer to IDs in another +file. By specificifying the "allow_external_parent" flag, you can +relax this restriction. A word of warning however: if the parent feature's +uniquename/ID was modified during loading (to make it unique), this +functionality won't work, as it won't beable to find the original +feature correctly. Actually, it may be worse than not working, +it may attach child features to the wrong parent. This is why it is +a bad idea to use this functionality! Please use with caution. + =back =head1 AUTHORS -Allen Day E<lt>all...@uc...E<gt>, Scott Cain E<lt>ca...@cs...E<gt> +Allen Day E<lt>all...@uc...E<gt>, Scott Cain E<lt>sc...@cp...E<gt> -Copyright (c) 2004 +Copyright (c) 2011 This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. @@ -556,7 +571,8 @@ $DROP_INDEX, $NOEXON, $NOUNIQUECACHE, $RECREATE_CACHE, $SAVE_TMPFILES,$RANDOM_TMP_DIR, $NO_TARGET_SYN, $UNIQUE_TARGET, $DBXREF, $FP_CV, $NO_ADDFP_CV, $MANPAGE, $DEBUG, $DELETE, $DELETE_CONFIRM, $CUSTOM_ADAPTER, - $PRIVATE_SCHEMA, $USE_PUBLIC_CV, $NO_SKIP_VACUUM, $END_SQL, $REMOVE_LOCK, ); + $PRIVATE_SCHEMA, $USE_PUBLIC_CV, $NO_SKIP_VACUUM, $END_SQL, $REMOVE_LOCK, + $ALLOW_EXTERNAL_PARENT, ); GetOptions( 'organism=s' => \$ORGANISM, @@ -598,6 +614,7 @@ 'private_schema=s' => \$PRIVATE_SCHEMA, 'use_public_cv' => \$USE_PUBLIC_CV, 'end_sql:s' => \$END_SQL, + 'allow_external_parent' => \$ALLOW_EXTERNAL_PARENT, ) # or ( system( 'pod2text', $0 ), exit -1 ); or pod2usage(-verbose => 1, -exitval => 1); @@ -696,6 +713,7 @@ $argv{addpropertycv}= ! $NO_ADDFP_CV; #dgg $argv{private_schema} = $PRIVATE_SCHEMA; $argv{use_public_cv}= $USE_PUBLIC_CV; + $argv{allow_external_parent} = $ALLOW_EXTERNAL_PARENT; #allow a feature_id to be referenced by multiple featureloc.feature_id's my %locgroup = (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |