This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import logging | |
from collections import Counter | |
import gffutils | |
from gffutils.create import logger | |
logger.setLevel(logging.INFO) | |
usage = """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Illustrates how to use pybedtools to count motifs along sliding windows | |
of UTRs from a GFF file. | |
This uses example data shipped with pybedtools. | |
""" | |
import pybedtools | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for pybedtools issue #99 | |
import pybedtools | |
# make a demo list of chrom:start-stop strings from example data shipped with | |
# pybedtools | |
n_intervals = 20000 | |
loc_list = [] | |
for i, feature in enumerate(pybedtools.example_bedtool('x.bed')): | |
if i >= n_intervals: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Demo pathfinding, with obstacles | |
""" | |
from matplotlib import pyplot as plt | |
import networkx as nx | |
GRID_SIZE = [100, 100] | |
G = nx.grid_graph(dim=GRID_SIZE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Demonstration of getting the coding sequence for each alterative isoform of | |
each gene in a GFF file. | |
Uses pybedtools.BedTool.seq to extract sequences from a FASTA file. | |
""" | |
import gffutils | |
import pybedtools | |
from gffutils.helpers import asinterval |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gffutils | |
# Import the GTF file into a sqlite3 database. | |
# This only ever has to be done once. | |
db = gffutils.create_db("example.gtf", dbfn='example.gtf.db') | |
# In other scripts, you can connect to the database like this: | |
db = gffutils.FeatureDB('example.gtf.db') | |
# Note that gene and transcript have been inferred |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# Defaults ------------------------------------------------------ | |
MINICONDA_DIR="${HOME}/miniconda" | |
INSTALL_DIR="$(pwd)/tools" | |
TO_INSTALL="bedtools,samtools,tabix,bigWigSummary" | |
INSTALL_MINICONDA=1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import os | |
import errno | |
import argparse | |
import logging | |
from urllib2 import urlopen | |
from urllib2 import Request | |
from socket import error as SocketError |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import platform | |
import argparse | |
import ftplib | |
import time | |
import netrc | |
from fnmatch import fnmatch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pybedtools | |
import pandas | |
def split_coverage(x): | |
""" | |
Split a coverage file created using bedtools coverage -hist -- which will | |
have trailing "all" hist lines -- into 1) a BedTool object with valid BED | |
lines and 2) a pandas DataFrame of all coverage, parsed from the trailing | |
"all" lines. |