Importing and querying HGNC data
PyHGNC is a Python package to access and query data provided by HGNC-approved gene nomenclature, gene families and associated resources including links to genomic, proteomic and phenotypic information.
Data are installed in a (local or remote) RDBMS enabling bioinformatic algorithms very fast response times to sophisticated queries and high flexibility by using SOLAlchemy database layer.
This development is supported by following IMI projects:
PyHGNC uses SQLAlchemy to cover a wide spectrum of RDMSs (Relational database management system). For best performance MySQL or MariaDB is recommended. But if you have no possibility to install software on your system SQLite - which needs no further installation - also works. Following RDMSs are supported (by SQLAlchemy):
This is a quick start tutorial for impatient.
PyHGNC can be installed with pip.
pip install pyhgnc
If you fail because you have no rights to install use superuser (sudo on Linux before the commend) or …
pip install --user pyhgnc
If you want to make sure you are installing this under python3 use …
python3 -m pip install pyhgnc
If you want to use SQLite as your database system, because you …
- have no possibility to use RDMSs like MySQL/MariaDB
- just test PyHGNC, but don’t want to spend time in setting up a database
skip the next MySQL/MariaDB setup section. But in general we strongly recommend MySQL or MariaDB as your relational database management system.
If you don’t know what all that means skip the section MySQL/MariaDB setup.
Don’t worry! You can always later change the configuration. For more information about changing database system later go to the subtitle Changing database configuration Changing database configuration in the documentation on readthedocs.
Log in MySQL as root user and create a new database, create a user, assign the rights and flush privileges.
CREATE DATABASE pyhgnc CHARACTER SET utf8 COLLATE utf8_general_ci; GRANT ALL PRIVILEGES ON pyhgnc.* TO 'pyhgnc_user'@'%' IDENTIFIED BY 'pyhgnc_passwd'; FLUSH PRIVILEGES;
There are two options to set the MySQL/MariaDB.
- The simplest is to start the command line tool
You will be guided with input prompts. Accept the default value in squared brackets with RETURN. You will see something like this
server name/ IP address database is hosted [localhost]: MySQL/MariaDB user [pyhgnc_user]: MySQL/MariaDB password [pyhgnc_passwd]: database name [pyhgnc]: character set [utf8]:
Connection will be tested and in case of success return Connection was successful. Otherwise you will see following hint
Test was NOT successful Please use one of the following connection schemas MySQL/MariaDB (strongly recommended): mysql+pymysql://user:passwd@localhost/database?charset=utf8 PostgreSQL: postgresql://user:passwd@localhost/database MsSQL (pyodbc needed): mssql+pyodbc://user:passwd@database SQLite (always works): - Linux: sqlite:////absolute/path/to/database.db - Windows: sqlite:///C:\absolute\path\to\database.db Oracle: oracle://user:passwd@localhost:1521/database
2. The second option is to start a python shell and set the MySQL configuration. If you have not changed anything in the SQL statements above …
import pyhgnc pyhgnc.set_mysql_connection()
If you have used you own settings, please adapt the following command to you requirements.
import pyhgnc pyhgnc.set_mysql_connection(host='localhost', user='pyhgnc_user', passwd='pyhgnc_passwd', db='pyhgnc')
The updating process will download the complete HGNC json file and the HCOP file.
import pyhgnc pyhgnc.manager.database.update()
This will use either the default connection settings of PyHGNC or the settings defined by the user. It is also possible to run the update process from shell.
Quick start with query functions
Initialize the query object
query = pyhgnc.query()
Get all HGNC entries:
all_entries = query.hgnc()
Check out the documentation: Query functions section for more examples and check out the Query section for all possible parameters for the different models.
See the installation documentation for more advanced
instructions. Also, check the change log at
HGNC provides also online tools .
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size & hash SHA256 hash help||File type||Python version||Upload date|
|PyHGNC-0.2.4-py2-none-any.whl (80.8 kB) Copy SHA256 hash SHA256||Wheel||py2||Nov 22, 2017|
|PyHGNC-0.2.4-py3-none-any.whl (80.8 kB) Copy SHA256 hash SHA256||Wheel||py3||Nov 22, 2017|
|PyHGNC-0.2.4.tar.gz (494.4 kB) Copy SHA256 hash SHA256||Source||None||Nov 22, 2017|