From d538afc7a2e24d3b9bb3ef99ccb4e5554fa1322d Mon Sep 17 00:00:00 2001 From: Simon Sarasova Date: Mon, 5 Aug 2024 21:29:14 +0000 Subject: [PATCH] Added LocusIsPhased information to the local user profile creation process. --- Changelog.md | 1 + Contributors.md | 2 +- .../myProfileExports/myProfileExports.go | 55 ++++++++++--------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/Changelog.md b/Changelog.md index 57854d7..ff610ad 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,6 +6,7 @@ Small and insignificant changes may not be included in this log. ## Unversioned Changes +* Added LocusIsPhased information to the local user profile creation process. - *Simon Sarasova* * Added the Height trait the traits package. Migrated locus metadata from json encoding to gob encoding. - *Simon Sarasova* * Upgraded Fyne to version 2.5.0. - *Simon Sarasova* * Added neural network trait prediction to genetic analyses. - *Simon Sarasova* diff --git a/Contributors.md b/Contributors.md index 1dac246..6fbd618 100644 --- a/Contributors.md +++ b/Contributors.md @@ -9,4 +9,4 @@ Many other people have written code for modules which are imported by Seekia. Th Name | Date Of First Commit | Number Of Commits --- | --- | --- -Simon Sarasova | June 13, 2023 | 269 \ No newline at end of file +Simon Sarasova | June 13, 2023 | 270 \ No newline at end of file diff --git a/internal/profiles/myProfileExports/myProfileExports.go b/internal/profiles/myProfileExports/myProfileExports.go index c6c6c28..e571261 100644 --- a/internal/profiles/myProfileExports/myProfileExports.go +++ b/internal/profiles/myProfileExports/myProfileExports.go @@ -196,7 +196,11 @@ func UpdateMyExportedProfile(myProfileType string, networkType byte)error{ } polygenicDiseaseObjectsList, err := polygenicDiseases.GetPolygenicDiseaseObjectsList() - if (err != nil) { return err } + if (err != nil) { return err } + + // This map stores the rsIDs to share in our profile + // We use a map to avoid duplicates + myLociToShareMap := make(map[int64]struct{}) for _, diseaseObject := range polygenicDiseaseObjectsList{ @@ -219,18 +223,7 @@ func UpdateMyExportedProfile(myProfileType string, networkType byte)error{ locusRSID := locusObject.LocusRSID - locusValueObject, exists := myGenomeLocusValuesMap[locusRSID] - if (exists == true){ - - rsIDString := helpers.ConvertInt64ToString(locusRSID) - - locusBase1 := locusValueObject.Base1Value - locusBase2 := locusValueObject.Base2Value - - basePairValue := locusBase1 + ";" + locusBase2 - - profileMap["LocusValue_rs" + rsIDString] = basePairValue - } + myLociToShareMap[locusRSID] = struct{}{} } } @@ -256,21 +249,33 @@ func UpdateMyExportedProfile(myProfileType string, networkType byte)error{ for _, rsID := range lociList{ - locusValueObject, exists := myGenomeLocusValuesMap[rsID] - if (exists == true){ - - rsIDString := helpers.ConvertInt64ToString(rsID) - - locusBase1 := locusValueObject.Base1Value - locusBase2 := locusValueObject.Base2Value - - basePairValue := locusBase1 + ";" + locusBase2 - - profileMap["LocusValue_rs" + rsIDString] = basePairValue - } + myLociToShareMap[rsID] = struct{}{} } } + for rsID, _ := range myLociToShareMap{ + + locusValueObject, exists := myGenomeLocusValuesMap[rsID] + if (exists == false){ + continue + } + + rsIDString := helpers.ConvertInt64ToString(rsID) + + locusBase1 := locusValueObject.Base1Value + locusBase2 := locusValueObject.Base2Value + locusIsPhased := locusValueObject.LocusIsPhased + + basePairValue := locusBase1 + ";" + locusBase2 + locisIsPhasedString := helpers.ConvertBoolToYesOrNoString(locusIsPhased) + + locusValueAttributeName := "LocusValue_rs" + rsIDString + locusIsPhasedAttributeName := "LocusIsPhased_rs" + rsIDString + + profileMap[locusValueAttributeName] = basePairValue + profileMap[locusIsPhasedAttributeName] = locisIsPhasedString + } + return nil }