def test_autoselect_connectors():
    data_root = flametree.file_tree(".").tests.data.select_connectors
    parts = [
        dc.load_record(f._path, topology="circular", id=f._name_no_extension)
        for f in data_root.parts_missing_connectors._all_files
        if f._extension == "gb"
    ]
    connectors = [
        dc.load_record(f._path, topology="circular", id=f._name_no_extension)
        for f in data_root.connectors._all_files if f._extension == "gb"
    ]
    mix = dc.RestrictionLigationMix(parts, enzyme="BsmBI")
    selected_connectors = mix.autoselect_connectors(connectors)
    assert sorted([c.id for c in selected_connectors]) == sorted([
        "conn J-K",
        "conn L-N",
        "conn R-W",
        "conn W-Z",
        "conn_a_b",
        "conn D-F",
    ])
import flametree  # for getting/writing files and folders
from dnacauldron import RestrictionLigationMix, load_record, write_record

root = flametree.file_tree(".")
parts = [
    load_record(f._path, topology="circular")
    for f in root.data.assemblies._all_files
]
mix = RestrictionLigationMix(parts, enzyme="BsmBI")
assemblies_records = mix.compute_circular_assemblies()
output_folder = root._dir("output_data")._dir("combinatorial_assemblies")
for i, record in enumerate(assemblies_records):
    output = output_folder._file("assembly_%03d.gb" % i)
    write_record(record, output, "genbank")
print(
    "%d combinatorial assembly genbanks written in output_data/assemblies"
    % (i + 1)
)
Example #3
0
import flametree  # for getting/writing files and folders
from Bio import SeqIO  # for exporting to Genbank
from dnacauldron import full_assembly_report, load_record
root = flametree.file_tree(".")
parts = [
    load_record(f._path, linear=False, id=f._name_no_extension)
    for f in root.data.assemblies._all_files
]
target = root._dir('output_data')._dir('report')._path
full_assembly_report(parts,
                     target=target,
                     enzyme="BsmBI",
                     max_assemblies=40,
                     fragments_filters='auto',
                     assemblies_prefix='asm')
print("Your report is ready at 'output_data/report/'")
Example #4
0
import flametree # for getting/writing files and folders
from dnacauldron import RestrictionLigationMix, load_record, write_record

root = flametree.file_tree('.')
parts = [
    load_record(f._path, linear=False)
    for f in root.data.assemblies._all_files
]
mix = RestrictionLigationMix(parts, enzyme='BsmBI')
assemblies_records = mix.compute_circular_assemblies()
output_folder = root._dir('output_data')._dir('combinatorial_assemblies')
for i, record in enumerate(assemblies_records):
    output = output_folder._file("assembly_%03d.gb" % i)
    write_record(record, output, "genbank")
print ("%d combinatorial assembly genbanks written in output_data/assemblies"
       % (i + 1))
import dnacauldron as dc
import os

parts_dir = os.path.join("data", "assemblies")
records_dict = {
    filename.split('.')[0]: dc.load_record(
        os.path.join(parts_dir, filename),
        topology="circular",
        id=filename.split('.')[0],
    )
    for filename in os.listdir(parts_dir)
}

constructs = {
    "C1": ["receptor", "partA", "partB", "partC"],
    "C2": ["receptor", "partA2", "partB2", "partC"],
    "C3": ["receptor", "partA", "partA2", "partB", "partC"],
}
part_names = set([p for parts in constructs.values() for p in parts])
parts = {name: records_dict[name] for name in part_names}
plan = [
    (construct, [parts[p] for p in construct_parts])
    for construct, construct_parts in constructs.items()
]
dc.full_assembly_plan_report(
    plan,
    target=os.path.join("output_data", "report.zip"),
    enzyme="autoselect",
    assert_single_assemblies=False,
    fail_silently=True,
)
import os
import pytest
import matplotlib

matplotlib.use("Agg")
import dnacauldron as dc
import flametree

records_dict = {
    name: dc.load_record(
        os.path.join("tests", "data", "assemblies", name + ".gb"),
        id=name,
        topology="circular",
    )
    for name in (
        "partA",
        "partA2",
        "partB",
        "partB2",
        "partC",
        "receptor",
        "connector_A2C",
    )
}


def test_filters():
    to_record = dc.sequence_to_biopython_record

    filter1 = dc.NoRestrictionSiteFilter("BsmBI")
    assert filter1(to_record("ATGATGATG"))
Example #7
0
import os
from dnacauldron import load_record
import flametree

data_path = os.path.join("app", "data")
data_dir = flametree.file_tree(data_path)
#
# with open(data_path, "r") as f:
#     DATA = f.read()

connector_records = [
    load_record(f._path, linear=False, id=f._name_no_extension)
    for f in data_dir.genbank.connectors._all_files if f._extension == "gb"
]

backbone = load_record(data_dir.genbank.hc_amp_backbone_gb._path,
                       linear=False,
                       id='hc_amp_backbone')
backbone.is_backbone = True
"""

"""
from dnacauldron import load_record, insert_parts_on_backbones, BackboneChoice
import flametree  # for getting/writing files and folders

root = flametree.file_tree('.')
output_dir = root._dir('output_data')._dir('backbone_autoselection')

# load lists of genbanks: one list for parts, one list for potential backbones
part_records = [
    load_record(f._path, topology='circular', id=f._name_no_extension)
    for f in root.data.assemblies._all_files
    if f._name_no_extension in ['partA', 'partB']
]
backbone_records = [
    load_record(f._path, topology='circular', id=f._name_no_extension)
    for f in root.data.backbones._all_files
]

choices = insert_parts_on_backbones(part_records,
                                    backbone_records,
                                    process_parts_with_backbone=True)
dataframe = BackboneChoice.list_to_infos_spreadsheet(choices)
dataframe.to_excel(output_dir._file('summary.xls')._path, index=False)
BackboneChoice.write_final_records(choices, output_dir._dir("records")._path)