[Bio] / FigKernelScripts / test_cv.pl Repository:
ViewVC logotype

Annotation of /FigKernelScripts/test_cv.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download) (as text)

1 : olson 1.2 #
2 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
3 :     # for Interpretations of Genomes. All Rights Reserved.
4 :     #
5 :     # This file is part of the SEED Toolkit.
6 :     #
7 :     # The SEED Toolkit is free software. You can redistribute
8 :     # it and/or modify it under the terms of the SEED Toolkit
9 :     # Public License.
10 :     #
11 :     # You should have received a copy of the SEED Toolkit Public License
12 :     # along with this program; if not write to the University of Chicago
13 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
14 :     # Genomes at veronika@thefig.info or download a copy from
15 :     # http://www.theseed.org/LICENSE.TXT.
16 :     #
17 :    
18 : efrank 1.1 #__perl__
19 :    
20 :     ########################################################################
21 :     # Regression test on CV related functions at FIG level, not
22 :     # at CGI level. Run this and diff with test_cv.expected
23 :     #
24 :     # Tested:
25 :     # 1. Throw error from API if required arguments are missing
26 :     # 2. Add CV terms to pegs
27 :     # 3. Find CV terms
28 :     # 4. Add two associations, same term, different vocabs.
29 :     # 5. delete CV terms
30 :    
31 :    
32 :     #
33 :     # search_index_by_attribute
34 :     # searchTerm -> ( (peg, org, aliasList, function), ... )
35 :     # find_by_attribute
36 :     # searchTerm -> ( (featureId, tag, val), ... )
37 :     #
38 :     #
39 :     # add_cv_term
40 :     # (user, peg, vocab, term_id, term) -> added. all args req'd.
41 :     #
42 :     # search_cv_file
43 :     # cv, search_term -> ( (cv, term_id,term), ... )
44 :     #
45 :     #
46 :     #
47 :     ########################################################################
48 :    
49 :     use URI::Escape;
50 :     use Data::Dumper;
51 :     use FIG;
52 :    
53 :     my $fig=new FIG;
54 :     my $status;
55 :    
56 :     print "start\n";
57 :    
58 :     print "Test dropping an arg. Expect error:\n";
59 :     testOne( "fig|9606.3.peg.26823", "ViaFigAPI", "1234", "Some text");
60 :    
61 :     print "Test empty string user. Expect error:\n";
62 :     testOne( " ", "fig|9606.3.peg.26823", "ViaFigAPI", "1234", "Some text");
63 :    
64 :     print "Test empty string peg. Expect error:\n";
65 :     testOne( "mast:EdF", "", "ViaFigAPI", "1234", "Some text");
66 :    
67 :     print "Test empty string vocab. Expect error:\n";
68 :     testOne( "master:EdF", "fig|9606.3.peg.26823", "", "1234", "Some text");
69 :    
70 :     print "Test empty string id. Expect error:\n";
71 :     testOne( "master:EdF", "fig|9606.3.peg.26823", "ViaFigAPI", "", "Some text");
72 :    
73 :     print "Test empty string term. Expect error:\n";
74 :     testOne( "master:EdF", "fig|9606.3.peg.26823", "ViaFigAPI", "1234", " ");
75 :    
76 :     print "Test add with extra spaces. Expect success:\n";
77 :     testOne( " master:EdF ", " fig|9606.3.peg.26823 ", " ViaFigAPICV1", " 1234 ", " Some text");
78 :    
79 :     print "Add again but 2nd vocab name to test multi-vocab, same term:\n";
80 :     testOne( " master:EdF ", " fig|9606.3.peg.26823 ", " ViaFigAPICV2", " 1234 ", " Some text");
81 :    
82 :    
83 :     print "Find term just added via find_by_attribute:\n";
84 :     my @result = $fig->find_by_attribute( "1234; Some text" );
85 :     if (@result) {
86 :     foreach my $x (@result) {
87 :     print "\t Found @$x[0], @$x[1], @$x[2]\n";
88 :     }
89 :     } else {
90 :     print "Nothing found\n";
91 :     }
92 :     print "\n";
93 :    
94 :    
95 :     print "Find term just added via search_index_by_attribute:\n";
96 :     my @result = $fig->search_index_by_attribute( "1234; Some text" );
97 :     if (@result) {
98 :     foreach my $x (@result) {
99 :     print "\t Found @$x[0], @$x[1], @$x[2], @$x[3], @$x[4]\n";
100 :     }
101 :     } else {
102 :     print "\t Nothing found\n";
103 :     }
104 :     print "\n";
105 :    
106 :     print "Delete the term in the first CV:\n";
107 :     $fig->delete_attribute( "fig|9606.3.peg.26823", "ViaFigAPICV1" );
108 :    
109 :     print "This search should come up with ViaFigAPICV2:\n";
110 :     my @result = $fig->find_by_attribute( "1234; Some text" );
111 :     if (@result) {
112 :     foreach my $x (@result) {
113 :     print "\t Found @$x[0], @$x[1], @$x[2]\n";
114 :     }
115 :     } else {
116 :     print "\t Nothing found\n";
117 :     }
118 :     print "\n";
119 :    
120 :     print "Delete the term in the second CV:\n";
121 :     $fig->delete_attribute( "fig|9606.3.peg.26823", "ViaFigAPICV2" );
122 :     print "This search should come up empty:\n";
123 :     my @result = $fig->find_by_attribute( "1234; Some text" );
124 :     if (@result) {
125 :     foreach my $x (@result) {
126 :     print "\t Found @$x[0], @$x[1], @$x[2]\n";
127 :     }
128 :     } else {
129 :     print "\t Nothing found\n";
130 :     }
131 :     print "\n";
132 :    
133 :     print "Test search_cv_file: MAPK in GO\n";
134 :     $result=$fig->search_cv_file("GO", "MAPK");
135 :     if (@$result) {
136 :     foreach my $x (@$result) {
137 :     print "\t Found $x\n";
138 :     }
139 :     } else {
140 :     print "\t Nothing found\n";
141 :     }
142 :    
143 :    
144 :     print "done\n";
145 :    
146 :     exit(0);
147 :    
148 :    
149 :     sub testOne {
150 :     my ($user, $peg, $vocab, $id, $term) = @_;
151 :     $status = $fig->add_cv_term( $user, $peg, $vocab, $id, $term);
152 :     if (!$status) {
153 :     print "User $user added ($vocab, $id, $term)\n";
154 :     } else {
155 :     print "Error for ($vocab, $id, $term):\t$status\n";
156 :     }
157 :    
158 :     return;
159 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3