files
Path and filename helpers for structure files.
glob_structure_files(input_dir)
Glob for structure files in a directory.
Uses StructureFileExtensions as valid extensions. Does not search recursively.
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.
Uses StructureFileExtensions as potential extensions. Also tries different casing of the PDB ID.
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. |
split_name_and_extension(name)
Split a filename into its name and extension.
.gz is considered part of the extension if present.
Examples:
Some example usages.
>>> from protein_quest.structure.files import split_name_and_extension
>>> split_name_and_extension("1234.pdb")
('1234', '.pdb')
>>> split_name_and_extension("1234.pdb.gz")
('1234', '.pdb.gz')
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The filename to split. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
A tuple containing the name and the extension. |