Skip to content

Commit

Permalink
feat(#684): introduce Genotype interface
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Jan 3, 2024
1 parent 6269e0c commit 6e99122
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/lib/common/models/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export 'drug/warning_level.dart';
export 'metadata.dart';
export 'userdata/cpic_lookup.dart';
export 'userdata/gene_result.dart';
export 'userdata/genotype.dart';
export 'userdata/userdata.dart';
6 changes: 5 additions & 1 deletion app/lib/common/models/userdata/cpic_lookup.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:hive/hive.dart';

import 'genotype.dart';

part 'cpic_lookup.g.dart';

@HiveType(typeId: 2)
@JsonSerializable()
class CpicLookup{
class CpicLookup implements Genotype {
CpicLookup({
required this.gene,
required this.phenotype,
Expand All @@ -19,10 +21,12 @@ class CpicLookup{
return _$CpicLookupFromJson(json);
}

@override
@HiveField(0)
@JsonKey(name: 'genesymbol')
String gene;

@override
@HiveField(1)
@JsonKey(name: 'diplotype')
String genotype;
Expand Down
5 changes: 4 additions & 1 deletion app/lib/common/models/userdata/gene_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import 'dart:convert';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:hive/hive.dart';
import 'package:http/http.dart';
import 'genotype.dart';

part 'gene_result.g.dart';

@HiveType(typeId: 1)
@JsonSerializable()
class GeneResult {
class GeneResult implements Genotype {
GeneResult({
required this.gene,
required this.genotype,
Expand All @@ -19,9 +20,11 @@ class GeneResult {
factory GeneResult.fromJson(dynamic json) => _$GeneResultFromJson(json);
Map<String, dynamic> toJson() => _$GeneResultToJson(this);

@override
@HiveField(0)
String gene;

@override
@HiveField(1)
String genotype;

Expand Down
9 changes: 9 additions & 0 deletions app/lib/common/models/userdata/genotype.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
abstract class Genotype{
Genotype({
required this.gene,
required this.genotype,
});

String gene;
String genotype;
}

0 comments on commit 6e99122

Please sign in to comment.