pyCADD.utils package

Submodules

pyCADD.utils.common module

class pyCADD.utils.common.BaseFile(path: str)[source]

Bases: object

class pyCADD.utils.common.ChDir(path: str = None, exist: bool = False, delete=False)[source]

Bases: object

class pyCADD.utils.common.File(path: str, exist: bool = True)[source]

Bases: BaseFile

class pyCADD.utils.common.FixedConfig(defaults=None)[source]

Bases: ConfigParser

optionxform(optionstr)[source]
class pyCADD.utils.common.FixedThread(*args, **kwargs)[source]

Bases: Thread

join()[source]

Wait until the thread terminates.

This blocks the calling thread until the thread whose join() method is called terminates – either normally or through an unhandled exception or until the optional timeout occurs.

When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call is_alive() after join() to decide whether a timeout happened – if the thread is still alive, the join() call timed out.

When the timeout argument is not present or None, the operation will block until the thread terminates.

A thread can be join()ed many times.

join() raises a RuntimeError if an attempt is made to join the current thread as that would cause a deadlock. It is also an error to join() a thread before it has been started and attempts to do so raises the same exception.

run()[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

exception pyCADD.utils.common.TimeoutError[source]

Bases: Exception

pyCADD.utils.env module

pyCADD.utils.log module

class pyCADD.utils.log.ModifiedFileHandler(filename: str, mode: str = 'a', maxBytes: int = 0, backupCount: int = 0, encoding: str | None = None, debug: bool = False, delay: None = None, use_gzip: bool = False, owner: Tuple[str, str] | None = None, chmod: int | None = None, umask: int | None = None, newline: str | None = None, terminator: str = '\n', unicode_error_policy: str = 'ignore', lock_file_directory: str | None = None)[source]

Bases: ConcurrentRotatingFileHandler

emit(record)[source]

Emit a record.

Override from parent class to handle file locking for the duration of rollover and write. This also does the formatting before locks are obtained, in case the format itself does logging calls from within. Rollover also occurs while the lock is held.

pyCADD.utils.log.get_logfile_name()[source]

Get log file name. Generate log file name based on current date.

Returns:

str: log file name

pyCADD.utils.tool module

pyCADD.utils.tool.download_pdb(pdbid: str, save_dir: str = None, overwrite: bool = False) None[source]

Download a PDB file from RCSB PDB.

Args:

pdbid (str): PDB ID to download save_dir (str, optional): directory to save the pdb file. Defaults to current working directory. overwrite (bool, optional): whether to overwrite the pdb file when it exists. Defaults to False.

pyCADD.utils.tool.download_pdb_list(pdblist: list, save_dir: str = None, overwrite: bool = False) None[source]

Download a list of PDB files from RCSB PDB.

Args:

pdblist (list): a list of PDB IDs to download save_dir (str, optional): directory to save the pdb files. Defaults to current working directory. overwrite (bool, optional): whether to overwrite the pdb files when they exist. Defaults to False.

pyCADD.utils.tool.is_amber_available() bool[source]

Check if AMBER is available in the PATH.

Returns:

bool: True if AMBER is available, False otherwise

pyCADD.utils.tool.is_gaussian_available() bool[source]

Check if Gaussian is available in the PATH.

Returns:

bool: True if Gaussian is available, False otherwise

pyCADD.utils.tool.is_multiwfn_available() bool[source]

Check if Multiwfn is available in the PATH.

Returns:

bool: True if Multiwfn is available, False otherwise

pyCADD.utils.tool.is_pmemd_cuda_available() bool[source]

Check if pmemd.cuda is available in the PATH.

Returns:

bool: True if pmemd.cuda is available, False otherwise

pyCADD.utils.tool.makedirs_from_list(dir_list: list) None[source]

Make directories from a list.

Args:

dir_list (list): list of required directory names

pyCADD.utils.tool.multiprocessing_run(func: Callable, iterable: Iterable, job_name: str, num_parallel: int, total_task_num: int = None, timeout: int = None, **kwargs) list[source]

Run a function in parallel using multiprocessing.

Args:

func (Callable): the function to run in parallel iterable (Iterable): the iterable to pass to the function. e.g [1, 2, 3] or [(1, 2), (3, 4)]

Each item in the iterable will be considered as a single argument if it is not a tuple. Otherwise, the item will be unpacked to multiple arguments and passed to the function.

job_name (str): the job name to display in the progress bar num_parallel (int): cpu core number total_task_num (int, optional): total number of tasks. If None, it will be set to the length of the iterable, and raise an exception if the iterable has no len(). timeout (int, optional): timeout for each function call. Defaults to None. kwargs: additional keyword arguments to pass to the function

Returns:

list: a list of return values from the function

pyCADD.utils.tool.shell_run(command: str, timeout: int = None) str[source]

Run a shell command.

Args:

command (str): shell command to run timeout (int, optional): timeout for the command. Defaults to None.

Returns:

str: command output

pyCADD.utils.tool.timeit(func: Callable)[source]

Decorator to measure the execution time of a function.

Args:

func (Callable): the function to measure the execution time

Returns:

wrapper: a wrapper function

pyCADD.utils.ui module

class pyCADD.utils.ui.UI(menu_name: str = 'Main')[source]

Bases: object

pyCADD程序用户交互界面(user interface)

property basic_info: None

基础信息

clear_info()[source]

清空额外信息内容

create_panel(options: list = None, additional_info: str | dict = None, options_label: str = 'Analysis Options', show_panel: bool = True) None[source]

建立并渲染UI Parameters ———- options : list

选项框内容

additional_infostr | dict

选项框上方的额外信息 传入字典时 可用于修改已存在的同key信息内容

options_labelstr

选项框标签名

show_panelbool

是否显示UI

get_confirm(text: str, default=True)[source]

读取输入指令 返回确认值

get_input(text: str, choices: list = None, default=None, show_default: bool = True, show_choices: bool = False)[source]

读取输入指令 返回flag

property info_index
property system_info: None

系统基本信息

property title: None

程序标题样式

property version_info: None

版本信息

Module contents