| 1 | # | ||
| 2 | # BioPerl module for Bio::Network::IO::psi10 | ||
| 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::psi10 | ||
| 10 | |||
| 11 | =head1 SYNOPSIS | ||
| 12 | |||
| 13 | Do not use this module directly, use Bio::Network::IO: | ||
| 14 | |||
| 15 | my $io = Bio::Network::IO->new(-format => 'psi10', | ||
| 16 | -file => 'data.xml'); | ||
| 17 | |||
| 18 | my $network = $io->next_network; | ||
| 19 | |||
| 20 | =head1 DESCRIPTION | ||
| 21 | |||
| 22 | PSI MI (Protein Standards Initiative Molecular Interaction) XML is a format | ||
| 23 | to describe protein-protein interactions and interaction networks. | ||
| 24 | This module parses version 1.0 of PSI MI. | ||
| 25 | |||
| 26 | =head2 Databases | ||
| 27 | |||
| 28 | The following databases provide their data as PSI MI XML: | ||
| 29 | |||
| 30 | =over 3 | ||
| 31 | |||
| 32 | =item * | ||
| 33 | |||
| 34 | DIP L<http://dip.doe-mbi.ucla.edu/> | ||
| 35 | |||
| 36 | =item * | ||
| 37 | |||
| 38 | HPRD L<http://www.hprd.org> | ||
| 39 | |||
| 40 | =item * | ||
| 41 | |||
| 42 | IntAct L<http://www.ebi.ac.uk/intact> | ||
| 43 | |||
| 44 | =item * | ||
| 45 | |||
| 46 | MINT L<http://cbm.bio.uniroma2.it/mint/> | ||
| 47 | |||
| 48 | =back | ||
| 49 | |||
| 50 | Each of these databases will call PSI format by some different name. | ||
| 51 | for example, PSI MI from DIP comes in files with the suffix "mif" | ||
| 52 | whereas PSI MI from IntAct or MINT has the "xml" suffix. | ||
| 53 | |||
| 54 | Documentation for PSI XML can be found at L<http://www.psidev.info>. | ||
| 55 | |||
| 56 | =head2 Version | ||
| 57 | |||
| 58 | This module supports a subset of the fields described in PSI MI version 1.0 | ||
| 59 | (L<http://www.psidev.info/index.php?q=node/88>). The NODE DATA section below | ||
| 60 | describes which fields are currently parsed into ProteinNet networks. | ||
| 61 | |||
| 62 | =head2 Notes | ||
| 63 | |||
| 64 | See the Bio::Network::IO::psi_xml page in the Bioperl Wiki | ||
| 65 | (L<http://bioperl.open-bio.org/wiki/Bio::Network::IO::psi_xml>) | ||
| 66 | for notes on PSI XML from various databases. | ||
| 67 | |||
| 68 | When using this parser recall that some PSI MI fields, or classes, | ||
| 69 | are populated by values taken from an ontology created for the PSI MI | ||
| 70 | format. This ontology is an OBO ontology and can be browsed at | ||
| 71 | L<http://www.ebi.ac.uk/ontology-lookup/browse.do?ontName=MI>. | ||
| 72 | |||
| 73 | =head1 METHODS | ||
| 74 | |||
| 75 | The naming system is analagous to the SeqIO system, although usually | ||
| 76 | next_network() will be called only once per file. | ||
| 77 | |||
| 78 | =head1 DATA IN THE NODE | ||
| 79 | |||
| 80 | The Node (protein or protein complex) is roughly equivalent to the PSI MI | ||
| 81 | B<interactor> (entrySet/entry/interactorList/interactor). The following are | ||
| 82 | subclasses of B<interactor> whose values are accessible through the Node | ||
| 83 | object. | ||
| 84 | |||
| 85 | =over 3 | ||
| 86 | |||
| 87 | =item * | ||
| 88 | |||
| 89 | interactor/names/shortLabel | ||
| 90 | |||
| 91 | L<Bio::Annotation::SimpleValue|Bio::Annotation::SimpleValue> | ||
| 92 | |||
| 93 | =item * | ||
| 94 | |||
| 95 | interactor/names/fullName | ||
| 96 | |||
| 97 | L<Bio::Annotation::SimpleValue|Bio::Annotation::SimpleValue> | ||
| 98 | |||
| 99 | =item * | ||
| 100 | |||
| 101 | interactor/xref/primaryRef | ||
| 102 | |||
| 103 | L<Bio::Annotation::DBLink|Bio::Annotation::DBLink> | ||
| 104 | |||
| 105 | =item * | ||
| 106 | |||
| 107 | interactor/xref/secondaryRef | ||
| 108 | |||
| 109 | L<Bio::Annotation::DBLink|Bio::Annotation::DBLink> | ||
| 110 | |||
| 111 | L<Bio::Species|Bio::Species> object | ||
| 112 | |||
| 113 | =item * | ||
| 114 | |||
| 115 | interactor/organism/names/alias | ||
| 116 | |||
| 117 | L<Bio::Species|Bio::Species> object | ||
| 118 | |||
| 119 | =item * | ||
| 120 | |||
| 121 | interactor/organism/names/fullName | ||
| 122 | |||
| 123 | L<Bio::Species|Bio::Species> object | ||
| 124 | |||
| 125 | =item * | ||
| 126 | |||
| 127 | interactor/organism/names/shortLabel | ||
| 128 | |||
| 129 | L<Bio::Species|Bio::Species> object | ||
| 130 | |||
| 131 | =back | ||
| 132 | |||
| 133 | =head1 DATA NOT YET AVAILABLE | ||
| 134 | |||
| 135 | The following are subclasses of B<interactor> whose values are currently not | ||
| 136 | accessible through the Node object. | ||
| 137 | |||
| 138 | =over 3 | ||
| 139 | |||
| 140 | =item * | ||
| 141 | |||
| 142 | interactor/names/alias | ||
| 143 | |||
| 144 | L<Bio::Annotation::SimpleValue|Bio::Annotation::SimpleValue> | ||
| 145 | |||
| 146 | =item * | ||
| 147 | |||
| 148 | interactor/sequence | ||
| 149 | |||
| 150 | =item * | ||
| 151 | |||
| 152 | interactor/interactorType/names | ||
| 153 | |||
| 154 | Controlled vocabulary maintained by PSI MI | ||
| 155 | L<http://www.ebi.ac.uk/ontology-lookup/browse.do?ontName=MI>. | ||
| 156 | Example: "protein". | ||
| 157 | |||
| 158 | L<Bio::Annotation::OntologyTerm|Bio::Annotation::OntologyTerm> | ||
| 159 | |||
| 160 | =item * | ||
| 161 | |||
| 162 | interactor/interactorType/xref | ||
| 163 | |||
| 164 | L<Bio::Annotation::DBLink|Bio::Annotation::DBLink> | ||
| 165 | |||
| 166 | =item * | ||
| 167 | |||
| 168 | interactor/organism/cellType | ||
| 169 | |||
| 170 | L<Bio::Annotation::OntologyTerm|Bio::Annotation::OntologyTerm> | ||
| 171 | |||
| 172 | =item * | ||
| 173 | |||
| 174 | interactor/organism/compartment | ||
| 175 | |||
| 176 | L<Bio::Annotation::OntologyTerm|Bio::Annotation::OntologyTerm> | ||
| 177 | |||
| 178 | =item * | ||
| 179 | |||
| 180 | interactor/organism/tissue | ||
| 181 | |||
| 182 | L<Bio::Annotation::OntologyTerm|Bio::Annotation::OntologyTerm> | ||
| 183 | |||
| 184 | =back | ||
| 185 | |||
| 186 | =head1 INTERACTION DATA | ||
| 187 | |||
| 188 | The Interaction object is roughly equivalent to the PSI MI B<interaction> | ||
| 189 | (entrySet/entry/interactionList/interaction) and B<experimentDescription> | ||
| 190 | (entrySet/entry/experimentList/experimentDescription). The following are | ||
| 191 | subclasses of B<interaction> and B<experimentDescription> whose values are | ||
| 192 | NOT yet accessible through the Interaction object. | ||
| 193 | |||
| 194 | =over 3 | ||
| 195 | |||
| 196 | =item * | ||
| 197 | |||
| 198 | interaction/xref/primaryRef | ||
| 199 | |||
| 200 | L<Bio::Annotation::DBLink|Bio::Annotation::DBLink> | ||
| 201 | |||
| 202 | =item * | ||
| 203 | |||
| 204 | interaction/xref/secondaryRef | ||
| 205 | |||
| 206 | L<Bio::Annotation::DBLink|Bio::Annotation::DBLink> | ||
| 207 | |||
| 208 | =item * | ||
| 209 | |||
| 210 | interaction/organism/names/shortLabel | ||
| 211 | |||
| 212 | L<Bio::Species|Bio::Species> object | ||
| 213 | |||
| 214 | =item * | ||
| 215 | |||
| 216 | interaction/organism/names/alias | ||
| 217 | |||
| 218 | L<Bio::Species|Bio::Species> object | ||
| 219 | |||
| 220 | =item * | ||
| 221 | |||
| 222 | interaction/organism/names/fullName | ||
| 223 | |||
| 224 | L<Bio::Species|Bio::Species> object | ||
| 225 | |||
| 226 | =item * | ||
| 227 | |||
| 228 | interaction/modelled | ||
| 229 | |||
| 230 | L<Bio::Annotation::SimpleValue|Bio::Annotation::SimpleValue> | ||
| 231 | |||
| 232 | =item * | ||
| 233 | |||
| 234 | interaction/intraMolecular | ||
| 235 | |||
| 236 | L<Bio::Annotation::SimpleValue|Bio::Annotation::SimpleValue> | ||
| 237 | |||
| 238 | =item * | ||
| 239 | |||
| 240 | interaction/negative | ||
| 241 | |||
| 242 | L<Bio::Annotation::SimpleValue|Bio::Annotation::SimpleValue> | ||
| 243 | |||
| 244 | =item * | ||
| 245 | |||
| 246 | interaction/interactionType | ||
| 247 | |||
| 248 | Controlled vocabulary maintained by PSI MI | ||
| 249 | L<http://www.ebi.ac.uk/ontology-lookup/browse.do?ontName=MI>. | ||
| 250 | Example: "phosphorylation reaction". | ||
| 251 | |||
| 252 | L<Bio::Annotation::OntologyTerm|Bio::Annotation::OntologyTerm> | ||
| 253 | |||
| 254 | =item * | ||
| 255 | |||
| 256 | interaction/confidenceList | ||
| 257 | |||
| 258 | L<Bio::Annotation::SimpleValue|Bio::Annotation::SimpleValue> | ||
| 259 | |||
| 260 | =item * | ||
| 261 | |||
| 262 | experimentDescription/confidenceList | ||
| 263 | |||
| 264 | L<Bio::Annotation::SimpleValue|Bio::Annotation::SimpleValue> | ||
| 265 | |||
| 266 | =item * | ||
| 267 | |||
| 268 | experimentDescription/interactionDetectionMethod | ||
| 269 | |||
| 270 | Controlled vocabulary maintained by PSI MI | ||
| 271 | L<http://www.ebi.ac.uk/ontology-lookup/browse.do?ontName=MI>. | ||
| 272 | Example: "two hybrid array". | ||
| 273 | |||
| 274 | L<Bio::Annotation::OntologyTerm|Bio::Annotation::OntologyTerm> | ||
| 275 | |||
| 276 | =item * | ||
| 277 | |||
| 278 | featureElementType/featureType | ||
| 279 | |||
| 280 | Controlled vocabulary maintained by PSI MI | ||
| 281 | L<http://www.ebi.ac.uk/ontology-lookup/browse.do?ontName=MI>. | ||
| 282 | The featureType includes data on post-translational modification. | ||
| 283 | Example: "phospho-histidine". | ||
| 284 | |||
| 285 | L<Bio::Annotation::OntologyTerm|Bio::Annotation::OntologyTerm> | ||
| 286 | |||
| 287 | =back | ||
| 288 | |||
| 289 | =head1 FEEDBACK | ||
| 290 | |||
| 291 | =head2 Mailing Lists | ||
| 292 | |||
| 293 | User feedback is an integral part of the evolution of this and other | ||
| 294 | Bioperl modules. Send your comments and suggestions preferably to one | ||
| 295 | of the Bioperl mailing lists. Your participation is much appreciated. | ||
| 296 | |||
| 297 | bioperl-l@bioperl.org - General discussion | ||
| 298 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||
| 299 | |||
| 300 | =head2 Support | ||
| 301 | |||
| 302 | Please direct usage questions or support issues to the mailing list: | ||
| 303 | |||
| 304 | I<bioperl-l@bioperl.org> | ||
| 305 | |||
| 306 | rather than to the module maintainer directly. Many experienced and | ||
| 307 | reponsive experts will be able look at the problem and quickly | ||
| 308 | address it. Please include a thorough description of the problem | ||
| 309 | with code and data examples if at all possible. | ||
| 310 | |||
| 311 | =head2 Reporting Bugs | ||
| 312 | |||
| 313 | Report bugs to the Bioperl bug tracking system to help us keep track | ||
| 314 | the bugs and their resolution. Bug reports can be submitted via the | ||
| 315 | web: | ||
| 316 | |||
| 317 | http://bugzilla.open-bio.org/ | ||
| 318 | |||
| 319 | =head1 AUTHORS | ||
| 320 | |||
| 321 | Brian Osborne bosborne at alum.mit.edu | ||
| 322 | Richard Adams richard.adams@ed.ac.uk | ||
| 323 | |||
| 324 | =cut | ||
| 325 | |||
| 326 | package Bio::Network::IO::psi10; | ||
| 327 | use strict; | ||
| 328 | use XML::Twig; | ||
| 329 | use Bio::Root::Root; | ||
| 330 | use Bio::Seq::SeqFactory; | ||
| 331 | use Bio::Network::ProteinNet; | ||
| 332 | use Bio::Network::Interaction; | ||
| 333 | use Bio::Network::IO; | ||
| 334 | use Bio::Network::Node; | ||
| 335 | use Bio::Species; | ||
| 336 | use Bio::Annotation::DBLink; | ||
| 337 | use Bio::Annotation::Collection; | ||
| 338 | # use Bio::Annotation::OntologyTerm; | ||
| 339 | # use Bio::Annotation::Comment; | ||
| 340 | # use Bio::Annotation::Reference; | ||
| 341 | # use Bio::Annotation::SimpleValue; | ||
| 342 | # use Bio::Network::IO::psi::intact; | ||
| 343 | |||
| 344 | use vars qw( @ISA %species $net $fac ); | ||
| 345 | @ISA = qw(Bio::Network::IO Bio::Root::Root ); | ||
| 346 | |||
| 347 | BEGIN { | ||
| 348 | $fac = Bio::Seq::SeqFactory->new(-type => 'Bio::Seq::RichSeq'); | ||
| 349 | } | ||
| 350 | |||
| 351 | =head2 next_network | ||
| 352 | |||
| 353 | Name : next_network | ||
| 354 | Purpose : Constructs a protein interaction graph from PSI XML data | ||
| 355 | Usage : my $net = $io->next_network() | ||
| 356 | Arguments : | ||
| 357 | Returns : A Bio::Network::ProteinNet object | ||
| 358 | |||
| 359 | =cut | ||
| 360 | |||
| 361 | sub next_network { | ||
| 362 | my $self = shift; | ||
| 363 | $net = Bio::Network::ProteinNet->new(refvertexed => 1); | ||
| 364 | |||
| 365 | my $t = XML::Twig->new(TwigHandlers => { | ||
| 366 | proteinInteractor => \&_proteinInteractor, | ||
| 367 | interaction => \&_addInteraction | ||
| 368 | }); | ||
| 369 | $t->parsefile($self->file); | ||
| 370 | $net; | ||
| 371 | } | ||
| 372 | |||
| 373 | =head2 _proteinInteractor | ||
| 374 | |||
| 375 | Name : _proteinInteractor | ||
| 376 | Purpose : Parses protein information into Bio::Seq::RichSeq objects | ||
| 377 | Returns : | ||
| 378 | Usage : Internally called by next_network() | ||
| 379 | Arguments : None | ||
| 380 | |||
| 381 | =cut | ||
| 382 | |||
| 383 | sub _proteinInteractor { | ||
| 384 | my ($twig, $pi) = @_; | ||
| 385 | |||
| 386 | my ($acc, $sp, $desc, $prim_id); | ||
| 387 | |||
| 388 | my $org = $pi->first_child('organism'); | ||
| 389 | my $taxid = $org->att('ncbiTaxId'); | ||
| 390 | |||
| 391 | # Make new species object if doesn't already exist | ||
| 392 | if ( !exists($species{$taxid}) ) { | ||
| 393 | my $common = $org->first_child('names')->first_child('shortLabel')->text; | ||
| 394 | my $full; | ||
| 395 | # some PSI MI files have entries with species lacking "fullName" | ||
| 396 | eval { | ||
| 397 | $full = $org->first_child('names')->first_child('fullName')->text; | ||
| 398 | }; | ||
| 399 | $full = $common if $@; | ||
| 400 | |||
| 401 | my $sp_obj = Bio::Species->new(-ncbi_taxid => $taxid, | ||
| 402 | -name => $full, | ||
| 403 | -common_name => $common | ||
| 404 | ); | ||
| 405 | $species{$taxid} = $sp_obj; | ||
| 406 | } | ||
| 407 | |||
| 408 | # Extract sequence and ontology identifiers | ||
| 409 | my @ids = $pi->first_child('xref')->children(); | ||
| 410 | my %ids = map {$_->att('db'), $_->att('id')} @ids; | ||
| 411 | $ids{'psixml'} = $pi->att('id'); | ||
| 412 | |||
| 413 | $prim_id = defined ($ids{'GI'}) ? $ids{'GI'} : ''; | ||
| 414 | # needs to be done by reference to an actual ontology: | ||
| 415 | $acc = $ids{'RefSeq'} || | ||
| 416 | $ids{'SWP'} || # DIP's name for Swissprot | ||
| 417 | $ids{'Swiss-Prot'} || # db name from HPRD | ||
| 418 | $ids{'Ref-Seq'} || # db name from HPRD | ||
| 419 | $ids{'uniprotkb'} || # db name from MINT | ||
| 420 | $ids{'GI'} || | ||
| 421 | $ids{'PIR'} || | ||
| 422 | $ids{'intact'} || # db name from IntAct | ||
| 423 | $ids{'psi-mi'} || # db name from IntAct | ||
| 424 | $ids{'DIP'} || # DIP node name | ||
| 425 | $ids{'ensembl'} || # db name from MINT | ||
| 426 | $ids{'flybase'} || # db name from MINT | ||
| 427 | $ids{'wormbase'} || # db name from MINT | ||
| 428 | $ids{'sgd'} || # db name from MINT | ||
| 429 | $ids{'ddbj/embl/genbank'} || # db name from MINT | ||
| 430 | $ids{'mint'}; # db name from MINT | ||
| 431 | |||
| 432 | # Get description line - certain files, like PSI XML from HPRD, have | ||
| 433 | # "shortLabel" but no "fullName" | ||
| 434 | eval { | ||
| 435 | $desc = $pi->first_child('names')->first_child('fullName')->text; | ||
| 436 | }; | ||
| 437 | if ($@) { | ||
| 438 | warn("No fullName, use shortLabel for description instead"); | ||
| 439 | $desc = $pi->first_child('names')->first_child('shortLabel')->text; | ||
| 440 | } | ||
| 441 | |||
| 442 | # Use ids other than accession_no or primary_id for DBLink annotations | ||
| 443 | my $ac = Bio::Annotation::Collection->new(); | ||
| 444 | for my $db (keys %ids) { | ||
| 445 | next if $ids{$db} eq $acc; | ||
| 446 | next if $ids{$db} eq $prim_id; | ||
| 447 | my $an = Bio::Annotation::DBLink->new( -database => $db, | ||
| 448 | -primary_id => $ids{$db}, | ||
| 449 | ); | ||
| 450 | $ac->add_Annotation('dblink',$an); | ||
| 451 | } | ||
| 452 | |||
| 453 | # Make sequence object | ||
| 454 | my $prot = $fac->create( | ||
| 455 | -accession_number => $acc, | ||
| 456 | -desc => $desc, | ||
| 457 | -display_id => $acc, | ||
| 458 | -primary_id => $prim_id, | ||
| 459 | -species => $species{$taxid}, | ||
| 460 | -annotation => $ac); | ||
| 461 | |||
| 462 | # Add node to network | ||
| 463 | my $node = Bio::Network::Node->new(-protein => [($prot)]); | ||
| 464 | $net->add_node($node); | ||
| 465 | |||
| 466 | # Add primary identifier and accession to internal id <-> node mapping hash | ||
| 467 | $net->add_id_to_node($ids{'psixml'},$node); | ||
| 468 | $net->add_id_to_node($prot->primary_id,$node); | ||
| 469 | $net->add_id_to_node($prot->accession_number,$node); | ||
| 470 | |||
| 471 | # Add secondary identifiers to internal id <-> node mapping hash | ||
| 472 | $ac = $prot->annotation(); | ||
| 473 | for my $an ($ac->get_Annotations('dblink')) { | ||
| 474 | $net->add_id_to_node($an->primary_id,$node); | ||
| 475 | } | ||
| 476 | |||
| 477 | $twig->purge(); | ||
| 478 | } | ||
| 479 | |||
| 480 | =head2 _addInteraction | ||
| 481 | |||
| 482 | Name : _addInteraction | ||
| 483 | Purpose : Adds a new Interaction to a graph | ||
| 484 | Usage : Do not call, called internally by next_network() | ||
| 485 | Returns : | ||
| 486 | Notes : The PSI MI 2.5 standard calls for a field titled interactorRef | ||
| 487 | |||
| 488 | =cut | ||
| 489 | |||
| 490 | sub _addInteraction { | ||
| 491 | my ($twig, $i) = @_; | ||
| 492 | my @ints = $i->first_child('participantList')->children; | ||
| 493 | my @nodeids = map {$_->first_child('proteinInteractorRef')->att('ref')} @ints; | ||
| 494 | |||
| 495 | my $interx_id = $i->first_child('xref')->first_child('primaryRef')->att('id'); | ||
| 496 | |||
| 497 | my $node1 = $net->get_nodes_by_id($nodeids[0]); | ||
| 498 | my $node2 = $net->get_nodes_by_id($nodeids[1]); | ||
| 499 | |||
| 500 | my $interx = Bio::Network::Interaction->new(-id => $interx_id); | ||
| 501 | $net->add_interaction(-nodes => [($node1,$node2)], | ||
| 502 | -interaction => $interx ); | ||
| 503 | $net->add_id_to_interaction($interx_id,$interx); | ||
| 504 | |||
| 505 | $twig->purge(); | ||
| 506 | } | ||
| 507 | |||
| 508 | 1; | ||
| 509 | |||
| 510 | __END__ |