Class documentation¶
Manipulation¶
-
class
BioPlate.manipulation.
BioPlateManipulation
¶ This parent class grouped all method that can be applied to BioPlate instance.
-
count
(reverse: bool = False)¶ Count number of occurance in BioPlate instance
Parameters: - reverse : bool (by default false)
Returns: - result : dict
return a dict of occurance name : number of occurance
-
get
(*well) → Union[List[str], BioPlate.manipulation.BioPlateManipulation, None, List[Sequence[Any]]]¶ Use to retrive informations from BioPlate instance
Parameters: - well : str
well is only a well identifier eg : “G5”, “2[B-G]”
- Returns
- ——-
- One_well : str
get back value in one well eg : “G5”
- multiple_well : np.array
get back all value eg : “2[B-G]”
- multiple_well_multiple_identifier : list
return a list of eqch given arguments
-
iterate
(order: str = 'C', accumulate: bool = True) → Generator¶ Generaror to Iterate a BioPlate instance by column or row, with ability to group value of same well
Parameters: - order : { ‘C’, ‘R’}
Iterate by column (C) or by row (R)
- accumulate : bool (by default True)
Group data of same well together
Yields: - well : tuple
each iteration contain well identifier and value(s) eg : (“B2”, “value”)
-
name
¶ Get object name (BioPlate, Inserts, Array)
Returns: - name : str
name of instance
Examples
>>> from BioPlate import BioPlate >>> plate = BioPlate(12, 8) >>> plate.name BioPlate
-
save
(plate_name: str, **kwargs) → Optional[str]¶ Save BioPlate objwct to plate history database
Parameters: - plate_name : str
name of plate to save it in database eg : “expetiment 1”
- kwargs : dict
To know kwargs see
add_hplate()
Returns: - response : str
database response for adding or updating plate historic database
-
set
(*args, merge=False)¶ Main entry point to assign value on plate
Parameters: - well : dict or str
- if dict, well must contain well identifier as key and value to assign as value.eg : {“A2” : “value”, “A[3-6]” : 42}
- if string, well is only a well identifier eg : “G5”
- value : list or str or int or float
- if list, value should be presented with multiple well identifer “B-D[2-5]”, [“value1”, “value2”, “value3”]
- merge : bool (by default False)
Value on well are not overide but added
- Returns
- ——-
- BioPlate : BioPlate
return instance of plate
-
table
(headers: str = 'firstrow', **kwargs) → tabulate.tabulate¶ Transform BioPlate object to table
Parameters: - headers : str (by default “firstrow”)
- kwargs : dict
To know kwargs see Tabulate
Returns: - table : str
outputs a nicely formatted plain-text table
-
to_excel
(file_name: str, sheets: List[str] = ['plate_representation', 'plate_data', 'plate_count'], header: bool = True, accumulate: bool = True, order: str = 'C', empty: str = 'empty')¶ Send BioPlate instance to spreadsheet
Parameters: - file_name : str
name of new created spreadsheet
- sheets : list[str]
name of sheets
- header : bool (default is True)
if header should be present in plate representation
- accumulate : bool (default is True)
If data in BioPlate object should be accumulate or not see
iterate()
- order : {“C”, “R”}
Iterate value by column or row
- empty : str
value assign to empty well
Returns: - spreadsheet : None
create a spreasheet at given filename (should contain path also)
-
To excel¶
-
class
BioPlate.writer.to_excel.
BioPlateToExcel
(file_name, sheets=['plate_representation', 'plate_data', 'plate_count'], header=True, accumulate=True, order='C', empty='empty', test=False)¶ Past BioPlate object to excel file.
-
_BioPlateToExcel__header_format_representation
(format)¶ Function to pass heqdwr format representation to workbook object
Parameters: - format : Dict
Dict of format to apply to plate header following xlswriter rules
-
__init__
(file_name, sheets=['plate_representation', 'plate_data', 'plate_count'], header=True, accumulate=True, order='C', empty='empty', test=False)¶ This class is instentiate with parameters for excel file. BioPlate object are only pass to method.
Parameters: - file_name: str
name of excel file
- sheets: List[str]
list of sheetname (default is [“plate_representation”, “plate_data”, “plate_count”])
- header: bool
if header should be put
- accumulate: bool
if plate data should be accumulate for same well or listed
- order: str, {“R”, “C”}
if iteration should be done by column or row
- empty: str
Name of well without value
- test : bool
For testing purpose, return in memory object
-
__weakref__
¶ list of weak references to the object (if defined)
-
_representation
(plate)¶ Pass Plate representation to spreadsheet
Parameters: - plate : Plate
Plate object to represent
-
_representation_inserts
(BPlate)¶ Pass Inserts representation to spreadsheet
Parameters: - BPlate : Inserts
Inserts object to represent
-
close
()¶ Close workbook properly
-
data
(BPlate, accumulate=None, order=None, header=None)¶ add to worksheet plate data, well and their value in column, ordered by column or row. If accumulated, well will be writen once. header should be a list of column name
-
get_test
()¶ Return list of value stocked in memory of workbook.
Returns: - values : Dict[str, List[List]]
returns values passed to workbook as dict with sheetnames as key and value as list of values.
-
open_excel_file
¶ Create a
xlsxwriter Workbook
to work with. If test isTrue
when class is instenciate this function will return a in memory Workbook.Returns: - Workbook : xlsxwriter.Workbook
An object to write excel file
-
plate_split
(plate)¶ Remove row and column
-
representation
(BPlate)¶ This function put reprenstation of BPlate depending on is type (Plate, Inserts, Stack)
Parameters: - BPlate : BioPlate
BioPlate object to represent in spreqdsheets
-
select_worksheet
¶ Create worksheets object for each sheets given.
Returns: - worksheets : List[xlsxwriter.worksheets]
Return a list of worksheets
-
From excel¶
-
class
BioPlate.writer.from_excel.
BioPlateFromExcel
¶ This class should be instanciate with those parameters
__init__()
Returns: - bioplate_dict : dict
Dict with sheetname as key and list of bioplate object as value
-
class
BioPlate.writer.from_excel.
_BioPlateFromExcel
(file_name: str, sheets: List[str] = None, plate_infos: Dict[str, Dict] = None)¶ -
__init__
(file_name: str, sheets: List[str] = None, plate_infos: Dict[str, Dict] = None)¶ This class load plate representation and data fron excel file. If no sheetnames are specifed all sheets will be process. If plate are only data and no headers are present, you should provide a plate information. Eg : {“sheetname” : { “row” : 9, “column” : 12, “stack” : True, “type” : “BioPlate”}}
Parameters: - sheets : list, default None
List of sheet name to process if None all sheet will be process
- plate_infos : dict, default None
Should be provide if no header are present in given sheet. Eg : {“sheetname” : { “row” : 9, “column” : 12, “stack” : True, “type” : “BioPlate”}}
-
__weakref__
¶ list of weak references to the object (if defined)
-
_get_no_empty_sheets
() → Dict[str, List]¶ Get only sheet with element in it and discard empty ones.
Returns: - Dict_of_sheet : dict
keys are sheet name, values are list of element
-
_get_one_plate
(values: List[List], sheetname: str) → Iterator¶ yield plate object representation from list for a given sheetname
Parameters: - value : List[List]
list of element return by pyexcel_xlsx.get_data
- sheetname : str
Name of sheet to process
Yields: - value_of_one_plate :
Plate
,Inserts
, List[List] Yields plate object filled with value or List[List]
-
_get_plate_informations
(value: List[List], sheetname: str) → Tuple[Callable, bool, int, int]¶ Guess or extract plate informations from a list of data
Parameters: - value : List[List]
list of element return by pyexcel_xlsx.get_data
- sheetname : str
Name of sheet to process
Returns: - Type : Plate or Inserts
Basic object type (Plate or Inserts)
- stack : Boolean, dafault False
values are a stack of basic object type (Plate or Inserts)
- column : int
number of column in plate
- row : int
number of row in plate
Examples
>>> from BioPlate.from_excel import _BioPlateFromExcel >>> BPFE = _BioPlateFromExcel("path/to/my_file.xlsx", sheetname = ["sheet1"]) >>> BPFE.loaded_file["sheet1"] [[, 1, 2, 3], ["A", "t1", "t2", "t3"], ["B", "y1", "y2", "y3"]] >>> BPFE._get_plate_informations(BPFE.loaded_file["sheet1"], "sheet1") (Plate, False, 3, 2)
-
_guess_column_row
(value: List[List]) → Tuple[int, int]¶ get column and row number from representation with header.
Parameters: - value : List[List]
list of element return by pyexcel_xlsx.get_data
Returns: - column_row : Tuple[int, int]
returns column and row numbers
-
_guess_type
(value)¶ this function have to guess from plate shape and return an empty BioPlate object to use
Parameters: - value : List[List]
list of element return by pyexcel_xlsx.get_data
Returns: - BioPlate :
Plate
,Inserts
return
__init__()
or__init__()
-
_instance_of_plate
(Type, column, row)¶ instantiate a plate object with column and row number.
Parameters: - Type :
Plate
,Inserts
class definitions to instanciate
- column : int
number of column in plate object
- row : int
number of row in plate object
Returns: - instanciate_plate: ``Plate``, ``Inserts``
instanciate object with right number of columns and rows
- Type :
-
_iterate_bp_value
(plate: List[List], row: int) → Iterator[Tuple[int, List]]¶ yield row index and value of given well for Plate.
Parameters: - plates : List[List]
list of element return by pyexcel_xlsx.get_data
- row : int
index of row
Yields: - Infos : Tuple[int, str]
Yields infos to assign value on Plate
-
_iterate_bpi_value
(plates: List[List], row: int) → Iterator[Tuple[int, str, List]]¶ yield row index, position (top or bottom) and value of given well for Inserts.
Parameters: - plates : List[List]
list of element return by pyexcel_xlsx.get_data
- row : int
index of row
Yields: - Infos : Tuple[int, str, str]
Yields infos to assign value on Inserts
-
_pre_bp_iterate
(value: List[List], row: int) → Iterator¶ Split value from a sheet into chunck of plate.
Parameters: - value : List[List]
list of element return by pyexcel_xlsx.get_data
- row : int
number of row in plate
-
_pre_bpi_iterate
(value: List[List], row: int) → Iterator¶ Split value from a sheet into chunck of inserts.
Parameters: - value : List[List]
list of element return by pyexcel_xlsx.get_data
- row : int
number of row in plate
-
get_BioPlate_object
() → Dict[str, Union[BioPlate.plate.Plate, BioPlate.inserts.Inserts, BioPlate.stack.Stack]]¶ Main method of this class, return a dict with sheetname as key and BioPlate object filled with element from spreadsheets as value.
Returns: - BioPlate_object : Dict[str, Union[Plate, Inserts, Stack]]
-
is_insert
(value: List[List]) → bool¶ Evaluate if BioPlate object is an insert.
Parameters: - value : List[List]
list of element return by pyexcel_xlsx.get_data
Returns: - is_insert : bool
True or False
-
is_stack
(value: List[List], sheetname: str = None) → bool¶ this function have to guess from plate if it is a stack
Parameters: - value : List[List]
list of element return by pyexcel_xlsx.get_data
- sheetname : str
Name of sheet to process
Returns: - is_stack: bool
True or False
-
Plate database¶
-
class
BioPlate.database.plate_db.
PlateDB
(db_name='plate.db')¶ -
class
PlateDatabase
(**kwargs)¶ Database for plate
-
add_plate
(numWell, numColumns, numRows, name=None, surfWell=None, maxVolWell=None, workVolWell=None, refURL=None)¶ add plate in the database
Parameters: - session – Sqlalchemy session
- numWell – number of well in a plate (INT)
- numColumns –
- numRows –
- name –
- surfWell –
- maxVolWell –
- workVolWell –
- refURL –
Returns: Nothing
-
class
Plate database historic¶
-
class
BioPlate.database.plate_historic_db.
PlateHist
(db_name='plate_historic.db')¶ -
class
PlateHistoric
(**kwargs)¶ historic of create plate
-
add_hplate
(numWell, plate_name, plate_array, Plate_id=None)¶ Parameters: - Plate_id – id of plate in plate.db
- numWell – int, number of well in plate
- date – date where plate was creating
- plate_name – name of experiment or plate
- plate_array – numpy array representation of the plate
Returns:
-
class