schrodinger.application.matsci.reportutils module¶
Utilities for creating MatSci reports.
Copyright Schrodinger, LLC. All rights reserved.
Bases:
tuple
Alias for field number 1
Alias for field number 0
- class schrodinger.application.matsci.reportutils.ReportInfo(panel, output_dir, base_name, outputs)¶
Bases:
object
Manages information about the report request. Contains user inputs as well as panel data.
- __init__(panel, output_dir, base_name, outputs)¶
Create an instance and store arguments
- Parameters:
panel (af2.App) – The panel for which the report is requested
output_dir (str) – The directory to write the report files in
base_name (str) – The base name for the exported files and folders
outputs (list) – The outputs that the user has requested for the report
- pdfRequested()¶
Determine whether a pdf was requested for the report
- Return type:
bool
- Returns:
Whether a pdf was requested for the report
- imagesRequested()¶
Determine whether images were requested for the report
- Return type:
bool
- Returns:
Whether images were requested for the report
- dataRequested()¶
Determine whether raw data was requested for the report
- Return type:
bool
- Returns:
Whether raw data was requested for the report
- getPDFPath()¶
Get the path to the report pdf file
- Return type:
str
- Returns:
path to the report pdf file
- getCsvFilePath()¶
Get the path to the data csv file
- Return type:
str
- Returns:
path to the data csv file
- getImagesDirPath()¶
Get the path to the images directory
- Return type:
str
- Returns:
path to the images directory
- setFigures(figures)¶
Set the figures for the report
- Parameters:
figures (matplotlib.figure.Figure) – The figures for the report
- okToWrite()¶
Ensure that target files and folders don’t already exist, or if they do, they can be overwritten
- Return type:
bool
- Returns:
Whether we are clear to write
- class schrodinger.application.matsci.reportutils.PDFBuilder(report_info, left_margin=27.0, top_margin=72.0, right_margin=18.0, bottom_margin=72.0)¶
Bases:
object
Contains features shared by all MatSci PDF builder classes.
- __init__(report_info, left_margin=27.0, top_margin=72.0, right_margin=18.0, bottom_margin=72.0)¶
Create a PDFBuilder instance. Store and initialize variables.
- Parameters:
report_info (ReportInfo) – The report information object
left_margin (int) – The left margin for the pdf
top_margin (int) – The top margin for the pdf
right_margin (int) – The right margin for the pdf
bottom_margin (int) – The bottom margin for the pdf
- build()¶
Build the report pdf. Calls methods that should be defined in derived classes to add flowables and footers.
- addFlowables()¶
Add flowables to the pdf, such as headers, titles, paragraphs, tables and images. Should be defined in derived classes.
Add footers. Should be defined in derived classes.
- writeParagraphs(paragraphs)¶
Add the paragraphs to the pdf as flowables.
- Parameters:
paragraphs (list) – A list of strings, each of which should be a paragraph
- addFigure(figure, box_x, box_y)¶
Add the figure to the pdf as a flowable.
- Parameters:
figure (matplotlib.figure.Figure) – The figure to add to the pdf
box_x – The width of the box that the image should be fitted in
box_y – The height of the box that the image should be fitted in
- getTempImageFilename()¶
Get a temporary image file path and add it to the list of files to be cleaned up.
- Return type:
str
- Returns:
A temporary image file path
- cleanupTempFiles()¶
Clean up all the temporary files
- getTableStyle(column_headers=True, row_headers=False, align_center=True)¶
Create a platypus table style based on desired headers and alignment
- Parameters:
column_headers (bool) – Whether the table columns have headers
row_headers (bool) – Whether the table rows have headers
align_center (bool) – Whether align center should be used for all cells
- Return type:
list of tuples
- Returns:
A platypus table style based on desired headers and alignment
- addSpacer()¶
Add a space between the last and next flowables
Bases:
NumberedCanvas
Canvas that automatically adds matsci logo to the header, and allows custom footers in addition to the page number and “Report generated” string.
Create an instance.
Draw fixed pdf contents such as headers, footers and fixed graphics
- class schrodinger.application.matsci.reportutils.ReportOutputsDialog(*args, default_base_name='', report_btn=True, images_btn=True, data_btn=True, **kwargs)¶
Bases:
SDialog
Dialog for allowing the user to specify requested report outputs. Calls the report generation method of the panel when the user accepts.
- DIR_SELECTOR_ID = 'REPORT_UTILS_DIR_SELECTOR_ID'¶
- __init__(*args, default_base_name='', report_btn=True, images_btn=True, data_btn=True, **kwargs)¶
Create an instance.
- Parameters:
report_btn (bool) – Whether PDF Report checkbox should be in the dialog
images_btn (bool) – Whether Plots checkbox should be in the dialog
data_btn (bool) – Whether Data checkbox should be in the dialog
- layOut()¶
Lay out the widgets.
- accept()¶
Get user inputs and call the report generation method of the panel.
- schrodinger.application.matsci.reportutils.save_figure(figure, file_path, panel)¶
Exports the figure to a file, showing an error if it fails.
- Parameters:
figure (matplotlib.figure.Figure) – The figure to export
file_path (str) – The path to the image file to be created
panel (af2.App) – The panel to show any error in
- Return type:
bool
- Returns:
Whether the image export was successful
- schrodinger.application.matsci.reportutils.save_images(report_info)¶
Save all images in the report information object to the output directory
- Parameters:
report_info (ReportInfo) – The report information object containing the figures
- schrodinger.application.matsci.reportutils.sub_script(text, size=10)¶
- Parameters:
text (str or int or float) – The text to write as a subscript
size (int) – The font size of the subscript
- Return type:
str
- Returns:
The text formatted to appear as a subscript in the report
- schrodinger.application.matsci.reportutils.super_script(text, size=10)¶
- Parameters:
text (str or int or float) – The text to write as a superscript
size (int) – The font size of the superscript
- Return type:
str
- Returns:
The text formatted to appear as a superscript in the report
- schrodinger.application.matsci.reportutils.save_matplotlib_figure(figures, pdf_name)¶
Save or Append the matplotlib figure to a pdf
- Parameters:
figures (list) – list of matplotlib figure to be added to the pdf
pdf_name (str) – filename for the pdf file