Bio::Network::IO
psi25
Toolbar
Summary
Bio::Network::IO::psi25
Package variables
No package variables defined.
Included modules
Bio::Annotation::Collection
Bio::Annotation::DBLink
Bio::Root::Root
Bio::Seq::SeqFactory
Bio::Species
XML::Twig
Inherit
Synopsis
Do not use this module directly, use Bio::Network::IO:
my $io = Bio::Network::IO->new(-format => 'psi25',
-file => 'data.xml');
my $network = $io->next_network;
Description
Methods
Methods description
Name : next_network Purpose : Constructs a protein interaction graph from PSI XML data Usage : my $net = $io->next_network() Arguments : Returns : A Bio::Network::ProteinNet object |
Name : _addInteractor Purpose : Parses protein information into Bio::Seq::RichSeq objects Returns : Usage : Internally called by next_network() Arguments : None Notes : Interactors without organism data get their Bio::Species fields set to -1 |
Name : _addInteraction Purpose : Adds a new Interaction to a graph Usage : Do not call, called internally by next_network() Returns : Notes : All interactions are made of 2 nodes - if there are more or less than 2 then no Interaction object is created |
Methods code
BEGIN { $fac = Bio::Seq::SeqFactory->new(-type => 'Bio::Seq::RichSeq'); } |
sub next_network
{ my $self = shift;
$net = Bio::Network::ProteinNet->new(refvertexed => 1);
$verbose = $self->verbose;
my $t = XML::Twig->new(TwigHandlers => {
interactor =>\& _addInteractor,
interaction =>\& _addInteraction
});
$t->parsefile($self->file);
$net; } |
sub _addInteractor
{ my ($twig, $pi) = @_;
my ($prot, $acc, $sp, $desc, $sp_obj, $taxid, $common, $full);
my $nullVal = "-1";
my $org = $pi->first_child('organism');
eval { $taxid = $org->att('ncbiTaxId'); };
if ($@) {
print "No organism for interactor " .
$pi->first_child('names')->first_child('fullName')->text . "\n" if $verbose;
$common = $full = $taxid = $nullVal;
} elsif ( !exists($species{$taxid}) ) {
$common = $org->first_child('names')->first_child('shortLabel')->text;
eval {
$full = $org->first_child('names')->first_child('fullName')->text;
};
$full = $common if $@;
eval {
$sp_obj = Bio::Species->new(-ncbi_taxid => $taxid,
-name => $full,
-common_name => $common
); };
$species{$taxid} = $sp_obj;
}
my @ids = $pi->first_child('xref')->children();
my %ids = map {$_->att('db'), $_->att('id')} @ids;
$ids{'psixml'} = $pi->att('id');
my $prim_id = defined ($ids{'GI'}) ? $ids{'GI'} : '';
$acc = $ids{'RefSeq'} ||
$ids{'SWP'} || $ids{'Swiss-Prot'} || $ids{'Ref-Seq'} || $ids{'uniprotkb'} || $ids{'GI'} ||
$ids{'PIR'} ||
$ids{'intact'} || $ids{'psi-mi'} || $ids{'DIP'} || $ids{'ensembl'} || $ids{'flybase'} || $ids{'wormbase'} || $ids{'sgd'} || $ids{'ddbj/embl/genbank'} || $ids{'mint'};
eval {
$desc = $pi->first_child('names')->first_child('fullName')->text;
};
if ($@) {
print "No fullName for interactor " .
$pi->first_child('names')->first_child('shortLabel')->text . "\n" if $verbose;
$desc = $pi->first_child('names')->first_child('shortLabel')->text;
}
my $ac = Bio::Annotation::Collection->new();
for my $db (keys %ids) {
next if $ids{$db} eq $acc;
next if $ids{$db} eq $prim_id;
my $an = Bio::Annotation::DBLink->new( -database => $db,
-primary_id => $ids{$db},
);
$ac->add_Annotation('dblink',$an);
}
eval {
$prot = $fac->create(
-accession_number => $acc,
-desc => $desc,
-display_id => $acc,
-primary_id => $prim_id,
-species => $species{$taxid},
-annotation => $ac);
};
my $node = Bio::Network::Node->new(-protein => [($prot)]);
$net->add_node($node);
$net->add_id_to_node($ids{'psixml'},$node);
$net->add_id_to_node($prot->primary_id,$node);
$net->add_id_to_node($prot->accession_number,$node);
$ac = $prot->annotation();
for my $an ($ac->get_Annotations('dblink')) {
$net->add_id_to_node($an->primary_id,$node);
}
$twig->purge();} |
sub _addInteraction
{ my ($twig, $i) = @_;
my @ints = $i->first_child('participantList')->children;
print "Interaction " . $i->first_child('xref')->first_child('primaryRef')->att('id') .
" has " . scalar @ints . " interactors\n" if $verbose;
if ( scalar @ints == 2 ) {
my @nodeids = map {$_->first_child('interactorRef')->text} @ints;
my $interx_id = $i->first_child('xref')->first_child('primaryRef')->att('id');
my $node1 = $net->get_nodes_by_id($nodeids[0]);
my $node2 = $net->get_nodes_by_id($nodeids[1]);
my $interx = Bio::Network::Interaction->new(-id => $interx_id);
$net->add_interaction(-nodes => [($node1,$node2)],
-interaction => $interx );
$net->add_id_to_interaction($interx_id,$interx);
$twig->purge();
}
}
1;
__END__} |
General documentation
| DATA NOT YET AVAILABLE | Top |
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to one
of the Bioperl mailing lists. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
Please direct usage questions or support issues to the mailing list:
bioperl-l@bioperl.org
rather than to the module maintainer directly. Many experienced and
reponsive experts will be able look at the problem and quickly
address it. Please include a thorough description of the problem
with code and data examples if at all possible.
Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via the
web:
http://bugzilla.open-bio.org/
Brian Osborne bosborne at alum.mit.edu