]> git.donarmstrong.com Git - function2gene.git/blobdiff - bin/parse_genecard_results
Add results to table; modify the search parssers to work better. Fix error in get_ncb...
[function2gene.git] / bin / parse_genecard_results
index 4c00d9b47b85b44ef07adb66042f224cd6513e45..4b7d514d7df0b5352a4fb71aa50f0d8cfd55365e 100755 (executable)
@@ -70,16 +70,17 @@ BEGIN{
 use IO::File;
 use IO::Dir;
 
-# XXX parse config file
-
 my %options = (debug    => 0,
               help     => 0,
               man      => 0,
               dir      => '.',
               keyword  => undef,
+              keywords => 0,
              );
 
-GetOptions(\%options,'keyword|k=s','dir|D=s','debug|d+','help|h|?','man|m');
+GetOptions(\%options,'keyword|k=s','dir|D=s','debug|d+','help|h|?','man|m',
+          'keywords',
+         );
 
 
 pod2usage() if $options{help};
@@ -99,6 +100,13 @@ use constant {NAME        => 0,
              FILENAME    => 8,
             };
 
+if ($options{keywords}) {
+     if (@ARGV != 1) {
+         pod2usage("If the --keywords option is used, exactly one argument (the keyword) must be passed");
+     }
+     $options{dir} = "$ARGV[0]_results_genecard";
+}
+
 if (not -d $options{dir}) {
      die "$options{dir} does not exist or is not a directory";
 }
@@ -120,15 +128,13 @@ while ($_ = $dir->read) {
      my @results;
 
      # Find gene name
-     ($results[NAME]) = $result =~ m&(?:Lean|Gene)Card\s+for\s+(?:(?:disorder\s+locus|uncategorized|
-                                    hugo\s*reserved\s*symbol|cluster|
-                                    potentially\s*expressed\s*sequence)|(?:predicted\s+|pseudo|rna\s+|)gene)
-                                    \s*(?:with\s*support\s*|)<FONT\s+COLOR=\"[^\"]+\">\s*<FONT\s+SIZE=\+2>\s*([^\s]+)\s*&xis;
+     ($results[NAME]) = $result =~ m{(?:Lean|Gene)Card\s+for\s+[^<]+<FONT[^>]+>\s*([^<]+)}xis;
 
      $results[NAME] ||= 'NO NAME';
      # Find REF SEQ number
-     ($results[REFSEQ]) = $result =~ m|http://www.ncbi.nlm.nih.gov/entrez/query.fcgi\?
-                              cmd=Search\&db=nucleotide\&doptcmdl=GenBank\&term=([^\"]+)\"|xis;
+     ($results[REFSEQ]) = $result =~ m{http://www.ncbi.nlm.nih.gov/entrez/query.fcgi\?
+                                      (?:cmd=Search\&db=nucleotide|db=nucleotide\&cmd=search)
+                                      \&doptcmdl=GenBank\&term=([^\"]+)\"}xis;
 
      $results[REFSEQ] ||= 'NO REFSEQ';
 
@@ -153,7 +159,10 @@ while ($_ = $dir->read) {
      my @functions = $result =~ m&<li><b>Function:</b>\s+(.+?)(?:<li>)|(?:</ul>)&gis;
 
      # GO Functions
-     push @functions, (map {s#\s*</a>\s*# #g; $_;} $result =~ m&(GO:\d+\s*</a>.+?)(?:<dd>|<p>)&gis);
+     push @functions, (map {s/\n//g}
+                      map {s#\s*\s*</a>(?:</td><td>\s*)?\s*# #g; $_;}
+                      $result =~ m{(GO:\d+\s*</a>(?:</td><td>\s*)?.+?)(?:</td><dd>|<p>)}gis
+                     );
      $results[FUNCTION] = join('; ', map {(defined $_)?($_):()} @functions);
      $results[FUNCTION] ||= 'NO FUNCTION';