Skip to content

io

glob_structure_files(input_dir)

Glob for structure files in a directory.

Parameters:

Name Type Description Default
input_dir Path

The input directory to search for structure files.

required

Yields:

Type Description
Generator[Path]

Paths to the found structure files.

locate_structure_file(root, pdb_id)

Locate a structure file for a given PDB ID in the specified directory.

Parameters:

Name Type Description Default
root Path

The root directory to search in.

required
pdb_id str

The PDB ID to locate.

required

Returns:

Type Description
Path

The path to the located structure file.

Raises:

Type Description
FileNotFoundError

If no structure file is found for the given PDB ID.

nr_residues_in_chain(file, chain='A')

Returns the number of residues in a specific chain from a mmCIF/pdb file.

Parameters:

Name Type Description Default
file Path | str

Path to the input mmCIF/pdb file.

required
chain str

Chain to count residues of.

'A'

Returns:

Type Description
int

The number of residues in the specified chain.

write_single_chain_pdb_file(input_file, chain2keep, output_dir, out_chain='A')

Write a single chain from a mmCIF/pdb file to a new mmCIF/pdb file.

Parameters:

Name Type Description Default
input_file Path

Path to the input mmCIF/pdb file.

required
chain2keep str

The chain to keep.

required
output_dir Path

Directory to save the output file.

required
out_chain str

The chain identifier for the output file.

'A'

Returns:

Type Description
Path | None

Path to the output mmCIF/pdb file or None if not created.

write_structure(structure, path)

Write a gemmi structure to a file.

Parameters:

Name Type Description Default
structure Structure

The gemmi structure to write.

required
path Path

The file path to write the structure to. The format depends on the file extension. Supported extensions are .pdb, .pdb.gz, .cif, .cif.gz.

required

Raises:

Type Description
ValueError

If the file extension is not supported.