from pathlib import Path

DATA_DIR = Path(__file__).parent / "data"

ACCESSION_NUMBER = "accession_number"
MIRRI_ACCESSION_NUMBER = 'mirri_accession_number'
RESTRICTION_ON_USE = "restriction_on_use"
NAGOYA_PROTOCOL = "nagoya_protocol"
ABS_RELATED_FILES = "abs_related_files"
MTA_FILES = "mta_file"
OTHER_CULTURE_NUMBERS = "other_culture_collection_numbers"
STRAIN_FROM_REGISTERED_COLLECTION = "strain_from_a_registered_collection"
RISK_GROUP = "risk_group"
DUAL_USE = "dual_use"
QUARANTINE = "quarantine"
ORGANISM_TYPE = "organism_type"
TAXON_NAME = "taxon_name"
TYPE = "type"
INFRASUBSPECIFIC_NAME = "infrasubspecific_names"
COMMENTS_ON_TAXONOMY = "comments_on_taxonomy"
STATUS = "status"
HISTORY_OF_DEPOSIT = "history_of_deposit"
DEPOSITOR = "depositor"
DATE_OF_DEPOSIT = "date_of_deposit"
COLLECTED_BY = "collected_by"
DATE_OF_COLLECTION = "date_of_collection"
ISOLATED_BY = "isolated_by"
DATE_OF_ISOLATION = "date_of_isolation"
DATE_OF_INCLUSION = "date_of_inclusion_on_catalog"
TESTED_TEMPERATURE_GROWTH_RANGE = "tested_temperature_growth_range"
RECOMMENDED_GROWTH_TEMP = "recommended_growth_temperature"
RECOMMENDED_GROWTH_MEDIUM = "recommended_media_for_growth"
FORM_OF_SUPPLY = "form_of_supply"
GEO_COORDS = "coordinates_of_geographic_origin"
ACCESSION_NAME = "other_denomination"
ALTITUDE = "altitude_of_geographic_origin"
GEOGRAPHIC_ORIGIN = "geographic_origin"
GMO = "gmo"
GMO_CONSTRUCTION_INFO = "gmo_construction_information"
MUTANT_INFORMATION = "mutant_information"
GENOTYPE = "genotype"
LITERATURE = "literature"
SEXUAL_STATE = "sexual_state"
PLOIDY = "ploidy"
INTERSPECIFIC_HYBRID = "interspecific_hybrid"
HYBRIDS = 'hybrids'
PLANT_PATHOGENICITY_CODE = "plant_pathogenicity_code"
PATHOGENICITY = "pathogenicity"
ENZYME_PRODUCTION = "enzyme_production"
PRODUCTION_OF_METABOLITES = "production_of_metabolites"
APPLICATIONS = "applications"
REMARKS = "remarks"
PLASMIDS = "plasmids"
PLASMIDS_COLLECTION_FIELDS = "plasmids_collections_fields"
SUBSTRATE_HOST_OF_ISOLATION = "substrate_host_of_isolation"
ISOLATION_HABITAT = "isolation_habitat"
ONTOBIOTOPE_ISOLATION_HABITAT = "ontobiotope_term_for_the_isolation_habitat"
LITERATURE_LINKED_TO_SEQ_GENOME = "literature_linked_to_the_sequence_genome"
AXENIC_CULTURE = "axenic_culture"
QPS ="qps"
SITE_LINK = "site_links"

# StrainId
STRAIN_ID = "id"
COLLECTION_CODE = "collection_code"
STRAIN_PUI = "strain_pui"
STRAIN_URL = "strain_url"

ID_SYNONYMS = 'id_synonyms'
# Taxonomy
GENUS = "genus"
SPECIES = "species"

