API reference¶
main.py¶
Main module for basicsynbio.
This module can import from utils but not from cam or parts_linkers packages.
-
class
basicsynbio.main.
BasicAssembly
(id: str, *parts_linkers: Union[basicsynbio.main.BasicPart, basicsynbio.main.BasicLinker])[source]¶ Class for BASIC DNA assemblies.
Note
BasicAssembly class requires alternating
BasicPart
andBasicLinker
instances in any order.-
id
¶ Identifier for BasicAssemby object. Must be unique amongst BasicAssembly instances used to initiate a BasicBuild object.
-
parts_linkers
¶ tuple of BasicPart and BasicLinker objects used to create this assembly.
-
return_clip_reactions
() → Tuple[basicsynbio.main.ClipReaction, …][source]¶ A function to return the
ClipReaction
instances required for BASIC assembly.- Returns
A collection of ClipReaction instances required for BASIC assembly.
- Return type
tuple
-
return_part
(**kwargs) → basicsynbio.main.BasicPart[source]¶ A function to return the assembled construct as a new part.
- Parameters
kwargs – assigns alternative SeqRecord attributes.
- Returns
assembled construct as a new part.
- Return type
-
-
class
basicsynbio.main.
BasicLinker
(seq: Bio.Seq.Seq, id: str, name: str = None, prefix_id: str = None, suffix_id: str = None, overhang_slice_params: Tuple[int, int] = None, **kwargs)[source]¶ Class for BASIC DNA assembly linkers.
A DNA sequence joined with other BasicLinkers via
BasicPart
instances when initializingBasicAssembly
objects.-
prefix_id
¶ The prefix half linker id.
- Type
str
-
suffix_id
¶ The suffix half linker id.
- Type
str
-
seq
¶ Refer to Bio.SeqRecord.SeqRecord documentation.
-
id
¶ Refer to Bio.SeqRecord.SeqRecord documentation.
-
name
¶ This attribute is used to label the annotation in exported gb files or equivalent.
-
overhang_slice_params
¶ Parameters used to slice seq attribute returning overhang sequence. Parameters are in the form (start, stop). Required to access linker_oligos attribute.
-
linker_oligos
¶ Oligonucleotides used to physically generate linker.
-
basic_slice
()[source]¶ The function to obtain the basic slice of BasicLinker objects.
- Returns
returns self, the basic slice of BasicLinker objects.
- Return type
-
property
seq
¶ The sequence itself, as a Seq or MutableSeq object.
-
-
class
basicsynbio.main.
BasicPart
(seq, id: str, **kwargs)[source]¶ Class for BASIC DNA assembly parts.
A DNA sequence joined with other BasicParts via
BasicLinker
instances when initializingBasicAssembly
objects. All sequences must contain intergated prefix and suffix sequences.-
_ip_loc
¶ The index/location of IP_STR within sequence.
- Type
int
-
_is_loc
¶ The index/location of IS_STR within sequence.
- Type
int
-
basic_slice
() → Bio.SeqRecord.SeqRecord[source]¶ The Function to obtain region flanked by BASIC iP & iS sequences
- Returns
The region flanked by BASIC iP & iS sequences as a SeqRecord object.
- Return type
SeqRecord
- Raises
ValueError – If iP and iS sequences not correctly identified.
-
clip_mass
(clip_vol: float = 30, circular: bool = True, ndigit: int = None) → Union[float, int][source]¶ Obtain the recommended mass of part (ng) for a clip reaction.
- Parameters
clip_vol – volume of the clip reaction (µL).
circular – The part is circular or linear if False.
ndigit – Refer to built-in round function documentation.
-
domesticating_primers
(seq_args: dict = 0, global_args: dict = 0, left_attrs: dict = None, right_attrs: dict = None, primer_pair: int = 0) → basicsynbio.main.DomesticatingPrimers[source]¶ Generate PCR primers and associated data for domesticating parts from various sources using PCR.
PCR primers contain iP and iS sequences, respectively, in addition to a region of homology for the intervening DNA sequence. They can be used to domesticate parts from various sources, adding iP and iS sequences, enabling downstream BASIC assemblies.
- Parameters
seq_args – Refer to ‘_primer3py’ method and primer3-py docs.
global_args – Refer to ‘_primer3py’ method and primer3-py docs.
left_attrs – Additional attributes to assign to left_primer SeqRecord.
right_attrs – Additional attributes to assign to the right_primer SeqRecord.
primer_pair – Which of the returned primer3-py primer pairs to use. Defaults to 0 which is the primer pair with the lowest penalty value.
- Returns
left_primer & right_primer attributes contain iP & iS sequences, respectively while data corresponds to primer regions homologous to template DNA.
- Return type
- Raises
ValueError – If primer3 fails to identify suitable primer pairs.
-
property
seq
¶ The sequence itself, as a Seq or MutableSeq object.
-
-
class
basicsynbio.main.
BasicUTRRBSLinker
(seq: Bio.Seq.Seq, id: str, name: str, prefix_id: str = None, suffix_id: str = None, **kwargs)[source]¶ Sub-class of
BasicLinker
for UTR-RBS linkers.
-
class
basicsynbio.main.
ClipReaction
(prefix, part, suffix)[source]¶ Class for describing clip reactions.
Note
ClipReaction is hashable.
-
clip_items
() → Tuple[basicsynbio.main.BasicLinker, basicsynbio.main.BasicPart, basicsynbio.main.BasicLinker][source]¶ A function to returns a tuple describing each of the items within each clip.
- Returns
(prefix linker, part, suffix linker)
- Return type
tuple
-
-
class
basicsynbio.main.
DomesticatingPrimers
(left_primer: Bio.SeqRecord.SeqRecord, right_primer: Bio.SeqRecord.SeqRecord, data: dict)[source]¶
-
class
basicsynbio.main.
LinkerHalfOligos
(long: Bio.Seq.Seq, adapter: Bio.Seq.Seq)[source]¶ Oligos used by a linker half.
-
basicsynbio.main.
seqrec2part
(seqrec: Bio.SeqRecord.SeqRecord, add_i_seqs: bool = False) → basicsynbio.main.BasicPart[source]¶ A function to generate BasicPart instances based on SeqRecords.
Note
Relevant attributes are maintained.
- Parameters
seqrec – SeqRecord to be converted to BasicPart subclass.
add_i_seqs – if True adds flanking BASIC iP and iS sequences. Note, letter_annotations attribute is lost.
- Returns
BasicPart instance of seqrec.
- Return type
bsb_io.py¶
Module contains objects for importing and exporting parts and sequences.
-
basicsynbio.bsb_io.
export_sequences_to_file
(sequences: Iterable[Union[Bio.SeqRecord.SeqRecord, basicsynbio.main.BasicPart, basicsynbio.main.BasicAssembly]], handle: str, format: str = 'genbank', molecule_type: str = 'DNA') → None[source]¶ Exports sequences to file using Bio.SeqIO.write().
Note
Refer to Biopython documentation for further information on Bio.SeqIO.write().
- Parameters
sequences – Sequences to export.
handle – handle to file.
format – file format.
molecule_type (optional) – Type of molecule within sequences. defaults to ‘DNA’.
- Raises
ValueError – sequences was not of correct type.
-
basicsynbio.bsb_io.
import_part
(handle: str, format: str, add_i_seqs: bool = False) → basicsynbio.main.BasicPart[source]¶ Imports a Part object using Bio.SeqIO.read().
Note
Refer to Biopython documentation for further information on Bio.SeqIO.read().
- Parameters
handle – handle to file.
format – file format.
add_i_seqs – if True adds flanking BASIC iP and iS sequences. Note, letter_annotations attribute is lost.
- Returns
a BASIC DNA assembly part.
- Return type
-
basicsynbio.bsb_io.
import_parts
(handle: str, format: str, add_i_seqs=False) → Iterable[basicsynbio.main.BasicPart][source]¶ Imports a Generator of BasicPart objects using Bio.SeqIO.parse().
Note
Refer to Biopython documentation for further information on Bio.SeqIO.parse().
- Parameters
handle – handle to file.
format – file format.
add_i_seqs – if True adds flanking BASIC iP and iS sequences. Note, letter_annotations attribute is lost.
- Yields
BasicPart – all parts within the file handle.
-
basicsynbio.bsb_io.
import_sbol_parts
(path: str, add_i_seqs=False) → Generator[basicsynbio.main.BasicPart, None, None][source]¶ Imports BasicPart objects using sbol2.Document.exportToFormat.
Note
Refer to Biopython documentation for further information on Bio.SeqIO.read(). Refer to pysbol2 documentation for further information.
- Parameters
path – path to SBOL file.
add_i_seqs – if True adds flanking BASIC iP and iS sequences. Note, letter_annotations attribute is lost.
- Yields
BasicPart – all parts within the file handle.
cam.main.py¶
Module contains key objects for computer assisted manufacturing (CAM) within the BASIC DNA assembly framework.
-
class
basicsynbio.cam.main.
BasicBuild
(*basic_assemblies: basicsynbio.main.BasicAssembly)[source]¶ Class provides methods and attributes for building BasicAssembly objects.
-
basic_assemblies
¶ Tuple of BasicAssembly objects used to initiate BasicBuild.
-
unique_clips
¶ Tuple of unique ClipReaction objects required to implement the build.
-
clips_data
¶ A dictionary with each ClipReaction as a key and BasicAssembly objects that require it as values.
-
unique_parts
¶ Tuple of the unique BasicPart object required to implement the build.
-
unique_linkers
¶ Tuple of the unique BasicLinker objects required to implement the build.
-
update_parts
(*parts: basicsynbio.main.BasicPart) → None[source]¶ Updates BasicBuild instance with parts.
Replaces all existing BasicParts used in assemblies with the matching equivalent in parts.
- Parameters
parts – parts to replace the BasicParts used in assemblies
- Raises
ValueError – if length parts is not equal to length this build’s unique parts
-
-
class
basicsynbio.cam.main.
BuildDecoder
[source]¶ A Class to decode json dictionary to basicsynbio objects, extending json.JSONDecoder class
-
decode_build
(dictionary: dict) → basicsynbio.cam.main.BasicBuild[source]¶ A method to return BasicBuild from encoded json object
- Parameters
dictionary – json object encoded by BuildEncoder
- Returns
BasicBuild object built from encoded json
- Return type
-
return_basic_assemblies
(dictionary: dict) → Generator[basicsynbio.main.BasicAssembly, None, None][source]¶ A method to yield BasicAssembly objects from encoded json object
- Parameters
dictionary – json object encoded by BuildEncoder
- Yields
BasicAssembly – BasicAssembly objects within encoded BasicBuild
-
-
class
basicsynbio.cam.main.
BuildEncoder
(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶ A Class to encode BasicBuild objects extending json.JSONEncoder class
-
static
assembly_data_json
(obj)[source]¶ A function to create machine readable json objects, completely describing BasicAssembly objects within BasicBuild.
- Parameters
obj – BasicBuild object to be decoded
- Returns
returns a list of dictionaries populated by dictionaries with items describing BasicAssemblies generated by the build.
- Return type
list
-
static
clips_data_json
(obj)[source]¶ A function to create machine readable json objects, completely describing ClipReaction objects within BasicBuild.
- Parameters
obj – BasicBuild object to be decoded
- Returns
Each item describes a given unique ClipReaction object required for the build.
- Return type
dictionary
-
default
(obj)[source]¶ Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
-
static
decorators.py¶
Module contains decorators.
-
class
basicsynbio.decorators.
ArgDescription
(argument: str, description: str)[source]¶ Class for documenting arguments.
-
basicsynbio.decorators.
addargs2docs
(*arg_descriptions: basicsynbio.decorators.ArgDescription)[source]¶ Decorator for adding argument docstrings to functions.
Note
Arguments for documentation must be given in the function docstring with a blank description.
- Parameters
arg_descriptions – The argument to document and its description.
- Returns
Decorator.
pdf_instructions.py¶
-
basicsynbio.cam.pdf_instructions.
pdf_instructions
(basic_build: basicsynbio.cam.main.BasicBuild, path: str = None, assemblies_per_clip: int = 28)[source]¶ Writes instructions to implement build to a pdf file.
- Parameters
basic_build – BasicBuild object the pdf lab instructions are written for.
path (optional) – path to pdf file. If none defaults to working directory with a time stamped name.
assemblies_per_clip (optional) – number of assemblies each purified clip reaction can support.
- Returns
filepath of created pdf
- Return type
str
echo_instructions.py¶
-
basicsynbio.cam.echo_instructions.
export_echo_assembly
(basic_build: basicsynbio.cam.main.BasicBuild, path: str = None, buffer_well: str = 'A1', water_well: str = 'B1', alternate_well: bool = False, assemblies_per_clip: int = 20, clips_plate_size: Literal[6, 24, 96, 384, 1536] = 384, assemblies_plate_size: Literal[6, 24, 96, 384, 1536] = 96) → None[source]¶ Writes automation scripts for a echo liquid handler to build assemblies from clips.
- Parameters
path (optional) – path to zipped folder of csv files. If none defaults to working directory with a time stamped name, output csvs is created.
buffer_well (optional) – location in 6 well plate of assembly buffer.
water_well (optional) – location in 6 well plate of dH20.
alternate_well (optional) – specifies whether alternating wells are to be used in the input 384 well plate.
assemblies_per_clip (optional) – number of assemblies each purified clip reaction can support.
clips_plate_size (optional) – specifies the size of the clips plate. Defaults to 384
assemblies_plate_size (optional) – specifiesthe size of the assemblies plates. Defaults to 96
- Returns
Path of zip file containing echo automation scripts
- Return type
str
- Raises
ValueError – If water_well or buffer_well is not in [“A1”, “B1”, “A2”, “B2”, “A3”, “B3”]; if self contains 96 or more assemblies or if the build requires equal or more than 384 used clip wells for alternate_well(True) or 192 for alternate_well(False).