def screen_simple(request):
    """View to take a smiles and then screen against a known library"""
    import urllib
    # Take the smiles in the request object
    # Now get the library
    if "dump_out" in request.GET:
        return HttpResponse(
            json.dumps(str(request)) + "\nBODY:" + request.body)
    mol_type, screen_lib, fp_method, sim_method, threshold, params = request_handler(
        request)
    if "structure_source" in request.GET:
        smiles = request.GET["structure_source"]
        scr_mols = CloseableQueue.CloseableQueue()
        [
            scr_mols.put({"RDMOL": Chem.MolFromSmiles(str(x))})
            for x in str(smiles).split(".")
        ]
        scr_mols.close()
    else:
        # TODO - work out how to throw this as 400 error - doing the obvious doesn't seem to work
        print "No smiles specified as parameter structure_source"
        return HttpResponse(
            "You must specify a structure as SMILES with the parameter structure_source"
        )
    # Now handle this file upload
    return process_input(fp_method,
                         sim_method,
                         screen_lib,
                         mol_type,
                         threshold,
                         params=None,
                         scr_mols=scr_mols)
Exemple #2
0
def screen_simple(request):
    """View to take a smiles and then screen against a known library of actives"""
    import urllib
    # Take the smiles in the request object
    # Now get the library
    if "dump_out" in request.GET:
        return HttpResponse(
            json.dumps(str(request)) + "\nBODY:" + request.body)
    mol_type, screen_lib, fp_method, sim_method, threshold, params = request_handler(
        request)
    if "smiles" in request.GET:
        smiles = request.GET["smiles"]
        scr_mols = CloseableQueue.CloseableQueue()
        [
            scr_mols.put({"RDMOL": Chem.MolFromSmiles(str(x))})
            for x in str(smiles).split(".")
        ]
        scr_mols.close()
    else:
        return HttpResponse("You must state a SMILES")
    # Now handle this file upload
    return process_input(fp_method,
                         sim_method,
                         screen_lib,
                         mol_type,
                         threshold,
                         params=None,
                         scr_mols=scr_mols)
Exemple #3
0
def start_dock(request):
    # Get the library -> either as an ID or as an upload
    if "LIB" in request.GET:
        lib_id = int(request.GET["LIB"])
    else:
        try:
            mol_type, screen_lib, fp_method, sim_method, threshold, params = request_handler(
                request)
        except:
            screen_lib = None
        if not screen_lib:
            return HttpResponse("NO LIB SPECIFIED")
        else:
            libm = LibMethods(screen_lib, mol_type)
            my_mols = libm.get_mols()
            my_lib = register_lib([x["RDMOL"] for x in my_mols])
            lib_id = my_lib.pk
        # Now process this libary -> save to disk
    # Get the environment
    if "ENV" in request.GET:
        env_id = int(request.GET["ENV"])
        my_env = DockingEnv.objects.filter(pk=env_id)
        if not my_env:
            return HttpResponse("INVALID ENV")
    else:
        return HttpResponse("ERROR DOCKING ENV NOT SPECIFIED")
    my_lib = DockingLib.objects.filter(pk=lib_id)
    if not my_lib:
        return HttpResponse("INVALID LIBARAY")
    run_id = register_docking(my_env[0], my_lib[0])
    # Now set this opff running
    response = start_docking.delay(run_id)
    return HttpResponse(run_id)
def start_dock(request):
    # Get the library -> either as an ID or as an upload
    if "LIB" in request.GET:
        lib_id = int(request.GET["LIB"])
    else:
        try:
            mol_type, screen_lib, fp_method, sim_method, threshold, params = request_handler(request)
        except:
            screen_lib = None
        if not screen_lib:
            return HttpResponse("NO LIB SPECIFIED")
        else:
            libm = LibMethods(screen_lib, mol_type)
            my_mols = libm.get_mols()
            my_lib = register_lib([x["RDMOL"] for x in my_mols])
            lib_id = my_lib.pk
        # Now process this libary -> save to disk
    # Get the environment
    if "ENV" in request.GET:
        env_id = int(request.GET["ENV"])
        my_env = DockingEnv.objects.filter(pk=env_id)
        if not my_env:
            return HttpResponse("INVALID ENV")
    else:
        return HttpResponse("ERROR DOCKING ENV NOT SPECIFIED")
    my_lib = DockingLib.objects.filter(pk=lib_id)
    if not my_lib:
        return HttpResponse("INVALID LIBARAY")
    run_id = register_docking(my_env[0], my_lib[0])
    # Now set this opff running
    response = start_docking.delay(run_id)
    return HttpResponse(run_id)
Exemple #5
0
def cluster_simple(request):
        # Read the mols
    # Take the smiles in the request object
    if "dump_out" in request.GET:
        return HttpResponse(json.dumps(str(request))+"\nBODY:" + request.body)
    mol_type, screen_lib, fp_method, sim_method, threshold, params = request_handler(request)
    # Now return the process
    return process_input(fp_method, sim_method, screen_lib, mol_type, threshold, params)
Exemple #6
0
def gen_confs(request):
    """View to take a library of input molecules and generate conformations from them"""
    mol_type, screen_lib, fp_method, sim_method, threshold, params = request_handler(request)
    # Now handle this file upload 
    libm = LibMethods(screen_lib, mol_type)
    my_mols = libm.get_mols()
    my_lib = register_lib([x["RDMOL"] for x in my_mols])
    my_pk = setup_conf_run(my_lib, num_mols=None)    
    response = start_conf_gen.delay(my_pk)
    return HttpResponse(str(my_pk))
Exemple #7
0
def screen_simple(request):
    """View to take a smiles and then screen against a known library of actives"""
    import urllib
    # Take the smiles in the request object
    # Now get the library
    if "dump_out" in request.GET:
        return HttpResponse(json.dumps(str(request))+"\nBODY:" + request.body)
    mol_type, screen_lib, fp_method, sim_method, threshold, params = request_handler(request)
    if "smiles" in request.GET:
        smiles = request.GET["smiles"]
        scr_mols = CloseableQueue.CloseableQueue()
        [scr_mols.put({"RDMOL": Chem.MolFromSmiles(str(x))}) for x in str(smiles).split(".")]
        scr_mols.close()
    else:
        return HttpResponse("You must state a SMILES")
    # Now handle this file upload 
    return process_input(fp_method, sim_method, screen_lib, mol_type, threshold, params=None, scr_mols=scr_mols)
def screen_simple(request):
    """View to take a smiles and then screen against a known library"""
    import urllib
    # Take the smiles in the request object
    # Now get the library
    if "dump_out" in request.GET:
        return HttpResponse(json.dumps(str(request))+"\nBODY:" + request.body)
    mol_type, screen_lib, fp_method, sim_method, threshold, params = request_handler(request)
    if "structure_source" in request.GET:
        smiles = request.GET["structure_source"]
        scr_mols = CloseableQueue.CloseableQueue()
        [scr_mols.put({"RDMOL": Chem.MolFromSmiles(str(x))}) for x in str(smiles).split(".")]
        scr_mols.close()
    else:
    	# TODO - work out how to throw this as 400 error - doing the obvious doesn't seem to work
    	print "No smiles specified as parameter structure_source"
        return HttpResponse("You must specify a structure as SMILES with the parameter structure_source")
    # Now handle this file upload 
    return process_input(fp_method, sim_method, screen_lib, mol_type, threshold, params=None, scr_mols=scr_mols)