3 # BioPerl module for Bio::Network::IO
5 # You may distribute this module under the same terms as perl itself
6 # POD documentation - main docs before the code
10 Bio::Network::IO - Class for reading and writing biological network data.
14 This is a modules for reading and writing protein-protein interaction
15 and creating networks from this data.
17 # Read protein interaction data in some format
18 my $io = Bio::Network::IO->new(-file => 'bovine.xml',
20 my $network = $io->next_network;
24 This class is analagous to the SeqIO and AlignIO classes. To read in a
25 file of a particular format, file and format are given as key/value
26 pairs as arguments. The Bio::Network::IO checks that the appropriate
27 module is available and loads it.
29 At present only the DIP tab-delimited format and PSI XML format are
36 =head2 $net = $io-E<gt>next_network
38 The next_network method does not imply that multiple networks are
39 contained in a file, this is to maintain a consistent nomenclature
40 with Bioperl methods like $seqio-E<gt>next_seq and $alnio-E<gt>next_aln.
42 =head2 $io-E<gt>write_network($network)
48 To read from PSI XML you will need the XML::Twig module,
55 User feedback is an integral part of the evolution of this and other
56 Bioperl modules. Send your comments and suggestions preferably to one
57 of the Bioperl mailing lists.
59 Your participation is much appreciated.
61 bioperl-l@bioperl.org - General discussion
62 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
66 Please direct usage questions or support issues to the mailing list:
68 L<bioperl-l@bioperl.org>
70 rather than to the module maintainer directly. Many experienced and
71 reponsive experts will be able look at the problem and quickly
72 address it. Please include a thorough description of the problem
73 with code and data examples if at all possible.
77 Report bugs to the Bioperl bug tracking system to help us keep track
78 the bugs and their resolution. Bug reports can be submitted via the
81 http://bugzilla.open-bio.org/
85 Brian Osborne bosborne at alum.mit.edu
86 Richard Adams richard.adams@ed.ac.uk
90 package Bio
::Network
::IO
;
92 use base
'Bio::Root::IO';
93 use vars
qw(%DBNAMES);
95 # these values are used to standardize database names
97 DIP => "DIP", # found in DIP files
98 SWP => "UniProt", # found in DIP files
99 PIR => "PIR", # found in DIP files
100 GI => "GenBank" # found id DIP files
106 Usage : $io = Bio::Network::IO->new(-file => 'myfile.xml',
108 Returns : A Bio::Network::IO stream initialised to the appropriate format.
109 Args : Named parameters:
112 -threshold => a confidence score for the interaction, optional
113 -source => optional database name (e.g. "intact")
114 -verbose => optional, set to 1 to get commentary
118 my ($caller, @args) = @_;
119 my $class = ref($caller) || $caller;
120 if ($class =~ /Bio::Network::IO::(\S+)/){
121 my $self = $class->SUPER::new(@args);
122 $self->_initialize_io(@args);
126 @param{ map { lc $_ } keys %param } = values %param;
127 if (!exists($param{'-format'})) {
128 Bio::Root::Root->throw("Must specify a valid format!");
130 my $format = $param{'-format'};
131 $format = "\L$format";
132 return undef unless ($class->_load_format_module($format));
133 return "Bio::Network::IO::$format"->new(@args);
140 Usage : $gr = $io->next_network
141 Returns : A Bio::Network::ProteinNet object.
147 my ($self, $gr) = @_;
148 $self->throw("Sorry, you cannot read from a generic Bio::Network::IO object.");
154 Usage : $gr = $io->write_network($net).
155 Args : A Bio::Network::ProteinNet object.
161 my ($self, $gr) = @_;
162 $self->throw("Sorry, you can't write from a generic Bio::NetworkIO object.");
167 Name : get or set a threshold
168 Usage : $io->threshold($val)
169 Returns : The threshold
170 Args : A number or none
176 $self->{_th} = @_ if @_;
182 Name : get or set verbosity
183 Usage : $io->verbose(1)
184 Returns : The verbosity setting
191 $self->{_verbose} = @_ if @_;
192 return $self->{_verbose};
195 =head2 _load_format_module
197 Title : _load_format_module
198 Usage : INTERNAL Bio::Network::IO stuff
199 Function: Loads up (like use) a module at run time on demand
205 sub _load_format_module {
206 my ($self, $format) = @_;
207 my $module = "Bio::Network::IO::" . $format;
211 $ok = $self->_load_module($module);
215 $self: $format cannot be found
217 For more information about the Bio::Network::IO system please see the Bio:Network::IO docs.
224 =head2 _initialize_io
226 Title : _initialize_io
227 Usage : *INTERNAL Bio::Network::IO stuff*
235 my ($self, @args) = @_;
236 $self->SUPER::_initialize_io
(@args);
237 my ($th,$verbose) = $self->_rearrange( [qw(THRESHOLD VERBOSE)], @args);
238 $self->{'_th'} = $th;
239 $self->{'_verbose'} = $verbose;
243 =head2 _get_standard_name
245 Title : _get_standard_name
247 Function: Returns some standard name for a database, uses global
254 sub _get_standard_name
{
255 my ($self,$name) = @_;