1 | from datetime import date |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
2 | from pathlib import Path |
||
3 | |||
4 | import pytest |
||
0 ignored issues
–
show
|
|||
5 | |||
6 | from mandos.pubchem_api import ( |
||
7 | QueryingPubchemApi, |
||
8 | CachingPubchemApi, |
||
9 | ) |
||
10 | from mandos.model.pubchem_support import ( |
||
0 ignored issues
–
show
|
|||
11 | Codes, |
||
12 | CoOccurrenceType, |
||
13 | AtcCode, |
||
14 | Publication, |
||
15 | CoOccurrence, |
||
16 | ) |
||
17 | |||
18 | |||
19 | class TestPubchemData: |
||
0 ignored issues
–
show
|
|||
20 | def test(self): |
||
0 ignored issues
–
show
|
|||
21 | pass # nav = PubchemData() |
||
22 | |||
23 | |||
24 | class TestPubchemApi: |
||
0 ignored issues
–
show
|
|||
25 | def test(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;
![]() |
|||
26 | path = Path(__file__).parent / "resources" / "pchem_store" |
||
27 | querier = CachingPubchemApi(path, QueryingPubchemApi(), compress=False) |
||
28 | x = querier.fetch_data("PIQVDUKEQYOJNR-VZXSFKIWSA-N") |
||
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. ![]() |
|||
29 | assert x.cid == 446220 |
||
30 | assert x.parent_or_self == 446220 |
||
31 | title = x.title_and_summary |
||
32 | assert title.safety is not None |
||
33 | assert title.safety == {"Irritant", "Acute Toxic"} |
||
34 | props = x.chemical_and_physical_properties |
||
35 | assert props.computed is not None |
||
36 | assert 0 < len(props.computed) < 40 |
||
37 | drug = x.drug_and_medication_information |
||
38 | assert drug.indication_summary_drugbank == "Cocaine has indications." |
||
39 | assert drug.classes == {"Central Nervous System Stimulants"} |
||
40 | assert drug.indication_summary_livertox == "Cocaine is a benzoid acid ester." |
||
41 | # assert drug.clinical_trials == set() |
||
42 | pharm = x.pharmacology_and_biochemistry |
||
43 | assert pharm.summary_drugbank_text == "Cocaine is a local anesthetic indicated for things." |
||
44 | assert pharm.summary_ncit_text == "Cocaine is a tropane alkaloid." |
||
45 | assert pharm.summary_ncit_links == frozenset( |
||
46 | {"dopamine", "serotonin", "norepinephrine", "cocaine"} |
||
47 | ) |
||
48 | assert pharm.mesh == frozenset( |
||
49 | {"Dopamine Uptake Inhibitors", "Anesthetics, Local", "Vasoconstrictor Agents"} |
||
50 | ) |
||
51 | assert pharm.atc == frozenset( |
||
52 | { |
||
53 | AtcCode(code="S02D", name="Other otologicals"), |
||
54 | AtcCode(code="R02A", name="Throat preparations"), |
||
55 | AtcCode(code="N01BC01", name="Cocaine"), |
||
56 | AtcCode(code="R", name="Respiratory system"), |
||
57 | AtcCode(code="R02AD", name="Anesthetics, local"), |
||
58 | AtcCode(code="R02", name="Throat preparations"), |
||
59 | AtcCode(code="R02AD03", name="Cocaine"), |
||
60 | AtcCode(code="S01", name="Ophthalmologicals"), |
||
61 | AtcCode(code="S02DA", name="Analgesics and anesthetics"), |
||
62 | AtcCode(code="N01B", name="Anesthetics, local"), |
||
63 | AtcCode(code="S01HA", name="Local anesthetics"), |
||
64 | AtcCode(code="N01BC", name="Esters of benzoic acid"), |
||
65 | AtcCode(code="S02DA02", name="Cocaine"), |
||
66 | AtcCode(code="N", name="Nervous system"), |
||
67 | AtcCode(code="S01HA01", name="Cocaine"), |
||
68 | AtcCode(code="S", name="Sensory organs"), |
||
69 | AtcCode(code="S02", name="Otologicals"), |
||
70 | AtcCode(code="S01H", name="Local anesthetics"), |
||
71 | AtcCode(code="N01", name="Anesthetics"), |
||
72 | } |
||
73 | ) |
||
74 | assert pharm.moa_summary_drugbank_links == frozenset( |
||
75 | {"norepinephrine", "serotonin", "cocaine", "dopamine"} |
||
76 | ) |
||
77 | assert ( |
||
78 | pharm.moa_summary_drugbank_text |
||
79 | == "Cocaine produces anesthesia by inhibiting excitation of nerve endings or by blocking conduction in peripheral nerves. This is achieved by reversibly binding to and inactivating sodium channels. Sodium influx through these channels is necessary for the depolarization of nerve cell membranes and subsequent propagation of impulses along the course of the nerve. Cocaine is the only local anesthetic with vasoconstrictive properties. This is a result of its blockade of norepinephrine reuptake in the autonomic nervous system. Cocaine binds differentially to the dopamine, serotonin, and norepinephrine transport proteins and directly prevents the re-uptake of dopamine, serotonin, and norepinephrine into pre-synaptic neurons. Its effect on dopamine levels is most responsible for the addictive property of cocaine." |
||
0 ignored issues
–
show
|
|||
80 | ) |
||
81 | # possible copyright issues with these ones, but they're correct |
||
82 | assert pharm.moa_summary_hsdb_links |
||
83 | assert pharm.moa_summary_hsdb_text |
||
84 | assert pharm.biochem_reactions == frozenset( |
||
85 | {"Metabolism", "Biological oxidations", "Phase I - Functionalization of compounds"} |
||
86 | ) |
||
87 | safety = x.safety_and_hazards |
||
88 | assert {g.code for g in safety.ghs_codes} == {"H331", "H317", "H311", "H301"} |
||
89 | tox = x.toxicity |
||
90 | assert tox.acute_effects == frozenset( |
||
91 | { |
||
92 | "autonomic nervous system: sympathomimetic", |
||
93 | "behavioral: altered sleep time (including change in righting " "reflex)", |
||
0 ignored issues
–
show
|
|||
94 | "behavioral: convulsions or effect on seizure threshold", |
||
95 | "behavioral: excitement", |
||
96 | "behavioral: general anesthetic", |
||
97 | "cardiac: pulse rate", |
||
98 | "lungs, thorax, or respiration: respiratory stimulation", |
||
99 | } |
||
100 | ) |
||
101 | lit = x.literature |
||
102 | chem_co = lit.chemical_cooccurrences |
||
103 | assert frozenset([c.strip_pubs() for c in chem_co]) == frozenset({}) |
||
104 | assert lit.gene_cooccurrences == frozenset({}) |
||
105 | assert lit.disease_cooccurrences == frozenset({}) |
||
106 | assert lit.drug_gene_interactions == frozenset({}) |
||
107 | assert lit.compound_gene_interactions == frozenset({}) |
||
108 | |||
109 | |||
110 | if __name__ == "__main__": |
||
111 | pytest.main() |
||
112 |