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

Annotation of /FigKernelScripts/test_cv.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3