"""Script to make a WCNF file from a dictionary of family scores """ import sys import cPickle from gPy.Structures import ProbADG for f in sys.argv[1:]: print f if f.endswith('.pck'): stem = f[:-4] else: raise ValueError('Expected a pickle file ending in .pck') family_scores = cPickle.load(open(f)) probadg = ProbADG(vertices=family_scores.keys()) probadg.condition_from_dict(cPickle.load(open(f))) cnf_filename = '%s.cnf' % stem probadg.write_cnf(cnf_filename,direct_reversible=False,atomsets=('families','total_order'),scaling=1,comments=True) cPickle.dump(probadg,open('%s_conditioned_probadg.pck' % stem, 'w'))