Exemplo n.º 1
0
def test_this():
    ret = unichem.get('AAOVKJBEBIDNHE-UHFFFAOYSA-N')
    filename = 'test.json'
    with open(filename, 'w') as f:
        json.dump(ret, f, indent=4)
    def test_search_compound_in_unichem(self):

        ret = unichem.get('AIN')
        self.assertEqual(len(ret), 1)
        self.assertTrue(set(['aspirin', 'CHEMBL25', 'SCHEMBL1353']).issubset(
            set([x['src_compound_id'] for x in ret[list(ret.keys())[0]]])))
Exemplo n.º 3
0
from chembl_webresource_client.unichem import unichem_client as unichem
import requests


def test_this():
    ret = unichem.get('AAOVKJBEBIDNHE-UHFFFAOYSA-N')
    filename = 'test.json'
    with open(filename, 'w') as f:
        json.dump(ret, f, indent=4)


if __name__ == '__main__':

    infile = sys.argv[1]
    outfile = sys.argv[2]

    # import ipdb; ipdb.set_trace()

    with open(infile) as data_file:
        data = json.load(data_file)

    inputkey = data['inchi-key']

    try:
        ret = unichem.get(inputkey)
    except requests.exceptions.RetryError:
        ret = {}

    with open(outfile, 'w') as f:
        json.dump(ret, f, indent=4)
Exemplo n.º 4
0
    # If all the data is the same it is repeat data
    # If the data is different is an update

    if not drug_id in PV_PK_drug_table:
        if not drug_id in NEW_drug_list:
            NEW_drug_list.append(drug_id)
            NEW_complete_drug_list.append(
                drug)  # Provisional list with the new complete data
            count_drug += 1
            n_ins_drug += 1

        # For each new drug id get the DrugBank id
        if not (drug_id, DB_RESOURCEID, DRUG_ENTITYID) in NEW_code_list:
            # Get the DrugBank code
            from chembl_webresource_client.unichem import unichem_client as unichem
            response = unichem.get(drug_id, 1,
                                   2)  #1 --> CHEMBL, 2 --> DrugBank
            # With the DrugBank code will be fill the table code and has_code
            if response:
                db_code = response[0]['src_compound_id']
                code = (db_code, DB_RESOURCEID, DRUG_ENTITYID)
                has_code = (ID_RESOURCE_ID, drug_id, db_code, DB_RESOURCEID,
                            DRUG_ENTITYID)
                chembl_cr = (drug_id, DB_RESOURCEID, DRUG_ENTITYID)
                NEW_code_list.append(chembl_cr)
                NEW_complete_code_list.append(code)
                NEW_complete_has_code_list.append(has_code)
                count_code += 1
                n_ins_code += 1
            else:
                with open(names[0]) as csvfile2:
                    csvreader2 = csv.reader(csvfile2, delimiter=",")