[Bioperl-l] Interpro parser example

Juguang Xiao juguang at tll.org.sg
Thu Dec 4 12:58:41 EST 2003


Hi,

After fixing the few bugs and making the existing Interpro parser able 
to run throughout the current Interpro xml file, I would like to give 
an example to the list, in case someone was, like me, trying to use it 
without knowing how.


use Bio::OntologyIO;

my $file = 'interpro.xml';
my $io = Bio::OntologyIO->new(
	-format => 'interpro',
	-file => $file,
	-ontology_engine => 'simple'
);

while(my $ontology = $io->next_ontology){ # Actually, there is only one 
ontology for an InterPro
#    print $ontology->name, "\n"; # InterPro

# For the InterPro, there are always and only six root items, according 
to the type, see
# http://www.ebi.ac.uk/interpro/user_manual.html#N673

	my @roots = $ontology->get_root_terms;
	my @interpros;
	foreach(@roots){
		push @interpros, $ontology->get_child_terms($_);
	}
	# each in @interpros is of Bio::Ontology::InterProTerm .
	foreach my $interpro(@interpros){
		print "Interpro id:\t", $interpro->identifier; # Same as the method 
interpro_id,"\n";
		print "Interpro (short) name:\t(", $interpro->short_name, ')', 
$interpro->name, "\n";
		
		# examines the related records in member databases
		foreach my $member ($interpro->get_members){ # of 
Bio::Annotation::DBLink
			print "\tMember database:\t", $member->database, "\n"; # Such as 
SWISSPROT, PFAM
			print "\taccession number:\t", $member->primary_id, "\n"; # Such as 
P01234, PF00000
		}
		
		# examines the publication
		foreach my $ref ($interpro->get_references){ # of 
Bio::Annotation::Reference
		}
	
	}
}

C&C? (Corrections and Comments)

Juguang



More information about the Bioperl-l mailing list