# coding: utf-8

"""
    ME TT DataPortal Data Portal API

    ME TT DataPortal Data Portal APIs to fetch Gut Microbes Genomes / Genes information.

    The version of the OpenAPI document: 1.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class SearchRequestSchema(BaseModel):
    """
    SearchRequestSchema
    """ # noqa: E501
    database: StrictStr = Field(description="Database identifier (consolidated or isolate-specific)")
    threshold: StrictStr
    threshold_value: Union[StrictFloat, StrictInt]
    input: StrictStr
    mx: Optional[StrictStr] = None
    e: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="E")
    dom_e: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="domE")
    inc_e: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="incE")
    incdom_e: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="incdomE")
    t: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="T")
    dom_t: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="domT")
    inc_t: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="incT")
    incdom_t: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="incdomT")
    popen: Optional[Union[Annotated[float, Field(strict=True, ge=0)], Annotated[int, Field(strict=True, ge=0)]]] = Field(default=0.02, description="Gap open penalty")
    pextend: Optional[Union[Annotated[float, Field(strict=True, ge=0)], Annotated[int, Field(strict=True, ge=0)]]] = Field(default=0.4, description="Gap extend penalty")
    __properties: ClassVar[List[str]] = ["database", "threshold", "threshold_value", "input", "mx", "E", "domE", "incE", "incdomE", "T", "domT", "incT", "incdomT", "popen", "pextend"]

    @field_validator('threshold')
    def threshold_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['evalue', 'bitscore']):
            raise ValueError("must be one of enum values ('evalue', 'bitscore')")
        return value

    @field_validator('mx')
    def mx_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['BLOSUM62', 'BLOSUM45', 'BLOSUM90', 'PAM30', 'PAM70', 'PAM250']):
            raise ValueError("must be one of enum values ('BLOSUM62', 'BLOSUM45', 'BLOSUM90', 'PAM30', 'PAM70', 'PAM250')")
        return value

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of SearchRequestSchema from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # set to None if mx (nullable) is None
        # and model_fields_set contains the field
        if self.mx is None and "mx" in self.model_fields_set:
            _dict['mx'] = None

        # set to None if e (nullable) is None
        # and model_fields_set contains the field
        if self.e is None and "e" in self.model_fields_set:
            _dict['E'] = None

        # set to None if dom_e (nullable) is None
        # and model_fields_set contains the field
        if self.dom_e is None and "dom_e" in self.model_fields_set:
            _dict['domE'] = None

        # set to None if inc_e (nullable) is None
        # and model_fields_set contains the field
        if self.inc_e is None and "inc_e" in self.model_fields_set:
            _dict['incE'] = None

        # set to None if incdom_e (nullable) is None
        # and model_fields_set contains the field
        if self.incdom_e is None and "incdom_e" in self.model_fields_set:
            _dict['incdomE'] = None

        # set to None if t (nullable) is None
        # and model_fields_set contains the field
        if self.t is None and "t" in self.model_fields_set:
            _dict['T'] = None

        # set to None if dom_t (nullable) is None
        # and model_fields_set contains the field
        if self.dom_t is None and "dom_t" in self.model_fields_set:
            _dict['domT'] = None

        # set to None if inc_t (nullable) is None
        # and model_fields_set contains the field
        if self.inc_t is None and "inc_t" in self.model_fields_set:
            _dict['incT'] = None

        # set to None if incdom_t (nullable) is None
        # and model_fields_set contains the field
        if self.incdom_t is None and "incdom_t" in self.model_fields_set:
            _dict['incdomT'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of SearchRequestSchema from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "database": obj.get("database"),
            "threshold": obj.get("threshold"),
            "threshold_value": obj.get("threshold_value"),
            "input": obj.get("input"),
            "mx": obj.get("mx"),
            "E": obj.get("E"),
            "domE": obj.get("domE"),
            "incE": obj.get("incE"),
            "incdomE": obj.get("incdomE"),
            "T": obj.get("T"),
            "domT": obj.get("domT"),
            "incT": obj.get("incT"),
            "incdomT": obj.get("incdomT"),
            "popen": obj.get("popen") if obj.get("popen") is not None else 0.02,
            "pextend": obj.get("pextend") if obj.get("pextend") is not None else 0.4
        })
        return _obj


