Skip to content

Instantly share code, notes, and snippets.

@armanbilge
Created September 6, 2015 11:08
Show Gist options
  • Save armanbilge/12ef3cfeb7ed5a3ffe05 to your computer and use it in GitHub Desktop.
Save armanbilge/12ef3cfeb7ed5a3ffe05 to your computer and use it in GitHub Desktop.
import sys
import itertools as it
from collections import Counter
fn = sys.argv[1]
with open(fn) as f:
N = sum(1 for _ in f)
counts = {}
for i in range(N):
with open(fn) as f:
for _ in range(i):
next(f)
_, A, T, G, C, x = next(f).strip().split(',')
for j in range(i+1, N):
_, _, _, _, _, y = next(f).strip().split(',')
counter = Counter(zip(x,y))
counter[('A', 'A')] += int(A)
counter[('T', 'T')] += int(T)
counter[('G', 'G')] += int(G)
counter[('C', 'C')] += int(C)
counts[(i,j)] = counter
print("Finished processing", i, j)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment