Skip to content

Commit

Permalink
feat(#684): rename CpicPhenotype to CpicLookup
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Jan 3, 2024
1 parent 2b53352 commit 4c5eab9
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/integration_test/drugs_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void main() {
warningLevel: WarningLevel.green))
]);
UserData.instance.lookups = {
'CYP2C9': CpicPhenotype(
'CYP2C9': CpicLookup(
geneSymbol: 'CYP2C9',
phenotype: 'Normal Metabolizer',
genotype: '*1/*1',
Expand Down
2 changes: 1 addition & 1 deletion app/lib/common/models/drug/drug_inhibitors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ List<String> inhibitorsFor(String geneSymbol) {
return _drugInhibitorsPerGene[geneSymbol] ?? [];
}

bool canBeInhibited(CpicPhenotype phenotype) {
bool canBeInhibited(CpicLookup phenotype) {
return inhibitableGenes.contains(phenotype.geneSymbol) &&
phenotype.lookupkey != '0.0';
}
2 changes: 1 addition & 1 deletion app/lib/common/models/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export 'drug/drug_inhibitors.dart';
export 'drug/guideline.dart';
export 'drug/warning_level.dart';
export 'metadata.dart';
export 'userdata/cpic_phenotype.dart';
export 'userdata/cpic_lookup.dart';
export 'userdata/gene_result.dart';
export 'userdata/userdata.dart';
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:hive/hive.dart';

part 'cpic_phenotype.g.dart';
part 'cpic_lookup.g.dart';

@HiveType(typeId: 2)
@JsonSerializable()
class CpicPhenotype {
CpicPhenotype({
class CpicLookup{
CpicLookup({
required this.geneSymbol,
required this.phenotype,
required this.genotype,
required this.lookupkey,
});

factory CpicPhenotype.fromJson(Map<String, dynamic> json) {
factory CpicLookup.fromJson(Map<String, dynamic> json) {
// transform lookupkey map to string
json['lookupkey'] = json['lookupkey'][json['genesymbol']];
return _$CpicPhenotypeFromJson(json);
return _$CpicLookupFromJson(json);
}

@HiveField(0)
Expand Down
4 changes: 2 additions & 2 deletions app/lib/common/models/userdata/userdata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class UserData {
UserData.instance.diplotypes?[gene]?.allelesTested;

@HiveField(1)
Map<String, CpicPhenotype>? lookups;
Map<String, CpicLookup>? lookups;

static MapEntry<String, String>? overwrittenLookup(
String gene,
Expand Down Expand Up @@ -223,7 +223,7 @@ Future<void> initUserData() async {
try {
Hive.registerAdapter(UserDataAdapter());
Hive.registerAdapter(GeneResultAdapter());
Hive.registerAdapter(CpicPhenotypeAdapter());
Hive.registerAdapter(CpicLookupAdapter());
} catch (e) {
return;
}
Expand Down
6 changes: 3 additions & 3 deletions app/lib/common/utilities/genome_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ Future<void> fetchAndSaveLookups() async {
// to a concrete CpicLookup instance, hence the cast to a List
final json = jsonDecode(response.body) as List<dynamic>;
final lookups =
json.map((e) => CpicPhenotype.fromJson(e as Map<String, dynamic>));
json.map((e) => CpicLookup.fromJson(e as Map<String, dynamic>));
final usersDiplotypes = UserData.instance.diplotypes;
if (usersDiplotypes == null) throw Exception();

// use a HashMap for better time complexity
final lookupsHashMap = HashMap<String, CpicPhenotype>.fromIterable(
final lookupsHashMap = HashMap<String, CpicLookup>.fromIterable(
lookups,
key: (lookup) => '${lookup.geneSymbol}__${lookup.genotype}',
value: (lookup) => lookup,
);
// ignore: omit_local_variable_types
final Map<String, CpicPhenotype> matchingLookups = {};
final Map<String, CpicLookup> matchingLookups = {};
// extract the matching lookups
for (final diplotype in usersDiplotypes.values) {
// the gene and the genotype build the key for the hashmap
Expand Down
2 changes: 1 addition & 1 deletion app/lib/report/pages/gene.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class GenePage extends HookWidget {
initialFilter: FilterState.forGene(phenotype.geneSymbol),
);

final CpicPhenotype phenotype;
final CpicLookup phenotype;
final DrugListCubit cubit;

@override
Expand Down
6 changes: 3 additions & 3 deletions app/lib/report/pages/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class ReportPage extends StatelessWidget {
final notTestedString = context.l10n.general_not_tested;
final userPhenotypes = CachedDrugs.instance.allGuidelineGenes.map(
(geneSymbol) => UserData.instance.lookups![geneSymbol] ??
// Add CpicPhenotype for unmatched lookup
CpicPhenotype(
// Add CpicLookup for unmatched lookup
CpicLookup(
geneSymbol: geneSymbol,
// phenotype will be overwritten with phenotype from lab or inhibited
// phenotype using PhenotypeInformation in GeneCard and GenePage
Expand Down Expand Up @@ -57,7 +57,7 @@ class ReportPage extends StatelessWidget {
class GeneCard extends StatelessWidget {
const GeneCard(this.phenotype, { super.key });

final CpicPhenotype phenotype;
final CpicLookup phenotype;

@override
Widget build(BuildContext context) {
Expand Down

0 comments on commit 4c5eab9

Please sign in to comment.