# Location
COUNTRY = "countryOfOriginCode"
SITE = "site"
STATE = "state"
PROVINCE = "province"
MUNICIPALITY = "municipality"
ISLAND = "island"
OTHER = "other"
LATITUDE = "latitude"
LONGITUDE = "longitude"
ALTITUDE = "altitude"
GEOREF_METHOD = "georeferencingMethod"
COORDUNCERTAINTY = "coordUncertainty"
COORD_SPATIAL_REFERENCE = "coordenatesSpatialReference"
LOCATION = "location"

ALLOWED_COLLECTING_SITE_KEYS = [
    COUNTRY,
    STATE,
    PROVINCE,
    ISLAND,
    MUNICIPALITY,
    OTHER,
    SITE,
    LATITUDE,
    LONGITUDE,
    ALTITUDE,
    GEOREF_METHOD,
    COORDUNCERTAINTY,
    COORD_SPATIAL_REFERENCE,
]

MIRRI_FIELDS = [
    {"attribute": "id", "label": "accessionNumber"},
    {"attribute": "mirri_accession_number", "label": "mirriAccessionNumber"},
    {"attribute": "qps", "label": "qps"},
    {"attribute": "axenic_culture", "label": "axenicCulture"},
    {"attribute": "restriction_on_use", "label": "useRestrictions"},
    {"attribute": "nagoya_protocol",
        "label": "nagoyaConditions"},
    {"attribute": ABS_RELATED_FILES, "label": "absFile"},
    {"attribute": "mta_files", "label": "mtaFile"},
    {"attribute": "other_numbers", "label": "otherCollectionNumbers"},
    {"attribute": "is_from_registered_collection",
        "label": "registeredCollection"},
    {"attribute": "risk_group", "label": "riskGroup"},
    {"attribute": "is_potentially_harmful", "label": "dualUse"},
    {"attribute": "is_subject_to_quarantine", "label": "euQuarantine"},
    {"attribute": "taxonomy.organism_type", "label": "organismType"},
    {"attribute": "taxonomy.taxon_name", "label": "speciesName"},
    {"attribute": "taxonomy.infrasubspecific_name",
        "label": "infrasubspecificNames"},
    {"attribute": "taxonomy.comments", "label": "taxonomyComments"},
    {"attribute": "taxonomy.interspecific_hybrid",
        "label": "hybrid"},
    {"attribute": "status", "label": "status"},
    {"attribute": "history", "label": "depositHistory", },
    {"attribute": "deposit.who", "label": "depositor"},
    {"attribute": "deposit.date", "label": "depositDate"},
    {"attribute": "catalog_inclusion_date",
        "label": "accessionDate"},
    {"attribute": "collect.who", "label": "collector"},
    {"attribute": "collect.date", "label": "collectionDate"},
    {"attribute": "isolation.who", "label": "isolator"},
    {"attribute": "isolation.date", "label": "isolationDate"},
    {"attribute": "isolation.substrate_host_of_isolation",
        "label": "substrate"},
    {"attribute": "growth.tested_temp_range",
        "label": "temperatureGrowthRange"},
    {"attribute": "growth.recommended_temp",
        "label": "recommendedTemperature"},
    {"attribute": "growth.recommended_media",
        "label": "recommendedMedium"},
    {"attribute": "form_of_supply", "label": "supplyForms"},
    {"attribute": "other_denominations", "label": "otherDenomination"},
    {"attribute": "collect.location.coords",
        "label": "geographicCoordinates"},
    {"attribute": "collect.site.links",
        "label": "siteLinks"}, 
    {"attribute": "collect.location.altitude",
        "label": "country"},
    {"attribute": "collect.location", "label": "geographicOrigin"},
    {"attribute": "collect.habitat", "label": "isolationHabitat"},
    {"attribute": "collect.habitat_ontobiotope",
        "label": "ontobiotopeTerms"},
    {"attribute": "genetics.gmo", "label": "gmo"},
    {"attribute": "genetics.gmo_construction",
        "label": "gmoConstruction"},
    {"attribute": "genetics.mutant_info", "label": "mutant"},
    {"attribute": "genetics.genotype", "label": "genotype"},
    {"attribute": "genetics.sexual_state", "label": "sexualState"},
    {"attribute": "genetics.ploidy", "label": "ploidy"},
    {"attribute": "genetics.plasmids", "label": "plasmids"},
    {"attribute": "genetics.plasmids_in_collections",
        "label": "plasmidCollections"},
    {"attribute": "publications", "label": "identificationLiterature"},
    {"attribute": PLANT_PATHOGENICITY_CODE, "label": "Plant pathogenicity code"},
    {"attribute": "pathogenicity", "label": "pathogenicity"},
    {"attribute": "enzyme_production", "label": "enzymes"},
    {"attribute": "production_of_metabolites",
        "label": "metabolites"},
    {"attribute": "type",
        "label": "type"},
    {"attribute": "applications", "label": "applications", },
    {"attribute": "remarks", "label": "remarks"},
    {"attribute": LITERATURE_LINKED_TO_SEQ_GENOME,
        "label": "sequenceLiterature"},
]

