-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#684): introduce GenotypeResult
- Loading branch information
Showing
21 changed files
with
280 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
abstract class Genotype{ | ||
Genotype({ | ||
const Genotype({ | ||
required this.gene, | ||
required this.variant, | ||
}); | ||
|
||
String gene; | ||
String variant; | ||
final String gene; | ||
final String variant; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import '../../module.dart'; | ||
|
||
class GenotypeKey implements Genotype { | ||
GenotypeKey(this.gene, this.variant); | ||
|
||
factory GenotypeKey.fromGenotype(Genotype genotype) => | ||
GenotypeKey(genotype.gene, genotype.variant); | ||
|
||
@override | ||
String gene; | ||
|
||
@override | ||
String variant; | ||
|
||
String get value { | ||
final geneResults = UserData.instance.geneResults!.where( | ||
(geneResult) => geneResult.gene == gene | ||
); | ||
if (geneResults.length > 1) { | ||
return '$gene ${variant.split(' ').first}'; | ||
} | ||
return gene; | ||
} | ||
|
||
static String extractGene(String genotypeKey) => | ||
genotypeKey.split(' ').first; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'package:hive/hive.dart'; | ||
|
||
import '../../module.dart'; | ||
|
||
part 'genotype_result.g.dart'; | ||
|
||
@HiveType(typeId: 2) | ||
class GenotypeResult implements Genotype { | ||
GenotypeResult({ | ||
required this.gene, | ||
required this.variant, | ||
required this.phenotype, | ||
required this.lookupkey, | ||
required this.allelesTested, | ||
}); | ||
|
||
factory GenotypeResult.fromGenotypeData( | ||
GeneResult labResult, | ||
LookupInformation lookup, | ||
) => GenotypeResult( | ||
gene: labResult.gene, | ||
variant: labResult.variant, | ||
phenotype: labResult.phenotype, | ||
lookupkey: lookup.lookupkey, | ||
allelesTested: labResult.allelesTested, | ||
); | ||
|
||
factory GenotypeResult.missingResult(String gene, BuildContext context) => | ||
GenotypeResult( | ||
gene: gene, | ||
variant: context.l10n.general_not_tested, | ||
phenotype: context.l10n.general_not_tested, | ||
lookupkey: context.l10n.general_not_tested, | ||
allelesTested: context.l10n.general_not_tested, | ||
); | ||
|
||
@override | ||
@HiveField(0) | ||
String gene; | ||
@override | ||
@HiveField(1) | ||
String variant; | ||
@HiveField(2) | ||
String phenotype; | ||
@HiveField(3) | ||
String lookupkey; | ||
@HiveField(4) | ||
String allelesTested; | ||
|
||
String get key => GenotypeKey.fromGenotype(this).value; | ||
} | ||
|
||
extension FindGenotypeResultByKey on Map<String, GenotypeResult> { | ||
GenotypeResult findOrMissing(String genotypeKey, BuildContext context) => | ||
this[genotypeKey] ?? GenotypeResult.missingResult( | ||
GenotypeKey.extractGene(genotypeKey), | ||
context, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class PhenotypeInformation { | ||
PhenotypeInformation({ | ||
required this.phenotype, | ||
this.adaptionText, | ||
this.overwrittenPhenotypeText, | ||
}); | ||
|
||
String phenotype; | ||
String? adaptionText; | ||
String? overwrittenPhenotypeText; | ||
} |
Oops, something went wrong.