]> git.donarmstrong.com Git - function2gene.git/blobdiff - bin/parse_ncbi_results
update function2gene to allow uniprot
[function2gene.git] / bin / parse_ncbi_results
index 51d339db66e38bb02918c5d0c3ce94f760558b30..eb82b3c3389dceb34b910a30354a220e7a1a1dc1 100755 (executable)
@@ -1,13 +1,12 @@
 #! /usr/bin/perl
 
-# parse_ncbi_results retreives files of search results from ncbi,
+# parse_ncbi_results parses search results retrieved from ncbi,
 # and is released under the terms of the GPL version 2, or any later
 # version, at your option. See the file README and COPYING for more
 # information.
 
-# Copyright 2004 by Don Armstrong <don@donarmstrong.com>.
+# Copyright 2005,7 by Don Armstrong <don@donarmstrong.com>.
 
-# $Id: ss,v 1.1 2004/06/29 05:26:35 don Exp $
 
 
 use warnings;
@@ -77,9 +76,12 @@ my %options = (debug    => 0,
               man      => 0,
               dir      => '.',
               keyword  => undef,
+              keywords => 0,
              );
 
-GetOptions(\%options,'keyword|k=s','debug|d+','help|h|?','man|m');
+GetOptions(\%options,'keyword|k=s','debug|d+','help|h|?','man|m',
+          'keywords'
+         );
 
 
 pod2usage() if $options{help};
@@ -179,10 +181,16 @@ $parser->setHandlers('Start' => \&tag_start,
                     'Char'  => \&tag_content
                    );
 
+print STDOUT join(",", map {qq("$_");} qw(Name RefSeq Location Alias Function Description Keyword DBName Filename)),qq(\n);
 for (@ARGV) {
      $file_name = $_;
-     ($keyword) = $options{keyword} || $file_name =~ m#(?:^|/)([^\/]+?)[\s-]+AND[\s\-].+_results.xml$#;
-     print STDOUT join(",", map {qq("$_");} qw(Name RefSeq Location Alias Function Description Keyword DBName Filename)),qq(\n);
+     if ($options{keywords}) {
+         $keyword = $_;
+         $file_name = "ncbi_${keyword}_results.xml";
+     }
+     else {
+         ($keyword) = $options{keyword} || $file_name =~ m#(?:^|/)([^\/]+?)[\s-]+AND[\s\-].+_results.xml$#;
+     }
      my $file = new IO::File $file_name, 'r' or die "Unable to open file $file_name $!";
 
      $parser->parse($file);