pestifer.objs.resid module

class pestifer.objs.resid.ResID(*args, resseqnum: int, insertion: str | None = None)[source]

Bases: BaseObj

A class for handling residue numbers and insertion codes. This class is used to represent a residue number and an optional insertion code. It provides methods to split and join residue numbers and insertion codes.

increment(by_seqnum: bool = False) ResID[source]

Increments the insertion code of this ResID object by one. If there is no insertion code, it sets it to ‘A’.

insertion: str | None
static join_ri(resseqnum: int, insertion: str | None = None) str[source]

Joins a residue sequence number and an insertion code into a single string.

Parameters:
  • resseqnum (int) – The residue sequence number, e.g., 123.

  • insertion (str | None) – The insertion code, e.g., A. If there is no insertion code, this should be an empty string or None.

Returns:

str

Return type:

The combined residue number and insertion code as a string.

model_config = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'frozen': False}

Configuration for pydantic.BaseModel.

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.

property pdbresid: str

Returns the residue number and insertion code in a format suitable for PDB files. If there is no insertion code, it returns just the residue number as a string.

property resid: str | int

Returns the residue number and insertion code as a string, or if there is no insertion code, returns just the residue number as an integer. This is equivalent to the string representation of the ResID object.

resseqnum: int
static split_ri(ri) tuple[int, str | None][source]

A simple utility function for splitting the integer resid and 1-byte insertion code out of a string resid-insertion code concatenation

Parameters:

ri (str) – the string representation of a residue number, e.g., 123A or 123

Returns:

tuple[int, str | None]

Return type:

the integer resid and the 1-byte insertion code or None if none

class pestifer.objs.resid.ResIDList(*args, **kwargs)[source]

Bases: BaseObjList[ResID]

A list of ResID objects. This class is used to handle a list of residue numbers and insertion codes. It inherits from BaseObjList and provides methods to describe the list.

describe() str[source]

Describe the ResIDList.

Returns:

A string description of the ResIDList, including the number of residues.

Return type:

str

static ri_range(val, split_chars: tuple[str] = ('-', '#')) tuple[ResID][source]

Splits a string representation of a range of residue numbers into a list of residue numbers. The string can contain multiple ranges separated by characters in split_chars. The ranges can be specified as a single residue number, a range of residue numbers (e.g., 123-456), or a range of residue numbers with insertion codes (e.g., 123A-456B).

Parameters:
  • val (str) – The string representation of the residue number range.

  • split_chars (list of str, optional) – A list of characters that can be used to split the string into multiple ranges. Defaults to [‘-’, ‘#’].

Returns:

tuple of ResID

Return type:

A tuple of residue instances, e.g., (ResID(‘123’), ResID(‘124’), ResID(‘125A’), ResID(‘126B’)).