Skip to main content

A simple library for executing BLAST searches with ncbi-blast+

Project description

multiset-key-dict

This small library implements a mapping-like object whose keys are taken to be unordered multisets (Counters, bags), regardless of the type of the actual indexes used.

Example

Create a MultisetKeyDict and insert an element for the set {1, 3, 5}.

from multiset_key_dict import MultisetKeyDict
mskd = MultisetKeyDict()
mskd[[1, 3, 5]] = 19

Access the element just added.

# In a different order.
print(mskd[[3, 5, 1]]) # 19
# With a different type of collection.
print(mskd[{3, 5, 1}]) # 19

__iter__ iterates over items in the MultisetKeyDict, viewed as frozensets (i.e., not accounting for multiplicity).

# Add more data.
mskd[[1]] = 9
mskd[[5, 6]] = 12
print(list(mskd)) # [(frozenset({1, 3, 5}), 19), (frozenset({1}), 9), (frozenset({5, 6}), 12)]

To iterate over key-value pairs where the keys are the FrozenMultiset objects that act as the true keys in the structure, use multiset_iter or items methods instead.

msked[[1, 1]] = 90
print(list(mskd))
# [(frozenset({1, 3, 5}), 19), (frozenset({1}), 9), (frozenset({5, 6}), 12),
# (frozenset({1}), 90)]

print(list(mskd.multiset_iter()))
# [(FrozenMultiset({(3, 1), (1, 1), (5, 1)}), 19), 
#  (FrozenMultiset({(1, 1)}), 9),
#  (FrozenMultiset({(6, 1), (5, 1)}), 12),
#  (FrozenMultiset({(1, 2)}), 90)]

To get the keys as frozenset objects, use set_keys. To get the keys as FrozenMultiset objects, use multiset_keys or keys.

It's sometimes useful to get the set of elements of the keys. For that, you can use the key_elements method.

print(mskd.key_elements()) # frozenset({1, 3, 5, 6})

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multiset_key_dict-0.1.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

multiset_key_dict-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file multiset_key_dict-0.1.0.tar.gz.

File metadata

  • Download URL: multiset_key_dict-0.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for multiset_key_dict-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5496624d65c326718f6b2b452be17f5e42ac8375b731cdeef35ad2b6b1bcf611
MD5 866f5d3de90ba0029c54768f5060ab98
BLAKE2b-256 2aeedd67884c8f8e4a8d7c5c9f587f8acef9a80429fcba2b6c26ad85af04f15f

See more details on using hashes here.

Provenance

The following attestation bundles were made for multiset_key_dict-0.1.0.tar.gz:

Publisher: package.yml on actapia/multiset-key-dict

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file multiset_key_dict-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for multiset_key_dict-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1468743b53ca09e8d56e8687e2a662248fa9386b088efb0ce3cfb95de283f9e5
MD5 7226dd2b5dda04d767c8907dfb5bd347
BLAKE2b-256 1bf06c8aeddd796d554f87f98f7653e1f7a561402a941dcf41bcd628d127c99f

See more details on using hashes here.

Provenance

The following attestation bundles were made for multiset_key_dict-0.1.0-py3-none-any.whl:

Publisher: package.yml on actapia/multiset-key-dict

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page