parchmint package
Submodules
parchmint.cmdline module
- parchmint.cmdline.validate_v1()
Validate the json file against the schema v1
parchmint.component module
- class parchmint.component.Component(name: str = '', ID: str = '', layers: List[Layer] | None = None, params: Params = {'data': {}}, ports_list: List[Port] | None = None, entity: str = '', xspan: int = -1, yspan: int = -1, xpos: float = -1, ypos: float = -1)
Bases:
object
The component class describes all the components in the device.
- add_component_port(port: Port) None
Adds a component port to the component
- Parameters:
port (Port) – port object
- add_component_ports(ports: List[Port]) None
Adds component ports to the component
- Parameters:
ports (List[Port]) – list of port objects
- property component_spacing: float
Returns the component spacing
- Returns:
component spacing
- Return type:
float
- static from_parchmint_v1(json_data, device_ref: Device | None = None)
Creates a new Component object from the json dict
- static from_parchmint_v1_2(json_data: Dict, device_ref: Device | None = None)
Creates a new Component object from the json dict
- get_absolute_port_coordinates(port_label: str) Tuple[float, float]
Gets the absolute coordinates of the component port identified by the label
- Parameters:
port_label (str) – unique identifier for the component port
- Returns:
coordinates of the component port
- Return type:
Tuple[float, float]
- get_port(label: str) Port
Returns a port in the component identified by the corresponding label
- Parameters:
label (str) – label of the componentport
- Raises:
Exception – if there is no component port with the corresponding label is found
- Returns:
component port
- Return type:
- get_rotated_component_definition(angle: int) Component
Returns a new component with the same parameters but rotated by the given angle
- Parameters:
angle (int) – angle of rotation
- Returns:
[description]
- Return type:
- property ports: List[Port]
Returns the ports of the component
- Returns:
list of ports
- Return type:
List[Port]
- rotate_component() None
Returns a new component with the same parameters but rotated by the given angle
- Parameters:
None –
- Returns:
None
- rotate_point(xpos: float, ypos: float, angle: float) Tuple[float, float]
Rotates a point around the topleft corner of the component clockwise
- Parameters:
xpos (float) – x coordinate of the point
ypos (float) – y coordinate of the point
angle (float) – angle of rotation in degrees
- Returns:
A tuple containing the rotated coordinates
- Return type:
Tuple[float, float]
- rotate_point_around_center(xpos: float, ypos: float, angle: float) Tuple[float, float]
Rotates a point around the component center clockwise
- Parameters:
xpos (float) – x coordinate of the point
ypos (float) – y coordinate of the point
angle (float) – angle of rotation in degrees
- Returns:
A tuple containing the rotated coordinates
- Return type:
Tuple[float, float]
- property rotation: float
Returns the rotation of the component
- Raises:
KeyError – when no rotation parameter is found
- Returns:
rotation of the component
- Return type:
int
- to_parchmint_v1()
Returns the json dict
- Returns:
dictionary that can be used in json.dumps()
- Return type:
dict
- property xpos: int
returns the x coordinate of the component
- Raises:
KeyError – when no position parameter object is found for the parchmint object
- Returns:
x-coordinate
- Return type:
int
- property ypos: int
Returns the y-coordinate in the parchmint object
- Raises:
KeyError – When no position parameter is found in the parchmint object
- Returns:
y coordinate of the component
- Return type:
int
parchmint.connection module
- class parchmint.connection.Connection(name: str = '', ID: str = '', entity: str = '', source: Target | None = None, sinks: List[Target] | None = None, params: Params = {'data': {}}, layer: Layer | None = None, paths: List[ConnectionPath] | None = None)
Bases:
object
Connection Object represented in parchmint
Connection object encapsulates all types of channels that can be drawn to connect different microfluidic components.
- add_path(path: ConnectionPath) None
Adds a path to the connection
- add_waypoints_path(source: Target, sink: Target, waypoints: List[Tuple[int, int]]) None
Adds a waypoints path to the connection
- static from_parchmint_v1(json_data: Dict, device_ref: Device) Connection
Parses from the json dict
- Parameters:
json (dict) – json dict after json.loads()
- static from_parchmint_v1_2(json_data: Dict, device_ref: Device) Connection
Parses from the json dict
- Parameters:
json (dict) – json dict after json.loads()
- property paths: List[ConnectionPath]
Returns the path in the connection
- Returns:
List of paths in the connection
- Return type:
List[ConnectionPath]
- to_parchmint_v1()
Returns the json dict
- Returns:
dictionary that can be used in json.dumps()
- Return type:
dict
- to_parchmint_v1_2()
Returns the updated json dict
- Returns:
dictionary that can be used in json.dumps()
- Return type:
dict
- class parchmint.connection.ConnectionPath(source: Target, sink: Target, waypoints: List[Tuple[int, int]] | None = None, features: List[Feature] | None = None)
Bases:
object
Describes the connection path which is a member of the connection, it consists of the source and sink targets and a list of waypoints that connect them.
- add_waypoint(x: int, y: int) None
Adds a waypoint to the connection path
- Parameters:
x (int) – x co-ordinate of the waypoint
y (int) – y co-ordinate of the waypoint
- property features: List[Feature]
Returns the features of the connection path
- Returns:
list of features
- Return type:
List[str]
- static from_parchmint_v1_2(json_data: Dict, device_ref: Device) ConnectionPath
Generates the connection path from the json dict for parchmint v1.2
- Parameters:
json_data (Dict) – JSON data dictionary
device_ref (Device) – Reference for parchmint device
- Returns:
Connection path object
- Return type:
- property sink: Target
Returns the sink information of the connection path
- Raises:
Error – No sink was set in the connection path
- Returns:
Sink information
- Return type:
- property source: Target
Returns the source information of the connection path
- Raises:
Error – No source was set in the connection path
- Returns:
Source information
- Return type:
- to_parchmint_v1_2()
Returns the json dict
- Returns:
dictionary that can be used in json.dumps()
- Return type:
dict
- property waypoints: List[Tuple[int, int]]
Returns the waypoints in the connection path
- Returns:
The list of waypoints
- Return type:
List[Tuple[int, int]]
parchmint.device module
- class parchmint.device.Device(name: str = '')
Bases:
object
The device object is the top level object for describing a microfluidic device. It contains the entire list of components, connections and all the relationships between them
- add_component(component: Component) None
Adds a component object to the device
- Parameters:
component (Component) – component to eb added
- Raises:
Exception – if the passed object is not a Component instance
- add_connection(connection: Connection) None
Adds a connection object to the device
- Parameters:
connection (Connection) – connectin to add
- Raises:
Exception – if the arg is not a Connection type object
- add_feature(feature: Feature) None
Adds a feature to the device :param feature: Feature object to be added :type feature: Feature
- add_layer(layer: Layer) None
Adds a layer to the device
- Parameters:
layer (Layer) – layer to be added to the device
- compare(device: Device, compare_params: bool = False) bool
compare against the input device. Return true if they are semnatcally feasible.
- Parameters:
device (Device) – expected device
compare_params (bool) – comparision includes parameter differences. Defaults to False.
- Returns:
If semntically feasible, return true. Else false.
- Return type:
bool
- component_exists(component_id: str) bool
checks if component exists in the device
- Parameters:
component_id (str) – id of the component
- Returns:
true if the component exists
- Return type:
bool
- connection_exists(connection_id: str) bool
checks if connection exists in the device
- Parameters:
connection_id (str) – id of the connection
- Returns:
true if the connection exists
- Return type:
bool
- static from_json(json_str: str) Device
Creates a device from a json string
- Parameters:
json_str (str) – json string
- Returns:
device created from the json string
- Return type:
- static from_parchmint_v1(json_data: Dict) Device
Parses the json string and creates the device for Version = 1.0
- Returns:
JSON Dictionary
- Return type:
dict
- static from_parchmint_v1_2(json_data: Dict) Device
Parses the json string and creates the device for Version = 1.2
- Returns:
JSON Dictionary
- Return type:
dict
- get_component(component_id: str) Component
Returns the component with the corresponding ID
- Parameters:
id (str) – id of the component
- Raises:
Exception – if the component is not found
- Returns:
component with the corresponding id
- Return type:
- get_components() List[Component]
Returns the components in the device
- Returns:
list of components in the device
- Return type:
List[Component]
- get_connection(component_id: str) Connection
Returns the connection with the corresponding id
- Parameters:
id (str) – id of the connection
- Raises:
Exception – if the connection is not found
- Returns:
connection with the corresponding id
- Return type:
- get_connection_between_components(source, sink) Connection
Returns the connection between two components
- Parameters:
- Returns:
connection between the two components
- Return type:
- get_connections() List[Connection]
Returns the connections in the device
- Returns:
list of connections in the device
- Return type:
List[Connection]
- get_connections_for_component(component: Component) List[Connection]
Returns the connections for the given component
- Parameters:
component (Component) – component
- Returns:
list of connections for the given component
- Return type:
List[Connection]
- get_connections_for_edge(source: Component, sink: Component) List[Connection]
Returns the connections for the given edge
- Parameters:
- Returns:
list of connections for the given edge
- Return type:
List[Connection]
- get_feature(feature_id: str) Feature
Returns the feature object with the given name
- Parameters:
name (str) – name of the feature
- Returns:
Feature object with the given name
- Return type:
Feature
- get_layer(layer_id: str) Layer
Returns the layer with the corresponding id
- Parameters:
layer_id (str) – id of the layer
- Raises:
Exception – if a layer with the corresponding id is not present
- Returns:
layer with the corresponding id
- Return type:
- get_name_from_id(component_id: str) str
Returns the name of the component with the corresponding id
- Parameters:
id (str) – id of the object
- Returns:
name of the corresponding object
- Return type:
Optional[str]
- get_valve_connection(valve: Component) Connection
Returns the connection associated with the valve object
- Parameters:
valve (Component) – Valve object for which we are finding the connection
- Returns:
connection object on which the valve is placed
- Return type:
- get_valves() List[Component]
Returns the list of valves in the device
- Returns:
Valve Component Objects
- Return type:
List[Component]
- map_valve(valve: Component, connection: Connection, type_info: ValveType = ValveType.NORMALLY_OPEN) None
Maps the valve to a connection in the device
- Parameters:
valve (Component) – valve component
connection (Connection) – connection on which the valve is mapped
type_info (Optional[ValveType]) – Type informaiton of the valve
- merge_netlist(netlist: Device) None
Merges two netlists together. Currently assumes that both devices have the same ordering of layers
- Parameters:
netlist (Device) – netlist to merge
- remove_component(component_id: str) None
Removes a component object from the device
- Parameters:
component_id (str) – ID of the component to be removed
- Raises:
Exception – Raises the error if the component is not found in the device
- remove_connection(connection_id: str) None
Removes a connection object from the device
- Parameters:
connection_id (str) – ID of the connection to be removed
- Raises:
Exception – Raises the error if the connection is not found in the device
- remove_feature(feature_id: str) None
Removes a feature from the device :param feature_id: ID of the feature to be removed :type feature_id: str
- Raises:
Exception – Raises the error if the feature is not found in the device
- remove_layer(layer_id: str) None
Removes a layer from the device, also removes all the components and connections corresponding to the layer
- Parameters:
layer_id (str) – ID of the layer to be removed
- remove_valve(valve_id) None
Removes the valve entry from the device, also deletes the component from the device’s components
- Parameters:
valve_id (str) – ID of the valve to be removed
- to_parchmint_v1()
Returns the json dict
- Returns:
dictionary that can be used in json.dumps()
- Return type:
dict
- to_parchmint_v1_2() Dict
Generating the parchmint v1.2 of the device
- Returns:
dictionary that can be used in json.dumps()
- Return type:
Dict
- update_valve_type(valve: Component, type_info: ValveType) None
Updates the type of the valve to normally closed or normally open
- static validate_v1(json_str: str) None
Validates the json string against the schema
- Parameters:
json_str (str) – json string
- static validate_v1_2(json_str: str) None
Validates the json string against the schema
- Parameters:
json_str (str) – json string
- property valves: List[Component]
Returns the valve components in the device
- Returns:
List of valve components in the device
- Return type:
List[Component]
- property xspan: int | None
Returns the x span of the device :returns: x span of the device :rtype: int
- property yspan: int | None
Returns the y span of the device :returns: y span of the device :rtype: int
parchmint.layer module
- class parchmint.layer.Layer(layer_id: str | None = None, name: str | None = None, layer_type: str | None = None, group: str | None = None, params: Params | None = None, json_data: Dict | None = None)
Bases:
object
Layer Object
Used to define a layer object that can be used in the device model.
- property ID: str
Returns the ID of the layer
- Raises:
ValueError – if ID is not set
- Returns:
ID of the layer
- Return type:
str
- property layer_type: str
Returns the layer type
- Returns:
layer type
- Return type:
str
- parse_from_json(json_data)
Loads instance data json dict from json.loads()
- Parameters:
json ([type]) – [description]
- to_parchmint_v1()
Returns the json dict
- Returns:
dictionary that can be used in json.dumps()
- Return type:
dict
parchmint.params module
- class parchmint.params.Params(json_data=None)
Bases:
object
Describes the Params object that is used to store the parameters of the component/connection/features/layers
- exists(key: str) bool
Checks if the key exists in the params
- Parameters:
key (str) – key of the param
- Returns:
true if key is present in the params
- Return type:
bool
- get_param(key: str)
Returns the value stored against the key
- Parameters:
key (str) – parameter name
- Returns:
[description]
- Return type:
[type]
- parse_from_json(json)
Parses from the json dict
- Parameters:
json (dict) – json dict after json.loads()
- set_param(key: str, value)
Sets the value for a given key to the param
- Parameters:
key (str) – parameter name
() (value) – value to be stored against the key
- to_parchmint_v1() dict
Returns the json dict
- Returns:
dictionary that can be used in json.dumps()
- Return type:
dict
parchmint.port module
- class parchmint.port.Port(label: str | None = None, layer: str | None = None, x: float = -1, y: float = -1, json_data: Dict | None = None)
Bases:
object
Describes the port on a component
- parse_from_json(json)
Parses the json dict from json.loads()
- Parameters:
json ([dict) – dictionary
- to_parchmint_v1()
Returns the json dict
- Returns:
dictionary that can be used in json.dumps()
- Return type:
dict
- property x: float
Returns the x coordinate of the port
- property y: float
Returns the y coordinate of the port
parchmint.target module
- class parchmint.target.Target(component_id: str | None = None, port: str | None = None, json_data: Dict | None = None)
Bases:
object
Target for Connection Object
- property component: str
Returns the component in the Target
- Returns:
Target component ID
- Return type:
str
- parse_from_json(json)
Loads the instance data from the json dict
- Parameters:
json ([type]) – json dict from json.loads()
- property port: str | None
Returns the port label in the target
- Returns:
port label of the target
- Return type:
Optional[str]
- to_parchmint_v1() dict
Returns the json dict
- Returns:
dictionary that can be used in json.dumps()
- Return type:
dict