package traits

import "seekia/internal/helpers"

import "maps"

func getEyeColorTraitObject()Trait{

	// Map Structure: rsID -> References Map
	locusReferencesMap := make(map[int64]map[string]string)

	// We use this function to add loci to the referencesMap while merging references for loci
	addLociListToLocusReferencesMap := func(inputLociList []int64, inputLociListReferencesMap map[string]string){

		for _, rsID := range inputLociList{

			existingReferencesMap, exists := locusReferencesMap[rsID]
			if (exists == false){
				locusReferencesMap[rsID] = maps.Clone(inputLociListReferencesMap)
			} else {

				// We merge the referencesMaps
				for key, value := range inputLociListReferencesMap{
					existingReferencesMap[key] = value
				}

				locusReferencesMap[rsID] = existingReferencesMap
			}
		}
	}

	// These SNPs are taken from https://www.snpedia.com/index.php/Eye_color

	lociList_1 := []int64{
		2733832,
		1800401,
		1800407,
		1800414,
		12913823,
		4911442,
		6058017,
		4911414,
		4778241,
		12593929,
		7183877,
		3935591,
		7170852,
		2238289,
		3940272,
		8028689,
		2240203,
		11631797,
		916977,
		3768056,
		728405,
		2835621,
		892839,
		9782955,
		12452184,
		10209564,
		1325127,
		7277820,
		1105879,
		7219915,
		12913832,
		2070959,
		2835630,
		9894429,
		1393350,
		2252893,
		1003719,
		3794604,
		7174027,
		989869,
		4778138,
		12906280,
	}

	referencesMap_List1 := make(map[string]string)
	referencesMap_List1["SNPedia.com - Eye Color"] = "https://www.snpedia.com/index.php/Eye_color"

	addLociListToLocusReferencesMap(lociList_1, referencesMap_List1)


	// These SNPs are taken from https://pubmed.ncbi.nlm.nih.gov/20546537/

	lociList_2 := []int64{
		12203592,
		1408799,
		1126809,
		12896399,
		7495174,
		1667394,
	}

	referencesMap_List2 := make(map[string]string)
	referencesMap_List2["Genome-wide association studies of pigmentation and skin cancer: a review and meta-analysis"] = "https://pubmed.ncbi.nlm.nih.gov/20546537/"

	addLociListToLocusReferencesMap(lociList_2, referencesMap_List2)


	// These SNPs are taken from https://pubmed.ncbi.nlm.nih.gov/33692100/

	lociList_3 := []int64{
		6693258,
		6696511,
		351385,
		2385028,
		13016869,
		112747614,
		121908120,
		12614022,
		74409360,
		188004381,
		3912104,
		116359091,
		4521336,
		141318671,
		6828137,
		142680396,
		73734205,
		145750983,
		62330021,
		148336621,
		142639084,
		35397,
		16891982,
		3797201,
		348613,
		72777200,
		1042713,
		1800888,
		11957757,
		12203592,
		116527520,
		10900944,
		62389423,
		6910861,
		341147,
		2854746,
		6944702,
		6997494,
		12543326,
		147068120,
		13297008,
		62538956,
		3949960,
		12552712,
		12335410,
		72928978,
		747572,
		2386579,
		139838980,
		187887338,
		144161465,
		56411871,
		181994037,
		10830237,
		72963168,
		4512823,
		1126809,
		9971729,
		790464,
		2095645,
		9301973,
		138777265,
		17184180,
		76519749,
		77816393,
		35167426,
		34931502,
		34422827,
		12440428,
		79335104,
		35690998,
		4778208,
		977589,
		117616283,
		8035315,
		4778218,
		76033022,
		4778224,
		145242923,
		749846,
		1470608,
		76375770,
		72712694,
		6497262,
		4778137,
		151090307,
		77542847,
		76415938,
		4778239,
		8026089,
		59138695,
		141685696,
		1129038,
		77854840,
		12593929,
		150287021,
		12901047,
		146550637,
		74447445,
		117504827,
		1667394,
		1426654,
		761063,
		4790309,
		3809761,
		6420484,
		73488486,
		2748901,
		2835660,
		622330,
		619484,
		35051352,

		// TODO: Add these loci once we can handle X Chromosome loci.
		// 78542430,
		//12837220
		// 5957354,
	}

	referencesMap_List3 := make(map[string]string)
	referencesMap_List3["Genome-wide association study in almost 195,000 individuals identifies 50 previously unidentified genetic loci for eye color."] = "https://pubmed.ncbi.nlm.nih.gov/33692100/"

	addLociListToLocusReferencesMap(lociList_3, referencesMap_List3)

	// These SNPs are taken from https://snpedia.com/index.php/GEDmatch_Eye_Color_SNPs

	lociList_4 := []int64{
		10467971,
		1105879,
		1129038,
		11634406,
		11636232,
		11638069,
		12203592,
		12906280,
		12913832,
		13160471,
		1393350,
		1448485,
		1470608,
		1597196,
		1667394,
		16891982,
		17762363,
		1800407,
	}

	referencesMap_List4 := make(map[string]string)
	referencesMap_List4["GEDmatch Eye Color SNPs - SNPedia"] = "https://snpedia.com/index.php/GEDmatch_Eye_Color_SNPs"

	addLociListToLocusReferencesMap(lociList_4, referencesMap_List4)


	eyeColorLociList := helpers.GetListOfMapKeys(locusReferencesMap)

	referencesMap := make(map[string]string)
	referencesMap["SNPedia.com - Eye Color"] = "https://www.snpedia.com/index.php/Eye_color"
	referencesMap["Genome-wide association studies of pigmentation and skin cancer: a review and meta-analysis"] = "https://pubmed.ncbi.nlm.nih.gov/20546537/"
	referencesMap["Genome-wide association study in almost 195,000 individuals identifies 50 previously unidentified genetic loci for eye color."] = "https://pubmed.ncbi.nlm.nih.gov/33692100/"
	referencesMap["GEDmatch Eye Color SNPs - SNPedia"] = "https://snpedia.com/index.php/GEDmatch_Eye_Color_SNPs"

	eyeColorObject := Trait{
		TraitName: "Eye Color",
		TraitDescription: "The color of a person's eyes.",
		DiscreteOrNumeric: "Discrete",
		LocusReferencesMap: locusReferencesMap,
		LociList: eyeColorLociList,
		LociList_Rules: []int64{},
		RulesList: []TraitRule{},
		OutcomesList: []string{"Blue", "Green", "Hazel", "Brown"},
		NumericValueFormatter: nil,
		ReferencesMap: referencesMap,
	}

	return eyeColorObject
}

