8 Usage: perl flag_obsolete_annot.pl -H dbhost -D dbname -o outfile [-v]
16 hostname for database [required]
20 database name [required]
28 db name of the controlled vocabulary
41 The script looks for locus and individual ontology annotations in the database and prints out a
42 list of annotations that require updating since the cvterms were obsoleted.
43 Ususally running this script is a good idea after updating cvterms in the database (see sgn-tools/phenome/load_cvterms.pl)
44 and prior to submitting an ontology association file to PO/GO.
48 Naama Menda <nm249@cornell.edu>
50 =head1 VERSION AND DATE
52 Version 0.1, February 2008.
62 use CXGN
::Phenome
::Locus
;
63 use CXGN
::Phenome
::Individual
;
64 use CXGN
::Chado
::Organism
;
66 use CXGN
::DB
::InsertDBH
;
67 use CXGN
::Chado
::Dbxref
;
68 use CXGN
::Chado
::Cvterm
;
69 use CXGN
::Chado
::Ontology
;
70 use CXGN
::Chado
::Relationship
;
72 our ($opt_H, $opt_D, $opt_v, $opt_o, $opt_d, $opt_t);
74 #getopts('F:d:H:o:n:vD:t');
75 getopts
('H:o:d:vD:t');
79 if (!$dbhost && !$dbname) { die "Need -D dbname and -H hostname arguments.\n"; }
81 my $error = 0; # keep track of input errors (in command line switches).
83 print STDERR
"Option -D required. Must be a valid database name.\n";
92 print STDERR
"A file is required as a command line argument.\n";
97 die "Some required command lines parameters not set. Aborting.\n" if $error;
100 open (OUT
, ">$opt_o") ||die "can't open error file $file for writting.\n" ;
103 my $dbh = CXGN
::DB
::InsertDBH
->new( { dbhost
=>$dbhost,
108 print STDERR
"Connected to database $dbname on host $dbhost.\n";
109 my @locus_annot= CXGN
::Phenome
::Locus
->get_annotations_by_db($dbh, $opt_d);
113 print STDERR
"Reading annotations from database..\n";
116 foreach my $annot(@locus_annot) {
118 my $locus_id= $annot->get_locus_id();
119 print STDERR
"locus_id = $locus_id\n";
120 print STDERR
"." if !$opt_v;
121 my $locus= CXGN
::Phenome
::Locus
->new($dbh,$locus_id);
122 my $locus_name = $locus->get_locus_name();
123 my $dbxref=CXGN
::Chado
::Dbxref
->new($dbh, $annot->get_dbxref_id);
125 my $cvterm = $dbxref->get_cvterm();
126 my $cvterm_name=$cvterm->get_cvterm_name();
127 my $accession = $dbxref->get_accession();
128 my $is_obsolete= $cvterm->get_obsolete();
129 my @alt_ids = $cvterm->get_alt_id();
130 print STDERR
"alt_ids = @alt_ids\n\n";
134 print STDERR
"Locus $locus_name (id=$locus_id) has obsolete annotation: $accession:$cvterm_name\n";
135 print OUT
"Locus $locus_name (id=$locus_id) has obsolete annotation: $accession:$cvterm_name\n";
139 $annot->update_annotation($alt_ids[0]);
140 print STDERR
"*Updated annotation to $alt_ids[0]!\n";
141 print OUT
"*Updated annotation to $alt_ids[0]\n";
143 print STDERR
"!did not find alternative cvterm for this obsolete annotation! $cvterm_name\n";
144 print OUT
"!did not find alternative cvterm for this obsolete annotation! $cvterm_name\n";
150 print STDERR
"Found $count obsolete annotations for SGN loci, $u_count annotations were updated.\n printed out file $file... Done.\n";
152 my @pheno_annot= CXGN
::Phenome
::Individual
->get_annotations_by_db($dbh, $opt_d);
156 print STDERR
"Reading annotations from SGN individual database..\n";
157 foreach my $annot(@pheno_annot) {
159 print STDERR
"." if !$opt_v;
160 my $ind_id= $annot->get_individual_id();
161 my $ind= CXGN
::Phenome
::Individual
->new($dbh,$ind_id);
162 my $ind_name=$ind->get_name();
163 my $dbxref=CXGN
::Chado
::Dbxref
->new($dbh, $annot->get_dbxref_id());
164 my $cvterm=$dbxref->get_cvterm();
165 my $cvterm_name=$cvterm->get_cvterm_name();
166 my $accession = $dbxref->get_accession();
167 my $is_obsolete=$cvterm->get_obsolete();
168 my @alt_ids = $cvterm->get_alt_id();
172 print STDERR
"Individual $ind_name (id=$ind_id) has obsolete annotation: $accession:$cvterm_name\n";
173 print STDERR
"Individual $ind_name (id=$ind_id) has obsolete annotation: $accession:$cvterm_name\n";
176 $annot->update_annotation($alt_ids[0]);
177 print STDERR
"*Updated annotation to $alt_ids[0]!\n";
178 print OUT
"*Updated annotation to $alt_ids[0]\n";
180 print STDERR
"!did not find alternative cvterm for this obsolete annotation! $cvterm_name\n";
181 print OUT
"!did not find alternative cvterm for this obsolete annotation! $cvterm_name\n";
186 if ($@
|| ($opt_t)) {
187 print STDERR
"Either running as trial mode (-t) or AN ERROR OCCURRED: $@\n";
188 print OUT
"Either running as trial mode (-t) or AN ERROR OCCURRED: $@\n" if $opt_o;
193 else { $dbh->commit(); }
198 print STDERR
"Found $count obsolete annotations for SGN individuals, $u_count annotations were updated.\n printed into out file $file... Done.\n";