A Python 2.7/3.6/3.7 library designed to help write backend services for GeneWeaver (GW).
The gwlib
package is comprised of five separate modules:
batch.py
: classes to parse and output gene sets in GW's batch format.config.py
: contains a simple configuration file parser based on python'sConfigParser
.db.py
: wrapper functions that encapsulate commonly used GW database queries.log.py
: output logging customization based python'slogging
module.util.py
: miscellaneous utility functions.
As an example, let's say we're interested in retrieving all the genes belonging to a
single species and removing any genes that don't have homologs in at least one other
species.
We can do this in just a few lines of code using the db.py
module:
from gwlib import db
## Replace these with your own credentials
db.connect('host', 'database', 'user', 'password')
## Returns a bijection of species names to unique species identifiers
species = db.get_species()
## Retrieve all known genes in mice
genes = db.get_species_genes(species['Mus musculus'])
## Discover genes that have homologs in >= 1 other species using NCBI Homologene
homologs = db.get_gene_homologs(set(genes.values()), source='Homologene')
## Print the gene identifiers
print(homologs.keys())
See the individual module docs for API and usage.
Installation can be accomplished by either retrieving the latest release and installing via pip or by cloning this repository and installing from source. To install the latest version via pip:
$ pip install https://github.com/treynr/gwlib/archive/v1.2.1.tar.gz
To install from source:
$ git clone https://github.com/treynr/gwlib.git
$ cd gwlib
$ python setup.py install
- Python 2.7/3.6/3.7
- configparser
- psycopg2