Skip to content

Instantly share code, notes, and snippets.

@brainstorm
Created February 15, 2012 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brainstorm/1836676 to your computer and use it in GitHub Desktop.
Save brainstorm/1836676 to your computer and use it in GitHub Desktop.
Try to recover illumina dataset with missing .filter files
#!/bin/env python
import os
import logging
import glob
import random
from collections import *
fters = defaultdict(set)
all = set(["%04d.filter" % x for x in range(1, 70)])
for dotfilter in glob.glob("*.filter"):
(_, lane, tile) = dotfilter.split("_")
fters[lane].add(tile)
# symlink all missing filters to previous .filter files
for lane in fters:
miss_fters = all.difference(fters[lane])
# take an existing .filter from the set...
src = random.sample(fters[lane],1)
for dst in miss_fters:
# ... and symlink the missing ones against it
print "creating symlink from %s to %s" % ("s_%s_%s" % (lane,src[0]), "s_%s_%s" % (lane,dst))
os.symlink("s_%s_%s" % (lane,src[0]), "s_%s_%s" % (lane,dst))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment