
// addLocusMetadata.go provides a function to add locus metadata to the .gob locus metadata file.
// This utility creates a NewLocusMetadata.gob file, which must be renamed to LocusMetadata.gob and placed in the /resources/geneticReferences/locusMetadata folder

package main

import "seekia/internal/genetics/geneticReferences/locusMetadata"
import "seekia/internal/genetics/geneticReferences/modifyLocusMetadata"
import "seekia/internal/helpers"
import "seekia/internal/localFilesystem"

import "log"

func main(){

	/*

	//TODO: Add these loci
	//		They are on the X chromosome, and we haven't defined the syntax to deal with X chromosome loci yet.

	newLocusMetadataObject_1 := locusMetadata.LocusMetadata{
		RSIDsList: []int64{5957354},
		Chromosome: X,
		Position: 120305480,
		GeneInfoIsKnown: true,
		GeneExists: true,
		GeneNamesList: []string{"TMEM255A"},
		CompanyAliases: make(map[locusMetadata.GeneticsCompany][]string),
		References: make(map[string]string),
	}

	newLocusMetadataObject_2 := locusMetadata.LocusMetadata{
		RSIDsList: []int64{78542430},
		Chromosome: X,
		Position: 48259397,
		GeneInfoIsKnown: true,
		GeneExists: true,
		GeneNamesList: []string{"SSX1"},
		CompanyAliases: make(map[locusMetadata.GeneticsCompany][]string),
		References: make(map[string]string),
	}

	*/

	// This is a list of metadata objects to add to the locus metadata
	lociToAddList := []locusMetadata.LocusMetadata{
		//newLocusMetadataObject_1,
		//newLocusMetadataObject_2,
	}

	quantityOfLociToAdd := len(lociToAddList)

	quantityOfAddedLoci, newLocusMetadataFileBytes, err := modifyLocusMetadata.AddLocusMetadata(lociToAddList)
	if (err != nil){
		log.Println("Error: " + err.Error())
		return
	}

	err = localFilesystem.CreateOrOverwriteFile(newLocusMetadataFileBytes, "./", "NewLocusMetadata.gob")
	if (err != nil){
		log.Println("Error: " + err.Error())
		return
	}

	quantityOfAddedLociString := helpers.ConvertIntToString(quantityOfAddedLoci)

	log.Println("Successfully added " + quantityOfAddedLociString + " locus metadatas!")
	log.Println("The new locus metadatas have been saved to the NewLocusMetadata.gob file.")

	quantityOfSkippedLoci := quantityOfLociToAdd - quantityOfAddedLoci

	if (quantityOfSkippedLoci != 0){

		quantityOfSkippedLociString := helpers.ConvertIntToString(quantityOfSkippedLoci)

		log.Println("Skipped " + quantityOfSkippedLociString + " locus metadatas because they already existed.")
	}
}


