cruzdb

python access to UCSC genomes database

https://github.com/brentp/cruzdb

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.3%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

python access to UCSC genomes database

Basic Info
  • Host: GitHub
  • Owner: brentp
  • License: mit
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 3.05 MB
Statistics
  • Stars: 136
  • Watchers: 16
  • Forks: 41
  • Open Issues: 13
  • Releases: 0
Created almost 15 years ago · Last pushed almost 6 years ago
Metadata Files
Readme License

README.rst

A rendered version of the docs is available at: http://pythonhosted.org/cruzdb/

A paper describing cruzdb is in Bioinformatics: https://doi.org/10.1093/bioinformatics/btt534

cruzdb overview
===============

The UCSC `Genomes Database`_ is a great resource for annotations, regulation
and variation and all kinds of data for a growing number of taxa.
This library aims to make utilizing that data simple so that we can do
sophisticated analyses without resorting to `awk-ful`_, error-prone
manipulations.
As motivation, here's an example of some of the capabilities::

    >>> from cruzdb import Genome

    >>> g = Genome(db="hg18")

    >>> muc5b = g.refGene.filter_by(name2="MUC5B").first()
    >>> muc5b
    refGene(chr11:MUC5B:1200870-1239982)

    >>> muc5b.strand
    '+'

    # the first 4 introns
    >>> muc5b.introns[:4]
    [(1200999L, 1203486L), (1203543L, 1204010L), (1204082L, 1204420L), (1204682L, 1204836L)]

    # the first 4 exons.
    >>> muc5b.exons[:4]
    [(1200870L, 1200999L), (1203486L, 1203543L), (1204010L, 1204082L), (1204420L, 1204682L)]

    # note that some of these are not coding because they are < cdsStart
    >>> muc5b.cdsStart
    1200929L

    # the extent of the 5' utr.
    >>> muc5b.utr5
    (1200870L, 1200929L)

    # we can get the (first 4) actual CDS's with:
    >>> muc5b.cds[:4]
    [(1200929L, 1200999L), (1203486L, 1203543L), (1204010L, 1204082L), (1204420L, 1204682L)]

    # the cds sequence from the UCSC DAS server as a list with one entry per cds
    >>> muc5b.cds_sequence #doctest: +ELLIPSIS
    ['atgggtgccccgagcgcgtgccggacgctggtgttggctctggcggccatgctcgtggtgccgcaggcag', ...]


    >>> transcript = g.knownGene.filter_by(name="uc001aaa.2").first()
    >>> transcript.is_coding
    False

    # convert a genome coordinate to a local coordinate.
    >>> transcript.localize(transcript.txStart)
    0L

    # or localize to the CDNA position.
    >>> print transcript.localize(transcript.cdsStart, cdna=True)
    None

Command-Line Interface
======================

with cruzdb 0.5.4+ installed, given a file `input.bed` you can do::

    python -m cruzdb hg18 input.bed refGene cpgIslandExt

to have the intervals annotated with the `refGene` and `cpgIslandExt`
tables from version `hg18`.

DataFrames
----------
... are so in. We can get one from a table as::

   >>> df = g.dataframe('cpgIslandExt') 
   >>> df.columns #doctest: +ELLIPSIS
   Index([chrom, chromStart, chromEnd, name, length, cpgNum, gcNum, perCpg, perGc, obsExp], dtype=object)



All of the above can be repeated using knownGene annotations by changing 'refGene' to 
'knownGene'. And, it can be done easily for a set of genes.

Spatial
-------

k-nearest neighbors, upstream, and downstream searches are available.
Up and downstream searches use the strand of the query feature to determine the direction:

    >>> nearest = g.knearest("refGene", "chr1", 9444, 9555, k=6)
    >>> up_list = g.upstream("refGene", "chr1", 9444, 9555, k=6)
    >>> down_list = g.downstream("refGene", "chr1", 9444, 9555, k=6)



Mirror
------

