The proto-Nucleic-Acid Builder (pNAB)
|
A file for displaying widgets in the Jupyter notebook. More...
Functions | |
def | view_nglview (molecule, label=False) |
Display molecules using the NGLView viewer. More... | |
def | fixed_bonds (num_bonds, num_atoms, param) |
Display widgets for determining indices of fixed bonds. More... | |
def | path (file_path, param) |
Display backbone to Jupyter notebook given a file path. More... | |
def | upload_backbone (f, param) |
Upload a backbone file to Jupyter notebook. More... | |
def | backbone (param) |
Main backbone widget for use in Jupyter notebook. More... | |
def | base_path (file_path, param, base_number) |
Display base to Jupyter notebook given a file path. More... | |
def | upload_base (f, param, base_number) |
Upload a base file to Jupyter notebook. More... | |
def | add_base (number_of_bases, param) |
Display widgets to upload the requested number of bases. More... | |
def | bases (param) |
Bases widget for use in Jupyter notebook. More... | |
def | helical_parameters (param) |
def | algorithm (chosen_algorithm, param) |
Display search parameters based on the chosen algorithm. More... | |
def | runtime_parameters (param) |
Runtime parameter widget for use in Jupyter notebook. More... | |
def | upload_input (param, f) |
Widget to upload an input file. More... | |
def | display_options_widgets (param, input_file, uploaded=False) |
Display all widgets in Jupyter notebook given an input file. More... | |
def | user_input_file (param) |
Display input file options. More... | |
def | run (button) |
Function to run the code when the user finishes specifying all options. More... | |
def | extract_options () |
Extracts user options from the widgets. More... | |
def | single_result (result, header, results, prefix) |
Interactive function to display a single result. More... | |
def | show_results (results, header, prefix) |
Display results. More... | |
def | builder () |
The function called from the Jupyter notebook to display the widgets. More... | |
Variables | |
dictionary | input_options = {} |
Stores the widgets corresponding to the user-defined options. More... | |
A file for displaying widgets in the Jupyter notebook.
This file containts widgets for sepecifying options in the Jupyter notebook using the ipywidgets library (https://github.com/jupyter-widgets/ipywidgets). Using Jupyter notebook is not necessary for using the program, as the program can be run in as a python script. However, the widgets provide a graphical user interface for making input files, running the code, and displaying the results. The Jupyter notebook can be run locally or on the clouds using Binder (https://mybinder.org/v2/gh/alenaizan/pnab/master?filepath=binder).
The widgets have four main components: Backbone, Bases, Helical Parameters, and Runtime Parameters. The Bases section does not require the user input but displays some information about the available nucleobases in the library. The NGLView library is used for visualization
To run the widgets from a Jupyter notebook, simply execute the following:
def jupyter_widgets.add_base | ( | number_of_bases, | |
param | |||
) |
Display widgets to upload the requested number of bases.
number_of_bases | (int) The number of additional bases to define |
param | (dict) options._options_dict['Base'] and dictionaries for the other defined bases |
def jupyter_widgets.algorithm | ( | chosen_algorithm, | |
param | |||
) |
Display search parameters based on the chosen algorithm.
There are six search algorithms and each one has a set of input parameters. The search algorithms are:
chosen_algorithm | (str) The chosen algorithm |
param | (dict) options._options_dict['RuntimeParameters'] |
def jupyter_widgets.backbone | ( | param | ) |
Main backbone widget for use in Jupyter notebook.
This function displays the backbone widgets.
param | (dict) options._options_dict['Backbone'] |
def jupyter_widgets.base_path | ( | file_path, | |
param, | |||
base_number | |||
) |
Display base to Jupyter notebook given a file path.
This function displays the options for the base. If the file_path does not exist, this function displays nothing.
file_path | (str) Path to a file containing the 3D structure of the base molecule |
param | (dict) options._options_dict['Base'] |
base_number | The number of the new base |
def jupyter_widgets.bases | ( | param | ) |
Bases widget for use in Jupyter notebook.
This function displays information on the available nucleobases that are defined in the program. The bases are defined in "data/bases_library.yaml"
def jupyter_widgets.builder | ( | ) |
The function called from the Jupyter notebook to display the widgets.
Execute the following to display all the widgets in the notebook
def jupyter_widgets.display_options_widgets | ( | param, | |
input_file, | |||
uploaded = False |
|||
) |
Display all widgets in Jupyter notebook given an input file.
If input_file is provided, then it updates the default options in options._options_dict to display the user-defined options. If input_file is "Upload file", then an ipywidgets.FileUpload widget is displayed. This function also displays a widget for running the program after the user defines all the options.
param | (dict) options._options_dict |
input_file | (str) Input file |
uploaded | (bool) Whether a file is uploaded by the user or not |
def jupyter_widgets.extract_options | ( | ) |
Extracts user options from the widgets.
This function extracts the values of all options specifed by the user. It access all the widgets in jupyter_widgets.input_options and extracts their values.
def jupyter_widgets.fixed_bonds | ( | num_bonds, | |
num_atoms, | |||
param | |||
) |
Display widgets for determining indices of fixed bonds.
This function is changed interactively bases on the number of fixed bonds requested by the user.
num_bonds | (int) number of fixed bonds; changed dynamically by the user |
num_atoms | (int) number of atoms in the backbone |
param | (dict) options._options_dict['Backbone'] |
def jupyter_widgets.helical_parameters | ( | param | ) |
Display widgets for specifying helical parameters. It also displays an image illustrating the used helical parameters. @param param (dict) @a options._options_dict['HelicalParameters'] @returns None; @a jupyter_widgets.input_options is modified in place @sa input_options @sa display_options_widgets @sa options._options_dict
def jupyter_widgets.path | ( | file_path, | |
param | |||
) |
Display backbone to Jupyter notebook given a file path.
This function displays the options for the backbone. If the file_path does not exist, this function displays nothing.
file_path | (str) Path to a file containing the 3D structure of a backbone molecule |
param | (dict) options._options_dict['Backbone'] |
def jupyter_widgets.run | ( | button | ) |
Function to run the code when the user finishes specifying all options.
It extracts the user-defined options and creates a pNAB.pNAB instance. Then, it run the code and display the results.
button | (variable) variable for using the widgets.Button.on_click method |
def jupyter_widgets.runtime_parameters | ( | param | ) |
Runtime parameter widget for use in Jupyter notebook.
Displays widgets for specifying runtime parameters.
param | (dict) options._options_dict['RuntimeParameters'] |
def jupyter_widgets.show_results | ( | results, | |
header, | |||
prefix | |||
) |
Display results.
A function to display all the accepted candidates using a dropdown list.
results | (np.ndarray) numpy array of results sorted by total energy |
header | (str) A comma separated string of the output properties of the conformer |
prefix | (dict) A dictionary of the prefix of the run and the associated helical configuration |
def jupyter_widgets.single_result | ( | result, | |
header, | |||
results, | |||
prefix | |||
) |
Interactive function to display a single result.
It displays one accepted conformer and prints its energies and other properties.
result | (int) index of the conformer in the results array |
header | (str) A comma separated string of the output properties of the conformer |
results | (np.ndarray) a numpy array of all the accepted conformers |
prefix | (dict) A dictionary of the prefix of the run and the associated helical configuration |
def jupyter_widgets.upload_backbone | ( | f, | |
param | |||
) |
Upload a backbone file to Jupyter notebook.
This function is used to upload a backbone file and write it. If a file is already specified, then the backbone is displayed. If a file is uploaded, this function writes the file to the current working directory. Then, the function calls the jupyter_widgets.path function interactively with the backbone file path.
f | (ipywidgets.FileUpload) File upload widget |
param | (dict) options._options_dict['Backbone'] |
def jupyter_widgets.upload_base | ( | f, | |
param, | |||
base_number | |||
) |
Upload a base file to Jupyter notebook.
This function is used to upload a base file and write it. If a file is already specified, then the base is displayed. If a file is uploaded, this function writes the file to the current working directory. Then, the function calls the jupyter_widgets.base_path function interactively with the base file path.
f | (ipywidgets.FileUpload) File upload widget |
param | (dict) options._options_dict['Base'] for the appropriate base number |
base_number | (int) The number of the additional base |
def jupyter_widgets.upload_input | ( | param, | |
f | |||
) |
Widget to upload an input file.
If a file is uploaded, it is written in the current working directory. Then, this function calls jupyter_widgets.display_options_widgets function with the newly written file.
param | (dict) options._options_dict |
f | (ipywidgets.FileUpload) file upload widget |
def jupyter_widgets.user_input_file | ( | param | ) |
Display input file options.
Gives the user several input files that they can try, and the option that they upload their input file. Once an input file is chosen, all widgets are displayed with the user-defined options.
param | (dict) options._options_dict |
def jupyter_widgets.view_nglview | ( | molecule, | |
label = False |
|||
) |
Display molecules using the NGLView viewer.
A function to view molecules using the NGLView project (https://github.com/arose/nglview). It is used to display the geometry of the backbone with atom index labels. It is also used to display accepted nucleic acid candidates generated after the search. For backbone molecules, the number of atoms in the backbone is computed here and returned to be used for bounding the displayed atomic indices in backbone widgets.
molecule | (str) Path to a file containing the 3D structure of the molecule |
label | (bool) Whether to display atom index labels |
dictionary jupyter_widgets.input_options = {} |
Stores the widgets corresponding to the user-defined options.
This dictionary has the same structure as the options._options_dict dictionary that has all the available options for the code. The widgets are added to this dictionary and the values of the widgets are extracted when the user runs the code