semvec/pypi-packages huggingface dataset:
zmqflp 0.8.3
PyZMQ server/client implementing asyncio freelance protocol based on Min RK's starter code

# zmqflp

Improvements to the Freelance protocol-based zeromq server/client (Python)
The client and server talk using cbor2, so the api accepts dictionaries as input.

## To create a zmqflp server:

```python
# create the server object (it runs in an asyncio zmq context)
self.server = zmqflp_server.ZMQFLPServer(self.config.identity, self.config.zmq_port)

# use the following code to process messages received by the server and send them back
async def process_messages(self):
    (serialized_request, orig_headers) = await self.server.receive()
    if serialized_request == 'EXIT':
        await self.server.send(orig_headers, 'exiting')
        return False
    elif serialized_request != "PING":
        try:
            request = serialized_request
            response = self.process_request(request)
            await self.server.send(orig_headers, response)
            return True
        except Exception as e:
            logging.exception(e)
            return False
    return True
```

## To create a client without using a context manager:

```python
# create the client object (this does NOT run in an asyncio context)
self.client = zmqflp_client.ZMQFLPClient(self.config.list_of_servers)

# to send and receive with the client
msg_to_send = {'message': 'hello!', 'other-key': 'stuff goes here'}
status = self.client.send_and_receive(msg_to_send)
```

## To create a client using a context manager (for example, to run on AWS Lambda):

```python
# create the client object (this does NOT run in an asyncio context)
with zmqflp_client.ZMQFLPClient(self.config.list_of_servers) as client:
    # to send and receive with the client
    msg_to_send = {'message': 'hello!', 'other-key': 'stuff goes here'}
    status = client.send_and_receive(msg_to_send)
```
library-simulator 0.1
Python software package for simulating random mutagenesis experiments

=================
Library Simulator
=================

Library simulator is a python package for generating random mutagenesis
libraries given a nucleotide sequence and error-prone polymerase. 

Examples
========

Create a library
----------------

.. code:: python

    from library_simulator import LibrarySimulator
    lib = LibrarySimulator("example.fasta",mutation_spectrum="published")
    lib.simulate(num_samples=10,mutation_rate=2)
    lib.clones

.. image:: example/output-table.png

- **aa**: amino acid changes (:code:`*`: new stop codon)
- **base**: base changes (:code:`-` and :code:`+` are insertions and deletions)
- **num**: total number of amino acid changes (could be a huge number if there is
  an early stop or indel)
- **indel**: whether or not there is an indel
- **stop**: whether or not there is new stop codon
- **start**: whether or not the real start codon was messed up

Find the frequencies of classes of mutants versus mutation rate
---------------------------------------------------------------

.. code:: python

    from library_simulator import LibrarySimulator, util
    lib = LibrarySimulator("example.fasta",mutation_spectrum="published")
    f_v_r = util.freq_vs_mutation_rate(lib,num_samples=10000)
    util.plot_freq_vs_mutation_rate(f_v_r)

.. image:: example/mutation-rate.png

See :code:`example/examples.ipynb` for more functionality.

Installation
============

.. code:: python

    pip install library_simulator


Assumptions
===========

- The number of mutations per clone is determined by a Poisson process.
- The sites mutated are independent within a clone and between clones
- The probability of each possible mutation (A->T, G->C, etc.) is determined
  by the enzyme, not the sequence.  The profiles for different enzymes
  are found in: :code:`library_simulator/mutation_spectra`