kripodb.makebits

Module to read/write fingerprints in Makebits file format

kripodb.makebits.iter_file(infile)[source]

Reads Makebits formatted file Yields header first then tuples of identifier and BitMap object

Yields:first header (format name, format version, number of bits, description), then tuples of the fingerprint identifier and an BitMap object
Parameters:infile (File) – File object of Makebits formatted file to read

Examples

Read a file

>>> f = iter_file(open('fingerprints01.fp'))
>>> read_fp_size(next(f))
4
>>> {frag_id: fp for frag_id, fp in f}
{'id1': BitMap([1, 2, 3, 4])}
kripodb.makebits.write_file(fp_size, bitsets, fn)[source]

Write makebits formatted file

Parameters:
  • fp_size (int) – Number of bits
  • bitsets (dict) – Dict with fingerprint identifier as key and BitMap object as value
  • fn (File) – File object to write to

Examples

Write a file

>>> write_file(4, {'id1': BitMap([1, 2, 3, 4])}, open('fingerprints01.fp', 'w'))