Skip to content

Instantly share code, notes, and snippets.

View ctb's full-sized avatar

C. Titus Brown ctb

View GitHub Profile
@ctb
ctb / prefetch-gather.py
Created November 2, 2020 03:05
a simple prefetch script that searches large sourmash databases for all possible matches, and then saves them
#! /usr/bin/env python
import sys
import argparse
import copy
import sourmash
from sourmash import sourmash_args
from sourmash.logging import notify, error
import numpy
# works fine
numpy.array([5, 6, 7, 8], dtype=numpy.uint64)
# fails
numpy.array(set([5, 6, 7, 8]), dtype=numpy.uint64)
# in a Jupyter notebook, after %pylab inline
# so - not a Python bug, but a pylab/numpy thing
c = collections.Counter()
c['a'] = 5
c['b'] = 3
print('XXX:', sum(c.values()))
print('YYY:', sum([ x for x in c.values() ]))
# gives:
import sys
import sourmash
sbt = sourmash.load_sbt_index(sys.argv[1])
print(next(iter(sbt.leaves())))
@ctb
ctb / Snakefile
Last active February 1, 2020 17:26
Testing out some snakemake namespace stuff.
global_var = 'a global variable'
rule all:
input:
"1-foo-hello.txt",
"2-bar-hello.txt",
"3-fiz-hello.txt",
"4-bif-hello.txt"
#

I spent Tues and Wed over by the Hermitage (downtown St Petersburg) being a tourist. A couple of suggestions for those of you who are here for a few more days and want to do the big tourism spots —

a good itinerary involving the below is,

  • hermitage early in the day, before it gets busy
  • late lunch at the blini place
  • boat trip

Everything below involves a total of about 45 minutes of walking, if you start at the hermitage.

I spent Tues and Wed over by the Hermitage (downtown St Petersburg) being a tourist. A couple of suggestions for those of you who are here for a few more days and want to do the big tourism spots —
a good itinerary involving the below is,
* hermitage early in the day, before it gets busy
* late lunch at the blini place
* boat trip
Everything below involves a total of about 45 minutes of walking, if you start at the hermitage.
#! /usr/bin/env python
"""
Usage:
python -m screed db <sequencefile>
python extract-screed.py <list of names> <sequencefile>
"""
import argparse, screed, sys
def main():
@ctb
ctb / README.md
Last active April 10, 2020 21:01

Implement contig contamination analysis as in (blog post)

@ctb
ctb / .gitignore
Last active September 3, 2017 16:13
*~
*.pyc
.sbt.delmont31/
.sbt.subs1/
.sbt.subs2/
.sbt.tully31/
delmont-genome-sigs.tar.gz
delmont-genome-sigs/
delmont31.sbt.json
subs1.sbt.json