# coding: utf-8

"""
    seqq

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 0.0.18
    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 datetime import datetime
from pydantic import BaseModel, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from seqq.models.v1alpha_code import V1alphaCode
from typing import Optional, Set
from typing_extensions import Self

class V1alphaSequence(BaseModel):
    """
    Sequence is a single entry containing nucleotides or amino acids and other optional metadata like a description, creation time, and taxonomy ID.
    """ # noqa: E501
    name: Optional[StrictStr] = Field(default=None, description="Name of the Sequence. Format: `collections/{collection_id}/sequences/{sequence_id}`.")
    collection: Optional[StrictStr] = Field(default=None, description="The `name` of the Collection the Sequence belongs to. Format: `collections/{collection_id}`.")
    sequence: StrictStr = Field(description="A sequence of nucleotides or amino acids. Only characters in the IUPAC alphabets are allowed.")
    code: Optional[V1alphaCode] = None
    taxonomy_id: Optional[StrictStr] = Field(default=None, description="The taxonomy ID of the sequence in NCBI's Taxonomy database. This can be used to filter BLAST search results.", alias="taxonomyId")
    create_time: Optional[datetime] = Field(default=None, description="The time that the Sequence was created. This is set once on creation by the server.", alias="createTime")
    etag: Optional[StrictStr] = Field(default=None, description="An opaque, server-assigned value that is a hash of all other fields in the Sequence resource. This is used during deletes to ensure stale Sequences are excluded from Search responses.")
    description: Optional[StrictStr] = Field(default=None, description="A description of the Sequence. For Sequences from FASTA files, this is the entire description line without the leading \">\". For Sequences from GenBank files, this is from the Description field.")
    __properties: ClassVar[List[str]] = ["name", "collection", "sequence", "code", "taxonomyId", "createTime", "etag", "description"]

    model_config = {
        "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 V1alphaSequence 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.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        """
        excluded_fields: Set[str] = set([
            "collection",
            "create_time",
            "etag",
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "name": obj.get("name"),
            "collection": obj.get("collection"),
            "sequence": obj.get("sequence"),
            "code": obj.get("code"),
            "taxonomyId": obj.get("taxonomyId"),
            "createTime": obj.get("createTime"),
            "etag": obj.get("etag"),
            "description": obj.get("description")
        })
        return _obj


