Lab module
PCR module
This part of the lab module is used for simulating and calculating PCR reactions.
- constrain.lab.PCR.Q5_NEB_PCR_program(amplicon)[source]
Simple PCR program designed to give a quick visual representations.
- Parameters:
amplicon (pydna.amplicon) – pydna amplicon object
- Returns:
schematic representation of a Q5 program
- Return type:
str
- constrain.lab.PCR.amplicon_by_name(name: str, amplicons_lst: list)[source]
Returns amplicon with specified name
- Parameters:
name (str) –
amplicons_lst (list) –
- Returns:
amplicon
- Return type:
pydna.amplicon
- constrain.lab.PCR.calculate_elongation_time(amplicon)[source]
Determines elongation time for an amplicon and add the elongation time to the amplicon annotations
- Parameters:
amplicon (pydna.amplicon) –
- Return type:
Adds the elongation time to the amplicon annotations
Notes
The amplicon needs to have a dict called proc_speed shown as follows: amplicon.annotations[“proc_speed”] This dict within the annotations can be made with the function proc_speed.
- constrain.lab.PCR.calculate_processing_speed(amplicon)[source]
Determines process speed based on the which polymerase is used.
- Parameters:
amplicon (pydna.amplicon) –
- Return type:
Adds annotations to the amplicon object dependent on which polymerase was used
Notes
The amplicon needs to have the following dict incorporated: amplicon.annotations[“polymerase”]
- constrain.lab.PCR.calculate_required_thermal_cyclers(amplicons: list, polymerase: str, elong_time_max_diff=15)[source]
Determines the number of thermalcyclers that is needed based on elongation time differences
- Parameters:
amplicons (list) – of pydna.amplicon objects
polymerase (str) –
- Returns:
dataframe of grouped amplicons
- Return type:
pd.DataFrame
- constrain.lab.PCR.calculate_volumes(vol_p_reac=0, no_of_reactions=1, standard_reagents=[], standard_volumes=[])[source]
Can make a reaction scheme for PCR master mixes. :param vol_p_reac: :type vol_p_reac: int :param no_of_reactions: :type no_of_reactions: int :param standard_reagents: :type standard_reagents: list :param standard_volumes: :type standard_volumes: list
- Return type:
pd.DataFrame
Examples
- calculate_volumes(vol_p_reac = 10,
no_of_reactions = 6, standard_reagents = [“DNA”,”Buffer, Cutsmart”,”H20”,”Enz, USER”], standard_volumes = [1,1,7,1])
vol_p_reac vol_p_x_reac
DNA 1.0 6.0 Buffer, Cutsmart 1.0 6.0 H20 7.0 42.0 Enz, USER 1.0 6.0 Total 10.0 60.0 ————————-
- constrain.lab.PCR.grouper(iterable, max_diff)[source]
Groups objects into distinct groups based on differences
- constrain.lab.PCR.nanophotometer_concentrations(path='')[source]
Reads a CSV file with nanophotometer concentraions and returns the concentrations in a list
- Parameters:
path (str) – path to file
- Returns:
concentrations – list of concentrations from the file as floats
- Return type:
list
- constrain.lab.PCR.pcr_locations(amplicons: list)[source]
Obtain information annotation information from amplicons.
- Parameters:
amplicon (list) – List of amplicon objects `pydna.amplicon`() # check this
- Returns:
Pandas dataframe with locations of your amplicons
- Return type:
pd.DataFrame
- constrain.lab.PCR.primer_ta_neb(primer1, primer2, conc=0.5, prodcode='q5-0')[source]
Calculates primer pair melting temp TA, from NEB.
- Parameters:
primer1 (str) – first primer to be used for finding the optimal ta
primer2 (str) – second primer to be used for finding the optimal ta
conc (float) –
prodcode (str) – find product codes on nebswebsite: https://tmapi.neb.com/docs/productcodes
- Returns:
ta – primer pair annealing temp
- Return type:
int
- constrain.lab.PCR.primer_tm_neb(primer, conc=0.5, prodcode='q5-0')[source]
Calculates a single primers melting temp from NEB.
- Parameters:
primer1 (str) –
conc (float) –
prodcode (str) – find product codes on nebswebsite: https://tmapi.neb.com/docs/productcodes
- Returns:
tm – primer melting temperature
- Return type:
int
- constrain.lab.PCR.set_plate_locations(amplicons: list)[source]
Makes a dataframe from amplicons
- Parameters:
amplicons (list) – list of pydna.amplicon objects
- Returns:
with overview of plate locations
- Return type:
pd.DataFrame
- constrain.lab.PCR.update_amplicon_annotations(amplicon_names: list, amplicons: list, locations: list, concentrations: list, volumes: list) None[source]
Updates the annotations of amplicons in the amplicon list.
- Parameters:
amplicon_names (list) – List of amplicon names.
locations (list) – List of locations for each amplicon.
concentrations (list) – List of concentrations for each amplicon.
volumes (list) – List of volumes for each amplicon.
- Return type:
None
Containers module
- exception constrain.lab.containers_wells_picklists.NoUniqueWell[source]
Bases:
ExceptionNoUniqueWell exception class.
- class constrain.lab.containers_wells_picklists.PickList(transfers_list=(), data=None)[source]
Bases:
objectRepresentation of a list of well-to-well transfers.
- Parameters:
transfers_list – A list of Transfer objects that will be part of the same dispensing operation, in the order in which they are meant to be simulated.
data – A dict with information on the picklist.
- add_transfer(source_well=None, destination_well=None, volume=None, data=None, transfer=None)[source]
Add a transfer to the picklist’s tranfers list.
You can either provide a
Transferobject with thetransferparameter, or the parameters.
- enforce_maximum_dispense_volume(max_dispense_volume)[source]
Return a new picklist were every too-large dispense is broken down into smaller dispenses.
- static merge_picklists(picklists_list)[source]
Merge the list of picklists into a single picklist.
The transfers in the final picklist are the concatenation of the transfers in the different picklists, in the order in which they appear in the list.
- restricted_to(transfer_filter=None, source_well=None, destination_well=None)[source]
Return a version of the picklist restricted to transfers with the right source/destination well.
You can provide
source_wellanddestination_wellor alternatively just a functiontransfer_filterwith signature (transfer)=>True/False that will be used to filter out transfers (for which it returns false).
- class constrain.lab.containers_wells_picklists.Plate(name=None, wells_data=None, plate_data=None)[source]
Bases:
objectBase class for all plates.
See the builtin_containers for usage classes, such as generic microplate classes (Plate96, Plate384, etc).
- Parameters:
name – Name or ID of the Plate as it will appear in strings and reports
wells_data – A dict {“A1”: {data}, “A2”: …}. The format of the data is left free
plate_data – plate data
- find_unique_well_by_condition(condition)[source]
Return the unique well of the plate satisfying the condition.
The
conditionmethod should have a signature of Well=>True/False.Raises a NoUniqueWell error if 0 or several wells satisfy the condition.
- find_unique_well_containing(query)[source]
Return the unique well whose content contains the query.
- get_well_at_index(index, direction='row')[source]
Return the well at the corresponding index.
Examples:
>>> plate.get_well_at_index(1) # well A1 >>> plate.get_well_at_index(2) # well A2 >>> plate.get_well_at_index(2, direction="column") # well B1
- index_to_wellname(index, direction='row')[source]
Return the name of the well at the corresponding index.
Examples:
>>> plate.index_to_wellname(1) # "A1" >>> plate.get_well_at_index(2) # "A2" >>> plate.get_well_at_index(2, direction="column") # "B1"
- iter_wells(direction='row')[source]
Iter through the wells either by row or by column.
Examples:
>>> for well in plate.iter_wells(): >>> print (well.name)
- list_filtered_wells(well_filter)[source]
List filtered wells.
Examples:
>>> def condition(well): >>> return well.volume > 50 >>> for well in myplate.list_filtered_wells(condition): >>> print(well.name)
- list_wells_in_column(column_number)[source]
Return the list of all wells of the plate in the given column.
Examples:
>>> for well in plate.list_wells_in_column(5): >>> print(well.name)
- list_wells_in_row(row)[source]
Return the list of all wells of the plate in the given row.
The row can be either a row number (1,2,3) or row letter(s) (A,B,C).
Examples:
>>> for well in plate.list_wells_in_row("H"): >>> print(well.name)
- return_column(column_number)[source]
Return the list of all wells of the plate in the given column.
- return_row(row)[source]
Return the list of all wells of the plate in the given row.
The row can be either a row number (1,2,3) or row letter(s) (A,B,C).
- to_pandas_dataframe(fields=None, direction='row')[source]
Return a dataframe with the info on each well.
- wellname_to_index(wellname, direction='row')[source]
Return the index of the well in the plate.
Examples: >>> plate.wellname_to_index(“A1”) # 1 >>> plate.wellname_to_index(“A2”) # 2 >>> plate.wellname_to_index(“A1”, direction=”column”) # 9 (8x12 plate)
- class constrain.lab.containers_wells_picklists.Plate2x4(name=None, wells_data=None, plate_data=None)[source]
Bases:
PlateClass for 8-well (2 x 4) plates such as colony plating plates
- num_columns = 4
- num_rows = 2
- class constrain.lab.containers_wells_picklists.Plate96(name=None, wells_data=None, plate_data=None)[source]
Bases:
PlateBase class for standard 96-well plates
- num_columns = 12
- num_rows = 8
- class constrain.lab.containers_wells_picklists.Transfer(source_well, destination_well, volume, data=None)[source]
Bases:
objectClass representing a transfer from a source well to a destination well.
- Parameters:
source_well – A Well object from which to transfer.
destination_well – A Well object to which to transfer.
volume – Volume to be transferred, expressed in liters.
data – A dict containing any useful information about the transfer. This information can be used later e.g. as parameters for the transfer when exporting a picklist.
- class constrain.lab.containers_wells_picklists.Well(plate, row, column, name, data=None)[source]
Bases:
objectGeneric class for a well.
- Parameters:
plate – The plate on which the well is located
row – The well’s row (a number, starting from 0)
column – The well’s column (a number, starting from 0)
name – The well’s name, for instance “A1”
data – A dictionary storing data on the well, used in algorithms and reports.
- add_content(components_quantities, volume=None, unit_volume='L')[source]
Add content to well.
- Parameters:
components_quantities – Dictionary of components and quantities (default: gram). Example {“Compound_1”: 5}.
volume – Volume (default: liter).
unit_volume – Unit of volume (default: liter). Options: liter (L), milliliter (mL), microliter (uL), nanoliter (nL).
- capacity = None
- property coordinates
Return (well.row, well.column).
- dead_volume_per_transfer_class = None
- is_after(other, direction='row')[source]
Return whether this well is located strictly after the other well.
Example: iterate over all free wells after the last non-free well:
>>> direction = 'row' >>> last_occupied_well = plate.last_nonempty_well(direction=direction) >>> free_wells = (w for w in plate.iter_wells(direction=direction) >>> if w.is_after(last_occupied_well)) >>> for well in free_wells: ...
- property is_empty
Return true if the well’s volume is 0.
- property volume
Return volume.
- class constrain.lab.containers_wells_picklists.WellContent(quantities=None, volume=0)[source]
Bases:
objectClass to represent the volume and quantities of a well.
Having the well content represented as a separate object makes it possible to have several wells share the same content, e.g. in throughs.
- constrain.lab.containers_wells_picklists.compute_rows_columns(num_wells)[source]
Convert 96->(8,12), 384->(16,24), etc.
- constrain.lab.containers_wells_picklists.coordinates_to_wellname(coords)[source]
Convert (1,1)->A1, (4,3)->D3, (12, 12)->H12, etc.
- constrain.lab.containers_wells_picklists.index_to_row_column(index, num_wells, direction='row')[source]
- constrain.lab.containers_wells_picklists.index_to_wellname(index, num_wells, direction='row')[source]
Convert e.g. 1..96 into A1..H12
- Parameters:
index (int) – the index of the well
num_wells (int) – number of wells on the plate
direction (str) – the direction of counting. Either “row” or “column”.
- constrain.lab.containers_wells_picklists.number_to_rowname(number)[source]
Convert 1->A 26->Z 27->AA etc.
- constrain.lab.containers_wells_picklists.replace_nans_in_dict(dictionary, replace_by='null')[source]
Replace NaNs in a dictionary with a string.
- Parameters:
dictionary (dict) – the dictionary
replace_by (str) – replacement
- constrain.lab.containers_wells_picklists.rowname_to_number(name)[source]
Convert A->1 Z->26 AA->27 etc.
- constrain.lab.containers_wells_picklists.wellname_to_coordinates(wellname)[source]
Convert A1->(1,1), H11->(8, 11), etc.
- constrain.lab.containers_wells_picklists.wellname_to_index(wellname, num_wells, direction='row')[source]
Convert e.g. A1..H12 into 1..96 direction is either row for A1 A2 A3… or column for A1 B1 C1 D1 etc.
- Parameters:
wellname – the name of the well
num_wells (int) – number of wells on the plate
direction (str) – the direction of counting. Either “row” or “column”.
Robot assembly module
A module to for automating biological assemblies with robots
- class constrain.lab.robot_assembly.LiquidHandler[source]
Bases:
TransferThis class is a subclass of the synbiopython Transfer class and be used to make flowbot instructions.
- class constrain.lab.robot_assembly.RobotAssembly(Pandas_dataframe_PCR, F_primers: list, R_primers: list, Templates: list)[source]
Bases:
objectClass to generate instructions for robots on demand.
Parameters
- F_primerslist
list of forward primers
- R_primers :list
list of reverse primers
- Templateslist
list of templates
- Returns:
Methods include printing robot- excecutable intructions.
- Return type:
RobotAssembly object.
- constrain.lab.robot_assembly.make_virtual_plates_fromDF(f_primers: list, r_primers: list, templates: list, Dataframe_with_PCR_contents)[source]
This function can make virtual plates from lists of primers and templates.The Pandas DataFrame is used to calculate how much pcr and h2o is needed for the reactions.
- Parameters:
f_primers (list) – list of forward primers
r_primers (list) – list of reverse primers
templates (list) – list of templates
Dataframe_with_PCR_contents (pandas.DataFrame) – dataframe with a PCR scheme.
- Return type:
Virtual 96 plates as containers.
- constrain.lab.robot_assembly.picklist_from_plates(F_primer_plate, R_primer_plate, Templates_plate, MM_H20_plate, PCR_dataframe)[source]
This function can generate picklist from virtual plates and pandas dataframe with PCR components
- constrain.lab.robot_assembly.well_keys_96(row=True)[source]
If true it generates keys for a 96 well plate by row. else it does it by column
- Parameters:
row (bool) – if true it will generate keys horisontally for a 96 well plate. Else vertically.
- Returns:
keys – list of keys i.e [‘A1’, ‘A2’, ‘A3’,..]
- Return type:
list
Transformation module
This part of the lab module is used for making transformations
- constrain.lab.transformation.ODtime(initialOD: float, time: float, td: float = 0.5)[source]
Calculates the OD based on doupling time. :param initialOD: in OD :type initialOD: float :param time: in hours :type time: float :param td: doupling time i.e. td in h^-1 :type td: float
- Returns:
OD – the OD after a certain time()
- Return type:
float
- constrain.lab.transformation.calculate_volume_and_total_concentration(amplicons, amplicon_parts_amounts_total, n=1)[source]
Calculates the volume and total concentration of a list of DNA parts.Parameters
- ampliconslist
A list of amplicon objects
- amplicon_parts_amounts_totaldict
A dictionary of amplicon names and their respective total amounts
- nint (optional)
Gives the option of multiplying the volume is needed. Optional set to 1.
- returns:
volumes (list) – List of volumes of each amplicon
ngs (list) – List of ngs of each amplicon
total_conc (float) – Total concentration of all amplicons
- constrain.lab.transformation.ng_to_nmol(ng: float, bp: float)[source]
Calculates nanogram to nanomol for transformation mixes.
To do a transformation it is important to have the right ratio of plasmid to insert. In other words this is done by calculating the nanomolar ratios and this tool can do that
- Parameters:
ng (float) – eg. nanogram
param (float) – eg. number of basepairs. Can also be an int
- Returns:
ng_to_nmol
- Return type:
float
Note
It calculates the nmol in the following way: nmol = ng/(bp*650)
- constrain.lab.transformation.pool_parts(amplicons: list, part_names: list, part_amounts: list, pool_names: list, pool_lengths) dict[source]
Pools amplicon parts and returns a dictionary of pooled volumes.
- Parameters:
amplicons (list) – List of amplicon objects.
part_names (list) – List of part names.
part_amounts (list) – List of amounts of each part.
pool_names (list) – List of pool names.
pool_lengths (list) – List of pool lengths.
- Returns:
pooled_volumes – Dictionary containing the pooled volumes for each amplicon part.
- Return type:
dict
- constrain.lab.transformation.print_pooled_parts(pooled_volumes)[source]
Prints the pooled parts and calculated concentrations.
- Parameters:
pooled_volumes (dict) – Dictionary containing the pooled volumes for each amplicon part.
- Return type:
None
- constrain.lab.transformation.time_to_inculate(initialOD=0.0025, td=0.4, verbose=False, transformation_time: int = 12)[source]
- Calculates when a starter culture is ready to be inoculated
with a transformation mixture.
- Parameters:
initialOD (float) –
td (float) – is doubling time
transformation_time (int) – The time you want to transform
verbose (Bool) – Provides extra information
- Return type:
A plot of cell growth at different td
Notes
This is used to calculate when the cells should be used for transformation. For example: OD_1 = 1 * 10^7 cells / ml For a succesfull S.cerevisiae transformation between 1 to 2 × 10^7 cells/ml should be used Normal doupling time is between 3-6 hours
- constrain.lab.transformation.transformation_mix(reaction_names, reaction_participants, wanted_amounts, water_dna_p_reac, media='')[source]
- This function makes a pandas dataframe of the parts(their location)
that needs to be put into the transformation mixes
- Parameters:
reaction_names (list) – list of reaction names
reaction_participants (list) – list of pydna.Dseqrecord objects of Bio.seqrecord objects
wanted_concentrations (dict) – dict of the names of the reactants with their calculated nmol
water_dna_p_reac (int) – the amount of water wanted for the reaction
media (list) – list of names of the media used. e.g. [‘LB_AMP’]
- Returns:
with a transformation scheme showing which parts should be mixed for each reaction including positive and negative controls.
- Return type:
pandas.DataFrame
Examples
# 1. Mention which reacion names you have reaction_names = [“insert”, “n.ctr”, “n.ctr”, “n.ctr”, “p. ctr”]
# 2. Add reaction reaction_participants reaction_participants = [[vector, gRNA1_pcr_prod,gRNA2_pcr_prod], #the insert we want
[vector], #negative control [gRNA1_pcr_prod], #negative control [gRNA2_pcr_prod], #negative control [LEU_plasmid]] #positive control
# 2. Calculate nmol: nmol_vector = ng_to_nmol(ng = 15, bp = len(vector)) nmol_gRNA = ng_to_nmol(ng = 30, bp = len(gRNA1_pcr_prod)) nmol_pctr = ng_to_nmol(ng = 10, bp = len(LEU_plasmid))
# 3. Add the concentrations wanted_concentrations = {‘p0056(pESC-LEU-ccdB-USER)’ : nmol_vector,
‘ATF1’ : nmol_gRNA, ‘CroCPR’ : nmol_gRNA, ‘LEU_plasmid’ : nmol_pctr}
# 4. what media the transformants are plated on (5 transformations here) media = [‘LB_AMP’] * 5
# 5. initate the function transformation_mix(reaction_names, reaction_participants, wanted_amounts = (wanted_concentrations, water_dna_p_reac = 7, media = media)
- Returns:
#these are freezer locations
name l4_I06 l4_I07 l4_I08 p1_F06 water plate on
0 insert 0.1 0.6 0.6 NaN 5.7 LB_AMP 1 n.ctr 0.1 NaN NaN NaN 6.9 LB_AMP 2 n.ctr NaN 0.6 NaN NaN 6.4 LB_AMP 3 n.ctr NaN NaN 0.6 NaN 6.4 LB_AMP 4 p. ctr NaN NaN NaN 0.1 6.9 LB_AMP
- constrain.lab.transformation.transformation_partitipants(reaction_participants, amnt=0.0005, sgRNA_plasmid_name=None, sgRNA_plasmid_conc=None)[source]
Returns a dict with the µl amounts needed in a transformation reaction.
- Parameters:
reaction_participants (list of list of Dseqrecord) – List of lists of Dseqrecord objects representing the reaction participants.
amnt (float, optional) – Amount in µl of the reagents other than sgRNA_plasmid_name. Default is 0.0005.
sgRNA_plasmid_name (str, optional) – Name of the sgRNA plasmid. If not provided, amnt is used for all reaction participants.
sgRNA_plasmid_conc (float, optional) – Concentration in µl of the sgRNA plasmid. If not provided, amnt is used for all reaction participants.
- Returns:
Dict with the µl amounts needed for the transformation reaction, with keys being the names of the reaction participants and values being the corresponding µl amounts.
- Return type:
dict