Improved previous sub finding.

This commit is contained in:
Landon Wark
2024-03-06 15:04:43 -06:00
parent 8b4b39f33e
commit b466cb61d2
14 changed files with 343 additions and 117 deletions

View File

@@ -2,7 +2,8 @@
Gel box for artic quality control
"""
from PyQt6.QtWidgets import (QWidget, QDialog, QGridLayout,
QLabel, QLineEdit, QDialogButtonBox
QLabel, QLineEdit, QDialogButtonBox,
QTextEdit
)
import numpy as np
import pyqtgraph as pg
@@ -44,7 +45,8 @@ class GelBox(QDialog):
# creating image view object
self.imv = pg.ImageView()
img = np.array(Image.open(self.img_path).rotate(-90).transpose(Image.FLIP_LEFT_RIGHT))
self.imv.setImage(img)#, xvals=np.linspace(1., 3., data.shape[0]))
self.imv.setImage(img, scale=None)#, xvals=np.linspace(1., 3., data.shape[0]))
layout = QGridLayout()
layout.addWidget(QLabel("DNA Core Submission Number"),0,1)
self.core_number = QLineEdit()
@@ -59,7 +61,7 @@ class GelBox(QDialog):
self.buttonBox = QDialogButtonBox(QBtn)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
layout.addWidget(self.buttonBox, 22, 5, 1, 1)#, alignment=Qt.AlignmentFlag.AlignTop)
layout.addWidget(self.buttonBox, 23, 1, 1, 1)#, alignment=Qt.AlignmentFlag.AlignTop)
self.setLayout(layout)
def parse_form(self) -> Tuple[str, str|Path, list]:
@@ -70,14 +72,14 @@ class GelBox(QDialog):
Tuple[str, str|Path, list]: output values
"""
dna_core_submission_number = self.core_number.text()
return dna_core_submission_number, self.img_path, self.form.parse_form()
values, comment = self.form.parse_form()
return dna_core_submission_number, self.img_path, values, comment
class ControlsForm(QWidget):
def __init__(self, parent) -> None:
super().__init__(parent)
self.layout = QGridLayout()
columns = []
rows = []
for iii, item in enumerate(["Negative Control Key", "Description", "Results - 65 C", "Results - 63 C", "Results - Spike"]):
@@ -98,6 +100,11 @@ class ControlsForm(QWidget):
widge.setText("Neg")
widge.setObjectName(f"{rows[iii]} : {columns[jjj]}")
self.layout.addWidget(widge, iii+1, jjj+2, 1, 1)
self.layout.addWidget(QLabel("Comments:"), 0,5,1,1)
self.comment_field = QTextEdit(self)
self.comment_field.setFixedHeight(50)
self.layout.addWidget(self.comment_field, 1,5,4,1)
self.setLayout(self.layout)
def parse_form(self) -> List[dict]:
@@ -118,4 +125,4 @@ class ControlsForm(QWidget):
if label[0] not in [item['name'] for item in output]:
output.append(dicto)
logger.debug(pformat(output))
return output
return output, self.comment_field.toPlainText()

View File

@@ -1,8 +1,10 @@
from PyQt6.QtWidgets import (QDialog, QScrollArea, QPushButton, QVBoxLayout, QMessageBox,
QDialogButtonBox, QTextEdit)
from PyQt6.QtWebEngineWidgets import QWebEngineView
from PyQt6.QtCore import Qt
from backend.db.models import BasicSubmission
from PyQt6.QtWebChannel import QWebChannel
from PyQt6.QtCore import Qt, pyqtSlot
from backend.db.models import BasicSubmission, BasicSample
from tools import check_if_app
from .functions import select_save_file
from io import BytesIO
@@ -31,7 +33,7 @@ class SubmissionDetails(QDialog):
self.app = parent.parent().parent().parent().parent().parent().parent()
except AttributeError:
self.app = None
self.setWindowTitle("Submission Details")
self.setWindowTitle(f"Submission Details - {sub.rsl_plate_num}")
# create scrollable interior
interior = QScrollArea()
interior.setParent(self)
@@ -46,19 +48,34 @@ class SubmissionDetails(QDialog):
self.base_dict['platemap'] = sub.make_plate_map()
self.base_dict, self.template = sub.get_details_template(base_dict=self.base_dict)
self.html = self.template.render(sub=self.base_dict)
webview = QWebEngineView()
webview.setMinimumSize(900, 500)
webview.setMaximumSize(900, 500)
webview.setHtml(self.html)
self.webview = QWebEngineView(parent=self)
self.webview.setMinimumSize(900, 500)
self.webview.setMaximumSize(900, 500)
self.webview.setHtml(self.html)
self.layout = QVBoxLayout()
interior.resize(900, 500)
interior.setWidget(webview)
interior.setWidget(self.webview)
self.setFixedSize(900, 500)
# button to export a pdf version
btn = QPushButton("Export PDF")
btn.setParent(self)
btn.setFixedWidth(900)
btn.clicked.connect(self.export)
# setup channel
self.channel = QWebChannel()
self.channel.registerObject('backend', self)
self.webview.page().setWebChannel(self.channel)
@pyqtSlot(str)
def sample_details(self, sample):
# print(f"{string} is in row {row}, column {column}")
# self.webview.setHtml(f"<html><body><br><br>{sample}</body></html>")
sample = BasicSample.query(submitter_id=sample)
base_dict = sample.to_sub_dict(full_data=True)
base_dict, template = sample.get_details_template(base_dict=base_dict)
html = template.render(sample=base_dict)
self.webview.setHtml(html)
# sample.show_details(obj=self)
def export(self):
"""
@@ -130,4 +147,4 @@ class SubmissionComment(QDialog):
full_comment = [{"name":commenter, "time": dt, "text": comment}]
logger.debug(f"Full comment: {full_comment}")
return full_comment

View File

@@ -103,6 +103,7 @@ class SubmissionsSheet(QTableView):
Args:
event (_type_): the item of interest
"""
# logger.debug(event().__dict__)
id = self.selectionModel().currentIndex()
id = id.sibling(id.row(),0).data()
submission = BasicSubmission.query(id=id)