Category: python

Here’s a quick method to get HGNC symbols and names that draws upon data from UCSC and the open source project:

$ wget -qO- | gunzip -c | cut -f13 | sort | uniq | > hgnc_symbols_with_names.txt

There’s a Python script in there that I call

#!/usr/bin/env python

import sys
from mygene import MyGeneInfo

hgnc_symbols = []
for line in sys.stdin:
    hgnc_symbols.append('%s' % (line.strip()))

mg = MyGeneInfo()
results = mg.querymany(hgnc_symbols, scopes='symbol', species='human', verbose=False)

for result in results:
    sys.stdout.write("%s\t%s\n" % (result['symbol'], result['name']))

The pipeline above writes a two-column text file called hgnc_symbols_with_names.txt that contains the HGNC symbol (e.g., AAR2) and its name (e.g., AAR2 splicing factor homolog), which could be put into a lookup table or, given that it is sorted, could be searched very quickly with a binary search via the Python bisect library.

Read More

This assumes Homebrew is installed and that it installs Graphviz 2.40.1:

$ brew install graphviz
$ git clone
$ cd pygraphviz
$ sudo python install --user --include-path=/usr/local/Cellar/graphviz/2.40.1/include --library-path=/usr/local/Cellar/graphviz/2.40.1/lib

Read More