WayScience / CytoSnake

Orchestrating high-dimensional cell morphology data processing pipelines
https://cytosnake.readthedocs.io
Creative Commons Attribution 4.0 International
3 stars 3 forks source link

Develop a function that searches for plate map based on given plate name. #83

Open axiomcura opened 1 year ago

axiomcura commented 1 year ago

There should be a helper function that makes it easy to locate platemaps. Currently, these functions are written in the scripts like this:

# loading in plate map
logging.info(f"Loading plate data from: {profile}")

logging.info(f"loadding barcodes from: {barcodes_path}")
barcode_platemap_df = pd.read_csv(barcodes_path)

logging.info("Searching plate map name")
plate = pathlib.Path(profile).stem.split(".")[0].split("_")[0]  # noqa

print(plate)
platemap = barcode_platemap_df.query(
    "Assay_Plate_Barcode == @plate"
).Plate_Map_Name.values[0]

# checking if plate map is found
if platemap == "" or platemap is None:
    e_msg = "Unable to find associated plate map"
    logging.error(e_msg)
    raise ValueError(e_msg)

logging.info(f"Plate map found: {platemap}")

The same code block is found repeatedly in every script.

Approach.

The function should do some simple steps: Parameters: (profile_name, barcode_path)

  1. Extract the plate name
  2. load in barcode a search if the name exists (porbably as a dictionary)
  3. develop a new exception unknown plate name or platemapnotfound
  4. if found, return the plate map file path from _paths.yaml

This should also be associated with #41