#!/usr/bin/env python
from __future__ import print_function
from collections import Counter
import screed
import json
import sys
from os import path
try:
    from itertools import zip
except ImportError:
    pass



def assess_file(filename):
    fq = screed.open(filename)

    ctr = Counter()
    for read_pair in zip(fq, fq):
        r1, r2 = read_pair

        data = json.loads(r1.name.split('\t')[1])
        ctr[data['id']] += 1
    return ctr

if __name__ == "__main__":
    for fn in sys.argv[1:]:
        ctr = assess_file(fn)
        samp = path.basename(fn).strip().strip('_').split('_')[0]
        good = bad = 0
        for k, v in ctr.most_common():
            #print(samp, k, v, sep='\t')
            if k == samp:
                good += v
            else:
                bad += v
        print(samp, good, bad, sep='\t')

@@ -472,16 +472,31 @@
 ain__%22:%0A
+    table = %7B%7D%0A
     for 
@@ -519,38 +519,8 @@
 :%5D:%0A
-        ctr = assess_file(fn)%0A
     
@@ -593,127 +593,148 @@
     
-good = bad = 0%0A        for k, v in ctr.most_common():%0A        
+ctr = assess_file(fn)%0A        table%5Bsamp%5D = ctr%0A%0A    samples = list(table.keys())%0A%0A
     
-#
 print(
-samp, k, v, sep='%5Ct')%0A            if k ==
+'%5Ct' + '%5Ct'.join(samples))%0A    for r in
  samp
+les
 :%0A  
@@ -743,106 +743,117 @@
     
-        good += v%0A            else:%0A                bad += v%0A        print(samp, good, bad, sep='%5Ct'
+print(r, end='')%0A        for c in samples:%0A            print('%5Ct%7B%7D'.format(table%5Br%5D%5Bc%5D), end='')%0A        print(
 )%0A

Make table of assignments