[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Tue Dec 9 22:24:03 UTC 2003
mwilkinson
Tue Dec 9 17:24:03 EST 2003
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv28763/Perl/MOBY
Modified Files:
CommonSubs.pm
Log Message:
updating my GO services to be 0.6 compliant and a bit more readable
moby-live/Perl/MOBY CommonSubs.pm,1.32,1.33
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm 2003/12/09 21:38:39 1.32
+++ /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm 2003/12/09 22:24:03 1.33
@@ -248,16 +248,16 @@
function : to get the IDs of simple articles that are in the given namespace
usage : my @ids = getSimpleArticleIDs("NCBI_gi", \@SimpleArticles);
args : (in order)
- $Namespace - (required) a namespace stringfrom the MOBY namespace ontology
+ $Namespace - (required) a namespace stringfrom the MOBY namespace ontology, or undef if you don't care
\@Simples - (required) a listref of Simple XML::DOM nodes
i.e. the XML::DOM representing an XML structure like this:
<Simple>
<Object namespace="NCBI_gi" id="163483"/>
</Simple>
- note : it will return *only* the ids that are in the given namespace
+ note : it will return *only* the ids that are in the given namespace, if you provide one
but since you are required to return an output for every input
(even if it is invalid) this routine will return undef for
- those articles that are not in that namespace
+ those articles in the list that are not in that namespace so you can keep track
=cut
@@ -271,45 +271,52 @@
my @input_nodes = @{$input_nodes};
my $OS = MOBY::Client::OntologyServer->new;
my ($s, $m);
- ($s, $m, $desired_namespace) = $OS->namespaceExists(term => $desired_namespace); # returns (success, message, lsid)
- return undef unless $s; # bail if not successful
+ if ($desired_namespace){
+ ($s, $m, $desired_namespace) = $OS->namespaceExists(term => $desired_namespace); # returns (success, message, lsid)
+ unless ($s){ # bail if not successful
+ print STDERR "MOBY::CommonSubs WARNING ** the namespace $desired_namespace does not exist in the MOBY ontology, and is not a valid LSID\n";
+ return undef;
+ }
+ }
- my @accessions;
+ my @ids;
foreach my $in(@input_nodes){
#$in = "<Simple><Object namespace='' id=''/></Simple>"
next unless $in->getNodeName =~ /simple/i; # only allow simples
my @simples = $in->getChildNodes;
foreach (@simples){ # $_ = <Object namespace='' id=''/>
next unless $_->getNodeType == ELEMENT_NODE;
- my $ns = $_->getAttributeNode('namespace'); # get the namespace DOM node
- $ns = $_->getAttributeNode('moby:namespace') unless ($ns); # perhaps it is namespaced...
- unless ($ns){ # if we don't get it at all, then move on to the next input
- push @accessions, undef; # but push an undef onto teh stack in order
- next;
- }
- $ns = $ns->getValue; # if we have a namespace, then get its value
- ($s, $m, $ns) = $OS->namespaceExists(term => $ns);
-
- unless ($ns eq $desired_namespace){ # we are registering as working in a particular namespace, so check this
- push @accessions, undef; # and push undef onto the stack if it isn't
- next;
+ if ($desired_namespace){
+ my $ns = $_->getAttributeNode('namespace'); # get the namespace DOM node
+ $ns = $_->getAttributeNode('moby:namespace') unless ($ns); # perhaps it is namespaced...
+ unless ($ns){ # if we don't get it at all, then move on to the next input
+ push @ids, undef; # but push an undef onto teh stack in order
+ next;
+ }
+ $ns = $ns->getValue; # if we have a namespace, then get its value
+ ($s, $m, $ns) = $OS->namespaceExists(term => $ns);
+
+ unless ($ns eq $desired_namespace){ # we are registering as working in a particular namespace, so check this
+ push @ids, undef; # and push undef onto the stack if it isn't
+ next;
+ }
}
# Now do the same thing for ID's
my $id = $_->getAttributeNode('id');
$id = $_->getAttributeNode('moby:id') unless ($id);
unless ($id){
- push @accessions, undef;
+ push @ids, undef;
next;
}
$id = $id->getValue;
unless (defined $id){ # it has to have a hope in hell of retrieving something...
- push @accessions, undef; # otherwise push undef onto the stack if it isn't
+ push @ids, undef; # otherwise push undef onto the stack if it isn't
next;
}
- push @accessions, $id;
+ push @ids, $id;
}
}
- return @accessions;
+ return @ids;
}
More information about the MOBY-guts
mailing list