ample.util.ample_util module

Various miscellaneous functions

exception FileNotFoundError[source]

Bases: exceptions.Exception

amoptd_fix_path(optd, newroot, i2mock=False)[source]

Update all the paths in an AMPLE results dictionary to be rooted at newroot

Parameters:
optd: dict

AMPLE results dictionary

newroot: str

Path to the AMPLE root directory (topdir containing MRBUMP dir etc.)

ccp4_version()[source]

Get CCP4 version as a tuple

Returns:
version : tuple

Major, minor, and revision number

construct_references(optd)[source]

Construct the reference list

Parameters:
optd : dict

A dictionary containing AMPLE options

Returns:
str

A string containing the references

extract_models(amoptd, sequence=None, single=True, allsame=True)[source]

Extract some models

extract_tar(filename, directory, suffixes=[‘.pdb’])[source]
extract_zip(filename, directory, suffixes=[‘.pdb’])[source]
filename_append(filename=None, astr=None, directory=None, separator=’_’)[source]

Append astr to filename, before the suffix, and return the new filename.

find_exe(executable, dirs=None)[source]

Find the executable exename.

Parameters:
executable : str

The name of the program or the path to an existing executable

dirs : list, tuple, optional

Additional directories to search for the location

ideal_helices(optd)[source]

Get some ideal helices

Parameters:
nresidues : int

Number of residues to be used

Returns:
pdbs : list
ensemble_options : dict
ensembles_data : list
is_exe(fpath)[source]

Check if an executable exists

Parameters:
fpath : str

The path to the executable

Returns:
bool
is_file(fpath)[source]

Check if a file exists

Parameters:
fpath : str

The path to the file

Returns
——
bool
make_workdir(run_dir, ccp4i2=False)[source]

Make a work directory rooted at run_dir and return its path

Parameters:
run_dir : str

The path to a run directory where the job was started

ccp4i2 : bool, optional

Indicate if we are running under CCP4I2

Returns:
work_dir : str

The path to the working directory

read_amoptd(amoptd_fname)[source]

Read a PICKLE-formatted AMPLE options file

Parameters:
amoptd_fname : str

The path to the PICKLE-formatted AMPLE options file

Returns:
amoptd : dict

AMPLE options from saved state

run_command(cmd, logfile=None, directory=None, dolog=True, stdin=None, check=False, **kwargs)[source]

Execute a command and return the exit code.

Parameters:
cmd : list

Command to run as a list

stdin : str, optional

Stdin for the command

logfile : str, optional

The path to the logfile

directory : str, optional

The directory to run the job in (cwd assumed)

dolog : bool, optional

Whether to output info to the system log [default: False]

Returns:
returncode : int

Subprocess exit code

Notes

We take care of outputting stuff to the logs and opening/closing logfiles

saveAmoptd(*args)[source]

Save AMPLE options to a PICKLE-formatted file

Warning

This function was deprecated and will be removed in future releases. Please use save_amoptd() instead.

See also

save_amoptd

save_amoptd(amoptd)[source]

Save AMPLE options to a PICKLE-formatted file

Parameters:
amoptd : dict

AMPLE options from saved state

split_models(dfile, directory)[source]

Split a single PDB with multiple models in individual PDB files

Parameters:
dfile : str

Single PDB file with multiple model entries

directory : str

Directory to extract the PDB files to

Returns:
extracted_models : list

List of PDB files for all models

split_quark(*args)[source]

Split a single PDB with multiple models in individual PDB files

See also

split_models

tmpFileName()[source]

Return a filename for a temporary file

Warning

This function was deprecated and will be removed in future releases. Please use tmp_file_name() instead.

See also

tmp_file_name

tmp_file_name(delete=True, directory=None, suffix=”)[source]

Return a filename for a temporary file

Parameters:
delete : bool, optional

Flag whether the temporary file should be deleted [default: True]

directory : str, optional

Path to a directory to write the files to.

suffix : str, optional

A suffix to the temporary filename