ALLOWED_SUBTAXA = ["subspecies", "variety", "convarietas", "group", "forma",
                   'forma.specialis']
ALLOWED_TAXONOMIC_RANKS = ["family", "genus", "species"] + ALLOWED_SUBTAXA

# nagoya
NAGOYA_NO_RESTRICTIONS = "no_known_restrictions_under_the_Nagoya_protocol"
NAGOYA_DOCS_AVAILABLE = "documents_providing_proof_of_legal_access_and_terms_of_use_available_at_the_collection"
NAGOYA_PROBABLY_SCOPE = "strain_probably_in_scope,_please_contact_the_culture_collection"

ALLOWED_NAGOYA_OPTIONS = [NAGOYA_NO_RESTRICTIONS,
                          NAGOYA_DOCS_AVAILABLE, NAGOYA_PROBABLY_SCOPE]

# Use restriction
NO_RESTRICTION = "no_restriction"
ONLY_RESEARCH = "only_research"
COMMERCIAL_USE_WITH_AGREEMENT = "commercial_use_with_agreement"

ALLOWED_RESTRICTION_USE_OPTIONS = [
    NO_RESTRICTION,
    ONLY_RESEARCH,
    COMMERCIAL_USE_WITH_AGREEMENT,
]

ALLOWED_RISK_GROUPS = ["1", "2", "3", "4"]

AGAR = "Agar"
CRYO = "Cryo"
DRY_ICE = "Dry Ice"
LIQUID_CULTURE_MEDIUM = "Liquid Culture Medium"
LYO = "Lyo"
OIL = "Oil"
WATER = "Water"
ALLOWED_FORMS_OF_SUPPLY = [AGAR, CRYO, DRY_ICE,
                           LIQUID_CULTURE_MEDIUM, LYO, OIL, WATER]

DEPOSIT = "deposit"
ISOLATION = "isolation"
COLLECT = "collect"
GROWTH = "growth"
GENETICS = "genetics"
TAXONOMY = "taxonomy"
# Markers
MARKERS = "markers"
MARKER_TYPE = "marker_type"
MARKER_INSDC = "INSDC"
MARKER_SEQ = "marker_seq"
ALLOWED_MARKER_TYPES = [
    {"acronym": "16S rRNA", "marker": "16S rRNA"},
    {"acronym": "ACT", "marker": "Actin"},
    {"acronym": "CaM", "marker": "Calmodulin"},
    {"acronym": "EF-1α", "marker": "elongation factor 1-alpha (EF-1α)"},
    {"acronym": "ITS",
        "marker": "nuclear ribosomal Internal Transcribed Spacer (ITS)"},
    {"acronym": "LSU", "marker": "nuclear ribosomal Large SubUnit (LSU)"},
    {"acronym": "RPB1", "marker": "Ribosomal RNA-coding genes RPB1"},
    {"acronym": "RPB2", "marker": "Ribosomal RNA-coding genes RPB2"},
    {"acronym": "TUBB", "marker": "β-Tubulin"},
]

