| 1 | # | ||||||||||||||||||||
| 2 | # BioPerl module for Bio::Network::IO | ||||||||||||||||||||
| 3 | # | ||||||||||||||||||||
| 4 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||
| 5 | # POD documentation - main docs before the code | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | Bio::Network::IO - Class for reading and writing biological network data. | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | This is a modules for reading and writing protein-protein interaction | ||||||||||||||||||||
| 14 | and creating networks from this data. | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | # Read protein interaction data in some format | ||||||||||||||||||||
| 17 | my $io = Bio::Network::IO->new(-file => 'bovine.xml', | ||||||||||||||||||||
| 18 | -format => 'psi25' ); | ||||||||||||||||||||
| 19 | my $network = $io->next_network; | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | =head1 DESCRIPTION | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | This class is analagous to the SeqIO and AlignIO classes. To read in a | ||||||||||||||||||||
| 24 | file of a particular format, file and format are given as key/value | ||||||||||||||||||||
| 25 | pairs as arguments. The Bio::Network::IO checks that the appropriate | ||||||||||||||||||||
| 26 | module is available and loads it. | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | At present only the DIP tab-delimited format and PSI XML format are | ||||||||||||||||||||
| 29 | supported. | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | =head1 METHODS | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | The main methods are: | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | =head2 $net = $io-E<gt>next_network | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | The next_network method does not imply that multiple networks are | ||||||||||||||||||||
| 38 | contained in a file, this is to maintain a consistent nomenclature | ||||||||||||||||||||
| 39 | with Bioperl methods like $seqio-E<gt>next_seq and $alnio-E<gt>next_aln. | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | =head2 $io-E<gt>write_network($network) | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | UNIMPLEMENTED. | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | =head1 REQUIREMENTS | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | To read from PSI XML you will need the XML::Twig module, | ||||||||||||||||||||
| 48 | available from CPAN. | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | =head1 FEEDBACK | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | =head2 Mailing Lists | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||
| 55 | Bioperl modules. Send your comments and suggestions preferably to one | ||||||||||||||||||||
| 56 | of the Bioperl mailing lists. | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | Your participation is much appreciated. | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||
| 61 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | =head2 Support | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||
| 70 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||
| 71 | address it. Please include a thorough description of the problem | ||||||||||||||||||||
| 72 | with code and data examples if at all possible. | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | =head2 Reporting Bugs | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||
| 77 | the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||||||||
| 78 | web: | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | http://bugzilla.open-bio.org/ | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | =head1 AUTHORS | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | Brian Osborne bosborne at alum.mit.edu | ||||||||||||||||||||
| 85 | Richard Adams richard.adams@ed.ac.uk | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | =cut | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | package Bio::Network::IO; | ||||||||||||||||||||
| 90 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 91 | 1 | ▶ | use base 'Bio::Root::IO'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 92 | 1 | ▶ | use vars qw(%DBNAMES); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | # these values are used to standardize database names | ||||||||||||||||||||
| 95 | 1 | %DBNAMES = ( | |||||||||||||||||||
| 96 | DIP => "DIP", # found in DIP files | ||||||||||||||||||||
| 97 | SWP => "UniProt", # found in DIP files | ||||||||||||||||||||
| 98 | PIR => "PIR", # found in DIP files | ||||||||||||||||||||
| 99 | GI => "GenBank" # found id DIP files | ||||||||||||||||||||
| 100 | ); | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | =head2 new | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | Name : new | ||||||||||||||||||||
| 105 | Usage : $io = Bio::Network::IO->new(-file => 'myfile.xml', | ||||||||||||||||||||
| 106 | -format => 'psi25'); | ||||||||||||||||||||
| 107 | Returns : A Bio::Network::IO stream initialised to the appropriate format. | ||||||||||||||||||||
| 108 | Args : Named parameters: | ||||||||||||||||||||
| 109 | -file => $filename | ||||||||||||||||||||
| 110 | -format => format | ||||||||||||||||||||
| 111 | -threshold => a confidence score for the interaction, optional | ||||||||||||||||||||
| 112 | -source => optional database name (e.g. "intact") | ||||||||||||||||||||
| 113 | -verbose => optional, set to 1 to get commentary | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | =cut | ||||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | 2 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.5
Pod
documented
| |||||||||||||||||||||
| 118 | 2 | my ($caller, @args) = @_; | |||||||||||||||||||
| 119 | 2 | ▶ | my $class = ref($caller) || $caller; | ||||||||||||||||||
|
Condition33%1/3
ref $caller || $caller
MC/DC0%0/2
ref $caller || $caller
ref $caller
$caller
Truth table33%1/3
A || B
A= ref $callerB= $caller
| |||||||||||||||||||||
| 120 | 2 | ▶ | if ($class =~ /Bio::Network::IO::(\S+)/){ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 121 | 1 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||
| 122 | 1 | $self->_initialize_io(@args); | |||||||||||||||||||
| 123 | 1 | return $self; | |||||||||||||||||||
| 124 | } else { | ||||||||||||||||||||
| 125 | 1 | my %param = @args; | |||||||||||||||||||
| 126 | 1 | @param{ map { lc $_ } keys %param } = values %param; | |||||||||||||||||||
| 127 | 1 | ▶ | if (!exists($param{'-format'})) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 128 | 0 | Bio::Root::Root->throw("Must specify a valid format!"); | |||||||||||||||||||
| 129 | } | ||||||||||||||||||||
| 130 | 1 | my $format = $param{'-format'}; | |||||||||||||||||||
| 131 | 1 | $format = "\L$format"; | |||||||||||||||||||
| 132 | 1 | ▶ | return undef unless ($class->_load_format_module($format)); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 133 | 1 | return "Bio::Network::IO::$format"->new(@args); | |||||||||||||||||||
| 134 | } | ||||||||||||||||||||
| 135 | } | ||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | =head2 next_network | ||||||||||||||||||||
| 138 | |||||||||||||||||||||
| 139 | Name : next_network | ||||||||||||||||||||
| 140 | Usage : $gr = $io->next_network | ||||||||||||||||||||
| 141 | Returns : A Bio::Network::ProteinNet object. | ||||||||||||||||||||
| 142 | Args : None | ||||||||||||||||||||
| 143 | |||||||||||||||||||||
| 144 | =cut | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | 0 | ▶ | sub next_network { | ||||||||||||||||||
|
Subroutine
next_network: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 147 | 0 | my ($self, $gr) = @_; | |||||||||||||||||||
| 148 | 0 | $self->throw("Sorry, you cannot read from a generic Bio::Network::IO object."); | |||||||||||||||||||
| 149 | } | ||||||||||||||||||||
| 150 | |||||||||||||||||||||
| 151 | =head2 write_network | ||||||||||||||||||||
| 152 | |||||||||||||||||||||
| 153 | Name : write_network | ||||||||||||||||||||
| 154 | Usage : $gr = $io->write_network($net). | ||||||||||||||||||||
| 155 | Args : A Bio::Network::ProteinNet object. | ||||||||||||||||||||
| 156 | Returns : None | ||||||||||||||||||||
| 157 | |||||||||||||||||||||
| 158 | =cut | ||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | 0 | ▶ | sub write_network { | ||||||||||||||||||
|
Subroutine
write_network: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 161 | 0 | my ($self, $gr) = @_; | |||||||||||||||||||
| 162 | 0 | $self->throw("Sorry, you can't write from a generic Bio::NetworkIO object."); | |||||||||||||||||||
| 163 | } | ||||||||||||||||||||
| 164 | |||||||||||||||||||||
| 165 | =head2 threshold | ||||||||||||||||||||
| 166 | |||||||||||||||||||||
| 167 | Name : get or set a threshold | ||||||||||||||||||||
| 168 | Usage : $io->threshold($val) | ||||||||||||||||||||
| 169 | Returns : The threshold | ||||||||||||||||||||
| 170 | Args : A number or none | ||||||||||||||||||||
| 171 | |||||||||||||||||||||
| 172 | =cut | ||||||||||||||||||||
| 173 | |||||||||||||||||||||
| 174 | 1 | ▶ | sub threshold { | ||||||||||||||||||
|
Subroutine
threshold: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||
| 175 | 1 | my $self = shift; | |||||||||||||||||||
| 176 | 1 | ▶ | $self->{_th} = @_ if @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 177 | 1 | return $self->{_th}; | |||||||||||||||||||
| 178 | } | ||||||||||||||||||||
| 179 | |||||||||||||||||||||
| 180 | =head2 verbose | ||||||||||||||||||||
| 181 | |||||||||||||||||||||
| 182 | Name : get or set verbosity | ||||||||||||||||||||
| 183 | Usage : $io->verbose(1) | ||||||||||||||||||||
| 184 | Returns : The verbosity setting | ||||||||||||||||||||
| 185 | Args : 1 or none | ||||||||||||||||||||
| 186 | |||||||||||||||||||||
| 187 | =cut | ||||||||||||||||||||
| 188 | |||||||||||||||||||||
| 189 | 3 | ▶ | sub verbose { | ||||||||||||||||||
|
Subroutine
verbose: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 190 | 3 | my $self = shift; | |||||||||||||||||||
| 191 | 3 | ▶ | $self->{_verbose} = @_ if @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 192 | 3 | return $self->{_verbose}; | |||||||||||||||||||
| 193 | } | ||||||||||||||||||||
| 194 | |||||||||||||||||||||
| 195 | =head2 _load_format_module | ||||||||||||||||||||
| 196 | |||||||||||||||||||||
| 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 | ||||||||||||||||||||
| 200 | Returns : | ||||||||||||||||||||
| 201 | Args : | ||||||||||||||||||||
| 202 | |||||||||||||||||||||
| 203 | =cut | ||||||||||||||||||||
| 204 | |||||||||||||||||||||
| 205 | 1 | ▶ | sub _load_format_module { | ||||||||||||||||||
|
Subroutine
_load_format_module: called CC=2 SCAR=7.1
| |||||||||||||||||||||
| 206 | 1 | my ($self, $format) = @_; | |||||||||||||||||||
| 207 | 1 | my $module = "Bio::Network::IO::" . $format; | |||||||||||||||||||
| 208 | 1 | my $ok; | |||||||||||||||||||
| 209 | |||||||||||||||||||||
| 210 | 1 | eval { | |||||||||||||||||||
| 211 | 1 | $ok = $self->_load_module($module); | |||||||||||||||||||
| 212 | }; | ||||||||||||||||||||
| 213 | 1 | ▶ | if ( $@ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 214 | 0 | print STDERR <<END | |||||||||||||||||||
| 215 | $self: $format cannot be found | ||||||||||||||||||||
| 216 | Exception $@ | ||||||||||||||||||||
| 217 | For more information about the Bio::Network::IO system please see the Bio:Network::IO docs. | ||||||||||||||||||||
| 218 | END | ||||||||||||||||||||
| 219 | ; | ||||||||||||||||||||
| 220 | } | ||||||||||||||||||||
| 221 | 1 | return $ok; | |||||||||||||||||||
| 222 | } | ||||||||||||||||||||
| 223 | |||||||||||||||||||||
| 224 | =head2 _initialize_io | ||||||||||||||||||||
| 225 | |||||||||||||||||||||
| 226 | Title : _initialize_io | ||||||||||||||||||||
| 227 | Usage : *INTERNAL Bio::Network::IO stuff* | ||||||||||||||||||||
| 228 | Function: | ||||||||||||||||||||
| 229 | Returns : | ||||||||||||||||||||
| 230 | Args : | ||||||||||||||||||||
| 231 | |||||||||||||||||||||
| 232 | =cut | ||||||||||||||||||||
| 233 | |||||||||||||||||||||
| 234 | 2 | ▶ | sub _initialize_io { | ||||||||||||||||||
|
Subroutine
_initialize_io: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 235 | 2 | my ($self, @args) = @_; | |||||||||||||||||||
| 236 | 2 | $self->SUPER::_initialize_io(@args); | |||||||||||||||||||
| 237 | 2 | my ($th,$verbose) = $self->_rearrange( [qw(THRESHOLD VERBOSE)], @args); | |||||||||||||||||||
| 238 | 2 | $self->{'_th'} = $th; | |||||||||||||||||||
| 239 | 2 | $self->{'_verbose'} = $verbose; | |||||||||||||||||||
| 240 | 2 | return $self; | |||||||||||||||||||
| 241 | } | ||||||||||||||||||||
| 242 | |||||||||||||||||||||
| 243 | =head2 _get_standard_name | ||||||||||||||||||||
| 244 | |||||||||||||||||||||
| 245 | Title : _get_standard_name | ||||||||||||||||||||
| 246 | Usage : | ||||||||||||||||||||
| 247 | Function: Returns some standard name for a database, uses global | ||||||||||||||||||||
| 248 | %DBNAMES | ||||||||||||||||||||
| 249 | Returns : | ||||||||||||||||||||
| 250 | Args : | ||||||||||||||||||||
| 251 | |||||||||||||||||||||
| 252 | =cut | ||||||||||||||||||||
| 253 | |||||||||||||||||||||
| 254 | 3 | ▶ | sub _get_standard_name { | ||||||||||||||||||
|
Subroutine
_get_standard_name: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 255 | 3 | my ($self,$name) = @_; | |||||||||||||||||||
| 256 | 3 | $DBNAMES{$name}; | |||||||||||||||||||
| 257 | } | ||||||||||||||||||||
| 258 | |||||||||||||||||||||
| 259 | 1 | 1; | |||||||||||||||||||
| 260 | |||||||||||||||||||||
| 261 | __END__ | ||||||||||||||||||||