pybedtools


Namepybedtools JSON
Version 0.10.0 PyPI version JSON
download
home_pagehttps://github.com/daler/pybedtools
SummaryWrapper around BEDTools for bioinformatics work
upload_time2024-04-09 22:45:45
maintainerRyan Dale
docs_urlhttps://pythonhosted.org/pybedtools/
authorNone
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
Overview
--------

.. image:: https://travis-ci.org/daler/pybedtools.png?branch=master
    :target: https://travis-ci.org/daler/pybedtools

.. image:: https://badge.fury.io/py/pybedtools.svg?style=flat
    :target: http://badge.fury.io/py/pybedtools

.. image:: https://img.shields.io/badge/install%20with-bioconda-brightgreen.svg
    :target: http://bioconda.github.io

The `BEDTools suite of programs <http://bedtools.readthedocs.org/>`_ is widely
used for genomic interval manipulation or "genome algebra".  `pybedtools` wraps
and extends BEDTools and offers feature-level manipulations from within
Python.

See full online documentation, including installation instructions, at
http://daler.github.io/pybedtools/.

Why `pybedtools`?
-----------------

Here is an example to get the names of genes that are <5 kb away from
intergenic SNPs:

.. code-block:: python

    from pybedtools import BedTool

    snps = BedTool('snps.bed.gz')  # [1]
    genes = BedTool('hg19.gff')    # [1]

    intergenic_snps = snps.subtract(genes)                       # [2]
    nearby = genes.closest(intergenic_snps, d=True, stream=True) # [2, 3]

    for gene in nearby:             # [4]
        if int(gene[-1]) < 5000:    # [4]
            print gene.name         # [4]

Useful features shown here include:

* `[1]` support for all BEDTools-supported formats (here gzipped BED and GFF)
* `[2]` wrapping of all BEDTools programs and arguments (here, `subtract` and `closest` and passing
  the `-d` flag to `closest`);
* `[3]` streaming results (like Unix pipes, here specified by `stream=True`)
* `[4]` iterating over results while accessing feature data by index or by attribute
  access (here `[-1]` and `.name`).

In contrast, here is the same analysis using shell scripting.  Note that this
requires knowledge in Perl, bash, and awk.  The run time is identical to the
`pybedtools` version above:

.. code-block:: bash

    snps=snps.bed.gz
    genes=hg19.gff
    intergenic_snps=/tmp/intergenic_snps

    snp_fields=`zcat $snps | awk '(NR == 2){print NF; exit;}'`
    gene_fields=9
    distance_field=$(($gene_fields + $snp_fields + 1))

    intersectBed -a $snps -b $genes -v > $intergenic_snps

    closestBed -a $genes -b $intergenic_snps -d \
    | awk '($'$distance_field' < 5000){print $9;}' \
    | perl -ne 'm/[ID|Name|gene_id]=(.*?);/; print "$1\n"'

    rm $intergenic_snps

See the `Shell script comparison <http://daler.github.io/pybedtools/sh-comparison.html>`_ in the docs
for more details on this comparison, or keep reading the full documentation at
http://daler.github.io/pybedtools.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/daler/pybedtools",
    "name": "pybedtools",
    "maintainer": "Ryan Dale",
    "docs_url": "https://pythonhosted.org/pybedtools/",
    "requires_python": null,
    "maintainer_email": "ryan.dale@nih.gov",
    "keywords": null,
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/cc/90/cea4197772a029e925bd5d414108b5438d621dfbb1b0cc2627529d1ec524/pybedtools-0.10.0.tar.gz",
    "platform": null,
    "description": "\nOverview\n--------\n\n.. image:: https://travis-ci.org/daler/pybedtools.png?branch=master\n    :target: https://travis-ci.org/daler/pybedtools\n\n.. image:: https://badge.fury.io/py/pybedtools.svg?style=flat\n    :target: http://badge.fury.io/py/pybedtools\n\n.. image:: https://img.shields.io/badge/install%20with-bioconda-brightgreen.svg\n    :target: http://bioconda.github.io\n\nThe `BEDTools suite of programs <http://bedtools.readthedocs.org/>`_ is widely\nused for genomic interval manipulation or \"genome algebra\".  `pybedtools` wraps\nand extends BEDTools and offers feature-level manipulations from within\nPython.\n\nSee full online documentation, including installation instructions, at\nhttp://daler.github.io/pybedtools/.\n\nWhy `pybedtools`?\n-----------------\n\nHere is an example to get the names of genes that are <5 kb away from\nintergenic SNPs:\n\n.. code-block:: python\n\n    from pybedtools import BedTool\n\n    snps = BedTool('snps.bed.gz')  # [1]\n    genes = BedTool('hg19.gff')    # [1]\n\n    intergenic_snps = snps.subtract(genes)                       # [2]\n    nearby = genes.closest(intergenic_snps, d=True, stream=True) # [2, 3]\n\n    for gene in nearby:             # [4]\n        if int(gene[-1]) < 5000:    # [4]\n            print gene.name         # [4]\n\nUseful features shown here include:\n\n* `[1]` support for all BEDTools-supported formats (here gzipped BED and GFF)\n* `[2]` wrapping of all BEDTools programs and arguments (here, `subtract` and `closest` and passing\n  the `-d` flag to `closest`);\n* `[3]` streaming results (like Unix pipes, here specified by `stream=True`)\n* `[4]` iterating over results while accessing feature data by index or by attribute\n  access (here `[-1]` and `.name`).\n\nIn contrast, here is the same analysis using shell scripting.  Note that this\nrequires knowledge in Perl, bash, and awk.  The run time is identical to the\n`pybedtools` version above:\n\n.. code-block:: bash\n\n    snps=snps.bed.gz\n    genes=hg19.gff\n    intergenic_snps=/tmp/intergenic_snps\n\n    snp_fields=`zcat $snps | awk '(NR == 2){print NF; exit;}'`\n    gene_fields=9\n    distance_field=$(($gene_fields + $snp_fields + 1))\n\n    intersectBed -a $snps -b $genes -v > $intergenic_snps\n\n    closestBed -a $genes -b $intergenic_snps -d \\\n    | awk '($'$distance_field' < 5000){print $9;}' \\\n    | perl -ne 'm/[ID|Name|gene_id]=(.*?);/; print \"$1\\n\"'\n\n    rm $intergenic_snps\n\nSee the `Shell script comparison <http://daler.github.io/pybedtools/sh-comparison.html>`_ in the docs\nfor more details on this comparison, or keep reading the full documentation at\nhttp://daler.github.io/pybedtools.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Wrapper around BEDTools for bioinformatics work",
    "version": "0.10.0",
    "project_urls": {
        "Homepage": "https://github.com/daler/pybedtools"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cc90cea4197772a029e925bd5d414108b5438d621dfbb1b0cc2627529d1ec524",
                "md5": "f9718c9ac32bc8c1748e1f67c4950478",
                "sha256": "1a6fbaad23b013becc741d7d5922a2df03e391bc44ff92772ffb7dd456711161"
            },
            "downloads": -1,
            "filename": "pybedtools-0.10.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f9718c9ac32bc8c1748e1f67c4950478",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12605040,
            "upload_time": "2024-04-09T22:45:45",
            "upload_time_iso_8601": "2024-04-09T22:45:45.341705Z",
            "url": "https://files.pythonhosted.org/packages/cc/90/cea4197772a029e925bd5d414108b5438d621dfbb1b0cc2627529d1ec524/pybedtools-0.10.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-09 22:45:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "daler",
    "github_project": "pybedtools",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pybedtools"
}
        
Elapsed time: 0.87214s