The above uses the mysql interface from UCSC. It is now possible to mirror
any tables from UCSC to a local sqlite database via:

   # cleanup

   >>> import os
   >>> if os.path.exists("/tmp/u.db"): os.unlink('/tmp/u.db')

   >>> g = Genome('hg18')



   >>> gs = g.mirror(['chromInfo'], 'sqlite:////tmp/u.db')

and then use as:

   >>> gs.chromInfo
   


Code
----

Most of the per-row features are implemented in `cruzdb/models.py` in the
Feature class. If you want to add something to a feature (like the existing
feature.utr5) add it here.

The tables are reflected using `sqlalchemy`_ and mapped in the
\_\_getattr\_\_\ method of the `Genome` class in `cruzdb/__init__.py`

So a call like::

    genome.knownGene

calls the \_\_getattr\_\_ method with the table arg set to 'knownGene'
that table is then reflected and an object with parent classes of `Feature`
and sqlalchemy's declarative_base is returned.


Contributing
------------

YES PLEASE!

To start coding, it is probably polite to grab your own copy of some of the
UCSC tables so as not to overload the UCSC server. 
You can run something like::

   Genome('hg18').mirror(["refGene", "cpgIslandExt", "chromInfo", "knownGene", "kgXref"], "sqlite:////tmp/hg18.db")

Then the connection would be something like::

    g = Genome("sqlite:////tmp/hg18.db")

If you have a feature you like to use/implement, open a ticket on github for
discussion. Below are some ideas.


.. _`Genomes Database`: http://genome.ucsc.edu/cgi-bin/hgTables
.. _`awk-ful`: https://gist.github.com/1173596
.. _`sqlalchemy`: http://sqlalchemy.org/

Owner

  • Name: Brent Pedersen
  • Login: brentp
  • Kind: user
  • Location: Oregon, USA

Doing genomics

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 167
  • Total Committers: 6
  • Avg Commits per committer: 27.833
  • Development Distribution Score (DDS): 0.12
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Brent Pedersen b****e@g****m 147
Roy Lardenoije 3****e 11
Luca Beltrame l****e@m****t 5
Adel Qalieh a****q 2
Minzhang Cheng m****g 1
Aaron Quinlan a****n@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 12 months ago

All Time
  • Total issues: 22
  • Total pull requests: 9
  • Average time to close issues: 7 months
  • Average time to close pull requests: 1 day
  • Total issue authors: 15
  • Total pull request authors: 6
  • Average comments per issue: 2.36
  • Average comments per pull request: 3.78
  • Merged pull requests: 8
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • lbeltrame (4)
  • brentp (4)
  • kevjp (2)
  • radwaraed (1)
  • parcbioinfo (1)
  • EricSHo (1)
  • daler (1)
  • kurtbern (1)
  • arq5x (1)
  • ghost (1)
  • jim-bo (1)
  • mylons (1)
  • TYRANISTAR (1)
  • jsolvason (1)
  • gilesc (1)
Pull Request Authors
  • adelq (2)
  • lbeltrame (2)
  • lardenoije (2)
  • minzhangcheng (1)
  • arq5x (1)
  • knkarthik (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 31 last-month
  • Total docker downloads: 1,133
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 7
    (may contain duplicates)
  • Total versions: 11
  • Total maintainers: 1
pypi.org: cruzdb

Interface to UCSC genomic databases. Also allows things like up/downstream/k-nearest-neighbor queries and mirroring of tables to local sqlite databases

  • Versions: 10
  • Dependent Packages: 0
  • Dependent Repositories: 7
  • Downloads: 31 Last month
  • Docker Downloads: 1,133
Rankings
Docker downloads count: 1.2%
Dependent repos count: 5.6%
Stargazers count: 6.3%
Forks count: 6.3%
Average: 8.8%
Dependent packages count: 10.0%
Downloads: 23.3%
Maintainers (1)
Last synced: 12 months ago
proxy.golang.org: github.com/brentp/cruzdb
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 9.0%
Average: 9.6%
Dependent repos count: 10.2%
Last synced: 12 months ago