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