# 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, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing import Optional, Set
from typing_extensions import Self

class PPIInteractionSchema(BaseModel):
    """
    Schema for a single PPI interaction.
    """ # noqa: E501
    pair_id: StrictStr
    species_scientific_name: Optional[StrictStr] = None
    species_acronym: Optional[StrictStr] = None
    isolate_name: Optional[StrictStr] = None
    protein_a: StrictStr
    protein_b: StrictStr
    participants: List[StrictStr]
    is_self_interaction: Optional[StrictBool] = False
    protein_a_locus_tag: Optional[StrictStr] = None
    protein_a_uniprot_id: Optional[StrictStr] = None
    protein_a_name: Optional[StrictStr] = None
    protein_a_product: Optional[StrictStr] = None
    protein_b_locus_tag: Optional[StrictStr] = None
    protein_b_uniprot_id: Optional[StrictStr] = None
    protein_b_name: Optional[StrictStr] = None
    protein_b_product: Optional[StrictStr] = None
    dl_score: Optional[Union[StrictFloat, StrictInt]] = None
    comelt_score: Optional[Union[StrictFloat, StrictInt]] = None
    perturbation_score: Optional[Union[StrictFloat, StrictInt]] = None
    abundance_score: Optional[Union[StrictFloat, StrictInt]] = None
    melt_score: Optional[Union[StrictFloat, StrictInt]] = None
    secondary_score: Optional[Union[StrictFloat, StrictInt]] = None
    bayesian_score: Optional[Union[StrictFloat, StrictInt]] = None
    string_score: Optional[Union[StrictFloat, StrictInt]] = None
    operon_score: Optional[Union[StrictFloat, StrictInt]] = None
    ecocyc_score: Optional[Union[StrictFloat, StrictInt]] = None
    tt_score: Optional[Union[StrictFloat, StrictInt]] = None
    ds_score: Optional[Union[StrictFloat, StrictInt]] = None
    has_xlms: Optional[StrictBool] = False
    has_string: Optional[StrictBool] = False
    has_operon: Optional[StrictBool] = False
    has_ecocyc: Optional[StrictBool] = False
    evidence_count: Optional[StrictInt] = 0
    __properties: ClassVar[List[str]] = ["pair_id", "species_scientific_name", "species_acronym", "isolate_name", "protein_a", "protein_b", "participants", "is_self_interaction", "protein_a_locus_tag", "protein_a_uniprot_id", "protein_a_name", "protein_a_product", "protein_b_locus_tag", "protein_b_uniprot_id", "protein_b_name", "protein_b_product", "dl_score", "comelt_score", "perturbation_score", "abundance_score", "melt_score", "secondary_score", "bayesian_score", "string_score", "operon_score", "ecocyc_score", "tt_score", "ds_score", "has_xlms", "has_string", "has_operon", "has_ecocyc", "evidence_count"]

    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 PPIInteractionSchema 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 species_scientific_name (nullable) is None
        # and model_fields_set contains the field
        if self.species_scientific_name is None and "species_scientific_name" in self.model_fields_set:
            _dict['species_scientific_name'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "pair_id": obj.get("pair_id"),
            "species_scientific_name": obj.get("species_scientific_name"),
            "species_acronym": obj.get("species_acronym"),
            "isolate_name": obj.get("isolate_name"),
            "protein_a": obj.get("protein_a"),
            "protein_b": obj.get("protein_b"),
            "participants": obj.get("participants"),
            "is_self_interaction": obj.get("is_self_interaction") if obj.get("is_self_interaction") is not None else False,
            "protein_a_locus_tag": obj.get("protein_a_locus_tag"),
            "protein_a_uniprot_id": obj.get("protein_a_uniprot_id"),
            "protein_a_name": obj.get("protein_a_name"),
            "protein_a_product": obj.get("protein_a_product"),
            "protein_b_locus_tag": obj.get("protein_b_locus_tag"),
            "protein_b_uniprot_id": obj.get("protein_b_uniprot_id"),
            "protein_b_name": obj.get("protein_b_name"),
            "protein_b_product": obj.get("protein_b_product"),
            "dl_score": obj.get("dl_score"),
            "comelt_score": obj.get("comelt_score"),
            "perturbation_score": obj.get("perturbation_score"),
            "abundance_score": obj.get("abundance_score"),
            "melt_score": obj.get("melt_score"),
            "secondary_score": obj.get("secondary_score"),
            "bayesian_score": obj.get("bayesian_score"),
            "string_score": obj.get("string_score"),
            "operon_score": obj.get("operon_score"),
            "ecocyc_score": obj.get("ecocyc_score"),
            "tt_score": obj.get("tt_score"),
            "ds_score": obj.get("ds_score"),
            "has_xlms": obj.get("has_xlms") if obj.get("has_xlms") is not None else False,
            "has_string": obj.get("has_string") if obj.get("has_string") is not None else False,
            "has_operon": obj.get("has_operon") if obj.get("has_operon") is not None else False,
            "has_ecocyc": obj.get("has_ecocyc") if obj.get("has_ecocyc") is not None else False,
            "evidence_count": obj.get("evidence_count") if obj.get("evidence_count") is not None else 0
        })
        return _obj


