@@ -0,0 +1,1547 @@
+import sys%0Aimport datetime%0Aimport hashlib%0Aimport re%0A%0Afsalt = 'salt.txt'%0Afs = open(fsalt, 'r')%0Asalt = fs.readline().rstrip('%5Cn')%0Afs.close%0A%0Adef anon(anything):%0A    return hashlib.sha256(anything+salt).hexdigest()%5B-12:%5D%0A%0A#this is working with cleartext ids%0Awith open('cogs.txt') as f:%0A    chains = f.read().splitlines()%0A%0Acoc = %7B%7D%0Afor i in xrange(len(chains)):%0A#for i in range(1, 100):%0A    #if i %3E 10:%0A    #    print chains%5Bi%5D%0A    chain_list = %5B%5D%0A    while len(chains%5Bi%5D) %3E 0:%0A        chain_list.append(chains%5Bi%5D%5B-6:%5D)%0A        chains%5Bi%5D = chains%5Bi%5D%5B:-6%5D%0A    #if i %3E 10:%0A    #    print chain_list%0A    #print chain_list%0A    try:%0A        coc%5Bchain_list%5B0%5D%5D = chain_list #some lines are blank?%0A    except:%0A        #print chain_list%0A        continue%0A%0Aprint 'length of coc dictionary', len(coc)%0A%0Afo = open('t_pairs_coc_dist_mar.txt', 'w+')%0Afa = open('t_pairs_coc_dist_anon_mar.txt', 'w+')%0A%0Awith open('t_pairs_clear.mar') as f:%0A    pairs = f.read().splitlines()%0A%0Afor i in xrange(len(pairs)):%0A#for i in range(0,100):%0A    peep1, peep2, count = pairs%5Bi%5D.split('%7C')%0A    chain1 = coc%5Bpeep1%5D%0A    chain2 = coc%5Bpeep2%5D%0A    try:%0A        match_peeps = %5Bval for val in chain1 if val in chain2%5D%5B0%5D%0A        distance = chain1.index(match_peeps) + chain2.index(match_peeps)%0A    except:%0A        #print chain1, ' ', chain2%0A        distance = len(chain1) + len(chain2)%0A    %0A    fo.write(peep1 + '%7C' + peep2 + '%7C' + str(distance) + '%7C' + str(count) + '%5Cn')%0A    fa.write(anon(peep1) + '%7C' + anon(peep2) + '%7C' + str(distance) + '%7C' + str(count) + '%5Cn')%0A    %0Afo.close()%0Afa.close()%0A

Create chain_calc.py