From 95527c3b3930fb683d58e9ba4e73e6af91acdd8b Mon Sep 17 00:00:00 2001 From: "C. Titus Brown" Date: Thu, 19 Jan 2017 20:26:54 -0800 Subject: [PATCH] mash JSON to sourmash --- utils/mash-to-sourmash-sig.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 utils/mash-to-sourmash-sig.py diff --git a/utils/mash-to-sourmash-sig.py b/utils/mash-to-sourmash-sig.py new file mode 100755 index 0000000000..7df27d40ce --- /dev/null +++ b/utils/mash-to-sourmash-sig.py @@ -0,0 +1,27 @@ +#! /usr/bin/env python +import sys +import json +import sourmash_lib, sourmash_lib.signature + +x = json.loads(open(sys.argv[1]).read()) +ksize = x['kmer'] +num = x['sketchSize'] + +assert x['hashType'] == "MurmurHash3_x64_128" +assert x['hashBits'] == 64 +assert x['hashSeed'] == 42 + +xx = x['sketches'][0] +hashes = xx['hashes'] + +# assert stuff HERE + + +E = sourmash_lib.Estimators(ksize=ksize, n=num, is_protein=False) +mh = E.mh +for h in hashes: + mh.add_hash(h) + +s = sourmash_lib.signature.SourmashSignature('', E, name=sys.argv[1]) +print(sourmash_lib.signature.save_signatures([s])) +