Skip to content
/ gwlib Public

Python library for writing GeneWeaver-related services.

Notifications You must be signed in to change notification settings

treynr/gwlib

Repository files navigation

gwlib

https://img.shields.io/travis/treynr/gwlib.svg?style=flat-square

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's ConfigParser.
  • db.py: wrapper functions that encapsulate commonly used GW database queries.
  • log.py: output logging customization based python's logging module.
  • util.py: miscellaneous utility functions.

Usage

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())

API

See the individual module docs for API and usage.

Installation

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

Requirements

About

Python library for writing GeneWeaver-related services.

Resources

Stars

Watchers

Forks

Packages

No packages published