예제 #1
0
def test_add_dummy():
    A = mw.Apparatus()
    dummy = mw.Dummy(name="dummy")
    A.add(dummy, mw.Vessel(), tube)
    P = mw.Protocol(A)
    with pytest.raises(ValueError):
        P.add(dummy, active=1)  # should be a bool!
예제 #2
0
def test_add_valve():
    A = mw.Apparatus()
    valve = mw.Valve(mapping={pump1: 1, pump2: 2})
    bad_valve = mw.Valve()
    A.add([pump1, pump2], [valve, bad_valve], tube)
    P = mw.Protocol(A)

    expected = [
        dict(start=0, stop=None, component=valve, params={"setting": 1})
    ]

    # directly pass the pump object
    P.add(valve, setting=pump1)
    assert P.procedures == expected
    P.procedures = []

    # using its name
    P.add(valve, setting="pump1")
    assert P.procedures == expected
    P.procedures = []

    # using its port number
    P.add(valve, setting=1)
    assert P.procedures == expected

    with pytest.raises(ValueError):
        P.add(valve, setting=3)

    with pytest.raises(ValueError):
        P.add(bad_valve, setting=3)
예제 #3
0
def test_describe():
    C = mw.Apparatus()
    C.add(mw.Vessel("water"), b, t)
    assert (
        C.describe() ==
        "A vessel containing water was connected to Component Component_1 using PVC tubing (length 1 foot, ID 1 inch, OD 2 inch). "
    )
예제 #4
0
import json
from datetime import timedelta

import pytest
import yaml

import mechwolf as mw

A = mw.Apparatus()
pump1 = mw.Pump(name="pump1")
pump2 = mw.Pump(name="pump2")
tube = mw.Tube(length="1 foot", ID="1 in", OD="2 in", material="PVC")
A.add(pump1, pump2, tube)


def test_create_protocol():
    # test naming
    assert mw.Protocol(A, name="testing").name == "testing"
    assert mw.Protocol(A).name == "Protocol_0"
    assert mw.Protocol(A).name == "Protocol_1"


def test_add():
    P = mw.Protocol(A)

    procedure = {
        "component": pump1,
        "params": {
            "rate": "10 mL/min"
        },
        "start": 0,
예제 #5
0
def create_apparatus(
    valve1: mw.Valve = mw.Valve(),
    valve2: mw.Valve = mw.Valve(),
    valve3: mw.Valve = mw.Valve(),
    pump1: mw.Pump = mw.Pump(),
    pump2: mw.Pump = mw.Pump(),
    pump3: mw.Pump = mw.Pump(),
) -> mw.Apparatus:

    aa_vessels = {
        "ala": mw.Vessel(name="FmocAla"),
        "arg": mw.Vessel(name="FmocArg_Pbf"),
        "asn": mw.Vessel(name="FmocAsn_Trt"),
        "asp": mw.Vessel(name="FmocAsp_tBu"),
        "cys": mw.Vessel(name="FmocCys_Trt"),
        "gln": mw.Vessel(name="FmocGln_Trt"),
        "glu": mw.Vessel(name="FmocGlu_tBu"),
        "gly": mw.Vessel(name="FmocGly"),
        "his": mw.Vessel(name="FmocHis_Trt"),
        "ile": mw.Vessel(name="FmocIle"),
        "leu": mw.Vessel(name="FmocLeu"),
        "lys": mw.Vessel(name="FmocLys_Boc"),
        "met": mw.Vessel(name="FmocMet"),
        "phe": mw.Vessel(name="FmocPhe"),
        "pro": mw.Vessel(name="FmocPro"),
        "ser": mw.Vessel(name="FmocSer_tBu"),
        "thr": mw.Vessel(name="FmocThr_tBu"),
        "trp": mw.Vessel(name="FmocTrp_Boc"),
        "tyr": mw.Vessel(name="FmocTyr_tBu"),
        "val": mw.Vessel(name="FmocVal"),
    }

    # other vessels
    solvent = mw.Vessel("Solvent", name="solvent")
    deprotection = mw.Vessel("20% Piperdine", name="deprotection")
    coupling_agent = mw.Vessel("HATU", name="coupling_agent")
    coupling_base = mw.Vessel("NMM", name="coupling_base")
    output = mw.Vessel("waste", name="output")

    valve1.mapping = {
        aa_vessels["ala"]: 1,
        aa_vessels["cys"]: 2,
        aa_vessels["asp"]: 3,
        aa_vessels["glu"]: 4,
        aa_vessels["phe"]: 5,
        aa_vessels["gly"]: 6,
        aa_vessels["his"]: 7,
        coupling_agent: 8,
        coupling_base: 9,
        solvent: 10,
    }
    valve2.mapping = {
        aa_vessels["leu"]: 1,
        aa_vessels["met"]: 2,
        aa_vessels["asn"]: 3,
        aa_vessels["pro"]: 4,
        aa_vessels["gln"]: 5,
        aa_vessels["arg"]: 6,
        aa_vessels["ser"]: 7,
        coupling_agent: 8,
        coupling_base: 9,
        solvent: 10,
    }
    valve3.mapping = {
        aa_vessels["thr"]: 1,
        aa_vessels["trp"]: 2,
        aa_vessels["ile"]: 3,
        aa_vessels["lys"]: 4,
        aa_vessels["tyr"]: 5,
        aa_vessels["val"]: 6,
        deprotection: 7,
        coupling_agent: 8,
        coupling_base: 9,
        solvent: 10,
    }

    # tubes and mixer
    fat_short_tube = mw.Tube(length="1 foot", ID="1/16 in", OD="1/8 in", material="PFA")
    thin_short_tube = mw.Tube(length="1 ft", ID="0.04 in", OD="1/16 in", material="PFA")
    thin_rxn_tube = mw.Tube(length="50 ft", ID="0.04 in", OD="1/16 in", material="PFA")

    mixer = mw.CrossMixer(name="Cross mixer")

    # define apparatus
    A = mw.Apparatus("Generic peptide synthesizer")

    A.add(valve1.mapping, valve1, fat_short_tube)
    A.add(valve1, pump1, fat_short_tube)
    A.add(pump1, mixer, thin_short_tube)

    A.add(valve2.mapping, valve2, fat_short_tube)
    A.add(valve2, pump2, fat_short_tube)
    A.add(pump2, mixer, thin_short_tube)

    A.add(valve3.mapping, valve3, fat_short_tube)
    A.add(valve3, pump3, fat_short_tube)
    A.add(pump3, mixer, thin_short_tube)

    A.add(mixer, output, thin_rxn_tube)

    A._validate()  # just an extra safety check (ya never know)

    return A
예제 #6
0
def test_add_multiple():
    # multiple components connected to same component in one line
    B = mw.Apparatus()
    B.add([a, b, c], d, t)
    assert B.network == [(a, d, t), (b, d, t), (c, d, t)]