2 # acro_gene outputs gene acronym definitions for use with acro
3 # and is released under the terms of the GNU GPL version 3, or any
4 # later version, at your option. See the file README and COPYING for
6 # Copyright 2016 by Don Armstrong <don@donarmstrong.com>.
17 acro_gene - outputs gene acronym definitions for use with acro
21 acro_gene [options] [gene1] [[gene2]...]
24 --debug, -d debugging level (Default 0)
25 --help, -h display this help
26 --man, -m display manual
34 Debug verbosity. (Default 0)
38 Display brief usage information.
55 my %options = (debug => 0,
58 hgnc_db => 'ftp://ftp.ebi.ac.uk/pub/databases/genenames/new/tsv/non_alt_loci_set.txt',
59 gene_db => [glob("~/.acro_gene_db")]->[0],
65 'debug|d+','help|h|?','man|m');
67 pod2usage() if $options{help};
68 pod2usage({verbose=>2}) if $options{man};
70 $DEBUG = $options{debug};
74 push @USAGE_ERRORS,"You must provide a gene name";
77 pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
80 if (! -e $options{gene_db}) {
81 system('wget','-O',$options{gene_db},$options{hgnc_db});
85 open($fh,'<',$options{gene_db}) or
86 die "Unable to open $options{gene_db} for reading: $!";
100 $genes{$r{symbol}} = $r{name};
101 my $alias = $r{alias_symbol};
103 my @aliases = split /\|/,$alias;
104 $aliases{@aliases} = ($r{name}) x @aliases;
109 my $name = $genes{$gene};
110 if (not defined $name) {
111 $gene = $aliases{$gene};
112 next unless defined $gene;
113 $name = $genes{$gene};
115 my $url = 'http://www.genenames.org/cgi-bin/gene_symbol_report?match='.$gene;
116 print '\DeclareAcronym{'.
117 $gene.'}{short=\href{'.$url.
118 '}{\textit{'.$gene.'}},long={'.$name.
119 '},first-style=reversed,single={'.
120 '\href{'.$url.'}{\textit{'.$gene.'}} ('.$name.')'.