def test_draw_grid(client): res = client.post( "/draw/grid", json={ "compounds": {"identifier": "inchi", "compounds": test_compounds["inchi"]} }, ) assert res.status_code == 200 res_json = res.get_json() assert len(res_json["svg"]) > 50000
def test_mass(client): res = client.post( "/properties/mass", json={ "compounds": {"identifier": "inchi", "compounds": test_compounds["inchi"]} }, ) assert res.status_code == 200 res_json = res.get_json() assert len(res_json["mass"]) == 4 assert all(x > 200 for x in res_json["mass"].values())
def test_id_conversion(client): res = client.post( "/properties/convert", json={ "compounds": {"identifier": "inchi", "compounds": test_compounds["inchi"]}, "target_identifier": "smiles", }, ) assert res.status_code == 200 res_json = res.get_json() assert len(res_json["compounds"]["compounds"]) == 4 assert all(len(x) > 10 for x in res_json["compounds"]["compounds"])
def test_calculate_fingerprints(client, fingerprint_type, fingerprint_args): res = client.post( "/fingerprints/calculate", json={ "query": { "identifier": "inchi", "compounds": test_compounds["inchi"][:2] }, "fingerprint_type": fingerprint_type, "fingerprint_args": fingerprint_args, }, ) assert res.status_code == 200 res_json = res.get_json() assert all(len(x) == 2 for x in res_json.values())
def test_tautomerize(client): res = client.post( "/tautomers/enumerate", json={ "compounds": { "identifier": "inchi", "compounds": test_compounds["inchi"][:2], }, "max_tautomers": 5, }, ) assert res.status_code == 200 res_json = res.get_json() assert len(res_json["tautomers"]) == 2 assert tuple(len(v["compounds"]) for v in res_json["tautomers"].values()) == (1, 4)
def test_similarity_threshold_fp(client): res = client.post( "/fingerprints/similarity_threshold", json={ "query": { "identifier": "inchi", "compounds": ["a", "b", "c"], "fingerprints": ["880DF", "881DF", "870E0"], }, "threshold": 0.8, }, ) assert res.status_code == 200 res_json = res.get_json() assert all(len(x) == 1 for x in res_json.values()) assert res_json["query"][0] == "0" assert res_json["target"][0] == "1"
def test_murcko_scaffold(client): res = client.post( "/fingerprints/murcko_scaffold", json={ "query": { "identifier": "smiles", "compounds": [ "O=C(NCc1cc(OC)c(O)cc1)CCCC/C=C/C(C)C", "CC1=C(C=C(C=C1)NC(=O)C2=CC=C(C=C2)CN3CCN(CC3)C)NC4=NC=CC(=N4)C5=CN=CC=C5", ], }, }, ) assert res.status_code == 200 res_json = res.get_json() assert res_json["scaffolds"]["compounds"][0] == "c1ccccc1"
def test_canonicalize(client): res = client.post( "/tautomers/canonicalize", json={ "compounds": { "identifier": "inchi", "compounds": test_compounds["inchi"][:2], }, "standardize": True, }, ) assert res.status_code == 200 res_json = res.get_json() assert len(res_json["canonical"]) == 2 assert res_json["canonical"]["identifier"] == "inchi" assert len(res_json["canonical"]["compounds"]) == 2 assert len(res_json["skipped"]) == 0
def test_maximum_common_substructure(client): res = client.post( "/fingerprints/maximum_common_substructure", json={ "query": { "identifier": "smiles", "compounds": [ "O=C(NCc1cc(OC)c(O)cc1)CCCC/C=C/C(C)C", "CC(C)CCCCCC(=O)NCC1=CC(=C(C=C1)O)OC", "c1(C=O)cc(OC)c(O)cc1", ], }, }, ) assert res.status_code == 200 res_json = res.get_json() assert res_json["substructure"]["compounds"] == "COC1:C:C(C):C:C:C:1O"
def test_organic(client): res = client.post( "/properties/organic", json={ "compounds": { "identifier": "smiles", "compounds": [ r"COc1ccc(CCN2CCCn3c2nc4N(C)C(=O)N(CC(C)C)C(=O)c34)cc1OC", r"[Pb]", ], } }, ) assert res.status_code == 200 res_json = res.get_json() print(res_json) assert len(res_json["organic"]) == 2 assert tuple(res_json["organic"].values()) == (True, False)
def test_substructure(client, substructure_args): res = client.post( "/fingerprints/substructure", json={ "query": { "identifier": "inchi", "compounds": test_compounds["inchi"][:2] }, "target": { "identifier": "smiles", "compounds": test_compounds["smiles"][1:4], }, "substructure_args": substructure_args, }, ) assert res.status_code == 200 res_json = res.get_json() assert all(len(x) == 1 for x in res_json.values()) assert len(res_json["match"][0][0]) == 41
def test_similarity(client, fingerprint_type, fingerprint_args): res = client.post( "/fingerprints/similarity", json={ "query": { "identifier": "inchi", "compounds": test_compounds["inchi"][:2] }, "target": { "identifier": "smiles", "compounds": test_compounds["smiles"][1:4], }, "fingerprint_type": fingerprint_type, "fingerprint_args": fingerprint_args, }, ) assert res.status_code == 200 res_json = res.get_json() assert all(len(x) == 6 for x in res_json.values())
def test_compound_identity(client): res = client.post( "/fingerprints/compound_identity", json={ "query": { "identifier": "inchi", "compounds": test_compounds["inchi"][:2] }, "target": { "identifier": "smiles", "compounds": test_compounds["smiles"][1:4], }, }, ) assert res.status_code == 200 res_json = res.get_json() assert all(len(x) == 1 for x in res_json.values()) assert res_json["query"][0] == "1" assert res_json["target"][0] == "0"