Skip to content

Commit

Permalink
Uniform compute for wells that have not been qc-ed.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgcam committed Mar 4, 2024
1 parent ce953e3 commit c08cd84
Showing 1 changed file with 21 additions and 37 deletions.
58 changes: 21 additions & 37 deletions lang_qc/db/helper/wells.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,40 +350,18 @@ def _upcoming_wells(self):
)
)

wells = self.session.execute(query).scalars().all()
ids_with_qc_state = products_have_qc_state(
session=self.qcdb_session, ids=[w.id_pac_bio_product for w in wells]
)
wells = [w for w in wells if w.id_pac_bio_product not in ids_with_qc_state]

recent_wells = self.session.execute(query).scalars().all()
wells = self._wells_without_seq_qc_state(recent_wells)
self.total_number_of_items = len(wells) # Save the number of retrieved wells.

return self._well_models(self.slice_data(wells))

def _recent_inbox_wells(self, recent_wells):

inbox_wells_indexes = []
for index, db_well in enumerate(recent_wells):
id_product = db_well.id_pac_bio_product
# TODO: Create a method for retrieving a seq. QC state for a product.
qced_products = get_qc_states_by_id_product_list(
session=self.qcdb_session,
ids=[id_product],
sequencing_outcomes_only=True,
).get(id_product)
if qced_products is None:
inbox_wells_indexes.append(index)

# Save the number of retrieved rows.
self.total_number_of_items = len(inbox_wells_indexes)

inbox_wells = []
# Iterate over indexes of records we want for this page and retrieve data
# for this page.
for index in self.slice_data(inbox_wells_indexes):
inbox_wells.append(recent_wells[index])

return self._well_models(inbox_wells)
wells = self._wells_without_seq_qc_state(recent_wells)
self.total_number_of_items = len(wells)

return self._well_models(self.slice_data(wells))

def _aborted_and_unknown_wells(self, qc_flow_status: QcFlowStatusEnum):

Expand All @@ -402,15 +380,7 @@ def _aborted_and_unknown_wells(self, qc_flow_status: QcFlowStatusEnum):
)

if qc_flow_status == QcFlowStatusEnum.UNKNOWN:
# Remove the wells that the QC team has dealt with.
ids_with_qc_state = products_have_qc_state(
session=self.qcdb_session,
ids=[w.id_pac_bio_product for w in wells],
sequencing_outcomes_only=True,
)
wells = [w for w in wells if w.id_pac_bio_product not in ids_with_qc_state]

# Save the number of retrieved rows.
wells = self._wells_without_seq_qc_state(wells)
self.total_number_of_items = len(wells)

return self._well_models(self.slice_data(wells))
Expand Down Expand Up @@ -441,3 +411,17 @@ def _well_models(
pb_wells.append(pb_well)

return pb_wells

def _wells_without_seq_qc_state(
self,
db_wells_list: List[PacBioRunWellMetrics],
):

ids_with_qc_state = products_have_qc_state(
session=self.qcdb_session,
ids=[w.id_pac_bio_product for w in db_wells_list],
sequencing_outcomes_only=True,
)
return [
w for w in db_wells_list if w.id_pac_bio_product not in ids_with_qc_state
]

0 comments on commit c08cd84

Please sign in to comment.