Skip to content

Instantly share code, notes, and snippets.

View astewart-twist's full-sized avatar

Andrew Stewart astewart-twist

View GitHub Profile
@vhoulbreque
vhoulbreque / nteract-tricks.md
Last active March 30, 2021 14:44
Make conda environments visible in nteract

Nteract tricks

To add a conda environment to the list of environments:

$ source activate thisenv
(thisenv) $ pip install ipykernel
(thisenv) $ python -m ipykernel install --user --name thisenv
@marcelm
marcelm / mismatches.py
Created September 16, 2015 09:06
Use pysam and pyfaidx to find mismatches in an interval
from pysam import AlignmentFile
from pyfaidx import Fasta
def has_mismatch_in_interval(reference, bamfile, chrom, start, end):
"""
Return whether there is a mismatch in the interval (start, end) in any read mapping to the given chromosome.
reference -- a pyfaidx.Fasta object or something that behaves similarly
"""
for column in bamfile.pileup(chrom, start, end):
@TomAugspurger
TomAugspurger / to_redshift.py
Last active September 16, 2021 16:55
to_redshift.py
# see also https://github.com/wrobstory/pgshift
import gzip
from io import StringIO, BytesIO
from functools import wraps
import boto
from sqlalchemy import MetaData
from pandas import DataFrame
from pandas.io.sql import SQLTable, pandasSQL_builder