[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Wed Dec 10 22:22:03 UTC 2003


mwilkinson
Wed Dec 10 17:22:03 EST 2003
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv32614/Perl/MOBY

Modified Files:
	CommonSubs.pm 
Log Message:
minor changes to make some CommonSubs more friendly.  Also added a new service which is the beginning of me weaning myself off of GenBank because genbank is broken almost every time I need to use it.  The new service uses SeqHound to make the data lookups, so it is always 24 hours behind the real genbank, but thats not bad.  The new service consumes NCBI_Acc, NCBI_gi, PIR, Swissprot, EMBL, or PDB identifiers and returns the genbank record as a flatfile

moby-live/Perl/MOBY CommonSubs.pm,1.33,1.34
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm	2003/12/09 22:24:03	1.33
+++ /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm	2003/12/10 22:22:03	1.34
@@ -247,24 +247,29 @@
  name     : getSimpleArticleIDs
  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, or undef if you don't care
+            my @ids = getSimpleArticleIDs(\@SimpleArticles);
+ args     : $Namespace  - (optional) 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, 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 in the list that are not in that namespace so you can keep track
+ note     : If you provide a namespace, it will return *only* the ids that are in the given namespace,
+            but will return 'undef' for any articles in the WRONG namespace so that you get an
+            equivalent number of outputs to inputs.
+            
+            Note that if you call this with a single argument, this is assumed to
+            be \@Articles, so you will get ALL id's regardless of namespace!
 
 =cut
 
 
 sub getSimpleArticleIDs {
 	my ($desired_namespace, $input_nodes) = @_;
-	return undef unless $input_nodes;
+	if ($desired_namespace && !($input_nodes)){  # if called with ONE argument, then these are the input nodes!
+        $input_nodes = $desired_namespace;
+        $desired_namespace = undef;   
+	}
     $input_nodes = [$input_nodes] unless ref($input_nodes) =~ /ARRAY/; # be flexible!
 	return undef unless scalar @{$input_nodes};
 
@@ -281,6 +286,7 @@
 
 	my @ids;	
 	foreach my $in(@input_nodes){
+        next unless $in;
 		#$in = "<Simple><Object namespace='' id=''/></Simple>"
         next unless $in->getNodeName =~ /simple/i;  # only allow simples
 		my @simples = $in->getChildNodes;
@@ -932,6 +938,7 @@
 sub validateThisNamespace {
     my ($ns, @namespaces) = @_;
     foreach (@namespaces){
+        next unless $_;
         return 1 if $ns eq $_;
     }
     return 0;




More information about the MOBY-guts mailing list