From 7ef75043dcbf139630bcfa05bd98cc410840e38c Mon Sep 17 00:00:00 2001 From: cjfields Date: Tue, 16 Dec 2008 04:50:39 +0000 Subject: [PATCH] Bio::Graph deprecated in 1.6 svn path=/bioperl-live/trunk/; revision=15172 --- t/protgraph.t | 251 ---------------------------------------------------------- 1 file changed, 251 deletions(-) delete mode 100644 t/protgraph.t diff --git a/t/protgraph.t b/t/protgraph.t deleted file mode 100644 index 4f9744bd2..000000000 --- a/t/protgraph.t +++ /dev/null @@ -1,251 +0,0 @@ -# -*-Perl-*- Test Harness script for Bioperl -# $Id$ - -use strict; - -BEGIN { - use lib '.'; - use Bio::Root::Test; - - # note: modules have been deprecated for the 1.6 release. Use - # bioperl-network instead - - test_begin(-tests => 0); -} - -################1st of all let's test the io..... -############### test dip tab delimited format ################### -## test read... - -my %ids; -my $gr; -ok my $io = Bio::Graph::IO->new( - -format => 'dip', - -file => test_input_file('tab1part.mif'), - -threshold => 0.6); - -ok $gr = $io->next_network(); - -ok my $node = $gr->nodes_by_id('A64696'); -is $node->accession_number, 'A64696'; - -##test write. to filehandle... -my $out_file = test_output_file(); -ok my $out = Bio::Graph::IO->new( - -format => 'dip', - -file =>">$out_file"); -ok $out->write_network($gr); - -## get articulation_points. -my @nodes = $gr->articulation_points(); - -##now remove 2 nodes: this removes 4 edges and 3087 should be a new artic point -is $gr->edge_count, 72; -$gr->remove_nodes($gr->nodes_by_id('3082N'), $gr->nodes_by_id('3083N')); -is $gr->edge_count, 68; - my $nodes = $gr->articulation_points(); -ok grep {$_->object_id eq 'H64521'} @$nodes; -is scalar @$nodes, 13; -@nodes = @{$gr->articulation_points()}; -# -# these were failing, I don't understand the module enough to know if -# this is a bug. Richard needs to look at it -TODO: { - local $TODO = 'Possible bug!'; - ok grep {$_->object_id eq 'B64701'} @nodes; - is scalar @nodes, 14; -} - -ok grep {$_->object_id eq 'B64528'} @nodes; -is scalar @nodes, 13; -# - -ok $node = $gr->nodes_by_id('A64696'); -is $node->accession_number, 'A64696'; - - -## can we round trip, is out format same as original format? -ok my $io2 = Bio::Graph::IO->new( - -format => 'dip', - -file => $out_file); -ok my $g2 = $io2->next_network(); -ok $node = $g2->nodes_by_id('A64696'); -is $node->accession_number, 'A64696'; - -##### now lets test some graph properties.....## -## basic properties from SImpleGraph. - -is sprintf("%.3f",$g2->density), "0.027"; -is $g2->is_connected, ''; -is $g2->is_forest, undef; -is $g2->is_tree, ''; -is $g2->is_empty, ''; -is $g2->is_cyclic, 1; - -## get connected subgraphs -my @components = $g2->components(); -is scalar @components, 5; - -## get nodes connected to parameter -my $t = $g2->traversal($g2->nodes_by_id('3079N')); -my @dfnodes = $t->get_all; -## - -##before deleting 3048N, 3047N has 2 neighbours -my @n1 = $g2->neighbors($g2->nodes_by_id('3047N')); -is scalar @n1,2; - -ok $g2->remove_nodes($g2->nodes_by_id('3048N')); - -## after deleting there is only 1 interactor -@n1 = $g2->neighbors($g2->nodes_by_id('3047N')); -is scalar @n1,1; - -##check no undefs left after node removal ## - -ok map {$_->object_id}$g2->edges; - -## get an edge by its id - -ok my $edge = $g2->edge_by_id('4368E'); -is $edge->object_id, '4368E'; - -## count all edges -my $count = 0; -is $g2->edge_count, 71; - -my @n = $g2->neighbors($g2->nodes_by_id('3075N')); -is scalar @n, 13; - -ok $g2->remove_nodes($g2->nodes_by_id('3075N')); - -## should be 13 less interactions in graph. -is scalar $g2->edge_count, 58; - -## many more subgraphs now -@components = $g2->components(); -#there were 5 subgraphs, now there are 10 unconnected nodes, total 15 -is scalar @components, 15; - -## how many unconnected nodes? -my @ucnodes = $g2->unconnected_nodes; -is scalar @ucnodes, 10; - -##get CC using protein object.. -is sprintf("%.3f", $g2->clustering_coefficient($g2->nodes_by_id('B64525'))), 0.022; - -#.. and using id string (same as previous, for convenience ) -is sprintf("%.3f", $g2->clustering_coefficient('B64525')), 0.022; - -## test has_node() method -is $g2->has_node('B64525'), 1; -is $g2->has_node('B64'), 0; - -## remove a single duplicate edge -ok $g2->remove_dup_edges($g2->nodes_by_id('3103N')); - -## remove all duplicate edges -ok $g2->remove_dup_edges(); - -## should now be no duplicates -my @dupids = map{$_->object_id()} $g2->dup_edges(); -is $dupids[0], undef; - -########### now we test the 'union()' method to see it conforms to -## the rules described in its documentation: - -$io = Bio::Graph::IO->new( - -format => 'dip', - -file => test_input_file('tab1part.mif')); -$gr = $io->next_network(); -$io2 = Bio::Graph::IO->new( - -format => 'dip', - -file => test_input_file('tab1part.mif')); - -$g2 = $io2->next_network(); - -# First of all we put the same graph into both variables. After a union -# graph 1 should be unaffected. Because all edge ids are the same, -# all duplicates will be redundant. -# therea re 3 duplicates in dataset. -my @dups = $gr->dup_edges(); -is scalar @dups, 3; -$gr->union($g2); -@dups = $gr->dup_edges(); -is scalar @dups, 3; -my @redundant = $gr->redundant_edge(); -is scalar @redundant, 72; - -## now lets do a union with a graph that has some new edges, -## using existing nodes - -##read in graph data -$gr = undef; -$g2 = undef; -$io = Bio::Graph::IO->new( - -format => 'dip', - -file => test_input_file('tab1part.mif')); -$gr = $io->next_network(); -$io2 = Bio::Graph::IO->new( - -format => 'dip', - -file => test_input_file('tab2part.mif')); -$g2 = $io2->next_network(); -is $gr->edge_count, 72; -is $gr->node_count, 74; -$gr->union($g2); -#there should be 1 more edge in the graph $gr now, with no new nodes. -#$g2 is unaffected. -is $gr->edge_count, 73; -is $gr->node_count, 74; - -## now lets test a union that has new nodes in $g2 -$gr = undef; -$g2 = undef; -$io = Bio::Graph::IO->new - (-format => 'dip', - -file => test_input_file('tab1part.mif')); -$gr = $io->next_network(); -$io2 = Bio::Graph::IO->new - (-format => 'dip', - -file => test_input_file('tab3part.mif')); - -$g2 = $io2->next_network(); -is $gr->edge_count, 72; -is $gr->node_count, 74; -$gr->union($g2); -# there should be 2 more edge in the graph $gr now and 2 more nodes. -# $g2 is unaffected. -is $gr->edge_count, 74; -is $gr->node_count, 76; - -# test IO/psi_xml if the required modules are present -SKIP: { - test_skip(-tests => 12, -requires_module => 'XML::Twig'); - # PSI XML from DIP - ok $io = Bio::Graph::IO->new - (-format => 'psi_xml', - -file => test_input_file('psi_xml.dat')); - ok my $g = $io->next_network(); - is $g->edge_count, 3; - is $g->node_count, 4; - #my @rts =$g->articulation_points(); - my $n = $g->nodes_by_id(207153); - is $n->species->node_name,"Helicobacter pylori 26695"; - is $n->primary_seq->desc,"bogus-binding membrane protein (lepA) HP0355"; - - # PSI XML from IntAct - ok my $io2 = Bio::Graph::IO->new - (-format => 'psi_xml', - -file => test_input_file('sv40_small.xml')); - ok my $g3 = $io2->next_network(); - is $g3->edge_count, 3; - is $g3->node_count, 5; - - my @rts =$g->articulation_points(); - $n = $g->nodes_by_id(207153); - TODO: { - local $TODO = 'Possible bug in binomial output'; - is $n->species->binomial(),"Helicobacter pylori 26695"; - } - is $n->primary_seq->desc,"bogus-binding membrane protein (lepA) HP0355"; -} -- 2.11.4.GIT