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

View of /FigKernelScripts/test_cv.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Thu Nov 10 19:57:41 2005 UTC (14 years, 2 months ago) by efrank
Branch: MAIN
CVS Tags: caBIG-00-00-00
Basic regression test on CV stuff at FIG API level (which underlies CGI).

#__perl__

########################################################################
# Regression test on CV related functions at FIG level, not
# at CGI level.  Run this and diff with test_cv.expected
#
# Tested:
#    1. Throw error from API if required arguments are missing
#    2. Add CV terms to pegs
#    3. Find CV terms 
#    4. Add two associations, same term, different vocabs.
#    5. delete CV terms


#
# search_index_by_attribute
#    searchTerm -> ( (peg, org, aliasList, function), ... )
# find_by_attribute
#    searchTerm -> ( (featureId, tag, val), ... )
#
#
# add_cv_term
#    (user, peg, vocab, term_id, term) -> added.  all args req'd.
#
# search_cv_file
#    cv, search_term -> ( (cv, term_id,term), ... )
#
#
#
########################################################################

use URI::Escape;
use Data::Dumper;
use FIG;

my $fig=new FIG;
my $status;

print "start\n";

print "Test dropping an arg. Expect error:\n";
testOne( "fig|9606.3.peg.26823", "ViaFigAPI", "1234", "Some text");

print "Test empty string user. Expect error:\n";
testOne( "   	", "fig|9606.3.peg.26823", "ViaFigAPI", "1234", "Some text");

print "Test empty string peg. Expect error:\n";
testOne( "mast:EdF", "", "ViaFigAPI", "1234", "Some text");

print "Test empty string vocab. Expect error:\n";
testOne( "master:EdF", "fig|9606.3.peg.26823", "", "1234", "Some text");

print "Test empty string id. Expect error:\n";
testOne( "master:EdF", "fig|9606.3.peg.26823", "ViaFigAPI", "", "Some text");

print "Test empty string term. Expect error:\n";
testOne( "master:EdF", "fig|9606.3.peg.26823", "ViaFigAPI", "1234", "   ");

print "Test add with extra spaces. Expect success:\n";
testOne( " master:EdF  ", " fig|9606.3.peg.26823 	", "  ViaFigAPICV1", " 1234  ", " Some text");

print "Add again but 2nd vocab name to test multi-vocab, same term:\n";
testOne( " master:EdF  ", " fig|9606.3.peg.26823 	", "  ViaFigAPICV2", " 1234  ", " Some text");


print "Find term just added via find_by_attribute:\n";
my @result = $fig->find_by_attribute( "1234; Some text" );
if (@result) {
    foreach my $x (@result) {
	print "\t Found @$x[0], @$x[1], @$x[2]\n";
    }
} else {
    print "Nothing found\n";
}
print "\n";


print "Find term just added via search_index_by_attribute:\n";
my @result = $fig->search_index_by_attribute( "1234; Some text" );
if (@result) {
    foreach my $x (@result) {
	print "\t Found @$x[0], @$x[1], @$x[2], @$x[3], @$x[4]\n";
    }
} else {
    print "\t Nothing found\n";
}
print "\n";

print "Delete the term in the first CV:\n";
$fig->delete_attribute( "fig|9606.3.peg.26823", "ViaFigAPICV1" );

print "This search should come up with ViaFigAPICV2:\n";
my @result = $fig->find_by_attribute( "1234; Some text" );
if  (@result) {
    foreach my $x (@result) {
	print "\t Found @$x[0], @$x[1], @$x[2]\n";
    }
} else {
    print "\t Nothing found\n";
}
print "\n";

print "Delete the term in the second CV:\n";
$fig->delete_attribute( "fig|9606.3.peg.26823", "ViaFigAPICV2" );
print "This search should come up empty:\n";
my @result = $fig->find_by_attribute( "1234; Some text" );
if  (@result) {
    foreach my $x (@result) {
	print "\t Found @$x[0], @$x[1], @$x[2]\n";
    }
} else {
    print "\t Nothing found\n";
}
print "\n";

print "Test search_cv_file:  MAPK in GO\n";
$result=$fig->search_cv_file("GO", "MAPK");
if  (@$result) {
    foreach my $x (@$result) {
	print "\t Found $x\n";
    }
} else {
    print "\t Nothing found\n";
}


print "done\n";

exit(0);


sub testOne {
    my ($user, $peg, $vocab, $id, $term) = @_;
    $status = $fig->add_cv_term( $user, $peg, $vocab, $id, $term);
    if (!$status) {
	print "User $user added ($vocab, $id, $term)\n";
    } else {
	print "Error for ($vocab, $id, $term):\t$status\n";
    }

    return;
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3