[Bioperl-guts-l] bioperl-live/t EUtilities.t,1.4,1.5

Christopher John Fields cjfields at dev.open-bio.org
Wed Sep 6 01:37:29 EDT 2006


Update of /home/repository/bioperl/bioperl-live/t
In directory dev.open-bio.org:/tmp/cvs-serv11158

Modified Files:
	EUtilities.t 
Log Message:
Additional tests

Index: EUtilities.t
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/t/EUtilities.t,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** EUtilities.t	5 Sep 2006 22:36:54 -0000	1.4
--- EUtilities.t	6 Sep 2006 05:37:27 -0000	1.5
***************
*** 15,19 ****
  
  BEGIN { 
! 	$NUMTESTS = 45;
  	$error = 0;
  	$DEBUG = $ENV{'BIOPERLDEBUG'} || 0;
--- 15,19 ----
  
  BEGIN { 
! 	$NUMTESTS = 90;
  	$error = 0;
  	$DEBUG = $ENV{'BIOPERLDEBUG'} || 0;
***************
*** 45,49 ****
  require_ok('XML::Simple');
  
! # NOTE : Bio::DB::EUtilities is just a specialized pipeline to get any and all
  # data available via NCBI's Entrez interface, with a few convenience methods
  # to get UIDs and other additional information.  All data returned
--- 45,49 ----
  require_ok('XML::Simple');
  
! # NOTE : Bio::DB::EUtilities is just a specialized pipeline to get any 
  # data available via NCBI's Entrez interface, with a few convenience methods
  # to get UIDs and other additional information.  All data returned
***************
*** 54,65 ****
  my @acc = qw(MUSIGHBA1 P18584 CH402638);
  # protein GI
! my @ids = (70733119,68347418,26991676,82736201);
  # test search term
  my $term = 'dihydroorotase AND human';
  
  # Simple EFetch
  
  SKIP: {
! 	my $efetch = Bio::DB::EUtilities->new(
                                      -db         => 'protein',
                                      -id         => $ids[0],
--- 54,67 ----
  my @acc = qw(MUSIGHBA1 P18584 CH402638);
  # protein GI
! my @ids = qw(1621261 89318838 68536103 20807972 730439);
  # test search term
  my $term = 'dihydroorotase AND human';
  
+ my ($eutil, $response);
+ 
  # Simple EFetch
  
  SKIP: {
! 	$eutil = Bio::DB::EUtilities->new(
                                      -db         => 'protein',
                                      -id         => $ids[0],
***************
*** 67,86 ****
                                        );
  		  
! 	isa_ok($efetch, 'Bio::DB::GenericWebDBI');
! 	my $response;
! 	eval {$response = $efetch->get_response; };
  	skip("EFetch HTTP error: $@", 2) if $@;
  	isa_ok($response, 'HTTP::Response');
  	my $content = $response->content;
! 	like($content, qr(dihydroorotase \[Pseudomonas fluorescens Pf-5\]),'EFetch: Fasta format');
  	
  	# reuse the webagent
! 	$efetch->id($ids[1]);
! 	$efetch->rettype('gb');
! 	eval {$response = $efetch->get_response; };
  	skip("EFetch HTTP error: $@", 2) if $@;
  	isa_ok($response, 'HTTP::Response');
  	$content = $response->content;
! 	like($content, qr(^LOCUS\s+AAY95024),'EFetch: GenBank format');
  }
  
--- 69,88 ----
                                        );
  		  
! 	isa_ok($eutil, 'Bio::DB::GenericWebDBI');
! 	eval {$response = $eutil->get_response; };
  	skip("EFetch HTTP error: $@", 2) if $@;
  	isa_ok($response, 'HTTP::Response');
  	my $content = $response->content;
! 	like($content, qr(PYRR \[Mycobacterium tuberculosis H37Rv\]),
! 		 'EFetch: Fasta format');
  	
  	# reuse the webagent
! 	$eutil->id($ids[1]);
! 	$eutil->rettype('gb');
! 	eval {$response = $eutil->get_response; };
  	skip("EFetch HTTP error: $@", 2) if $@;
  	isa_ok($response, 'HTTP::Response');
  	$content = $response->content;
! 	like($content, qr(^LOCUS\s+EAS10332),'EFetch: GenBank format');
  }
  
***************
*** 88,92 ****
  
  SKIP: {
! 	my $epost = Bio::DB::EUtilities->new(
                                      -eutil      => 'epost',
                                      -db         => 'protein',
--- 90,94 ----
  
  SKIP: {
! 	$eutil = Bio::DB::EUtilities->new(
                                      -eutil      => 'epost',
                                      -db         => 'protein',
***************
*** 94,120 ****
                                        );
  		  
! 	isa_ok($epost, 'Bio::DB::GenericWebDBI');
! 	my $response;
! 	eval {$response = $epost->get_response; };
  	skip("EPost HTTP error: $@", 12) if $@;
  	isa_ok($response, 'HTTP::Response');
! 	my $cookie = $epost->next_cookie;
  	isa_ok($cookie, 'Bio::DB::EUtilities::Cookie');
  	
  	# set for epost, esearch, elink
! 	is($cookie->eutil, 'epost', 'eutil()');
! 	is($cookie->database, 'protein', 'database()');
  	
  	# these are not set using epost
! 	is($cookie->elink_dbfrom, undef, 'elink_dbfrom()');
! 	is($cookie->esearch_total, undef, 'esearch_total()');
! 	is($cookie->esearch_query, undef, 'esearch_query()');
! 	is($cookie->elink_queryids, undef, 'elink_queryids()');
! 	is($cookie->elink_linkname, undef, 'elink_linkname()');
  	
  	# check the actual cookie
  	my ($webenv, $key) = @{ $cookie->cookie };
! 	like($webenv, qr{^\S{50}}, 'cookie() WebEnv');
! 	like($key, qr{^\d+}, 'cookie() query key');
  	
  	# can we fetch the sequences using the cookie
--- 96,121 ----
                                        );
  		  
! 	isa_ok($eutil, 'Bio::DB::GenericWebDBI');
! 	eval {$response = $eutil->get_response; };
  	skip("EPost HTTP error: $@", 12) if $@;
  	isa_ok($response, 'HTTP::Response');
! 	my $cookie = $eutil->next_cookie;
  	isa_ok($cookie, 'Bio::DB::EUtilities::Cookie');
  	
  	# set for epost, esearch, elink
! 	is($cookie->eutil, 'epost', '$epost->cookie->eutil()');
! 	is($cookie->database, 'protein', '$epost->cookie->database()');
  	
  	# these are not set using epost
! 	is($cookie->elink_dbfrom, undef, '$epost->cookie->elink_dbfrom()');
! 	is($cookie->esearch_total, undef, '$epost->cookie->esearch_total()');
! 	is($cookie->esearch_query, undef, '$epost->cookie->esearch_query()');
! 	is($cookie->elink_queryids, undef, '$epost->cookie->elink_queryids()');
! 	is($cookie->elink_linkname, undef, '$epost->cookie->elink_linkname()');
  	
  	# check the actual cookie
  	my ($webenv, $key) = @{ $cookie->cookie };
! 	like($webenv, qr{^\S{50}}, '$epost->cookie->cookie() WebEnv');
! 	like($key, qr{^\d+}, '$epost->cookie->cookie() query key');
  	
  	# can we fetch the sequences using the cookie
***************
*** 125,129 ****
  	# look for fasta headers
  	my $total = grep(m{^>.*$}, split "\n", $efetch->get_response->content);
! 	is($total, 4, 'EPost->EFetch');
  }
  
--- 126,130 ----
  	# look for fasta headers
  	my $total = grep(m{^>.*$}, split "\n", $efetch->get_response->content);
! 	is($total, 5, 'EPost to EFetch');
  }
  
***************
*** 131,135 ****
  
  SKIP: {
! 	my $esearch = Bio::DB::EUtilities->new(
                                      -eutil      => 'esearch',
                                      -db         => 'protein',
--- 132,136 ----
  
  SKIP: {
! 	$eutil = Bio::DB::EUtilities->new(
                                      -eutil      => 'esearch',
                                      -db         => 'protein',
***************
*** 138,154 ****
                                        );
  		  
! 	isa_ok($esearch, 'Bio::DB::GenericWebDBI');
! 	my $response;
! 	eval {$response = $esearch->get_response; };
  	skip("ESearch HTTP error:$@", 3) if $@;
  	isa_ok($response, 'HTTP::Response');
  	
! 	my @ids = $esearch->get_ids;
! 	is(scalar(@ids), 100, 'ESearch retmax');
  	
! 	cmp_ok($esearch->esearch_count, '>', 117, 'ESearch count');
  
  	# usehistory (get a cookie)
! 	$esearch = Bio::DB::EUtilities->new(
                                      -eutil      => 'esearch',
                                      -db         => 'protein',
--- 139,155 ----
                                        );
  		  
! 	isa_ok($eutil, 'Bio::DB::GenericWebDBI');
! 	eval {$response = $eutil->get_response; };
  	skip("ESearch HTTP error:$@", 3) if $@;
  	isa_ok($response, 'HTTP::Response');
  	
! 	# can't really check for specific ID's but can check total ID's returned
! 	my @esearch_ids = $eutil->get_ids;
! 	is(scalar(@esearch_ids), 100, '$esearch->get_ids()');
  	
! 	cmp_ok($eutil->esearch_count, '>', 117, '$esearch->esearch_count()');
  
  	# usehistory (get a cookie)
! 	$eutil = Bio::DB::EUtilities->new(
                                      -eutil      => 'esearch',
                                      -db         => 'protein',
***************
*** 157,178 ****
                                        );
  	
! 	eval {$response = $esearch->get_response; };
  	skip("ESearch HTTP error:$@", 11) if $@;
! 	my $cookie = $esearch->next_cookie;
  	isa_ok($cookie, 'Bio::DB::EUtilities::Cookie');
! 	is($cookie->eutil, 'esearch', 'eutil()');
! 	is($cookie->database, 'protein', 'database()');
! 	cmp_ok($cookie->esearch_total, '>', 117, 'esearch_total()');
! 	is($cookie->esearch_query, $term, 'esearch_query()');
  	
! 	## these are not set using esearch
! 	is($cookie->elink_dbfrom, undef, 'elink_dbfrom()');
! 	is($cookie->elink_queryids, undef, 'elink_queryids()');
! 	is($cookie->elink_linkname, undef, 'elink_linkname()');
  	
! 	## check the actual cookie
  	my ($webenv, $key) = @{ $cookie->cookie };
! 	like($webenv, qr{^\S{50}}, 'cookie() WebEnv');
! 	like($key, qr{^\d+}, 'cookie() query key');
  	
  	# can we fetch the sequences using the cookie?
--- 158,179 ----
                                        );
  	
! 	eval {$response = $eutil->get_response; };
  	skip("ESearch HTTP error:$@", 11) if $@;
! 	my $cookie = $eutil->next_cookie;
  	isa_ok($cookie, 'Bio::DB::EUtilities::Cookie');
! 	is($cookie->eutil, 'esearch', '$esearch->cookie->eutil()');
! 	is($cookie->database, 'protein', '$esearch->cookie->database()');
! 	cmp_ok($cookie->esearch_total, '>', 117, '$esearch->cookie->esearch_total()');
! 	is($cookie->esearch_query, $term, '$esearch->cookie->esearch_query()');
  	
! 	# these are not set using esearch
! 	is($cookie->elink_dbfrom, undef, '$esearch->cookie->elink_dbfrom()');
! 	is($cookie->elink_queryids, undef, '$esearch->cookie->elink_queryids()');
! 	is($cookie->elink_linkname, undef, '$esearch->cookie->elink_linkname()');
  	
! 	# check the actual cookie
  	my ($webenv, $key) = @{ $cookie->cookie };
! 	like($webenv, qr{^\S{50}}, '$esearch->cookie->cookie() WebEnv');
! 	like($key, qr{^\d+}, '$esearch->cookie->cookie() query key');
  	
  	# can we fetch the sequences using the cookie?
***************
*** 184,188 ****
  	# look for the fasta headers
  	my $total = grep(m{^>.*$}, split "\n", $efetch->get_response->content);
! 	is($total, 5, 'ESearch->EFetch'); 
  }
  
--- 185,189 ----
  	# look for the fasta headers
  	my $total = grep(m{^>.*$}, split "\n", $efetch->get_response->content);
! 	is($total, 5, 'ESearch to EFetch'); 
  }
  
***************
*** 190,241 ****
  
  SKIP: {
! 	my $eutil = Bio::DB::EUtilities->new(
                                      -eutil      => 'einfo',
                                      -db  		=> 'protein',
                                        );
- 		  
  	isa_ok($eutil, 'Bio::DB::GenericWebDBI');
- 	my $response;
  	eval {$response = $eutil->get_response; };
  	skip("EInfo HTTP error:$@", 4) if $@;
  	isa_ok($response, 'HTTP::Response');
  	like($response->content, qr(<eInfoResult>), 'EInfo response');
! 	is($eutil->einfo_dbs, 'protein', 'einfo_dbs()');
  	like($eutil->einfo_db_lastupdate, qr(\d{4}\/\d{2}\/\d{2}\s\d{2}:\d{2}),
! 		 'einfo_db_lastupdate()');
  	
- 	# need tests for einfo_db_desc, einfo_db_count,
  	# einfo_dbfield_info, einfo_dblink_info 
  	
! 	# all databases
! #	$eutil = Bio::DB::EUtilities->new(
! #                                    -eutil      => 'einfo',
! #                                    -db  		=> 'protein',
! #                                      );
! #	
! #	eval {$response = $eutil->get_response; };
! #	skip("EInfo HTTP error:$@", 5) if $@;
! #	
! #	my @db = qw(pubmed  protein  nucleotide  nuccore  nucgss  nucest  structure
! #	genome  books  cancerchromosomes  cdd  domains  gene  genomeprj  gensat
! #	geo  gds  homologene  journals  mesh  ncbisearch  nlmcatalog  omia  omim
! #	pmc  popset  probe  pcassay  pccompound  pcsubstance  snp  taxonomy
! #	unigene  unists);
! #	
! #	my @einfo_dbs = $eutil->einfo_dbs;
! #	
! #	for my $db (@db) {
! #		is(grep(m{$db eq $_}, @einfo_dbs), 1, "DB: $db");
! #	}
  }
  
  # To be added:
  
! # ELink (normal) 
  
! # ELink (normal, cookies) 
  
  # ELink (multi_id)
  
  # ELink (multi_id, cookies)
  
--- 191,328 ----
  
  SKIP: {
! 	$eutil = Bio::DB::EUtilities->new(
                                      -eutil      => 'einfo',
                                      -db  		=> 'protein',
                                        );
  	isa_ok($eutil, 'Bio::DB::GenericWebDBI');
  	eval {$response = $eutil->get_response; };
  	skip("EInfo HTTP error:$@", 4) if $@;
  	isa_ok($response, 'HTTP::Response');
  	like($response->content, qr(<eInfoResult>), 'EInfo response');
! 	is($eutil->einfo_dbs->[0], 'protein', '$einfo->einfo_dbs()');
  	like($eutil->einfo_db_lastupdate, qr(\d{4}\/\d{2}\/\d{2}\s\d{2}:\d{2}),
! 		 '$einfo->einfo_db_lastupdate()');
! 	cmp_ok($eutil->einfo_db_count, '>', 9200000, '$einfo->einfo_db_count()');
! 	is($eutil->einfo_db_desc, 'Protein sequence record', '$einfo->einfo_db_desc()');
! 	my @links = $eutil->einfo_dblink_info;
! 	my @fields = $eutil->einfo_dbfield_info;
! 	is(scalar(@links), 30, '$einfo->einfo_dblink_info()');
! 	is(scalar(@fields), 24, '$einfo->einfo_dbfield_info()');
! 
! 	my %field = ('SingleToken' => 'Y',
! 				'Hierarchy' => 'N',
! 				'IsDate' => 'N',
! 				'TermCount' => '0',
! 				'Description' => 'Unique number assigned to each sequence',
! 				'Name' => 'UID',
! 				'IsNumerical' => 'Y');
! 	my %link = ('DbTo' => 'cdd',
! 				'Description' => 'Link to conserved domains within a protein',
! 				'Name' => 'protein_cdd',
! 				'Menu' => 'Conserved Domain Links');
! 
! 	eq_hash($fields[1], \%field, '$einfo->einfo_dbfield_info()');
! 	eq_hash($links[1], \%link, '$einfo->einfo_dblink_info()');
  	
  	# einfo_dbfield_info, einfo_dblink_info 
  	
! 	# all databases (list)
! 	$eutil = Bio::DB::EUtilities->new(
!                                     -eutil      => 'einfo',
!                                       );
! 	
! 	eval {$response = $eutil->get_response; };
! 	skip("EInfo HTTP error:$@", 1) if $@;
! 	
! 	my @db = sort qw(pubmed  protein  nucleotide  nuccore  nucgss  nucest  structure
! 	genome  books  cancerchromosomes  cdd  domains  gene  genomeprj  gensat
! 	geo  gds  homologene  journals  mesh  ncbisearch  nlmcatalog  omia  omim
! 	pmc  popset  probe  pcassay  pccompound  pcsubstance  snp  taxonomy
! 	unigene  unists);
! 	
! 	my @einfo_dbs = sort $eutil->einfo_dbs;
! 	is_deeply(\@einfo_dbs, \@db, 'All EInfo databases');
! }
! 
! # ELink (normal; one db, one dbfrom) - ElinkData tests
! 
! SKIP: {
! 	my $eutil = Bio::DB::EUtilities->new(
!                                     -eutil      => 'elink',
!                                     -db  		=> 'taxonomy',
! 									-dbfrom		=> 'protein',
! 									-id			=> \@ids,
!                                       );
! 		  
! 	isa_ok($eutil, 'Bio::DB::GenericWebDBI');
! 	my $response;
! 	eval {$response = $eutil->get_response; };
! 	skip("ELink HTTP error:$@", 4) if $@;
! 	isa_ok($response, 'HTTP::Response');
! 	like($response->content, qr(<eLinkResult>), 'ELink response');
! 	my @ids2 = qw(350054 306537 273068 83332 1394);
! 	is_deeply([sort $eutil->get_ids], [sort @ids2],'$elink->get_ids()');
! 	
! 	# Linkset tests
! 	is($eutil->get_linkset_count, 1, '$elink->get_linkset_count()');
! 	my $linkobj = $eutil->next_linkset;
! 	isa_ok($linkobj, 'Bio::DB::EUtilities::ElinkData');
! 	is($linkobj->elink_dbfrom, 'protein', '$linkdata->elink_dbfrom()');
! 	is_deeply([sort $linkobj->elink_queryids],
! 			  [sort @ids], '$linkdata->elink_queryids()');
! 	is($linkobj->elink_command, 'neighbor', '$linkdata->elink_command()');
! 	my $db = $linkobj->next_linkdb;
! 	is($db, 'taxonomy', '$linkdata->next_linkdb()');
! 	is_deeply([sort $linkobj->get_LinkIds_by_db($db)],
! 			  [sort @ids2], '$linkdata->get_LinkIds_by_db($db)');	
  }
  
  # To be added:
  
! # ELink (normal, multiple db) 
  
! # ELink (normal, multiple db, cookies)
  
  # ELink (multi_id)
  
+ SKIP: {
+ 	my $eutil = Bio::DB::EUtilities->new(
+                                     -eutil      => 'elink',
+                                     -db  		=> 'taxonomy',
+ 									-dbfrom		=> 'protein',
+ 									-multi_id 	=> 1,
+ 									-id			=> \@ids,
+                                       );
+ 		  
+ 	isa_ok($eutil, 'Bio::DB::GenericWebDBI');
+ 	my $response;
+ 	eval {$response = $eutil->get_response; };
+ 	skip("ELink HTTP error:$@", 4) if $@;
+ 	isa_ok($response, 'HTTP::Response');
+ 	like($response->content, qr(<eLinkResult>), 'ELink response');
+ 	my @ids2 = qw(350054 306537 273068 83332 1394);
+ 	eval{$eutil->get_ids;};
+ 	ok($@,'$elink->get_ids()');
+ 	
+ 	# Linkset tests
+ 	is($eutil->get_linkset_count, 5, '$elink->get_linkset_count()');
+ 	my $ct = 0;
+ 	my @qids;
+ 	my @retids;
+ 	# ids may not be returned in same order as array, so need to grab and sort
+ 	while (	my $linkobj = $eutil->next_linkset) {
+ 		isa_ok($linkobj, 'Bio::DB::EUtilities::ElinkData');
+ 		is($linkobj->elink_dbfrom, 'protein', '$linkdata->elink_dbfrom()');
+ 		is($linkobj->elink_command, 'neighbor', '$linkdata->elink_command()');
+ 		push @qids, $linkobj->elink_queryids;
+ 		while (	my $db = $linkobj->next_linkdb) {
+ 			is($db, 'taxonomy', '$linkdata->next_linkdb()');
+ 			push @retids, $linkobj->get_LinkIds_by_db($db);
+ 		}
+ 	}
+ 	is_deeply([sort @qids], [sort @ids], '$linkdata->elink_queryids()');
+ 	is_deeply([sort @retids], [sort @ids2], '$linkdata->get_LinkIds_by_db($db)');
+ }
+ 
  # ELink (multi_id, cookies)
  
***************
*** 243,247 ****
  
  # Although the other EUtilities are available, no postprocessing is done on the
! # XML yet
  
  SKIP: {
--- 330,334 ----
  
  # Although the other EUtilities are available, no postprocessing is done on the
! # returned XML yet
  
  SKIP: {



More information about the Bioperl-guts-l mailing list