seekia/gui/viewAnalysisGui_Person.go

2445 lines
90 KiB
Go
Raw Normal View History

package gui
// viewAnalysisGui_Person.go implements pages to view a person genetic analysis
//TODO: Use person's sex to show opposite sex diseases and traits in different section
// For example, Ovarian Cancer for men, and Testicular Cancer for women
// We still want these risks/traits to be viewable, just put into a different part of the gui
import "fyne.io/fyne/v2"
import "fyne.io/fyne/v2/container"
import "fyne.io/fyne/v2/layout"
import "fyne.io/fyne/v2/theme"
import "fyne.io/fyne/v2/widget"
import "seekia/resources/geneticReferences/monogenicDiseases"
import "seekia/resources/geneticReferences/polygenicDiseases"
import "seekia/resources/geneticReferences/traits"
import "seekia/internal/appMemory"
import "seekia/internal/genetics/myGenomes"
import "seekia/internal/genetics/myPeople"
import "seekia/internal/genetics/readGeneticAnalysis"
import "seekia/internal/helpers"
import "errors"
func setViewPersonGeneticAnalysisPage(window fyne.Window, personIdentifier string, analysisMapList []map[string]string, numberOfGenomesAnalyzed int, previousPage func()){
appMemory.SetMemoryEntry("CurrentViewedPage", "ViewGeneticAnalysisPage")
currentPage := func(){setViewPersonGeneticAnalysisPage(window, personIdentifier, analysisMapList, numberOfGenomesAnalyzed, previousPage)}
title := getPageTitleCentered("Viewing Genetic Analysis")
backButton := getBackButtonCentered(previousPage)
warningLabel := getBoldLabelCentered("WARNING: Results are not accurate!")
personFound, personName, _, _, err := myPeople.GetPersonInfo(personIdentifier)
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
if (personFound == false){
setErrorEncounteredPage(window, errors.New("setViewPersonGeneticAnalysisPage called with unknown personIdentifier: " + personIdentifier), previousPage)
return
}
personNameLabel := widget.NewLabel("Person Name:")
personNameText := getBoldLabel(personName)
personNameRow := container.NewHBox(layout.NewSpacer(), personNameLabel, personNameText, layout.NewSpacer())
numberOfGenomesAnalyzedString := helpers.ConvertIntToString(numberOfGenomesAnalyzed)
numberOfAnalyzedGenomesLabel := widget.NewLabel("Number of Analyzed Genomes:")
numberOfAnalyzedGenomesText := getBoldLabel(numberOfGenomesAnalyzedString)
numberOfAnalyzedGenomesRow := container.NewHBox(layout.NewSpacer(), numberOfAnalyzedGenomesLabel, numberOfAnalyzedGenomesText, layout.NewSpacer())
generalButton := widget.NewButton("General", func(){
//TODO: Inbred rating (parent relatedness), ancestry
showUnderConstructionDialog(window)
})
monogenicDiseasesButton := widget.NewButton("Monogenic Diseases", func(){
setViewPersonGeneticAnalysisMonogenicDiseasesPage(window, analysisMapList, currentPage)
})
polygenicDiseasesButton := widget.NewButton("Polygenic Diseases", func(){
setViewPersonGeneticAnalysisPolygenicDiseasesPage(window, personIdentifier, analysisMapList, currentPage)
})
traitsButton := widget.NewButton("Traits", func(){
setViewPersonGeneticAnalysisTraitsPage(window, personIdentifier, analysisMapList, currentPage)
})
categoryButtonsGrid := getContainerCentered(container.NewGridWithColumns(1, generalButton, monogenicDiseasesButton, polygenicDiseasesButton, traitsButton))
page := container.NewVBox(title, backButton, widget.NewSeparator(), warningLabel, widget.NewSeparator(), personNameRow, numberOfAnalyzedGenomesRow, widget.NewSeparator(), categoryButtonsGrid)
setPageContent(page, window)
}
func setViewPersonGeneticAnalysisMonogenicDiseasesPage(window fyne.Window, analysisMapList []map[string]string, previousPage func()){
currentPage := func(){setViewPersonGeneticAnalysisMonogenicDiseasesPage(window, analysisMapList, previousPage)}
title := getPageTitleCentered("Viewing Genetic Analysis - Monogenic Diseases")
backButton := getBackButtonCentered(previousPage)
description := getLabelCentered("Below is an analysis of the monogenic diseases found in the person's genome.")
getMonogenicDiseasesContainer := func()(*fyne.Container, error){
allRawGenomeIdentifiersList, multipleGenomesExist, onlyExcludeConflictsGenomeIdentifier, _, err := readGeneticAnalysis.GetMetadataFromPersonGeneticAnalysis(analysisMapList)
if (err != nil){ return nil, err }
// Outputs:
// -string: Main genome identifier (Is either the combined Only exclude conflicts genome or the only genome)
// -error
getMainGenomeIdentifier := func()(string, error){
if (multipleGenomesExist == true){
return onlyExcludeConflictsGenomeIdentifier, nil
}
// Only 1 genome exists
genomeIdentifier := allRawGenomeIdentifiersList[0]
return genomeIdentifier, nil
}
mainGenomeIdentifier, err := getMainGenomeIdentifier()
if (err != nil){ return nil, err }
diseaseNameLabel := getItalicLabelCentered("Disease Name")
emptyLabelA := widget.NewLabel("")
probabilityOfLabelA := getItalicLabelCentered("Probability of")
havingDiseaseLabel := getItalicLabelCentered("Having Disease")
probabilityOfLabelB := getItalicLabelCentered("Probability of")
passingVariantLabel := getItalicLabelCentered("Passing Variant")
emptyLabelB := widget.NewLabel("")
conflictExistsLabel := getItalicLabelCentered("Conflict Exists?")
emptyLabelC := widget.NewLabel("")
emptyLabelD := widget.NewLabel("")
diseaseNameColumn := container.NewVBox(emptyLabelA, diseaseNameLabel, widget.NewSeparator())
probabilityOfHavingDiseaseColumn := container.NewVBox(probabilityOfLabelA, havingDiseaseLabel, widget.NewSeparator())
probabilityOfPassingVariantColumn := container.NewVBox(probabilityOfLabelB, passingVariantLabel, widget.NewSeparator())
conflictExistsColumn := container.NewVBox(emptyLabelB, conflictExistsLabel, widget.NewSeparator())
viewButtonsColumn := container.NewVBox(emptyLabelC, emptyLabelD, widget.NewSeparator())
monogenicDiseaseNamesList, err := monogenicDiseases.GetMonogenicDiseaseNamesList()
if (err != nil) { return nil, err }
for _, diseaseName := range monogenicDiseaseNamesList{
probabilitiesKnown, _, probabilityOfHavingDiseaseFormatted, _, probabilityOfPassingAVariantFormatted, _, conflictExistsBool, err := readGeneticAnalysis.GetPersonMonogenicDiseaseInfoFromGeneticAnalysis(analysisMapList, diseaseName, mainGenomeIdentifier, multipleGenomesExist)
if (err != nil) { return nil, err }
getProbabilityOfHavingDiseaseText := func()string{
if (probabilitiesKnown == false){
result := translate("Unknown")
return result
}
return probabilityOfHavingDiseaseFormatted
}
probabilityOfHavingDiseaseText := getProbabilityOfHavingDiseaseText()
getProbabilityOfPassingAVariantText := func()string{
if (probabilitiesKnown == false){
result := translate("Unknown")
return result
}
return probabilityOfPassingAVariantFormatted
}
probabilityOfPassingAVariantText := getProbabilityOfPassingAVariantText()
diseaseNameText := getBoldLabelCentered(diseaseName)
diseaseNameColumn.Add(diseaseNameText)
probabilityOfHavingDiseaseLabel := getBoldLabelCentered(probabilityOfHavingDiseaseText)
probabilityOfHavingDiseaseColumn.Add(probabilityOfHavingDiseaseLabel)
probabilityOfPassingVariantLabel := getBoldLabelCentered(probabilityOfPassingAVariantText)
probabilityOfPassingVariantColumn.Add(probabilityOfPassingVariantLabel)
conflictExistsString := helpers.ConvertBoolToYesOrNoString(conflictExistsBool)
conflictExistsLabel := getBoldLabelCentered(conflictExistsString)
conflictExistsColumn.Add(conflictExistsLabel)
viewDetailsButton := getWidgetCentered(widget.NewButtonWithIcon("", theme.VisibilityIcon(), func(){
setViewPersonGeneticAnalysisMonogenicDiseaseDetailsPage(window, analysisMapList, diseaseName, currentPage)
}))
viewButtonsColumn.Add(viewDetailsButton)
diseaseNameColumn.Add(widget.NewSeparator())
probabilityOfHavingDiseaseColumn.Add(widget.NewSeparator())
probabilityOfPassingVariantColumn.Add(widget.NewSeparator())
conflictExistsColumn.Add(widget.NewSeparator())
viewButtonsColumn.Add(widget.NewSeparator())
}
probabilityOfHavingDiseaseHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setPersonProbabilityOfHavingMonogenicDiseaseExplainerPage(window, currentPage)
})
probabilityOfHavingDiseaseColumn.Add(probabilityOfHavingDiseaseHelpButton)
probabilityOfPassingVariantHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setPersonProbabilityOfPassingVariantExplainerPage(window, currentPage)
})
probabilityOfPassingVariantColumn.Add(probabilityOfPassingVariantHelpButton)
diseasesContainer := container.NewHBox(layout.NewSpacer(), diseaseNameColumn, probabilityOfHavingDiseaseColumn, probabilityOfPassingVariantColumn)
if (multipleGenomesExist == true){
conflictExistsHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setPersonGeneticAnalysisConflictExistsExplainerPage(window, currentPage)
})
conflictExistsColumn.Add(conflictExistsHelpButton)
diseasesContainer.Add(conflictExistsColumn)
}
diseasesContainer.Add(viewButtonsColumn)
diseasesContainer.Add(layout.NewSpacer())
return diseasesContainer, nil
}
monogenicDiseasesContainer, err := getMonogenicDiseasesContainer()
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
page := container.NewVBox(title, backButton, widget.NewSeparator(), description, widget.NewSeparator(), monogenicDiseasesContainer)
setPageContent(page, window)
}
func setViewPersonGeneticAnalysisMonogenicDiseaseDetailsPage(window fyne.Window, analysisMapList []map[string]string, diseaseName string, previousPage func()){
currentPage := func(){setViewPersonGeneticAnalysisMonogenicDiseaseDetailsPage(window, analysisMapList, diseaseName, previousPage)}
title := getPageTitleCentered("Viewing Genetic Analysis - " + diseaseName)
backButton := getBackButtonCentered(previousPage)
allRawGenomeIdentifiersList, multipleGenomesExist, onlyExcludeConflictsGenomeIdentifier, onlyIncludeSharedGenomeIdentifier, err := readGeneticAnalysis.GetMetadataFromPersonGeneticAnalysis(analysisMapList)
if (err != nil) {
setErrorEncounteredPage(window, err, previousPage)
return
}
getDescriptionSection := func()*fyne.Container{
if (multipleGenomesExist == false){
description := getLabelCentered("Below is the disease information for this person's genome.")
return description
}
description1 := getLabelCentered("Below is the disease information for this person's genomes.")
description2 := getLabelCentered("The first two genomes are created by combining multiple genomes.")
descriptionsSection := container.NewVBox(description1, description2)
return descriptionsSection
}
descriptionSection := getDescriptionSection()
diseaseNameLabel := widget.NewLabel("Disease:")
diseaseNameText := getBoldLabel(diseaseName)
diseaseNameInfoButton := widget.NewButtonWithIcon("", theme.InfoIcon(), func(){
setViewMonogenicDiseaseDetailsPage(window, diseaseName, currentPage)
})
diseaseNameRow := container.NewHBox(layout.NewSpacer(), diseaseNameLabel, diseaseNameText, diseaseNameInfoButton, layout.NewSpacer())
getGenomesContainer := func()(*fyne.Container, error){
emptyLabelA := widget.NewLabel("")
genomeNameLabel := getItalicLabelCentered("Genome Name")
probabilityOfLabelA := getItalicLabelCentered("Probability of")
havingDiseaseLabel := getItalicLabelCentered("Having Disease")
probabilityOfLabelB := getItalicLabelCentered("Probability of")
passingVariantLabel := getItalicLabelCentered("Passing Variant")
numberOfLabel := getItalicLabelCentered("Number of")
variantsTestedLabel := getItalicLabelCentered("Variants Tested")
emptyLabelB := widget.NewLabel("")
emptyLabelC := widget.NewLabel("")
genomeNameColumn := container.NewVBox(emptyLabelA, genomeNameLabel, widget.NewSeparator())
probabilityOfHavingDiseaseColumn := container.NewVBox(probabilityOfLabelA, havingDiseaseLabel, widget.NewSeparator())
probabilityOfPassingAVariantColumn := container.NewVBox(probabilityOfLabelB, passingVariantLabel, widget.NewSeparator())
numberOfVariantsTestedColumn := container.NewVBox(numberOfLabel, variantsTestedLabel, widget.NewSeparator())
viewButtonsColumn := container.NewVBox(emptyLabelB, emptyLabelC, widget.NewSeparator())
addGenomeRow := func(genomeName string, genomeIdentifier string, isACombinedGenome bool)error{
probabilitiesKnown, _, probabilityOfHavingDiseaseFormatted, _, probabilityOfPassingAVariantFormatted, numberOfVariantsTested, _, err := readGeneticAnalysis.GetPersonMonogenicDiseaseInfoFromGeneticAnalysis(analysisMapList, diseaseName, genomeIdentifier, multipleGenomesExist)
if (err != nil) { return err }
getProbabilityOfHavingDiseaseText := func()string{
if (probabilitiesKnown == false){
result := translate("Unknown")
return result
}
return probabilityOfHavingDiseaseFormatted
}
probabilityOfHavingDiseaseText := getProbabilityOfHavingDiseaseText()
getProbabilityOfPassingAVariantText := func()string{
if (probabilitiesKnown == false){
result := translate("Unknown")
return result
}
return probabilityOfPassingAVariantFormatted
}
probabilityOfPassingAVariantText := getProbabilityOfPassingAVariantText()
getGenomeNameCell := func()*fyne.Container{
if (isACombinedGenome == false){
genomeNameLabel := getBoldLabelCentered(genomeName)
return genomeNameLabel
}
viewHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setCombinedGenomesExplainerPage(window, currentPage)
})
genomeNameLabel := getBoldLabel(genomeName)
genomeNameCell := container.NewHBox(layout.NewSpacer(), viewHelpButton, genomeNameLabel, layout.NewSpacer())
return genomeNameCell
}
genomeNameCell := getGenomeNameCell()
genomeNameColumn.Add(genomeNameCell)
probabilityOfHavingDiseaseLabel := getBoldLabelCentered(probabilityOfHavingDiseaseText)
probabilityOfHavingDiseaseColumn.Add(probabilityOfHavingDiseaseLabel)
probabilityOfPassingAVariantLabel := getBoldLabelCentered(probabilityOfPassingAVariantText)
probabilityOfPassingAVariantColumn.Add(probabilityOfPassingAVariantLabel)
numberOfVariantsTestedString := helpers.ConvertIntToString(numberOfVariantsTested)
numberOfVariantsTestedLabel := getBoldLabelCentered(numberOfVariantsTestedString)
numberOfVariantsTestedColumn.Add(numberOfVariantsTestedLabel)
viewButton := widget.NewButtonWithIcon("", theme.VisibilityIcon(), func(){setViewPersonGenomeMonogenicDiseaseVariantsPage(window, analysisMapList, genomeIdentifier, genomeName, diseaseName, currentPage)})
viewButtonsColumn.Add(viewButton)
genomeNameColumn.Add(widget.NewSeparator())
probabilityOfHavingDiseaseColumn.Add(widget.NewSeparator())
probabilityOfPassingAVariantColumn.Add(widget.NewSeparator())
numberOfVariantsTestedColumn.Add(widget.NewSeparator())
viewButtonsColumn.Add(widget.NewSeparator())
return nil
}
if (multipleGenomesExist == true){
err := addGenomeRow("Only Exclude Conflicts", onlyExcludeConflictsGenomeIdentifier, true)
if (err != nil){ return nil, err }
err = addGenomeRow("Only Include Shared", onlyIncludeSharedGenomeIdentifier, true)
if (err != nil){ return nil, err }
}
for _, genomeIdentifier := range allRawGenomeIdentifiersList{
getGenomeName := func()(string, error){
genomeFound, _, timeGenomeWasExported, _, _, _, companyName, _, _, err := myGenomes.GetMyRawGenomeMetadata(genomeIdentifier)
if (err != nil) { return "", err }
if (genomeFound == false){
return "", errors.New("MyGenomeInfo for genome from analysisMapList not found.")
}
if (multipleGenomesExist == false){
return companyName, nil
}
// We show the date that the genome was exported
exportTimeAgo, err := helpers.ConvertUnixTimeToTimeAgoTranslated(timeGenomeWasExported, false)
if (err != nil){ return "", err }
genomeName := companyName + " (Exported " + exportTimeAgo + ")"
return genomeName, nil
}
genomeName, err := getGenomeName()
if (err != nil) { return nil, err }
err = addGenomeRow(genomeName, genomeIdentifier, false)
if (err != nil){ return nil, err }
}
probabilityOfHavingDiseaseHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setPersonProbabilityOfHavingMonogenicDiseaseExplainerPage(window, currentPage)
})
probabilityOfHavingDiseaseColumn.Add(probabilityOfHavingDiseaseHelpButton)
probabilityOfPassingAVariantHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setPersonProbabilityOfPassingVariantExplainerPage(window, currentPage)
})
probabilityOfPassingAVariantColumn.Add(probabilityOfPassingAVariantHelpButton)
numberOfVariantsTestedHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setNumberOfTestedVariantsExplainerPage(window, currentPage)
})
numberOfVariantsTestedColumn.Add(numberOfVariantsTestedHelpButton)
genomesContainer := container.NewHBox(layout.NewSpacer(), genomeNameColumn, probabilityOfHavingDiseaseColumn, probabilityOfPassingAVariantColumn, numberOfVariantsTestedColumn, viewButtonsColumn, layout.NewSpacer())
return genomesContainer, nil
}
genomesContainer, err := getGenomesContainer()
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
page := container.NewVBox(title, backButton, widget.NewSeparator(), descriptionSection, widget.NewSeparator(), diseaseNameRow, widget.NewSeparator(), genomesContainer)
setPageContent(page, window)
}
// This page is used to view the person's variants for a particular genome
func setViewPersonGenomeMonogenicDiseaseVariantsPage(window fyne.Window, geneticAnalysisMapList []map[string]string, genomeIdentifier string, genomeName string, diseaseName string, previousPage func()){
setLoadingScreen(window, "Loading Disease Variants", "Loading disease variants...")
currentPage := func(){setViewPersonGenomeMonogenicDiseaseVariantsPage(window, geneticAnalysisMapList, genomeIdentifier, genomeName, diseaseName, previousPage)}
title := getPageTitleCentered("View Monogenic Disease Variants - " + diseaseName)
backButton := getBackButtonCentered(previousPage)
description1 := widget.NewLabel("Below are the monogenic disease variant results for this genome.")
variantsHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setMonogenicDiseaseVariantsExplainerPage(window, currentPage)
})
description1Row := container.NewHBox(layout.NewSpacer(), description1, variantsHelpButton, layout.NewSpacer())
getGenomeNameRow := func()*fyne.Container{
genomeLabel := widget.NewLabel("Genome:")
genomeNameLabel := getBoldLabel(genomeName)
if (genomeName == "Only Exclude Conflicts" || genomeName == "Only Include Shared"){
genomeHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setCombinedGenomesExplainerPage(window, currentPage)
})
genomeNameRow := container.NewHBox(layout.NewSpacer(), genomeLabel, genomeNameLabel, genomeHelpButton, layout.NewSpacer())
return genomeNameRow
}
genomeNameRow := container.NewHBox(layout.NewSpacer(), genomeLabel, genomeNameLabel, layout.NewSpacer())
return genomeNameRow
}
genomeNameRow := getGenomeNameRow()
_, multipleGenomesExist, _, _, err := readGeneticAnalysis.GetMetadataFromPersonGeneticAnalysis(geneticAnalysisMapList)
if (err != nil) {
setErrorEncounteredPage(window, err, previousPage)
return
}
_, _, _, _, _, numberOfVariantsTested, _, err := readGeneticAnalysis.GetPersonMonogenicDiseaseInfoFromGeneticAnalysis(geneticAnalysisMapList, diseaseName, genomeIdentifier, multipleGenomesExist)
if (err != nil) {
setErrorEncounteredPage(window, err, previousPage)
return
}
diseaseVariantsMap, err := monogenicDiseases.GetMonogenicDiseaseVariantsMap(diseaseName)
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
totalNumberOfVariants := len(diseaseVariantsMap)
totalNumberOfVariantsString := helpers.ConvertIntToString(totalNumberOfVariants)
numberOfVariantsTestedString := helpers.ConvertIntToString(numberOfVariantsTested)
variantsTestedLabel := widget.NewLabel("Variants Tested:")
variantsTestedText := getBoldLabel(numberOfVariantsTestedString + "/" + totalNumberOfVariantsString)
variantsTestedHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setNumberOfTestedVariantsExplainerPage(window, currentPage)
})
variantsTestedRow := container.NewHBox(layout.NewSpacer(), variantsTestedLabel, variantsTestedText, variantsTestedHelpButton, layout.NewSpacer())
//TODO: Add navigation buttons and pages
getVariantsGrid := func()(*fyne.Container, error){
variantNameLabel := getItalicLabelCentered("Variant Name")
genomeHasMutationLabel := getItalicLabelCentered("Genome Has Mutation")
numberOfMutationsLabel := getItalicLabelCentered("Number of Mutations")
emptyLabel := widget.NewLabel("")
variantNameColumn := container.NewVBox(variantNameLabel, widget.NewSeparator())
genomeHasMutationColumn := container.NewVBox(genomeHasMutationLabel, widget.NewSeparator())
numberOfMutationsColumn := container.NewVBox(numberOfMutationsLabel, widget.NewSeparator())
viewButtonsColumn := container.NewVBox(emptyLabel, widget.NewSeparator())
addVariantRow := func(variantIdentifier string)error{
variantObject, exists := diseaseVariantsMap[variantIdentifier]
if (exists == false) {
return errors.New("Cannot add variantRow: diseaseVariantsMap missing variant.")
}
variantName := variantObject.VariantNames[0]
numberOfMutationsIsKnown, genomeNumberOfMutations, err := readGeneticAnalysis.GetPersonMonogenicDiseaseVariantInfoFromGeneticAnalysis(geneticAnalysisMapList, diseaseName, variantIdentifier, genomeIdentifier)
if (err != nil) { return err }
variantNameLabel := getBoldLabelCentered(variantName)
variantNameColumn.Add(variantNameLabel)
getGenomeHasMutationString := func()string{
if (numberOfMutationsIsKnown == false){
result := translate("Unknown")
return result
}
if (genomeNumberOfMutations == 0){
result := translate("No")
return result
}
result := translate("Yes")
return result
}
genomeHasMutationString := getGenomeHasMutationString()
genomeHasMutationLabel := getBoldLabelCentered(genomeHasMutationString)
genomeHasMutationColumn.Add(genomeHasMutationLabel)
getNumberOfVariantMutationsString := func()string{
if (numberOfMutationsIsKnown == false){
result := translate("Unknown")
return result
}
variantNumberOfMutationsString := helpers.ConvertIntToString(genomeNumberOfMutations)
return variantNumberOfMutationsString
}
numberOfVariantMutationsString := getNumberOfVariantMutationsString()
genomeNumberOfMutationsLabel := getBoldLabelCentered(numberOfVariantMutationsString)
numberOfMutationsColumn.Add(genomeNumberOfMutationsLabel)
viewMutationButton := widget.NewButtonWithIcon("", theme.VisibilityIcon(), func(){
setViewPersonGeneticAnalysisMonogenicDiseaseVariantDetailsPage(window, geneticAnalysisMapList, diseaseName, variantIdentifier, currentPage)
})
viewButtonsColumn.Add(viewMutationButton)
variantNameColumn.Add(widget.NewSeparator())
genomeHasMutationColumn.Add(widget.NewSeparator())
numberOfMutationsColumn.Add(widget.NewSeparator())
viewButtonsColumn.Add(widget.NewSeparator())
return nil
}
variantsList_2Mutations := make([]string, 0)
variantsList_1Mutation := make([]string, 0)
variantsList_0Mutations := make([]string, 0)
variantsList_Unknown := make([]string, 0)
for variantIdentifier, _ := range diseaseVariantsMap{
numberOfMutationsIsKnown, genomeNumberOfMutations, err := readGeneticAnalysis.GetPersonMonogenicDiseaseVariantInfoFromGeneticAnalysis(geneticAnalysisMapList, diseaseName, variantIdentifier, genomeIdentifier)
if (err != nil) { return nil, err }
if (numberOfMutationsIsKnown == false){
variantsList_Unknown = append(variantsList_Unknown, variantIdentifier)
continue
}
if (genomeNumberOfMutations == 0){
variantsList_0Mutations = append(variantsList_0Mutations, variantIdentifier)
} else if (genomeNumberOfMutations == 1) {
variantsList_1Mutation = append(variantsList_1Mutation, variantIdentifier)
} else if (genomeNumberOfMutations == 2){
variantsList_2Mutations = append(variantsList_2Mutations, variantIdentifier)
} else {
return nil, errors.New("GetPersonMonogenicDiseaseVariantInfoFromGeneticAnalysis returning invalid genome number of mutations")
}
}
// Items within each group are sorted so they will display the same way whenever user refreshes page
helpers.SortStringListToUnicodeOrder(variantsList_2Mutations)
helpers.SortStringListToUnicodeOrder(variantsList_1Mutation)
helpers.SortStringListToUnicodeOrder(variantsList_0Mutations)
helpers.SortStringListToUnicodeOrder(variantsList_Unknown)
for _, variantIdentifier := range variantsList_2Mutations{
err = addVariantRow(variantIdentifier)
if (err != nil) { return nil, err }
}
for _, variantIdentifier := range variantsList_1Mutation{
err = addVariantRow(variantIdentifier)
if (err != nil) { return nil, err }
}
for _, variantIdentifier := range variantsList_0Mutations{
err = addVariantRow(variantIdentifier)
if (err != nil) { return nil, err }
}
for _, variantIdentifier := range variantsList_Unknown{
err = addVariantRow(variantIdentifier)
if (err != nil) { return nil, err }
}
genomeHasMutationHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setGenomeHasMonogenicDiseaseVariantMutationExplainerPage(window, currentPage)
})
genomeHasMutationColumn.Add(genomeHasMutationHelpButton)
genomeNumberOfMutationsHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setMonogenicDiseaseVariantsExplainerPage(window, currentPage)
})
numberOfMutationsColumn.Add(genomeNumberOfMutationsHelpButton)
variantsGrid := container.NewHBox(layout.NewSpacer(), variantNameColumn, genomeHasMutationColumn, numberOfMutationsColumn, viewButtonsColumn, layout.NewSpacer())
return variantsGrid, nil
}
variantsGrid, err := getVariantsGrid()
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
page := container.NewVBox(title, backButton, widget.NewSeparator(), description1Row, widget.NewSeparator(), genomeNameRow, widget.NewSeparator(), variantsTestedRow, widget.NewSeparator(), variantsGrid)
setPageContent(page, window)
}
// This page will show the details of a specific variant from a person's genetic analysis
// It will show the variant details for all of the person's genomes
func setViewPersonGeneticAnalysisMonogenicDiseaseVariantDetailsPage(window fyne.Window, geneticAnalysisMapList []map[string]string, diseaseName string, variantIdentifier string, previousPage func()){
currentPage := func(){setViewPersonGeneticAnalysisMonogenicDiseaseVariantDetailsPage(window, geneticAnalysisMapList, diseaseName, variantIdentifier, previousPage)}
title := getPageTitleCentered("Monogenic Disease Variant Details - " + diseaseName)
backButton := getBackButtonCentered(previousPage)
variantObject, err := monogenicDiseases.GetMonogenicDiseaseVariantObject(diseaseName, variantIdentifier)
if (err != nil) {
setErrorEncounteredPage(window, err, previousPage)
return
}
variantName := variantObject.VariantNames[0]
description := getLabelCentered("Below is the variant status for the person's genomes.")
variantNameLabel := widget.NewLabel("Variant Name:")
variantNameText := getBoldLabel(variantName)
variantNameHelpButton := widget.NewButtonWithIcon("", theme.InfoIcon(), func(){
setViewMonogenicDiseaseVariantDetailsPage(window, diseaseName, variantIdentifier, currentPage)
})
variantNameRow := container.NewHBox(layout.NewSpacer(), variantNameLabel, variantNameText, variantNameHelpButton, layout.NewSpacer())
getGenomesHaveVariantGrid := func()(*fyne.Container, error){
allRawGenomeIdentifiersList, multipleGenomesExist, onlyExcludeConflictsGenomeIdentifier, onlyIncludeSharedGenomeIdentifier, err := readGeneticAnalysis.GetMetadataFromPersonGeneticAnalysis(geneticAnalysisMapList)
if (err != nil) { return nil, err }
genomeNameLabel := getItalicLabelCentered("Genome Name")
genomeHasMutationLabel := getItalicLabelCentered("Genome Has Mutation")
numberOfMutationsLabel := getItalicLabelCentered("Number of Mutations")
genomeNameColumn := container.NewVBox(genomeNameLabel, widget.NewSeparator())
genomeHasMutationColumn := container.NewVBox(genomeHasMutationLabel, widget.NewSeparator())
numberOfMutationsColumn := container.NewVBox(numberOfMutationsLabel, widget.NewSeparator())
addGenomeRow := func(genomeName string, genomeIdentifier string, isACombinedGenome bool)error{
genomeMutationsKnown, genomeNumberOfMutations, err := readGeneticAnalysis.GetPersonMonogenicDiseaseVariantInfoFromGeneticAnalysis(geneticAnalysisMapList, diseaseName, variantIdentifier, genomeIdentifier)
if (err != nil) { return err }
getGenomeNameCell := func()*fyne.Container{
if (isACombinedGenome == false){
genomeNameLabel := getBoldLabelCentered(genomeName)
return genomeNameLabel
}
viewHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setCombinedGenomesExplainerPage(window, currentPage)
})
genomeNameLabel := getBoldLabel(genomeName)
genomeNameCell := container.NewHBox(layout.NewSpacer(), viewHelpButton, genomeNameLabel, layout.NewSpacer())
return genomeNameCell
}
genomeNameCell := getGenomeNameCell()
genomeNameColumn.Add(genomeNameCell)
getGenomeHasMutationText := func()string{
if (genomeMutationsKnown == false){
result := translate("Unknown")
return result
}
if (genomeNumberOfMutations == 0){
result := translate("No")
return result
}
result := translate("Yes")
return result
}
genomeHasMutationText := getGenomeHasMutationText()
getGenomeNumberOfMutationsText := func()string{
if (genomeMutationsKnown == false){
result := translate("Unknown")
return result
}
genomeNumberOfMutationsString := helpers.ConvertIntToString(genomeNumberOfMutations)
return genomeNumberOfMutationsString
}
genomeNumberOfMutationsText := getGenomeNumberOfMutationsText()
genomeHasMutationLabel := getBoldLabelCentered(genomeHasMutationText)
genomeHasMutationColumn.Add(genomeHasMutationLabel)
genomeNumberOfMutationsLabel := getBoldLabelCentered(genomeNumberOfMutationsText)
numberOfMutationsColumn.Add(genomeNumberOfMutationsLabel)
genomeNameColumn.Add(widget.NewSeparator())
genomeHasMutationColumn.Add(widget.NewSeparator())
numberOfMutationsColumn.Add(widget.NewSeparator())
return nil
}
if (multipleGenomesExist == true){
err := addGenomeRow("Only Exclude Conflicts", onlyExcludeConflictsGenomeIdentifier, true)
if (err != nil){ return nil, err }
err = addGenomeRow("Only Include Shared", onlyIncludeSharedGenomeIdentifier, true)
if (err != nil){ return nil, err }
}
for _, genomeIdentifier := range allRawGenomeIdentifiersList{
getGenomeName := func()(string, error){
genomeFound, _, timeGenomeWasExported, _, _, _, companyName, _, _, err := myGenomes.GetMyRawGenomeMetadata(genomeIdentifier)
if (err != nil) { return "", err }
if (genomeFound == false){
return "", errors.New("MyGenomeInfo for genome from analysisMapList not found.")
}
if (multipleGenomesExist == false){
return companyName, nil
}
// We show the date that the genome was exported
exportTimeAgo, err := helpers.ConvertUnixTimeToTimeAgoTranslated(timeGenomeWasExported, false)
if (err != nil){ return "", err }
genomeName := companyName + " (Exported " + exportTimeAgo + ")"
return genomeName, nil
}
genomeName, err := getGenomeName()
if (err != nil) { return nil, err }
err = addGenomeRow(genomeName, genomeIdentifier, false)
if (err != nil){ return nil, err }
}
genomeHasMutationHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setGenomeHasMonogenicDiseaseVariantMutationExplainerPage(window, currentPage)
})
genomeHasMutationColumn.Add(genomeHasMutationHelpButton)
genomeNumberOfMutationsHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setMonogenicDiseaseVariantsExplainerPage(window, currentPage)
})
numberOfMutationsColumn.Add(genomeNumberOfMutationsHelpButton)
genomesContainer := container.NewHBox(layout.NewSpacer(), genomeNameColumn, genomeHasMutationColumn, numberOfMutationsColumn, layout.NewSpacer())
return genomesContainer, nil
}
genomesHaveVariantGrid, err := getGenomesHaveVariantGrid()
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
page := container.NewVBox(title, backButton, widget.NewSeparator(), description, widget.NewSeparator(), variantNameRow, widget.NewSeparator(), genomesHaveVariantGrid)
setPageContent(page, window)
}
func setViewPersonGeneticAnalysisPolygenicDiseasesPage(window fyne.Window, personIdentifier string, analysisMapList []map[string]string, previousPage func()){
currentPage := func(){setViewPersonGeneticAnalysisPolygenicDiseasesPage(window, personIdentifier, analysisMapList, previousPage)}
title := getPageTitleCentered("Viewing Genetic Analysis - Polygenic Diseases")
backButton := getBackButtonCentered(previousPage)
description := getLabelCentered("Below is an analysis of the polygenic disease risks for this person's genome.")
getPolygenicDiseasesContainer := func()(*fyne.Container, error){
allRawGenomeIdentifiersList, multipleGenomesExist, onlyExcludeConflictsGenomeIdentifier, _, err := readGeneticAnalysis.GetMetadataFromPersonGeneticAnalysis(analysisMapList)
if (err != nil){ return nil, err }
// Outputs:
// -string: Main genome identifier (Is either the combined Only exclude conflicts genome or the only genome)
// -error
getMainGenomeIdentifier := func()(string, error){
if (multipleGenomesExist == true){
return onlyExcludeConflictsGenomeIdentifier, nil
}
// Only 1 genome exists
genomeIdentifier := allRawGenomeIdentifiersList[0]
return genomeIdentifier, nil
}
mainGenomeIdentifier, err := getMainGenomeIdentifier()
if (err != nil){ return nil, err }
diseaseNameLabel := getItalicLabelCentered("Disease Name")
riskScoreLabel := getItalicLabelCentered("Risk Score")
conflictExistsLabel := getItalicLabelCentered("Conflict Exists?")
emptyLabel := widget.NewLabel("")
diseaseNameColumn := container.NewVBox(diseaseNameLabel, widget.NewSeparator())
riskScoreColumn := container.NewVBox(riskScoreLabel, widget.NewSeparator())
conflictExistsColumn := container.NewVBox(conflictExistsLabel, widget.NewSeparator())
viewButtonsColumn := container.NewVBox(emptyLabel, widget.NewSeparator())
polygenicDiseaseNamesList, err := polygenicDiseases.GetPolygenicDiseaseNamesList()
if (err != nil) { return nil, err }
for _, diseaseName := range polygenicDiseaseNamesList{
diseaseNameText := getBoldLabelCentered(diseaseName)
personRiskScoreKnown, _, personRiskScoreFormatted, _, conflictExists, err := readGeneticAnalysis.GetPersonPolygenicDiseaseInfoFromGeneticAnalysis(analysisMapList, diseaseName, mainGenomeIdentifier, multipleGenomesExist)
if (err != nil) { return nil, err }
getPersonRiskScoreLabelText := func()string{
if (personRiskScoreKnown == false){
result := translate("Unknown")
return result
}
return personRiskScoreFormatted
}
personRiskScoreLabelText := getPersonRiskScoreLabelText()
riskScoreText := getBoldLabelCentered(personRiskScoreLabelText)
conflictExistsString := helpers.ConvertBoolToYesOrNoString(conflictExists)
conflictExistsLabel := getBoldLabelCentered(conflictExistsString)
viewDetailsButton := getWidgetCentered(widget.NewButtonWithIcon("", theme.VisibilityIcon(), func(){
setViewPersonGeneticAnalysisPolygenicDiseaseDetailsPage(window, personIdentifier, analysisMapList, diseaseName, currentPage)
}))
diseaseNameColumn.Add(diseaseNameText)
riskScoreColumn.Add(riskScoreText)
conflictExistsColumn.Add(conflictExistsLabel)
viewButtonsColumn.Add(viewDetailsButton)
diseaseNameColumn.Add(widget.NewSeparator())
riskScoreColumn.Add(widget.NewSeparator())
conflictExistsColumn.Add(widget.NewSeparator())
viewButtonsColumn.Add(widget.NewSeparator())
}
riskScoreHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setPolygenicDiseaseRiskScoreExplainerPage(window, currentPage)
})
riskScoreColumn.Add(riskScoreHelpButton)
diseasesContainer := container.NewHBox(layout.NewSpacer(), diseaseNameColumn, riskScoreColumn)
if (multipleGenomesExist == true){
conflictExistsHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setPersonGeneticAnalysisConflictExistsExplainerPage(window, currentPage)
})
conflictExistsColumn.Add(conflictExistsHelpButton)
diseasesContainer.Add(conflictExistsColumn)
}
diseasesContainer.Add(viewButtonsColumn)
diseasesContainer.Add(layout.NewSpacer())
return diseasesContainer, nil
}
diseasesContainer, err := getPolygenicDiseasesContainer()
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
page := container.NewVBox(title, backButton, widget.NewSeparator(), description, widget.NewSeparator(), diseasesContainer)
setPageContent(page, window)
}
func setViewPersonGeneticAnalysisPolygenicDiseaseDetailsPage(window fyne.Window, personIdentifier string, analysisMapList []map[string]string, diseaseName string, previousPage func()){
currentPage := func(){setViewPersonGeneticAnalysisPolygenicDiseaseDetailsPage(window, personIdentifier, analysisMapList, diseaseName, previousPage)}
title := getPageTitleCentered("Viewing Genetic Analysis - " + diseaseName)
backButton := getBackButtonCentered(previousPage)
allRawGenomeIdentifiersList, multipleGenomesExist, onlyExcludeConflictsGenomeIdentifier, onlyIncludeSharedGenomeIdentifier, err := readGeneticAnalysis.GetMetadataFromPersonGeneticAnalysis(analysisMapList)
if (err != nil) {
setErrorEncounteredPage(window, err, previousPage)
return
}
getDescriptionSection := func()*fyne.Container{
if (multipleGenomesExist == false){
description := getLabelCentered("Below is the disease information for this person's genome.")
return description
}
description1 := getLabelCentered("Below is the disease information for this person's genomes.")
description2 := getLabelCentered("The first two genomes are created by combining multiple genomes.")
descriptionsSection := container.NewVBox(description1, description2)
return descriptionsSection
}
descriptionSection := getDescriptionSection()
diseaseNameLabel := widget.NewLabel("Disease:")
diseaseNameText := getBoldLabel(diseaseName)
diseaseInfoButton := widget.NewButtonWithIcon("", theme.InfoIcon(), func(){
setViewPolygenicDiseaseDetailsPage(window, diseaseName, currentPage)
})
diseaseNameRow := container.NewHBox(layout.NewSpacer(), diseaseNameLabel, diseaseNameText, diseaseInfoButton, layout.NewSpacer())
getGenomesContainer := func()(*fyne.Container, error){
emptyLabelA := widget.NewLabel("")
genomeNameLabel := getItalicLabelCentered("Genome Name")
emptyLabelB := widget.NewLabel("")
riskScoreLabel := getItalicLabelCentered("Risk Score")
numberOfLabel := getItalicLabelCentered("Number of")
lociTestedLabel := getItalicLabelCentered("Loci Tested")
emptyLabelD := widget.NewLabel("")
emptyLabelE := widget.NewLabel("")
emptyLabelF := widget.NewLabel("")
emptyLabelG := widget.NewLabel("")
genomeNameColumn := container.NewVBox(emptyLabelA, genomeNameLabel, widget.NewSeparator())
riskScoreColumn := container.NewVBox(emptyLabelB, riskScoreLabel, widget.NewSeparator())
numberOfLociTestedColumn := container.NewVBox(numberOfLabel, lociTestedLabel, widget.NewSeparator())
viewLifetimeRiskButtonsColumn := container.NewVBox(emptyLabelD, emptyLabelE, widget.NewSeparator())
viewLociButtonsColumn := container.NewVBox(emptyLabelF, emptyLabelG, widget.NewSeparator())
addGenomeRow := func(genomeName string, genomeIdentifier string, isACombinedGenome bool)error{
getGenomeNameCell := func()*fyne.Container{
if (isACombinedGenome == false){
genomeNameLabel := getBoldLabelCentered(genomeName)
return genomeNameLabel
}
viewHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setCombinedGenomesExplainerPage(window, currentPage)
})
genomeNameLabel := getBoldLabel(genomeName)
genomeNameCell := container.NewHBox(layout.NewSpacer(), viewHelpButton, genomeNameLabel, layout.NewSpacer())
return genomeNameCell
}
genomeNameCell := getGenomeNameCell()
diseaseRiskScoreKnown, _, diseaseRiskScoreFormatted, numberOfLociTested, _, err := readGeneticAnalysis.GetPersonPolygenicDiseaseInfoFromGeneticAnalysis(analysisMapList, diseaseName, genomeIdentifier, multipleGenomesExist)
if (err != nil) { return err }
getRiskScoreLabelText := func()string{
if (diseaseRiskScoreKnown == false){
result := translate("Unknown")
return result
}
return diseaseRiskScoreFormatted
}
genomeRiskScoreLabelText := getRiskScoreLabelText()
riskScoreLabel := getBoldLabelCentered(genomeRiskScoreLabelText)
genomeNumberOfLociTestedString := helpers.ConvertIntToString(numberOfLociTested)
numberOfLociTestedLabel := getBoldLabelCentered(genomeNumberOfLociTestedString)
viewLifetimeRiskButton := widget.NewButtonWithIcon("", theme.HistoryIcon(), func(){
personFound, _, _, personSex, err := myPeople.GetPersonInfo(personIdentifier)
if (err != nil){
setErrorEncounteredPage(window, err, currentPage)
return
}
if (personFound == false){
setErrorEncounteredPage(window, errors.New("setViewPersonGeneticAnalysisPolygenicDiseaseDetailsPage called with unknown personIdentifier"), currentPage)
return
}
getSexToDisplay := func()string{
if (personSex == "Male" || personSex == "Female"){
return personSex
}
return "Male"
}
sexToDisplay := getSexToDisplay()
setViewPersonPolygenicDiseaseLifetimeProbabilitiesPage(window, diseaseName, genomeName, sexToDisplay, currentPage)
})
viewLociButton := widget.NewButtonWithIcon("", theme.VisibilityIcon(), func(){
setViewPersonGenomePolygenicDiseaseLociPage(window, analysisMapList, diseaseName, genomeIdentifier, genomeName, currentPage)
})
genomeNameColumn.Add(genomeNameCell)
riskScoreColumn.Add(riskScoreLabel)
numberOfLociTestedColumn.Add(numberOfLociTestedLabel)
viewLifetimeRiskButtonsColumn.Add(viewLifetimeRiskButton)
viewLociButtonsColumn.Add(viewLociButton)
genomeNameColumn.Add(widget.NewSeparator())
riskScoreColumn.Add(widget.NewSeparator())
numberOfLociTestedColumn.Add(widget.NewSeparator())
viewLifetimeRiskButtonsColumn.Add(widget.NewSeparator())
viewLociButtonsColumn.Add(widget.NewSeparator())
return nil
}
if (multipleGenomesExist == true){
err := addGenomeRow("Only Exclude Conflicts", onlyExcludeConflictsGenomeIdentifier, true)
if (err != nil){ return nil, err }
err = addGenomeRow("Only Include Shared", onlyIncludeSharedGenomeIdentifier, true)
if (err != nil){ return nil, err }
}
for _, genomeIdentifier := range allRawGenomeIdentifiersList{
getGenomeName := func()(string, error){
genomeFound, _, timeGenomeWasExported, _, _, _, companyName, _, _, err := myGenomes.GetMyRawGenomeMetadata(genomeIdentifier)
if (err != nil) { return "", err }
if (genomeFound == false){
return "", errors.New("MyGenomeInfo for genome from analysisMapList not found.")
}
if (multipleGenomesExist == false){
return companyName, nil
}
// We show the date the genome was exported
exportTimeAgo, err := helpers.ConvertUnixTimeToTimeAgoTranslated(timeGenomeWasExported, false)
if (err != nil){ return "", err }
genomeName := companyName + " (Exported " + exportTimeAgo + ")"
return genomeName, nil
}
genomeName, err := getGenomeName()
if (err != nil) { return nil, err }
err = addGenomeRow(genomeName, genomeIdentifier, false)
if (err != nil){ return nil, err }
}
riskScoreHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setPolygenicDiseaseRiskScoreExplainerPage(window, currentPage)
})
riskScoreColumn.Add(riskScoreHelpButton)
numberOfLociTestedHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setPolygenicDiseaseNumberOfLociTestedExplainerPage(window, currentPage)
})
numberOfLociTestedColumn.Add(numberOfLociTestedHelpButton)
genomesContainer := container.NewHBox(layout.NewSpacer(), genomeNameColumn, riskScoreColumn, numberOfLociTestedColumn, viewLifetimeRiskButtonsColumn, viewLociButtonsColumn, layout.NewSpacer())
return genomesContainer, nil
}
genomesContainer, err := getGenomesContainer()
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
page := container.NewVBox(title, backButton, widget.NewSeparator(), descriptionSection, widget.NewSeparator(), diseaseNameRow, widget.NewSeparator(), genomesContainer)
setPageContent(page, window)
}
func setViewPersonPolygenicDiseaseLifetimeProbabilitiesPage(window fyne.Window, diseaseName string, genomeName string, maleOrFemale string, previousPage func()){
currentPage := func(){setViewPersonPolygenicDiseaseLifetimeProbabilitiesPage(window, diseaseName, genomeName, maleOrFemale, previousPage)}
title := getPageTitleCentered("Viewing Disease Lifetime Probabilities")
backButton := getBackButtonCentered(previousPage)
description1 := getLabelCentered("Below are the lifetime probabilities for this disease.")
description2 := getLabelCentered("The average risk column describes the probability for the average person.")
//TODO: Once we understand how to calculate it, we will add adjusted risk column with estimated probability
getGenomeNameRow := func()*fyne.Container{
genomeLabel := widget.NewLabel("Genome:")
genomeNameLabel := getBoldLabel(genomeName)
if (genomeName == "Only Exclude Conflicts" || genomeName == "Only Include Shared"){
genomeHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setCombinedGenomesExplainerPage(window, currentPage)
})
genomeNameRow := container.NewHBox(layout.NewSpacer(), genomeLabel, genomeNameLabel, genomeHelpButton, layout.NewSpacer())
return genomeNameRow
}
genomeNameRow := container.NewHBox(layout.NewSpacer(), genomeLabel, genomeNameLabel, layout.NewSpacer())
return genomeNameRow
}
genomeNameRow := getGenomeNameRow()
getTabContainer := func(tabMaleOrFemale string)(*container.TabItem, error){
ageLabel := getItalicLabelCentered("Age")
averageRiskLabel := getItalicLabelCentered("Average Risk")
ageColumn := container.NewVBox(ageLabel, widget.NewSeparator())
averageRiskColumn := container.NewVBox(averageRiskLabel, widget.NewSeparator())
diseaseObject, err := polygenicDiseases.GetPolygenicDiseaseObject(diseaseName)
if (err != nil) { return nil, err }
getAverageRiskProbabilitiesFunction := diseaseObject.GetAverageRiskProbabilitiesFunction
rowInitialValuesSet := false
rowInitialAge := 0
rowInitialAgeRisk := float64(0)
rowSummedRisks := float64(0)
for age := 0; age <= 110; age++{
ageRisk, err := getAverageRiskProbabilitiesFunction(tabMaleOrFemale, age)
if (err != nil) { return nil, err }
if (rowInitialValuesSet == false){
rowInitialValuesSet = true
rowInitialAge = age
rowInitialAgeRisk = ageRisk
rowSummedRisks = ageRisk
continue
}
rowSummedRisks += ageRisk
nextAge := age+1
if (nextAge % 10 != 0){
continue
}
if (age < 109 && rowInitialAgeRisk == ageRisk){
continue
}
// We make a new row
averageRisk := rowSummedRisks / float64(age - rowInitialAge + 1)
if (rowInitialAge >= age){
return nil, errors.New("rowInitialAge is >= age.")
}
startAgeString := helpers.ConvertIntToString(rowInitialAge)
endAgeString := helpers.ConvertIntToString(age)
averageRiskString := helpers.ConvertFloat64ToStringRounded(averageRisk, 2)
ageRangeLabel := getBoldLabel(startAgeString + " - " + endAgeString)
averageRiskLabel := getBoldLabelCentered(averageRiskString + "%")
ageColumn.Add(ageRangeLabel)
averageRiskColumn.Add(averageRiskLabel)
ageColumn.Add(widget.NewSeparator())
averageRiskColumn.Add(widget.NewSeparator())
rowInitialValuesSet = false
}
averageRiskHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setPolygenicDiseaseAverageLifetimeRiskExplainerPage(window, currentPage)
})
averageRiskColumn.Add(averageRiskHelpButton)
ageProbabilitiesGrid := container.NewHBox(layout.NewSpacer(), ageColumn, averageRiskColumn, layout.NewSpacer())
ageProbabilitiesTabItem := container.NewTabItem(tabMaleOrFemale, ageProbabilitiesGrid)
return ageProbabilitiesTabItem, nil
}
maleTab, err := getTabContainer("Male")
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
femaleTab, err := getTabContainer("Female")
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
ageProbabilityTabs := container.NewAppTabs(maleTab, femaleTab)
if (maleOrFemale == "Male"){
ageProbabilityTabs.Select(maleTab)
} else {
ageProbabilityTabs.Select(femaleTab)
}
ageProbabilityTabsCentered := getContainerCentered(getAppTabsBoxed(ageProbabilityTabs))
page := container.NewVBox(title, backButton, widget.NewSeparator(), description1, description2, widget.NewSeparator(), genomeNameRow, widget.NewSeparator(), ageProbabilityTabsCentered)
setPageContent(page, window)
}
// This function provides a page to view the polygenic disease loci for a particular genome from a genetic analysis
func setViewPersonGenomePolygenicDiseaseLociPage(window fyne.Window, geneticAnalysisMapList []map[string]string, diseaseName string, genomeIdentifier string, genomeName string, previousPage func()){
setLoadingScreen(window, "Loading Polygenic Disease Loci", "Loading disease loci...")
currentPage := func(){setViewPersonGenomePolygenicDiseaseLociPage(window, geneticAnalysisMapList, diseaseName, genomeIdentifier, genomeName, previousPage)}
title := getPageTitleCentered("View Disease Loci - " + diseaseName)
backButton := getBackButtonCentered(previousPage)
description1 := widget.NewLabel("Below are the disease loci results for this genome.")
lociHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setPolygenicDiseaseLociExplainerPage(window, currentPage)
})
description1Row := container.NewHBox(layout.NewSpacer(), description1, lociHelpButton, layout.NewSpacer())
getGenomeNameRow := func()*fyne.Container{
genomeLabel := widget.NewLabel("Genome:")
genomeNameLabel := getBoldLabel(genomeName)
if (genomeName == "Only Exclude Conflicts" || genomeName == "Only Include Shared"){
genomeHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setCombinedGenomesExplainerPage(window, currentPage)
})
genomeNameRow := container.NewHBox(layout.NewSpacer(), genomeLabel, genomeNameLabel, genomeHelpButton, layout.NewSpacer())
return genomeNameRow
}
genomeNameRow := container.NewHBox(layout.NewSpacer(), genomeLabel, genomeNameLabel, layout.NewSpacer())
return genomeNameRow
}
genomeNameRow := getGenomeNameRow()
diseaseLociMap, err := polygenicDiseases.GetPolygenicDiseaseLociMap(diseaseName)
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
numberOfLociTested := 0
lociList_PositiveWeight := make([]string, 0)
lociList_ZeroWeight := make([]string, 0)
lociList_NegativeWeight := make([]string, 0)
lociList_UnknownWeight := make([]string, 0)
for locusIdentifier, _ := range diseaseLociMap{
locusRiskWeightIsKnown, genomeLocusRiskWeight, _, _, _, _, err := readGeneticAnalysis.GetPersonPolygenicDiseaseLocusInfoFromGeneticAnalysis(geneticAnalysisMapList, diseaseName, locusIdentifier, genomeIdentifier)
if (err != nil) {
setErrorEncounteredPage(window, err, previousPage)
return
}
if (locusRiskWeightIsKnown == false){
lociList_UnknownWeight = append(lociList_UnknownWeight, locusIdentifier)
continue
}
numberOfLociTested += 1
if (genomeLocusRiskWeight > 0){
lociList_PositiveWeight = append(lociList_PositiveWeight, locusIdentifier)
} else if (genomeLocusRiskWeight == 0) {
lociList_ZeroWeight = append(lociList_ZeroWeight, locusIdentifier)
} else {
// genomeLocusRiskWeight < 0
lociList_NegativeWeight = append(lociList_NegativeWeight, locusIdentifier)
}
}
numberOfLociTestedString := helpers.ConvertIntToString(numberOfLociTested)
totalNumberOfLoci := len(diseaseLociMap)
totalNumberOfLociString := helpers.ConvertIntToString(totalNumberOfLoci)
lociTestedLabel := widget.NewLabel("Loci Tested:")
lociTestedText := getBoldLabel(numberOfLociTestedString + "/" + totalNumberOfLociString)
lociTestedHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setPolygenicDiseaseNumberOfLociTestedExplainerPage(window, currentPage)
})
lociTestedRow := container.NewHBox(layout.NewSpacer(), lociTestedLabel, lociTestedText, lociTestedHelpButton, layout.NewSpacer())
getDiseaseLociGrid := func()(*fyne.Container, error){
locusNameLabel := getItalicLabelCentered("Locus Name")
riskWeightLabel := getItalicLabelCentered("Risk Weight")
oddsRatioLabel := getItalicLabelCentered("Odds Ratio")
emptyLabel := widget.NewLabel("")
locusNameColumn := container.NewVBox(locusNameLabel, widget.NewSeparator())
riskWeightColumn := container.NewVBox(riskWeightLabel, widget.NewSeparator())
oddsRatioColumn := container.NewVBox(oddsRatioLabel, widget.NewSeparator())
viewButtonsColumn := container.NewVBox(emptyLabel, widget.NewSeparator())
addLocusRow := func(locusIdentifier string)error{
diseaseLocusObject, exists := diseaseLociMap[locusIdentifier]
if (exists == false) {
return errors.New("Cannot add locusRow: diseaseLociMap missing locus: " + locusIdentifier)
}
locusRSID := diseaseLocusObject.LocusRSID
locusRSIDString := helpers.ConvertInt64ToString(locusRSID)
locusName := "rs" + locusRSIDString
locusNameLabel := getBoldLabelCentered(locusName)
locusRiskWeightIsKnown, genomeLocusRiskWeight, _, locusOddsRatioIsKnown, _, locusOddsRatioFormatted, err := readGeneticAnalysis.GetPersonPolygenicDiseaseLocusInfoFromGeneticAnalysis(geneticAnalysisMapList, diseaseName, locusIdentifier, genomeIdentifier)
if (err != nil) { return err }
getGenomeLocusRiskWeightText := func()string{
if (locusRiskWeightIsKnown == false){
result := translate("Unknown")
return result
}
locusRiskWeightString := helpers.ConvertIntToString(genomeLocusRiskWeight)
return locusRiskWeightString
}
locusRiskWeightText := getGenomeLocusRiskWeightText()
locusRiskWeightLabel := getBoldLabelCentered(locusRiskWeightText)
getOddsRatioText := func()string{
if (locusOddsRatioIsKnown == false){
result := translate("Unknown")
return result
}
return locusOddsRatioFormatted
}
locusOddsRatioText := getOddsRatioText()
genomeLocusOddsRatioLabel := getBoldLabelCentered(locusOddsRatioText)
viewLocusButton := widget.NewButtonWithIcon("", theme.VisibilityIcon(), func(){
setViewPersonGeneticAnalysisPolygenicDiseaseLocusDetailsPage(window, geneticAnalysisMapList, diseaseName, locusIdentifier, currentPage)
})
locusNameColumn.Add(locusNameLabel)
riskWeightColumn.Add(locusRiskWeightLabel)
oddsRatioColumn.Add(genomeLocusOddsRatioLabel)
viewButtonsColumn.Add(viewLocusButton)
locusNameColumn.Add(widget.NewSeparator())
riskWeightColumn.Add(widget.NewSeparator())
oddsRatioColumn.Add(widget.NewSeparator())
viewButtonsColumn.Add(widget.NewSeparator())
return nil
}
// Items within each group are sorted so they will display the same way whenever user refreshes page
helpers.SortStringListToUnicodeOrder(lociList_PositiveWeight)
helpers.SortStringListToUnicodeOrder(lociList_NegativeWeight)
helpers.SortStringListToUnicodeOrder(lociList_ZeroWeight)
helpers.SortStringListToUnicodeOrder(lociList_UnknownWeight)
for _, locusIdentifier := range lociList_PositiveWeight{
err = addLocusRow(locusIdentifier)
if (err != nil) { return nil, err }
}
for _, locusIdentifier := range lociList_NegativeWeight{
err = addLocusRow(locusIdentifier)
if (err != nil) { return nil, err }
}
for _, locusIdentifier := range lociList_ZeroWeight{
err = addLocusRow(locusIdentifier)
if (err != nil) { return nil, err }
}
for _, locusIdentifier := range lociList_UnknownWeight{
err = addLocusRow(locusIdentifier)
if (err != nil) { return nil, err }
}
riskWeightHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setPolygenicDiseaseLocusRiskWeightExplainerPage(window, currentPage)
})
riskWeightColumn.Add(riskWeightHelpButton)
oddsRatioHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
//TODO
showUnderConstructionDialog(window)
})
oddsRatioColumn.Add(oddsRatioHelpButton)
diseaseLociGrid := container.NewHBox(layout.NewSpacer(), locusNameColumn, riskWeightColumn, oddsRatioColumn, viewButtonsColumn, layout.NewSpacer())
return diseaseLociGrid, nil
}
diseaseLociGrid, err := getDiseaseLociGrid()
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
page := container.NewVBox(title, backButton, widget.NewSeparator(), description1Row, widget.NewSeparator(), genomeNameRow, widget.NewSeparator(), lociTestedRow, widget.NewSeparator(), diseaseLociGrid)
setPageContent(page, window)
}
// This function provides a page to view the details of a specific locus from a person genetic analysis
// It will show the locus details for all of the person's genomes
func setViewPersonGeneticAnalysisPolygenicDiseaseLocusDetailsPage(window fyne.Window, geneticAnalysisMapList []map[string]string, diseaseName string, locusIdentifier string, previousPage func()){
currentPage := func(){setViewPersonGeneticAnalysisPolygenicDiseaseLocusDetailsPage(window, geneticAnalysisMapList, diseaseName, locusIdentifier, previousPage)}
title := getPageTitleCentered("Disease Locus Details - " + diseaseName)
backButton := getBackButtonCentered(previousPage)
locusObject, err := polygenicDiseases.GetPolygenicDiseaseLocusObject(diseaseName, locusIdentifier)
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
locusRSID := locusObject.LocusRSID
locusRSIDString := helpers.ConvertInt64ToString(locusRSID)
locusName := "rs" + locusRSIDString
description := getLabelCentered("Below is the locus result for the person's genomes.")
locusNameLabel := widget.NewLabel("Locus Name:")
locusNameText := getBoldLabel(locusName)
locusInfoButton := widget.NewButtonWithIcon("", theme.InfoIcon(), func(){
setViewPolygenicDiseaseLocusDetailsPage(window, diseaseName, locusIdentifier, currentPage)
})
locusNameRow := container.NewHBox(layout.NewSpacer(), locusNameLabel, locusNameText, locusInfoButton, layout.NewSpacer())
getGenomesLocusInfoGrid := func()(*fyne.Container, error){
allRawGenomeIdentifiersList, multipleGenomesExist, onlyExcludeConflictsGenomeIdentifier, onlyIncludeSharedGenomeIdentifier, err := readGeneticAnalysis.GetMetadataFromPersonGeneticAnalysis(geneticAnalysisMapList)
if (err != nil) { return nil, err }
genomeNameLabel := getItalicLabelCentered("Genome Name")
riskWeightLabel := getItalicLabelCentered("Risk Weight")
oddsRatioLabel := getItalicLabelCentered("Odds Ratio")
genomeNameColumn := container.NewVBox(genomeNameLabel, widget.NewSeparator())
riskWeightColumn := container.NewVBox(riskWeightLabel, widget.NewSeparator())
oddsRatioColumn := container.NewVBox(oddsRatioLabel, widget.NewSeparator())
addGenomeRow := func(genomeName string, genomeIdentifier string, isACombinedGenome bool)error{
genomeRiskWeightKnown, genomeRiskWeight, _, genomeOddsRatioKnown, _, genomeOddsRatioFormatted, err := readGeneticAnalysis.GetPersonPolygenicDiseaseLocusInfoFromGeneticAnalysis(geneticAnalysisMapList, diseaseName, locusIdentifier, genomeIdentifier)
if (err != nil) { return err }
getGenomeRiskWeightText := func()string{
if (genomeRiskWeightKnown == false){
result := translate("Unknown")
return result
}
genomeRiskWeightString := helpers.ConvertIntToString(genomeRiskWeight)
return genomeRiskWeightString
}
genomeRiskWeightText := getGenomeRiskWeightText()
getGenomeOddsRatioText := func()string{
if (genomeOddsRatioKnown == false){
result := translate("Unknown")
return result
}
return genomeOddsRatioFormatted
}
genomeOddsRatioText := getGenomeOddsRatioText()
getGenomeNameCell := func()*fyne.Container{
if (isACombinedGenome == false){
genomeNameLabel := getBoldLabelCentered(genomeName)
return genomeNameLabel
}
viewHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setCombinedGenomesExplainerPage(window, currentPage)
})
genomeNameLabel := getBoldLabel(genomeName)
genomeNameCell := container.NewHBox(layout.NewSpacer(), viewHelpButton, genomeNameLabel, layout.NewSpacer())
return genomeNameCell
}
genomeNameCell := getGenomeNameCell()
genomeNameColumn.Add(genomeNameCell)
riskWeightLabel := getBoldLabelCentered(genomeRiskWeightText)
riskWeightColumn.Add(riskWeightLabel)
oddsRatioLabel := getBoldLabelCentered(genomeOddsRatioText)
oddsRatioColumn.Add(oddsRatioLabel)
genomeNameColumn.Add(widget.NewSeparator())
riskWeightColumn.Add(widget.NewSeparator())
oddsRatioColumn.Add(widget.NewSeparator())
return nil
}
if (multipleGenomesExist == true){
err := addGenomeRow("Only Exclude Conflicts", onlyExcludeConflictsGenomeIdentifier, true)
if (err != nil){ return nil, err }
err = addGenomeRow("Only Include Shared", onlyIncludeSharedGenomeIdentifier, true)
if (err != nil){ return nil, err }
}
for _, genomeIdentifier := range allRawGenomeIdentifiersList{
getGenomeName := func()(string, error){
genomeFound, _, timeGenomeWasExported, _, _, _, companyName, _, _, err := myGenomes.GetMyRawGenomeMetadata(genomeIdentifier)
if (err != nil) { return "", err }
if (genomeFound == false){
return "", errors.New("MyGenomeInfo for genome from analysisMapList not found.")
}
if (multipleGenomesExist == false){
return companyName, nil
}
// We show the date that the genome was exported
exportTimeAgo, err := helpers.ConvertUnixTimeToTimeAgoTranslated(timeGenomeWasExported, false)
if (err != nil){ return "", err }
genomeName := companyName + " (Exported " + exportTimeAgo + ")"
return genomeName, nil
}
genomeName, err := getGenomeName()
if (err != nil) { return nil, err }
err = addGenomeRow(genomeName, genomeIdentifier, false)
if (err != nil){ return nil, err }
}
riskWeightHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setPolygenicDiseaseLocusRiskWeightExplainerPage(window, currentPage)
})
riskWeightColumn.Add(riskWeightHelpButton)
oddsRatioHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
//TODO
showUnderConstructionDialog(window)
})
oddsRatioColumn.Add(oddsRatioHelpButton)
genomesContainer := container.NewHBox(layout.NewSpacer(), genomeNameColumn, riskWeightColumn, oddsRatioColumn, layout.NewSpacer())
return genomesContainer, nil
}
genomesLocusInfoGrid, err := getGenomesLocusInfoGrid()
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
page := container.NewVBox(title, backButton, widget.NewSeparator(), description, widget.NewSeparator(), locusNameRow, widget.NewSeparator(), genomesLocusInfoGrid)
setPageContent(page, window)
}
func setViewPersonGeneticAnalysisTraitsPage(window fyne.Window, personIdentifier string, analysisMapList []map[string]string, previousPage func()){
currentPage := func(){setViewPersonGeneticAnalysisTraitsPage(window, personIdentifier, analysisMapList, previousPage)}
title := getPageTitleCentered("Viewing Genetic Analysis - Traits")
backButton := getBackButtonCentered(previousPage)
description := getLabelCentered("Below is an analysis of the traits for this person's genome.")
getTraitsContainer := func()(*fyne.Container, error){
allRawGenomeIdentifiersList, multipleGenomesExist, onlyExcludeConflictsGenomeIdentifier, _, err := readGeneticAnalysis.GetMetadataFromPersonGeneticAnalysis(analysisMapList)
if (err != nil){ return nil, err }
// Outputs:
// -string: Main genome identifier (Is either the combined Only exclude conflicts genome or the only genome)
// -error
getMainGenomeIdentifier := func()(string, error){
if (multipleGenomesExist == true){
return onlyExcludeConflictsGenomeIdentifier, nil
}
// Only 1 genome exists
genomeIdentifier := allRawGenomeIdentifiersList[0]
return genomeIdentifier, nil
}
mainGenomeIdentifier, err := getMainGenomeIdentifier()
if (err != nil){ return nil, err }
traitNameLabel := getItalicLabelCentered("Trait Name")
outcomeScoresLabel := getItalicLabelCentered("Outcome Scores")
conflictExistsLabel := getItalicLabelCentered("Conflict Exists?")
emptyLabel := widget.NewLabel("")
traitNameColumn := container.NewVBox(traitNameLabel, widget.NewSeparator())
outcomeScoresColumn := container.NewVBox(outcomeScoresLabel, widget.NewSeparator())
conflictExistsColumn := container.NewVBox(conflictExistsLabel, widget.NewSeparator())
viewButtonsColumn := container.NewVBox(emptyLabel, widget.NewSeparator())
traitObjectsList, err := traits.GetTraitObjectsList()
if (err != nil) { return nil, err }
for _, traitObject := range traitObjectsList{
traitName := traitObject.TraitName
traitRulesList := traitObject.RulesList
if (len(traitRulesList) == 0){
// This trait does not have any rules
// We cannot analyze it yet
// We will add neural network prediction so we can predict these traits
continue
}
traitOutcomeNamesList := traitObject.OutcomesList
_, anyTraitRuleTested, outcomeScoresMap, _, conflictExists, err := readGeneticAnalysis.GetPersonTraitInfoFromGeneticAnalysis(analysisMapList, traitName, mainGenomeIdentifier, multipleGenomesExist)
if (err != nil) { return nil, err }
// We add all of the columns except for the trait outcomes column, which may be multiple rows high
conflictExistsString := helpers.ConvertBoolToYesOrNoString(conflictExists)
conflictExistsLabel := getBoldLabelCentered(conflictExistsString)
viewDetailsButton := getWidgetCentered(widget.NewButtonWithIcon("", theme.VisibilityIcon(), func(){
setViewPersonGeneticAnalysisTraitDetailsPage(window, personIdentifier, analysisMapList, traitName, currentPage)
}))
traitNameText := getBoldLabelCentered(traitName)
traitNameColumn.Add(traitNameText)
conflictExistsColumn.Add(conflictExistsLabel)
viewButtonsColumn.Add(viewDetailsButton)
if (anyTraitRuleTested == false){
unknownTranslated := translate("Unknown")
unknownLabel := getBoldLabelCentered(unknownTranslated)
outcomeScoresColumn.Add(unknownLabel)
} else {
// We have to sort outcome names so they always show up in the same order
traitOutcomeNamesListSorted := helpers.CopyAndSortStringListToUnicodeOrder(traitOutcomeNamesList)
for index, outcomeName := range traitOutcomeNamesListSorted{
outcomeScore, exists := outcomeScoresMap[outcomeName]
if (exists == false){
return nil, errors.New("Outcome name not found in outcomeScoresMap: " + outcomeName)
}
outcomeScoreString := helpers.ConvertIntToString(outcomeScore)
outcomeRow := getBoldLabelCentered(outcomeName + ": " + outcomeScoreString)
outcomeScoresColumn.Add(outcomeRow)
if (index > 0){
emptyLabelA := widget.NewLabel("")
emptyLabelB := widget.NewLabel("")
emptyLabelC := widget.NewLabel("")
traitNameColumn.Add(emptyLabelA)
conflictExistsColumn.Add(emptyLabelB)
viewButtonsColumn.Add(emptyLabelC)
}
}
}
traitNameColumn.Add(widget.NewSeparator())
outcomeScoresColumn.Add(widget.NewSeparator())
conflictExistsColumn.Add(widget.NewSeparator())
viewButtonsColumn.Add(widget.NewSeparator())
}
outcomeScoresHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setTraitOutcomeScoresExplainerPage(window, currentPage)
})
outcomeScoresColumn.Add(outcomeScoresHelpButton)
traitsContainer := container.NewHBox(layout.NewSpacer(), traitNameColumn, outcomeScoresColumn)
if (multipleGenomesExist == true){
conflictExistsHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setPersonGeneticAnalysisConflictExistsExplainerPage(window, currentPage)
})
conflictExistsColumn.Add(conflictExistsHelpButton)
traitsContainer.Add(conflictExistsColumn)
}
traitsContainer.Add(viewButtonsColumn)
traitsContainer.Add(layout.NewSpacer())
return traitsContainer, nil
}
traitsContainer, err := getTraitsContainer()
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
page := container.NewVBox(title, backButton, widget.NewSeparator(), description, widget.NewSeparator(), traitsContainer)
setPageContent(page, window)
}
func setViewPersonGeneticAnalysisTraitDetailsPage(window fyne.Window, personIdentifier string, analysisMapList []map[string]string, traitName string, previousPage func()){
currentPage := func(){setViewPersonGeneticAnalysisTraitDetailsPage(window, personIdentifier, analysisMapList, traitName, previousPage)}
title := getPageTitleCentered("Viewing Genetic Analysis - " + traitName)
backButton := getBackButtonCentered(previousPage)
allRawGenomeIdentifiersList, multipleGenomesExist, onlyExcludeConflictsGenomeIdentifier, onlyIncludeSharedGenomeIdentifier, err := readGeneticAnalysis.GetMetadataFromPersonGeneticAnalysis(analysisMapList)
if (err != nil) {
setErrorEncounteredPage(window, err, previousPage)
return
}
getDescriptionSection := func()*fyne.Container{
if (multipleGenomesExist == false){
description := getLabelCentered("Below is the trait information for this person's genome.")
return description
}
description1 := getLabelCentered("Below is the trait information for this person's genomes.")
description2 := getLabelCentered("The first two genomes are created by combining multiple genomes.")
descriptionsSection := container.NewVBox(description1, description2)
return descriptionsSection
}
descriptionSection := getDescriptionSection()
traitNameLabel := widget.NewLabel("Trait:")
traitNameText := getBoldLabel(traitName)
traitInfoButton := widget.NewButtonWithIcon("", theme.InfoIcon(), func(){
setViewTraitDetailsPage(window, traitName, currentPage)
})
traitNameRow := container.NewHBox(layout.NewSpacer(), traitNameLabel, traitNameText, traitInfoButton, layout.NewSpacer())
getGenomesContainer := func()(*fyne.Container, error){
emptyLabelA := widget.NewLabel("")
genomeNameLabel := getItalicLabelCentered("Genome Name")
emptyLabelB := widget.NewLabel("")
outcomeScoresLabel := getItalicLabelCentered("Outcome Scores")
numberOfLabel := getItalicLabelCentered("Number of")
rulesTestedLabel := getItalicLabelCentered("Rules Tested")
emptyLabelD := widget.NewLabel("")
emptyLabelE := widget.NewLabel("")
genomeNameColumn := container.NewVBox(emptyLabelA, genomeNameLabel, widget.NewSeparator())
outcomeScoresColumn := container.NewVBox(emptyLabelB, outcomeScoresLabel, widget.NewSeparator())
numberOfRulesTestedColumn := container.NewVBox(numberOfLabel, rulesTestedLabel, widget.NewSeparator())
viewRulesButtonsColumn := container.NewVBox(emptyLabelD, emptyLabelE, widget.NewSeparator())
addGenomeRow := func(genomeName string, genomeIdentifier string, isACombinedGenome bool)error{
getGenomeNameCell := func()*fyne.Container{
if (isACombinedGenome == false){
genomeNameLabel := getBoldLabelCentered(genomeName)
return genomeNameLabel
}
viewHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setCombinedGenomesExplainerPage(window, currentPage)
})
genomeNameLabel := getBoldLabel(genomeName)
genomeNameCell := container.NewHBox(layout.NewSpacer(), viewHelpButton, genomeNameLabel, layout.NewSpacer())
return genomeNameCell
}
genomeNameCell := getGenomeNameCell()
_, anyTraitRuleTested, outcomeScoresMap, numberOfRulesTested, _, err := readGeneticAnalysis.GetPersonTraitInfoFromGeneticAnalysis(analysisMapList, traitName, genomeIdentifier, multipleGenomesExist)
if (err != nil) { return err }
// We add all of the columns except for the trait rule column, which may be multiple rows high
genomeNumberOfRulesTestedString := helpers.ConvertIntToString(numberOfRulesTested)
numberOfRulesTestedLabel := getBoldLabelCentered(genomeNumberOfRulesTestedString)
viewRulesButton := widget.NewButtonWithIcon("", theme.VisibilityIcon(), func(){
setViewPersonGenomeTraitRulesPage(window, analysisMapList, traitName, genomeIdentifier, genomeName, currentPage)
})
genomeNameColumn.Add(genomeNameCell)
numberOfRulesTestedColumn.Add(numberOfRulesTestedLabel)
viewRulesButtonsColumn.Add(viewRulesButton)
if (anyTraitRuleTested == false){
unknownTranslated := translate("Unknown")
unknownLabel := getBoldLabelCentered(unknownTranslated)
outcomeScoresColumn.Add(unknownLabel)
} else {
// We have to sort the outcome names so they always show up in the same order
outcomeNamesList := helpers.GetListOfMapKeys(outcomeScoresMap)
helpers.SortStringListToUnicodeOrder(outcomeNamesList)
for index, outcomeName := range outcomeNamesList{
outcomeScore, exists := outcomeScoresMap[outcomeName]
if (exists == false){
return errors.New("Outcome name not found in outcome scores map after being found already: " + outcomeName)
}
outcomeScoreString := helpers.ConvertIntToString(outcomeScore)
outcomeRow := getBoldLabelCentered(outcomeName + ": " + outcomeScoreString)
outcomeScoresColumn.Add(outcomeRow)
if (index > 0){
emptyLabelA := widget.NewLabel("")
emptyLabelB := widget.NewLabel("")
emptyLabelC := widget.NewLabel("")
genomeNameColumn.Add(emptyLabelA)
numberOfRulesTestedColumn.Add(emptyLabelB)
viewRulesButtonsColumn.Add(emptyLabelC)
}
}
}
genomeNameColumn.Add(widget.NewSeparator())
outcomeScoresColumn.Add(widget.NewSeparator())
numberOfRulesTestedColumn.Add(widget.NewSeparator())
viewRulesButtonsColumn.Add(widget.NewSeparator())
return nil
}
if (multipleGenomesExist == true){
err := addGenomeRow("Only Exclude Conflicts", onlyExcludeConflictsGenomeIdentifier, true)
if (err != nil){ return nil, err }
err = addGenomeRow("Only Include Shared", onlyIncludeSharedGenomeIdentifier, true)
if (err != nil){ return nil, err }
}
for _, genomeIdentifier := range allRawGenomeIdentifiersList{
getGenomeName := func()(string, error){
genomeFound, _, timeGenomeWasExported, _, _, _, companyName, _, _, err := myGenomes.GetMyRawGenomeMetadata(genomeIdentifier)
if (err != nil) { return "", err }
if (genomeFound == false){
return "", errors.New("MyGenomeInfo for genome from analysisMapList not found.")
}
if (multipleGenomesExist == false){
return companyName, nil
}
// We show the date that the genome was exported
exportTimeAgo, err := helpers.ConvertUnixTimeToTimeAgoTranslated(timeGenomeWasExported, false)
if (err != nil){ return "", err }
genomeName := companyName + " (Exported " + exportTimeAgo + ")"
return genomeName, nil
}
genomeName, err := getGenomeName()
if (err != nil) { return nil, err }
err = addGenomeRow(genomeName, genomeIdentifier, false)
if (err != nil){ return nil, err }
}
outcomeScoresHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setTraitOutcomeScoresExplainerPage(window, currentPage)
})
outcomeScoresColumn.Add(outcomeScoresHelpButton)
numberOfRulesTestedHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setTraitNumberOfRulesTestedExplainerPage(window, currentPage)
})
numberOfRulesTestedColumn.Add(numberOfRulesTestedHelpButton)
genomesContainer := container.NewHBox(layout.NewSpacer(), genomeNameColumn, outcomeScoresColumn, numberOfRulesTestedColumn, viewRulesButtonsColumn, layout.NewSpacer())
return genomesContainer, nil
}
genomesContainer, err := getGenomesContainer()
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
page := container.NewVBox(title, backButton, widget.NewSeparator(), descriptionSection, widget.NewSeparator(), traitNameRow, widget.NewSeparator(), genomesContainer)
setPageContent(page, window)
}
// Ths function provides a page to view the trait rules for a particular genome from a genetic analysis
func setViewPersonGenomeTraitRulesPage(window fyne.Window, geneticAnalysisMapList []map[string]string, traitName string, genomeIdentifier string, genomeName string, previousPage func()){
setLoadingScreen(window, "Loading Trait Rules", "Loading trait rules...")
currentPage := func(){setViewPersonGenomeTraitRulesPage(window, geneticAnalysisMapList, traitName, genomeIdentifier, genomeName, previousPage)}
title := getPageTitleCentered("View Trait Rules - " + traitName)
backButton := getBackButtonCentered(previousPage)
description1 := widget.NewLabel("Below are the trait rule results for this genome.")
rulesHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setTraitRulesExplainerPage(window, currentPage)
})
description1Row := container.NewHBox(layout.NewSpacer(), description1, rulesHelpButton, layout.NewSpacer())
getGenomeNameRow := func()*fyne.Container{
genomeLabel := widget.NewLabel("Genome:")
genomeNameLabel := getBoldLabel(genomeName)
if (genomeName == "Only Exclude Conflicts" || genomeName == "Only Include Shared"){
genomeHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setCombinedGenomesExplainerPage(window, currentPage)
})
genomeNameRow := container.NewHBox(layout.NewSpacer(), genomeLabel, genomeNameLabel, genomeHelpButton, layout.NewSpacer())
return genomeNameRow
}
genomeNameRow := container.NewHBox(layout.NewSpacer(), genomeLabel, genomeNameLabel, layout.NewSpacer())
return genomeNameRow
}
genomeNameRow := getGenomeNameRow()
traitRulesMap, err := traits.GetTraitRulesMap(traitName)
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
numberOfRulesTested := 0
rulesList_RulePassed := make([]string, 0)
rulesList_RuleNotPassed := make([]string, 0)
rulesList_Unknown := make([]string, 0)
for ruleIdentifier, _ := range traitRulesMap{
ruleStatusIsKnown, genomePassesRule, _, err := readGeneticAnalysis.GetPersonTraitRuleInfoFromGeneticAnalysis(geneticAnalysisMapList, traitName, ruleIdentifier, genomeIdentifier)
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
if (ruleStatusIsKnown == false){
rulesList_Unknown = append(rulesList_Unknown, ruleIdentifier)
continue
}
numberOfRulesTested += 1
if (genomePassesRule == true){
rulesList_RulePassed = append(rulesList_RulePassed, ruleIdentifier)
} else {
rulesList_RuleNotPassed = append(rulesList_RuleNotPassed, ruleIdentifier)
}
}
numberOfRulesTestedString := helpers.ConvertIntToString(numberOfRulesTested)
totalNumberOfRules := len(traitRulesMap)
totalNumberOfRulesString := helpers.ConvertIntToString(totalNumberOfRules)
rulesTestedLabel := widget.NewLabel("Rules Tested:")
rulesTestedText := getBoldLabel(numberOfRulesTestedString + "/" + totalNumberOfRulesString)
rulesTestedHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setTraitNumberOfRulesTestedExplainerPage(window, currentPage)
})
rulesTestedRow := container.NewHBox(layout.NewSpacer(), rulesTestedLabel, rulesTestedText, rulesTestedHelpButton, layout.NewSpacer())
getTraitRulesGrid := func()(*fyne.Container, error){
ruleIdentifierLabel := getItalicLabelCentered("Rule Identifier")
ruleEffectsLabel := getItalicLabelCentered("Rule Effects")
genomePassesRuleLabel := getItalicLabelCentered("Genome Passes Rule")
emptyLabel := widget.NewLabel("")
ruleIdentifierColumn := container.NewVBox(ruleIdentifierLabel, widget.NewSeparator())
ruleEffectsColumn := container.NewVBox(ruleEffectsLabel, widget.NewSeparator())
genomePassesRuleColumn := container.NewVBox(genomePassesRuleLabel, widget.NewSeparator())
viewButtonsColumn := container.NewVBox(emptyLabel, widget.NewSeparator())
addRuleRow := func(ruleIdentifier string)error{
ruleIdentifierLabel := getBoldLabelCentered(ruleIdentifier)
ruleStatusIsKnown, genomePassesRule, _, err := readGeneticAnalysis.GetPersonTraitRuleInfoFromGeneticAnalysis(geneticAnalysisMapList, traitName, ruleIdentifier, genomeIdentifier)
if (err != nil) { return err }
getGenomePassesRuleText := func()string{
if (ruleStatusIsKnown == false){
result := translate("Unknown")
return result
}
genomePassesRuleString := helpers.ConvertBoolToYesOrNoString(genomePassesRule)
genomePassesRuleTranslated := translate(genomePassesRuleString)
return genomePassesRuleTranslated
}
genomePassesRuleText := getGenomePassesRuleText()
genomePassesRuleLabel := getBoldLabelCentered(genomePassesRuleText)
// We add all of the columns except for the rule effects column
// We do this because the rule effects column may be multiple rows tall
viewRuleButton := widget.NewButtonWithIcon("", theme.VisibilityIcon(), func(){
setViewPersonGeneticAnalysisTraitRuleDetailsPage(window, geneticAnalysisMapList, traitName, ruleIdentifier, currentPage)
})
ruleIdentifierColumn.Add(ruleIdentifierLabel)
genomePassesRuleColumn.Add(genomePassesRuleLabel)
viewButtonsColumn.Add(viewRuleButton)
traitRuleObject, exists := traitRulesMap[ruleIdentifier]
if (exists == false){
return errors.New("Trait rule not found after being found already.")
}
ruleOutcomePointsMap := traitRuleObject.OutcomePointsMap
outcomeNamesList := helpers.GetListOfMapKeys(ruleOutcomePointsMap)
// We have to sort the outcome names so they always show up in the same order
helpers.SortStringListToUnicodeOrder(outcomeNamesList)
for index, outcomeName := range outcomeNamesList{
outcomeEffectInt, exists := ruleOutcomePointsMap[outcomeName]
if (exists == false){
return errors.New("OutcomeName not found in ruleOutcomePointsMap after being found already: " + outcomeName)
}
getOutcomeEffectString := func()string{
outcomeEffectString := helpers.ConvertIntToString(outcomeEffectInt)
if (outcomeEffectInt < 0){
return outcomeEffectString
}
outcomeEffect := "+" + outcomeEffectString
return outcomeEffect
}
outcomeEffect := getOutcomeEffectString()
outcomeRow := getBoldLabelCentered(outcomeName + ": " + outcomeEffect)
ruleEffectsColumn.Add(outcomeRow)
if (index > 0){
emptyLabelA := widget.NewLabel("")
emptyLabelB := widget.NewLabel("")
emptyLabelC := widget.NewLabel("")
ruleIdentifierColumn.Add(emptyLabelA)
genomePassesRuleColumn.Add(emptyLabelB)
viewButtonsColumn.Add(emptyLabelC)
}
}
ruleIdentifierColumn.Add(widget.NewSeparator())
ruleEffectsColumn.Add(widget.NewSeparator())
genomePassesRuleColumn.Add(widget.NewSeparator())
viewButtonsColumn.Add(widget.NewSeparator())
return nil
}
// Items within each group are sorted so they will display the same way whenever user refreshes page
helpers.SortStringListToUnicodeOrder(rulesList_RulePassed)
helpers.SortStringListToUnicodeOrder(rulesList_RuleNotPassed)
helpers.SortStringListToUnicodeOrder(rulesList_Unknown)
for _, ruleIdentifier := range rulesList_RulePassed{
err = addRuleRow(ruleIdentifier)
if (err != nil) { return nil, err }
}
for _, ruleIdentifier := range rulesList_RuleNotPassed{
err = addRuleRow(ruleIdentifier)
if (err != nil) { return nil, err }
}
for _, ruleIdentifier := range rulesList_Unknown{
err = addRuleRow(ruleIdentifier)
if (err != nil) { return nil, err }
}
ruleEffectsHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setTraitRuleOutcomeEffectsExplainerPage(window, currentPage)
})
ruleEffectsColumn.Add(ruleEffectsHelpButton)
genomePassesRuleHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setGenomePassesTraitRuleExplainerPage(window, currentPage)
})
genomePassesRuleColumn.Add(genomePassesRuleHelpButton)
traitRulesGrid := container.NewHBox(layout.NewSpacer(), ruleIdentifierColumn, ruleEffectsColumn, genomePassesRuleColumn, viewButtonsColumn, layout.NewSpacer())
return traitRulesGrid, nil
}
traitRulesGrid, err := getTraitRulesGrid()
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
page := container.NewVBox(title, backButton, widget.NewSeparator(), description1Row, widget.NewSeparator(), genomeNameRow, widget.NewSeparator(), rulesTestedRow, widget.NewSeparator(), traitRulesGrid)
setPageContent(page, window)
}
// This function provides a page to view the details of a specific trait rule from a person genetic analysis
// The page will show the rule details for all of the person's genomes
func setViewPersonGeneticAnalysisTraitRuleDetailsPage(window fyne.Window, geneticAnalysisMapList []map[string]string, traitName string, ruleIdentifier string, previousPage func()){
currentPage := func(){setViewPersonGeneticAnalysisTraitRuleDetailsPage(window, geneticAnalysisMapList, traitName, ruleIdentifier, previousPage)}
title := getPageTitleCentered("Trait Rule Details - " + traitName)
backButton := getBackButtonCentered(previousPage)
description := getLabelCentered("Below is the rule result for the person's genomes.")
ruleIdentifierLabel := widget.NewLabel("Rule Identifier:")
ruleIdentifierText := getBoldLabel(ruleIdentifier)
ruleInfoButton := widget.NewButtonWithIcon("", theme.InfoIcon(), func(){
setViewTraitRuleDetailsPage(window, traitName, ruleIdentifier, currentPage)
})
ruleIdentifierRow := container.NewHBox(layout.NewSpacer(), ruleIdentifierLabel, ruleIdentifierText, ruleInfoButton, layout.NewSpacer())
getGenomesRuleInfoGrid := func()(*fyne.Container, error){
allRawGenomeIdentifiersList, multipleGenomesExist, onlyExcludeConflictsGenomeIdentifier, onlyIncludeSharedGenomeIdentifier, err := readGeneticAnalysis.GetMetadataFromPersonGeneticAnalysis(geneticAnalysisMapList)
if (err != nil) { return nil, err }
genomeNameLabel := getItalicLabelCentered("Genome Name")
genomePassesRuleLabel := getItalicLabelCentered("Genome Passes Rule")
genomeNameColumn := container.NewVBox(genomeNameLabel, widget.NewSeparator())
genomePassesRuleColumn := container.NewVBox(genomePassesRuleLabel, widget.NewSeparator())
addGenomeRow := func(genomeName string, genomeIdentifier string, isACombinedGenome bool)error{
genomeRuleStatusKnown, genomePassesRule, _, err := readGeneticAnalysis.GetPersonTraitRuleInfoFromGeneticAnalysis(geneticAnalysisMapList, traitName, ruleIdentifier, genomeIdentifier)
if (err != nil) { return err }
getGenomePassesRuleText := func()string{
if (genomeRuleStatusKnown == false){
result := translate("Unknown")
return result
}
genomePassesRuleString := helpers.ConvertBoolToYesOrNoString(genomePassesRule)
genomePassesRuleTranslated := translate(genomePassesRuleString)
return genomePassesRuleTranslated
}
genomePassesRuleText := getGenomePassesRuleText()
getGenomeNameCell := func()*fyne.Container{
if (isACombinedGenome == false){
genomeNameLabel := getBoldLabelCentered(genomeName)
return genomeNameLabel
}
viewHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setCombinedGenomesExplainerPage(window, currentPage)
})
genomeNameLabel := getBoldLabel(genomeName)
genomeNameCell := container.NewHBox(layout.NewSpacer(), viewHelpButton, genomeNameLabel, layout.NewSpacer())
return genomeNameCell
}
genomeNameCell := getGenomeNameCell()
genomeNameColumn.Add(genomeNameCell)
genomePassesRuleLabel := getBoldLabelCentered(genomePassesRuleText)
genomePassesRuleColumn.Add(genomePassesRuleLabel)
genomeNameColumn.Add(widget.NewSeparator())
genomePassesRuleColumn.Add(widget.NewSeparator())
return nil
}
if (multipleGenomesExist == true){
err := addGenomeRow("Only Exclude Conflicts", onlyExcludeConflictsGenomeIdentifier, true)
if (err != nil){ return nil, err }
err = addGenomeRow("Only Include Shared", onlyIncludeSharedGenomeIdentifier, true)
if (err != nil){ return nil, err }
}
for _, genomeIdentifier := range allRawGenomeIdentifiersList{
getGenomeName := func()(string, error){
genomeFound, _, timeGenomeWasExported, _, _, _, companyName, _, _, err := myGenomes.GetMyRawGenomeMetadata(genomeIdentifier)
if (err != nil) { return "", err }
if (genomeFound == false){
return "", errors.New("MyGenomeInfo for genome from analysisMapList not found.")
}
if (multipleGenomesExist == false){
return companyName, nil
}
// We show the date that the genome was exported
exportTimeAgo, err := helpers.ConvertUnixTimeToTimeAgoTranslated(timeGenomeWasExported, false)
if (err != nil){ return "", err }
genomeName := companyName + " (Exported " + exportTimeAgo + ")"
return genomeName, nil
}
genomeName, err := getGenomeName()
if (err != nil) { return nil, err }
err = addGenomeRow(genomeName, genomeIdentifier, false)
if (err != nil){ return nil, err }
}
genomePassesRuleHelpButton := widget.NewButtonWithIcon("", theme.QuestionIcon(), func(){
setGenomePassesTraitRuleExplainerPage(window, currentPage)
})
genomePassesRuleColumn.Add(genomePassesRuleHelpButton)
genomesContainer := container.NewHBox(layout.NewSpacer(), genomeNameColumn, genomePassesRuleColumn, layout.NewSpacer())
return genomesContainer, nil
}
genomesRuleInfoGrid, err := getGenomesRuleInfoGrid()
if (err != nil){
setErrorEncounteredPage(window, err, previousPage)
return
}
page := container.NewVBox(title, backButton, widget.NewSeparator(), description, widget.NewSeparator(), ruleIdentifierRow, widget.NewSeparator(), genomesRuleInfoGrid)
setPageContent(page, window)
}