Skip to content

System Bio Model

An abstract base class for Models in the Models.

SysBioModel

Bases: ABC, BaseModel

Abstract base class for Models in the data section, allowing different mathematical approaches to be implemented in subclasses.

This class enforces a standard interface for models working with SBML (Systems Biology Markup Language) files.

Source code in vpeleaderboard/data/src/sys_bio_model.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class SysBioModel(ABC, BaseModel):
    """
    Abstract base class for Models in the data section, allowing
    different mathematical approaches to be implemented in subclasses.

    This class enforces a standard interface for models working
    with SBML (Systems Biology Markup Language) files.
    """
    sbml_file_path: Optional[str] = Field(None, description="Path to an SBML file")
    name: Optional[str] = Field(..., description="Name of the model")
    description: Optional[str] = Field("", description="Description of the model")

    @model_validator(mode="after")
    def validate_sbml_file_path(self):
        """
        Ensure the SBML directory contains valid XML files.

        Args:
            sbml_file_path (str): The path to the SBML folder.

        Raises:
            ValueError: If the SBML directory does not exist or contains no XML files
        """
        if not self.sbml_file_path:
            raise ValueError("sbml_file_path must be provided.")
        return self
    @abstractmethod
    def get_model_metadata(self) -> pd.DataFrame:
        """
        Abstract method to retrieve metadata of the SBML model.

        This method must be implemented in subclasses to extract and return
        relevant details about the SBML model, such as its structure, components,
        and parameters.

        Returns:
            pd.DataFrame: A pandas DataFrame containing the metadata of the model.
        """

get_model_metadata() abstractmethod

Abstract method to retrieve metadata of the SBML model.

This method must be implemented in subclasses to extract and return relevant details about the SBML model, such as its structure, components, and parameters.

Returns:

Type Description
DataFrame

pd.DataFrame: A pandas DataFrame containing the metadata of the model.

Source code in vpeleaderboard/data/src/sys_bio_model.py
37
38
39
40
41
42
43
44
45
46
47
48
@abstractmethod
def get_model_metadata(self) -> pd.DataFrame:
    """
    Abstract method to retrieve metadata of the SBML model.

    This method must be implemented in subclasses to extract and return
    relevant details about the SBML model, such as its structure, components,
    and parameters.

    Returns:
        pd.DataFrame: A pandas DataFrame containing the metadata of the model.
    """

validate_sbml_file_path()

Ensure the SBML directory contains valid XML files.

Parameters:

Name Type Description Default
sbml_file_path str

The path to the SBML folder.

required

Raises:

Type Description
ValueError

If the SBML directory does not exist or contains no XML files

Source code in vpeleaderboard/data/src/sys_bio_model.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
@model_validator(mode="after")
def validate_sbml_file_path(self):
    """
    Ensure the SBML directory contains valid XML files.

    Args:
        sbml_file_path (str): The path to the SBML folder.

    Raises:
        ValueError: If the SBML directory does not exist or contains no XML files
    """
    if not self.sbml_file_path:
        raise ValueError("sbml_file_path must be provided.")
    return self