Exemplo n.º 1
0
def custom_db_analysis():
# Deal with a custom database file
	import os
	import glob
	import shutil
	from genewordsearch.DBBuilder import geneWordBuilder 
	
	# Prep the database files for processing
	ip = str(request.environ['REMOTE_ADDR'])
	folder = os.path.join(app.config['UPLOAD_FOLDER'], ip)
	os.makedirs(folder, exist_ok=True)
	dbFiles = request.files.getlist('geneDBs')
	fileCount = len(dbFiles)
	fileNum = 0
	for db in dbFiles:
		filename = secure_filename(db.filename)
		db.save(os.path.join(folder, (str(fileNum)+filename[-4:])))
		fileNum += 1
	fileList = glob.glob(folder+'/*')
	fileList.sort()
	
	# Pull and organize the rest of the database info
	headers = []
	headtxt = []
	delimiters = []
	geneCols = []
	desCols = []
	fileNum = 0
	while(fileNum < fileCount):
		headtxt.append(str(request.form['header'+str(fileNum)]))
		delimiters.append(str(request.form['delimiter'+str(fileNum)]))
		geneCols.append(str(request.form['geneCol'+str(fileNum)]))
		desCols.append(str(request.form['desCols'+str(fileNum)]))
		fileNum += 1
	for header in headtxt:
		if(header =='y'):
			headers.append(True)
		else:
			headers.append(False)
	geneWordBuilder(ip,fileList,geneCols,desCols,delimiters,headers)
	shutil.rmtree(folder+'/')
	
	# Run the enrichment analysis
	genes = str(request.form['geneList'])
	probCutoff = float(request.form['probCut'])
	genes = re.split('\r| |,|\t|\n',genes)
	genes = list(filter((lambda x: x != ''),genes))
	try:
		results = geneWordSearch(genes,ip,minChance=probCutoff)
	except KeyError:
		abort(400)
	ans = WordFreq.to_JSON_array(results[0])
	shutil.rmtree('genewordsearch/databases/'+ip+'/')
	return jsonify(result=ans)
Exemplo n.º 2
0
def custom_db_analysis():
    # Deal with a custom database file

    # Prep the database files for processing
    ip = str(request.environ['REMOTE_ADDR'])
    folder = os.path.join(app.config['UPLOAD_FOLDER'], ip)
    os.makedirs(folder, exist_ok=True)
    dbFiles = request.files.getlist('geneDBs')
    fileCount = len(dbFiles)
    fileNum = 0
    for db in dbFiles:
        filename = secure_filename(db.filename)
        db.save(os.path.join(folder, (str(fileNum) + filename[-4:])))
        fileNum += 1
    fileList = glob.glob(folder + '/*')
    fileList.sort()

    # Pull and organize the rest of the database info
    headers = []
    headtxt = []
    delimiters = []
    geneCols = []
    desCols = []
    fileNum = 0
    while (fileNum < fileCount):
        headtxt.append(str(request.form['header' + str(fileNum)]))
        delimiters.append(str(request.form['delimiter' + str(fileNum)]))
        geneCols.append(str(request.form['geneCol' + str(fileNum)]))
        desCols.append(str(request.form['desCols' + str(fileNum)]))
        fileNum += 1
    for header in headtxt:
        if (header == 'y'):
            headers.append(True)
        else:
            headers.append(False)
    geneWordBuilder(ip, fileList, geneCols, desCols, delimiters, headers)
    shutil.rmtree(folder + '/')

    # Run the enrichment analysis
    genes = str(request.form['geneList'])
    probCutoff = float(request.form['probCut'])
    genes = re.split('\r| |,|\t|\n', genes)
    genes = list(filter((lambda x: x != ''), genes))
    try:
        results = geneWordSearch(genes, ip, minChance=probCutoff)
    except KeyError:
        abort(400)
    ans = WordFreq.to_JSON_array(results[0])
    shutil.rmtree('genewordsearch/databases/' + ip + '/')
    return jsonify(result=ans)
Exemplo n.º 3
0
def gene_word_search():
    cob = networks[str(request.form['network'])]
    pCutoff = safeOpts('pCutoff',float(request.form['pCutoff']))
    geneList = str(request.form['geneList'])
    geneList = list(filter((lambda x: x != ''), re.split('\r| |,|;|\t|\n', geneList)))
    
    # Run the analysis and return the JSONified results
    if cob._global('parent_refgen') in func_data_db:
        results = geneWordSearch(geneList, cob._global('parent_refgen'), minChance=pCutoff)
    else:
        abort(405)
    if len(results[0]) == 0:
        abort(400)
    results = WordFreq.to_JSON_array(results[0])
    return jsonify(result=results)
Exemplo n.º 4
0
def gene_word_search():
    cob = networks[str(request.form['network'])]
    pCutoff = safeOpts('pCutoff',float(request.form['pCutoff']))
    geneList = str(request.form['geneList'])
    geneList = list(filter((lambda x: x != ''), re.split('\r| |,|;|\t|\n', geneList)))
    
    # Run the analysis and return the JSONified results
    if hasGWS and (cob._global('parent_refgen') in func_data_db):
        results = geneWordSearch(geneList, cob._global('parent_refgen'), minChance=pCutoff)
    else:
        abort(405)
    if len(results[0]) == 0:
        abort(400)
    results = WordFreq.to_JSON_array(results[0])
    return jsonify(result=results)
Exemplo n.º 5
0
def gene_analysis():
    # Run the genes through genewordsearch
    # Sanitize the input
    species = str(request.form['species'])
    genes = str(request.form['geneList'])
    probCutoff = float(request.form['probCut'])
    genes = re.split('\r| |,|\t|\n', genes)
    genes = list(filter((lambda x: x != ''), genes))

    # Run the analysis and return the JSONified results
    try:
        results = geneWordSearch(genes, species, minChance=probCutoff)
    except KeyError:
        abort(400)
    ans = WordFreq.to_JSON_array(results[0])
    return jsonify(result=ans)
Exemplo n.º 6
0
def gene_analysis():
# Run the genes through genewordsearch
	# Sanitize the input
	species = str(request.form['species'])
	genes = str(request.form['geneList'])
	probCutoff = float(request.form['probCut'])
	genes = re.split('\r| |,|\t|\n',genes)
	genes = list(filter((lambda x: x != ''),genes))

	# Run the analysis and return the JSONified results
	try:
		results = geneWordSearch(genes,species,minChance=probCutoff)
	except KeyError:
		abort(400)
	ans = WordFreq.to_JSON_array(results[0])
	return jsonify(result=ans)