dmyersturnbull /
mandos
| 1 | import pytest |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 2 | |||
| 3 | from mandos.chembl_api import ChemblApi, ChemblEntrypoint |
||
| 4 | from mandos.model.targets import Target, TargetFactory, TargetRelationshipType, TargetType |
||
| 5 | |||
| 6 | |||
| 7 | class TestTargets: |
||
|
0 ignored issues
–
show
|
|||
| 8 | def test_find(self): |
||
|
0 ignored issues
–
show
This method could be written as a function/class method.
If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example class Foo:
def some_method(self, x, y):
return x + y;
could be written as class Foo:
@classmethod
def some_method(cls, x, y):
return x + y;
Loading history...
|
|||
| 9 | dat = dict( |
||
| 10 | target_chembl_id="CHEMBL4444", |
||
| 11 | pref_name="dopamine transporter", |
||
| 12 | target_type="SINGLE_PROTEIN", |
||
| 13 | ) |
||
| 14 | api = ChemblApi.mock({"target": ChemblEntrypoint.mock({"DAT": dat})}) |
||
| 15 | target = TargetFactory.find("DAT", api) |
||
| 16 | assert isinstance(target, Target) |
||
| 17 | assert target.type == TargetType.single_protein |
||
| 18 | assert target.name == "dopamine transporter" |
||
| 19 | assert target.chembl == "CHEMBL4444" |
||
| 20 | |||
| 21 | def test_parents(self): |
||
|
0 ignored issues
–
show
This method could be written as a function/class method.
If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example class Foo:
def some_method(self, x, y):
return x + y;
could be written as class Foo:
@classmethod
def some_method(cls, x, y):
return x + y;
Loading history...
|
|||
| 22 | dat = dict( |
||
| 23 | target_chembl_id="CHEMBL4444", |
||
| 24 | pref_name="dopamine transporter", |
||
| 25 | target_type="SINGLE_PROTEIN", |
||
| 26 | ) |
||
| 27 | monoamine = dict( |
||
| 28 | target_chembl_id="CHEMBL1111", |
||
| 29 | pref_name="monoamine transporter", |
||
| 30 | target_type="SINGLE_PROTEIN", |
||
| 31 | ) |
||
| 32 | receptor = dict( |
||
| 33 | target_chembl_id="CHEMBL0000", pref_name="receptor", target_type="PROTEIN_COMPLEX" |
||
| 34 | ) |
||
| 35 | relations = [ |
||
| 36 | dict(relationship="SUBSET OF", related_target_chembl_id="CHEMBL1111"), |
||
| 37 | dict(relationship="SUBSET OF", related_target_chembl_id="CHEMBL0000"), |
||
| 38 | ] |
||
| 39 | get_target = { |
||
| 40 | "DAT": dat, |
||
| 41 | "CHEMBL4444": dat, |
||
| 42 | "CHEMBL1111": monoamine, |
||
| 43 | "CHEMBL0000": receptor, |
||
| 44 | } |
||
| 45 | |||
| 46 | def filter_targets(kwargs): |
||
|
0 ignored issues
–
show
|
|||
| 47 | x = kwargs["target_chembl_id"] |
||
|
0 ignored issues
–
show
Variable name "x" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. Loading history...
|
|||
| 48 | if x == "CHEMBL4444": |
||
|
0 ignored issues
–
show
|
|||
| 49 | return [dat] |
||
| 50 | elif x == "CHEMBL1111": |
||
| 51 | return [monoamine] |
||
| 52 | elif x == "CHEMBL0000": |
||
| 53 | return [receptor] |
||
| 54 | |||
| 55 | def filter_relations(kwargs): |
||
|
0 ignored issues
–
show
|
|||
| 56 | return relations |
||
| 57 | |||
| 58 | api = ChemblApi.mock( |
||
| 59 | { |
||
| 60 | "target": ChemblEntrypoint.mock(get_target, filter_targets), |
||
| 61 | "target_relation": ChemblEntrypoint.mock({}, filter_relations), |
||
| 62 | } |
||
| 63 | ) |
||
| 64 | target = TargetFactory.find("CHEMBL4444", api) |
||
| 65 | assert len(target.links({TargetRelationshipType.subset_of})) == 2 |
||
| 66 | # should sort by CHEMBL ID first, so 0000 will be first |
||
| 67 | parent, link_type = target.links({TargetRelationshipType.subset_of})[0] |
||
|
0 ignored issues
–
show
|
|||
| 68 | assert parent.name == "receptor" |
||
| 69 | assert parent.chembl == "CHEMBL0000" |
||
| 70 | parent, link_type = target.links({TargetRelationshipType.subset_of})[1] |
||
| 71 | assert parent.name == "monoamine transporter" |
||
| 72 | assert parent.chembl == "CHEMBL1111" |
||
| 73 | |||
| 74 | def test_traverse_gabaa(self): |
||
|
0 ignored issues
–
show
This method could be written as a function/class method.
If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example class Foo:
def some_method(self, x, y):
return x + y;
could be written as class Foo:
@classmethod
def some_method(cls, x, y):
return x + y;
Loading history...
|
|||
| 75 | x = dict( |
||
|
0 ignored issues
–
show
Variable name "x" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. Loading history...
|
|||
| 76 | target_chembl_id="CHEMBL5112", |
||
| 77 | pref_name="GABA receptor alpha-5 subunit", |
||
| 78 | target_type="SINGLE PROTEIN", |
||
| 79 | ) |
||
| 80 | x_row1 = dict( |
||
| 81 | target_chembl_id="CHEMBL2093872", |
||
| 82 | pref_name="GABA-A receptor; anion channel", |
||
| 83 | target_type="PROTEIN COMPLEX GROUP", |
||
| 84 | ) |
||
| 85 | x_row1_superset = dict( |
||
|
0 ignored issues
–
show
|
|||
| 86 | target_chembl_id="CHEMBL1111", pref_name="supergroup", target_type="SELECTIVITY FILTER" |
||
| 87 | ) |
||
| 88 | x_row2 = dict( |
||
|
0 ignored issues
–
show
|
|||
| 89 | target_chembl_id="CHEMBL2094122", |
||
| 90 | pref_name="GABA-A receptor; alpha-5/beta-3/gamma-2", |
||
| 91 | target_type="PROTEIN COMPLEX", |
||
| 92 | ) |
||
| 93 | x_row3 = dict( |
||
|
0 ignored issues
–
show
|
|||
| 94 | target_chembl_id="CHEMBL2109243", |
||
| 95 | pref_name="GABA-A receptor; benzodiazepine site", |
||
| 96 | target_type="PROTEIN COMPLEX GROUP", |
||
| 97 | ) |
||
| 98 | x_row4 = dict( |
||
| 99 | target_chembl_id="CHEMBL2109244", |
||
| 100 | pref_name="GABA-A receptor; agonist GABA site", |
||
| 101 | target_type="PROTEIN COMPLEX GROUP", |
||
| 102 | ) |
||
| 103 | x_row5 = dict( |
||
|
0 ignored issues
–
show
|
|||
| 104 | target_chembl_id="CHEMBL3885576", |
||
| 105 | pref_name="Gamma-aminobutyric acid receptor subunit alpha-5/beta-2", |
||
| 106 | target_type="PROTEIN COMPLEX", |
||
| 107 | ) |
||
| 108 | x_row6 = dict( |
||
|
0 ignored issues
–
show
|
|||
| 109 | target_chembl_id="CHEMBL3885577", |
||
| 110 | pref_name="Gamma-aminobutyric acid receptor subunit alpha-5/beta-3/gamma-3", |
||
| 111 | target_type="PROTEIN COMPLEX", |
||
| 112 | ) |
||
| 113 | x_row7 = dict( |
||
|
0 ignored issues
–
show
|
|||
| 114 | target_chembl_id="CHEMBL4296057", |
||
| 115 | pref_name="Gamma-aminobutyric acid receptor subunit alpha-5/beta-3", |
||
| 116 | target_type="PROTEIN COMPLEX", |
||
| 117 | ) |
||
| 118 | xrow2_row2 = x_row1 |
||
|
0 ignored issues
–
show
|
|||
| 119 | xrow3_row3 = x_row1 |
||
|
0 ignored issues
–
show
|
|||
| 120 | xrow4_row5 = x_row1 |
||
|
0 ignored issues
–
show
|
|||
| 121 | xrow5_row3 = x_row1 |
||
|
0 ignored issues
–
show
|
|||
| 122 | xrow5_row7 = x_row4 |
||
|
0 ignored issues
–
show
|
|||
| 123 | relations = [ |
||
|
0 ignored issues
–
show
|
|||
| 124 | dict(relationship="SUBSET OF", related_target_chembl_id="CHEMBL1111"), |
||
| 125 | dict(relationship="SUBSET OF", related_target_chembl_id="CHEMBL0000"), |
||
| 126 | ] |
||
| 127 | # TODO |
||
|
0 ignored issues
–
show
|
|||
| 128 | |||
| 129 | |||
| 130 | if __name__ == "__main__": |
||
| 131 | pytest.main() |
||
| 132 |