PUBLICATIONS = "publications"
PUB_ID = "pub_id"
PUB_DOI = "pub_doi"
PUB_PMID = "pub_pmid"
PUB_PUBMED_ID = ''
PUB_FULL_REFERENCE = "full_reference"
PUB_TITLE = "title"
PUB_AUTHORS = "authors"
PUB_JOURNAL = "journal"
PUB_YEAR = "year"
PUB_VOLUME = "volume"
PUB_ISSUE = "issue"
PUB_FIRST_PAGE = "first_page"
PUB_LAST_PAGE = "last_page"
BOOK_TITLE = "book_title"
BOOK_EDITOR = "book_editor"
BOOK_PUBLISHER = "book_publisher"


PUBLICATION_FIELDS = [
    {"label": "ID", "attribute": PUB_ID},
    {"label": "PMID", "attribute": PUB_PMID},
    {"label": "DOI", "attribute": PUB_DOI},
    {"label": "Full reference", "attribute": PUB_FULL_REFERENCE},
    {"label": "Authors", "attribute": PUB_AUTHORS},
    {"label": "Title", "attribute": PUB_TITLE},
    {"label": "Journal", "attribute": PUB_JOURNAL},
    {"label": "Year", "attribute": PUB_YEAR},
    {"label": "Volume", "attribute": PUB_VOLUME},
    {"label": "Issue", "attribute": PUB_ISSUE},
    {"label": "First page", "attribute": PUB_FIRST_PAGE},
    {"label": "Last page", "attribute": PUB_FIRST_PAGE},
    {"label": "Book title", "attribute": BOOK_TITLE},
    {"label": "Editors", "attribute": BOOK_EDITOR},
    {"label": "Publisher", "attribute": BOOK_PUBLISHER},
]


# ploidy
ANEUPLOID = 0
HAPLOID = 1
DIPLOID = 2
TRIPLOID = 3
TETRAPLOID = 4
POLYPLOID = 9

ALLOWED_PLOIDIES = [ANEUPLOID, HAPLOID, DIPLOID, TRIPLOID, TETRAPLOID,
                    POLYPLOID]

SUBTAXAS = {
    "subsp.": "subspecies",
    "var.": "variety",
    "convar.": "convarietas",
    "group.": "group",
    "f.": "forma",
    "f.sp.": "forma.specialis"
}

#Control
VERSION = "Version"
DATE = "Date"


#Country codes
COUNTRY = "Country"
CODE = "Code"
ADDITIONAL_INFORMATION_ON_THE_COUNTRY_OR_CODE = "Additional information on the country or code"


#Country codes files
COUNTRY_CODES_SHEET = [
    {"label": "Country", "attribute": COUNTRY},
    {"label": "Code", "attribute": CODE},
    {"label": "Additional information on the country or code", "attribute": ADDITIONAL_INFORMATION_ON_THE_COUNTRY_OR_CODE},
]


#Controle files
CONTROL_FIELDS = [
    {"label": "Version", "attribute": VERSION},
    {"label": "Date", "attribute": DATE},
]

# Excel sheet name
LOCATIONS = "Geographic origin"  # 'Locations'
GROWTH_MEDIA = "Growth media"
GENOMIC_INFO = "Genomic information"
STRAINS = "Strains"
LITERATURE_SHEET = "Literature"
SEXUAL_STATE_SHEET = "Sexual state"
RESOURCE_TYPES_VALUES = "Resource types values"
FORM_OF_SUPPLY_SHEET = "Forms of supply"
PLOIDY_SHEET = "Ploidy"
ONTOBIOTOPE = "Ontobiotope"
MARKERS = "Markers"
CONTROL_SHEET = "Version"
COUNTRY_CODES_SHEET = "Country codes"
RESOURCE_SHEET = 'Resource types values'
