Code Duplication    Length = 27-27 lines in 2 locations

mandos/search/pubchem/dgidb_search.py 2 locations

@@ 48-74 (lines=27) @@
45
        ]
46
47
48
class CgiSearch(PubchemSearch[CgiHit]):
49
    """"""
50
51
    def __init__(self, key: str, api: PubchemApi):
52
        super().__init__(key, api)
53
54
    @property
55
    def data_source(self) -> str:
56
        return "The Drug Gene Interaction Database (DGIdb)"
57
58
    def find(self, inchikey: str) -> Sequence[DgiHit]:
59
        data = self.api.fetch_data(inchikey)
60
        return [
61
            DgiHit(
62
                record_id=None,
63
                origin_inchikey=inchikey,
64
                matched_inchikey=data.names_and_identifiers.inchikey,
65
                compound_id=str(data.cid),
66
                compound_name=data.name,
67
                predicate=f"interacts with gene (compound)",
68
                object_id=dd.gene_name,
69
                object_name=dd.gene_name,
70
                search_key=self.key,
71
                search_class=self.search_class,
72
                data_source=self.data_source,
73
            )
74
            for dd in data.biomolecular_interactions_and_pathways.compound_gene_interactions
75
        ]
76
77
@@ 18-44 (lines=27) @@
15
    """"""
16
17
18
class DgiSearch(PubchemSearch[DgiHit]):
19
    """"""
20
21
    def __init__(self, key: str, api: PubchemApi):
22
        super().__init__(key, api)
23
24
    @property
25
    def data_source(self) -> str:
26
        return "The Drug Gene Interaction Database (DGIdb)"
27
28
    def find(self, inchikey: str) -> Sequence[DgiHit]:
29
        data = self.api.fetch_data(inchikey)
30
        return [
31
            DgiHit(
32
                record_id=None,
33
                origin_inchikey=inchikey,
34
                matched_inchikey=data.names_and_identifiers.inchikey,
35
                compound_id=str(data.cid),
36
                compound_name=data.name,
37
                predicate=f"interacts with gene (drug)",
38
                object_id=dd.gene_claim_id,
39
                object_name=dd.gene_name,
40
                search_key=self.key,
41
                search_class=self.search_class,
42
                data_source=self.data_source,
43
            )
44
            for dd in data.biomolecular_interactions_and_pathways.drug_gene_interactions
45
        ]
46
47