Skip to main content

silvio is an environment for Simulation of Virtual Organisms. silvio contains several linked microbial models.

Project description

Silvio

https://img.shields.io/pypi/v/silvio.svg Documentation Status

silvio is an environment to combine microbiological models to simulate virtual cells.

Features

  • Simulate different components of a biological host using event-driven messaging.

  • Produce data on procedures performed on the host at the given state.

Writing a Module

Prefer the use of [standardized code style](https://pep8.org/).

Make use of [python type hints](https://docs.python.org/3/library/typing.html) whenever possible. When specifying types for variables and methods, your IDE will help you with organizing the inputs, outputs and arguments that you may use.

# Initial definition of a variable to store a probability
some_probability: float = 0

some_probability = 0.4      # Will work. The variable may receive fractional numbers.
some_probability = 0        # Will work. Integers are also numbers.

some_probability = "a lot"  # Error! The IDE will notify us about this bad assignment.
some_probability = "0.3"    # Error! This is still a string. No more conversion problems.

some_probability = -1.4     # Unfortunately this still works. Typing only defines simple types.

When writing classes, keep all properties (variables inside a class) at the top of the class definition, outside of the constructor. The constructor should only perform the initial assignment.

class BayesianNetworkNode :
    """
    Each class should document what it does. Ideally, it should have a single purpose.
    """

    # Probability that this node is true.
    true_prob: float

    # Probability that the node is false. Should be inverse of true probability.
    false_prob: float


    def __init__ ( self, true_prob: float ) :

        # Notice that constructor arguments may have the same name as properties.
        self.true_prob = true_prob

        # The constructor only uses necessary arguments to initialize all properties.
        self.false_prob = 1 - true_prob

How to name things is a very debated topic in many languages. When in doubt, follow the conventions that have been laid by the [python standard](https://www.python.org/dev/peps/pep-0008/#naming-conventions). Some common examples are.

# Use lower_case with underscores. Prefer distinct names to single letters.
num_strands = 2

# Constants are values embedded into the code. Use UPPER_CASE with underscores.
GOLDEN_RATIO = 1.6180


# Module names use lower_case and avoids underscore when possible.
import biolabsim.sequencing.evaluation


# Custom types use PascalCase.
from typing import Tuple, Literal
GeneBase = Literal['A','T','C','G']


# Functions use lower_case and typically start with a verb.
def complement_base ( base:GeneBase ) -> GeneBase :  # (input) -> output

    # Include most initilization on top of the method.
    orig_bases: List[GeneBase] = ['A','T','C','G']  # Common words may be shortened. orig = original
    comp_bases: List[GeneBase] = ['T','A','G','C']  # But spell it out in comments.  comp = complementary

    # Split your code into blocks of related operations. Provide a small summary of each block.
    # Comments should help outsiders to skim through the code and to explain programming decisions.
    found_orig_index = orig_bases.index(base)  # Avoid one-liners. Variable names provide context.
    return comp_bases[found_orig_index]


# Use simple types to construct more complex ones.
Codon = Tuple[ GeneBase, GeneBase, GeneBase ]


# Classes use PascalCase as well.
class AminoAcid :

    # Class properties use lower_case as well.
    gene_triplet : Codon


    # Constructors initialize the properties.
    def __init__ ( self, base1:GeneBase, base2:GeneBase, base3:GeneBase ) :
        self.gene_triplet = ( base1, base2, base3 )


    # Leave enough space between method definitions.
    def complement_triplet (self) -> Codon :
        return (                                       # Use multiple lines and more spacing if the
            complement_base( self.gene_triplet[0] ),   # code becomes too bulky.
            complement_base( self.gene_triplet[1] ),
            complement_base( self.gene_triplet[2] ),
        )

Generate Sphinx documentation.

Sphinx is not very automatic on how documentation is extracted from the code. We use [sphinx-apidoc](https://www.sphinx-doc.org/en/master/man/sphinx-apidoc.html) to periodically generate the documentation .rst files.

# Assuming you start at the project root directory.

# Enter the documentation directory.
cd docs

# Remove the old API documentation.
rm -ri ./api

# Generate the new reStructuredText files for the API documentation.
sphinx-apidoc --module-first -d 4 -o api ../biolabsim

# Generate the HTML from all documentation files.
make html

Credits

Extensive credits can be found in the author notes.

History

0.1.0 (2021-10-17)

  • First release on PyPI.

0.1.4 (2022-04-07)

  • add catalog with RecExpSim functions in src

0.1.5 (2022-04-07)

  • add __init__.py to catalog folder

0.1.6 (2022-04-07)

  • in RecExperiment: round print failure rate to two decimals

  • in RecExperiment.simulate_growth: separate argument progress bar waiting

0.1.7 (2022-05-03)

  • remove requirement cobra

0.1.8 (2022-05-03)

  • remove cobra code dependencies

0.1.8 (2022-05-03)

  • add cobra code dependencies

  • remove undelete_gene

0.2.0 (2023-03-29)

  • add GroExpSim, a class to simulate growth experiments

0.2.1 (2023-08-20)

  • add storage of simulated data to Data folder

0.2.2 (2023-09-02)

  • GroExpSim with:
    • measure_DryWeight: measure the OD to DW conversion factor

    • measure_TemperatureGrowth: measure the growth curve at different temperatures

    • measure_BiomassSubstrateExp: measure the growth curve and substrate concentrations

    • check_Results: check the results of the parameters

0.2.2 (2023-09-02)

  • GroExpSim, nightshift must be within 15h of experiment

0.2.5 (2024-02-22)

  • GroExpSim, export single growth experiments to existing reference excel sheet

0.2.6 (2024-04-23)

  • RecExpSim, add umax argument to ‘make’ in ‘RecHost’ for new argument demands of function ‘Make_TempGrowthExp’ in ‘extesions/modules/growth_behaviour.py’

0.2.7 (2025-02-12)

  • add FermProSimFun to silvio/src

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

silvio-0.2.7.tar.gz (508.8 kB view details)

Uploaded Source

Built Distribution

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

silvio-0.2.7-py2.py3-none-any.whl (545.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file silvio-0.2.7.tar.gz.

File metadata

  • Download URL: silvio-0.2.7.tar.gz
  • Upload date:
  • Size: 508.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.11.3 pkginfo/1.9.6 requests/2.28.2 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.7.6

File hashes

Hashes for silvio-0.2.7.tar.gz
Algorithm Hash digest
SHA256 3b5c1c0a0439b865993d9ba131302ea054aa9540c399e14ac2cfe33b699d9182
MD5 c01441d3db07fd3b6c6f03ed783398e9
BLAKE2b-256 ec71bbe52233c1c765db415319917d6b1f631fae3e2e6a31eb5c1b8fcf57b9b9

See more details on using hashes here.

File details

Details for the file silvio-0.2.7-py2.py3-none-any.whl.

File metadata

  • Download URL: silvio-0.2.7-py2.py3-none-any.whl
  • Upload date:
  • Size: 545.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.11.3 pkginfo/1.9.6 requests/2.28.2 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.7.6

File hashes

Hashes for silvio-0.2.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 34abb2d1f9ff54d3cfd0981db3efc8aaf47cc680694ebdc500d62b44608f3857
MD5 f9f63cd5f7695785ccdce8468ccc0524
BLAKE2b-256 e127b94d6de8984739570e94fdb6692564d5ae58ee6acd2f5485adc6047017db

See more details on using hashes here.

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