From 68dcb70b77c5e9b67d611a64af3e418d567df2fc Mon Sep 17 00:00:00 2001 From: Brian Osborne Date: Sun, 28 Sep 2014 01:09:55 -0400 Subject: [PATCH] Minor edits --- Bio/Ontology/OBOEngine.pm | 14 ++++++-------- Bio/OntologyIO/obo.pm | 13 ++++++------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Bio/Ontology/OBOEngine.pm b/Bio/Ontology/OBOEngine.pm index 16460dac1..2997a6eae 100644 --- a/Bio/Ontology/OBOEngine.pm +++ b/Bio/Ontology/OBOEngine.pm @@ -296,7 +296,7 @@ sub negatively_regulates_relationship { Function: Adds a Bio::Ontology::TermI to this engine Returns : true if the term was added and false otherwise (e.g., if the term already existed in the ontology engine) - Args : Bio::Ontology::TermI + Args : Bio::Ontology::TermI` =cut @@ -972,8 +972,7 @@ sub _get_id { if ( ref($term) ) { # use TermI standard API - $self->throw( - "Object doesn't implement Bio::Ontology::TermI. " . "Bummer." ) + $self->throw( "Object doesn't implement Bio::Ontology::TermI" ) unless $term->isa("Bio::Ontology::TermI"); $id = $term->identifier(); @@ -986,10 +985,8 @@ sub _get_id { } } - return $id - -# if $term->isa("Bio::Ontology::GOterm")||($id =~ /^[A-Z_]{1,8}:\d{1,}$/); - if $term->isa("Bio::Ontology::OBOterm") || ( $id =~ /^\w+:\w+$/ ); + # if $term->isa("Bio::Ontology::GOterm")||($id =~ /^[A-Z_]{1,8}:\d{1,}$/); + return $id if $term->isa("Bio::Ontology::OBOterm") || ( $id =~ /^\w+:\w+$/ ); # prefix with something if only numbers # if($id =~ /^\d+$/) { @@ -1000,8 +997,9 @@ sub _get_id { # we shouldn't have gotten here if it's at least a remotely decent ID $self->throw( ref($self) . ": non-standard identifier '$id'\n" ) unless $id =~ /\|/; + return $id; -} # _get_id +} # Helper for getting children and parent terms sub _get_child_parent_terms_helper { diff --git a/Bio/OntologyIO/obo.pm b/Bio/OntologyIO/obo.pm index 92bf0db5e..843d6f7e8 100644 --- a/Bio/OntologyIO/obo.pm +++ b/Bio/OntologyIO/obo.pm @@ -265,15 +265,13 @@ sub parse { $ont = $new_ont; } - $self->_add_term( $term, $ont ); # Adding the IS_A relationship - my $isa_parents_array_ref = $self->{'_isa_parents'}; - foreach my $parent_term (@$isa_parents_array_ref) { + for my $parent_term ( @{$self->{'_isa_parents'}} ) { # Check if parent exists, if not then add the term to the graph. - if ( !( $self->_has_term($parent_term) ) ) { - $self->_add_term( $parent_term, $ont ); + if ( ! $self->_has_term($parent_term) ) { + $self->_add_term( $parent_term, $ont ); # ! } $self->_add_relationship( $parent_term, $term, @@ -282,7 +280,7 @@ sub parse { # Adding the other relationships like part_of, related_to, develops_from my $relationship_hash_ref = $self->{'_relationships'}; - for my $relationship ( keys %$relationship_hash_ref ) { + for my $relationship ( keys %{$relationship_hash_ref} ) { my $reltype; # Check if relationship exists, if not add it if ( $self->_ont_engine->get_relationship_type($relationship) ) { @@ -695,7 +693,8 @@ sub _next_term { } } } - return $term; + + $term; } # Creates a Bio::Ontology::OBOterm object -- 2.11.4.GIT