X-Git-Url: https://git.donarmstrong.com/?p=function2gene.git;a=blobdiff_plain;f=bin%2Fparse_genecard_results;h=fbd98851a4a8d27f88cb7e9eee567b4ebda35643;hp=4b7d514d7df0b5352a4fb71aa50f0d8cfd55365e;hb=HEAD;hpb=0486e6434cd182e8b30ba008d98ad3d3f008d2ab diff --git a/bin/parse_genecard_results b/bin/parse_genecard_results index 4b7d514..fbd9885 100755 --- a/bin/parse_genecard_results +++ b/bin/parse_genecard_results @@ -70,6 +70,9 @@ BEGIN{ use IO::File; use IO::Dir; +use HTML::TreeBuilder; +use HTML::ElementTable; + my %options = (debug => 0, help => 0, man => 0, @@ -115,6 +118,8 @@ my $dir = new IO::Dir $options{dir} or die "Unable to open dir $options{dir}: $! print join(",", map {qq("$_");} qw(Name RefSeq Location Alias Function Description Keyword DBName Filename)),qq(\n); +my ($keyword) = $options{keyword} || $options{dir} =~ m#(?:^|/)([^\/]+)_results_genecard#; + while ($_ = $dir->read) { my $file_name = $_; next if $file_name =~ /^\./; @@ -139,40 +144,48 @@ while ($_ = $dir->read) { $results[REFSEQ] ||= 'NO REFSEQ'; # Find Gene Location - ($results[LOCATION]) = $result =~ m&LocusLink\s+cytogenetic\s+band:\s+ - \s*([^\<]+?)\s*&xis; + ($results[LOCATION]) = $result =~ m{cytogenetic\s+band:\s+ + ]*>\s*([^\<]+?)\s*}xis; $results[LOCATION] ||= 'NO LOCATION'; # Find gene aliases - my ($alias_table) = $result =~ m|Aliases and Descriptions(.+?)|is; - $alias_table ||=''; - - my @gene_aliases = $alias_table =~ m|
  • \s*([^\(]{0,20}?)\s*\(]+>]+>Aliases.+?)}is; + $alias_table ||= ''; + my @gene_aliases = map {s/\s*$//; $_;} $alias_table =~ m{\s*([^<]+)<}gis; $results[ALIAS] = join('; ', @gene_aliases); $results[ALIAS] ||= 'NO ALIASES'; # Find gene function(s) - # Swiss prot functions - my @functions = $result =~ m&
  • Function:\s+(.+?)(?:
  • )|(?:)&gis; - + my @functions; # GO Functions - push @functions, (map {s/\n//g} - map {s#\s*\s*(?:\s*)?\s*# #g; $_;} - $result =~ m{(GO:\d+\s*(?:\s*)?.+?)(?:
    |

    )}gis + push @functions, (map {s/\n//g; $_;} + map {s#\s*(?:\s*)?\s*# #g; $_;} + $result =~ m{(GO:\d+\s*(?:\s*)?.+?)(?:||

    |

    )}gis ); $results[FUNCTION] = join('; ', map {(defined $_)?($_):()} @functions); $results[FUNCTION] ||= 'NO FUNCTION'; # Figure out the keyword used - ($results[KEYWORD]) = $file_name =~ /search=([^&]+)/; + ($results[KEYWORD]) = $file_name =~ /search=?([^&]+)$/; + + $results[KEYWORD] ||= $keyword || 'NO KEYWORD'; - $results[KEYWORD] ||= 'NO KEYWORD'; + # Swiss prot functions + my @description = (map {s/<[^>]+>/ /g; + s/\s+/ /g; + $_; + } + $result =~ m{<(?:dd|li)>Function(?::|:)\s+ + (.+?)<(?:/dd|li)>}xgis + ); # Figure out what the description is - $results[DESCRIPTION] = ''; + $results[DESCRIPTION] = join('; ', + map {(defined $_)?($_):()} + @description); # Database searched $results[DBNAME] = 'genecard';