How to use full_status method in autotest

Best Python code snippet using autotest_python

generate_auc_comparison.py

Source:generate_auc_comparison.py Github

copy

Full Screen

1"""2(C) Casey Greene based on code by Irene Song.3This python script generates long format table with performance information4for GWAS runs (VEGAS format) and NetWAS runs (SVMperfer format) for later5visualization.6"""7import pandas as pd8from sklearn.metrics import roc_auc_score9# header on the first line, gene name in the second col10vegas_ad1 = pd.read_excel('data/vegas_adni1.xls', header=0, index_col=1)11vegas_ad2 = pd.read_excel('data/vegas_adni2.xls', header=0, index_col=1)12# clean up elements we don't use before combining13vegas_ad1.drop(['Chr', 'nSNPs', 'nSims', 'Start', 'Stop', 'Test'],14 inplace=True, axis=1)15vegas_ad1.rename(columns={'Pvalue': 'VEGAS_AD1'}, inplace=True)16vegas_ad2.drop(['Chr', 'nSNPs', 'nSims', 'Start', 'Stop', 'Test'],17 inplace=True, axis=1)18vegas_ad2.rename(columns={'Pvalue': 'VEGAS_AD2'}, inplace=True)19vegas = pd.merge(vegas_ad1, vegas_ad2, left_index=True, right_index=True,20 how='outer')21vegas = vegas.reset_index() # Unindex by gene so that we can go entrez later22# Map to Entrez23symbol_entrez = pd.read_csv('data/symbol_entrez.txt', sep='\t', header=None,24 index_col=0)25d_se = symbol_entrez.to_dict(orient='dict')[1]26vegas['Entrez'] = vegas['Gene'].map(d_se)27vegas = vegas.dropna(axis=0, how='any') # Drop anything that lacked entrez28vegas = vegas.set_index('Gene')29# Load AD associated genes30do_status = pd.read_csv('data/tribe_ad_list.csv', index_col=0)31full_status = pd.merge(vegas, do_status, left_index=True, right_index=True,32 how='outer')33# Set NAs in Tribe-AD-Status equal to zero34full_status['Tribe-DO-Status'].loc[full_status['Tribe-DO-Status'] != 1] = 035full_status = full_status.reset_index()36# Index on Entrez again37full_status = full_status.set_index('Entrez')38# no header, gene name in the first col39netwas_ad1 = pd.read_csv('results/vegas_ad1/0', sep='\t', header=None,40 index_col=0, names=["Entrez", "Standard", "NETWAS"])41# Keep only genes in the NetWAS also42new_status = pd.merge(full_status, netwas_ad1, left_index=True,43 right_index=True, how='inner')44o_fh = open('results-proc.txt', 'w')45o_fh.write('GWAS\tMethod\tAUC\n')46a1_do = roc_auc_score(new_status['Tribe-DO-Status'], 1-new_status['VEGAS_AD1'])47o_fh.write('AD1\tGWAS\t' + str(a1_do) + '\n')48a2_do = roc_auc_score(new_status['Tribe-DO-Status'], 1-new_status['VEGAS_AD2'])49o_fh.write('AD2\tGWAS\t' + str(a2_do) + '\n')50gwases = ['AD1', 'AD2']51num = 100052for gwas in gwases:53 gwas_fname = 'vegas_' + gwas.lower()54 new_status[gwas + '-NetWAS-RankSum'] = 055 for i in xrange(num):56 netwas = pd.read_csv('results/' + gwas_fname + '/' + str(i),57 sep='\t', header=None, index_col=0,58 names=["Entrez", "Standard", "NETWAS"])59 net_status = pd.merge(full_status, netwas, left_index=True,60 right_index=True, how='inner')61 new_status[gwas + '-NetWAS-RankSum'] = \62 new_status[gwas + '-NetWAS-RankSum'] + \63 net_status['NETWAS'].rank()64 score = roc_auc_score(net_status['Tribe-DO-Status'],65 net_status['NETWAS'])66 o_fh.write('\t'.join((gwas, 'NETWAS', str(score))) + '\n')67 # merge_auc = roc_auc_score(new_status['Tribe-DO-Status'],68 # new_status[gwas + '-NetWAS-RankSum'])69 # We don't want to plot the rank sum, we just want to have the rank70 # combined list available for the paper.71 # auc was similar to or slightly above what we observed for the individual72 # runs.73 # o_fh.write('\t'.join((gwas, 'NETWAS-RankSum', str(merge_auc))) + '\n')74 # processed permed files75 for i in xrange(num):76 netwas = pd.read_csv('results/p_' + gwas_fname + '/' + str(i),77 sep='\t', header=None, index_col=0,78 names=["Entrez", "Standard", "NETWAS"])79 net_status = pd.merge(full_status, netwas, left_index=True,80 right_index=True, how='inner')81 score = roc_auc_score(net_status['Tribe-DO-Status'],82 net_status['NETWAS'])83 o_fh.write('\t'.join((gwas, 'Permuted-NETWAS', str(score))) + '\n')84o_fh.close()85new_status.drop(['Standard', 'NETWAS'], inplace=True, axis=1)...

Full Screen

Full Screen

test_errordocument.py

Source:test_errordocument.py Github

copy

Full Screen

1from paste.errordocument import forward2from paste.fixture import *3from paste.recursive import RecursiveMiddleware4def simple_app(environ, start_response):5 start_response("200 OK", [('Content-type', 'text/plain')])6 return [b'requested page returned']7def not_found_app(environ, start_response):8 start_response("404 Not found", [('Content-type', 'text/plain')])9 return [b'requested page returned']10def test_ok():11 app = TestApp(simple_app)12 res = app.get('')13 assert res.header('content-type') == 'text/plain'14 assert res.full_status == '200 OK'15 assert 'requested page returned' in res16def error_docs_app(environ, start_response):17 if environ['PATH_INFO'] == '/not_found':18 start_response("404 Not found", [('Content-type', 'text/plain')])19 return [b'Not found']20 elif environ['PATH_INFO'] == '/error':21 start_response("200 OK", [('Content-type', 'text/plain')])22 return [b'Page not found']23 else:24 return simple_app(environ, start_response)25def test_error_docs_app():26 app = TestApp(error_docs_app)27 res = app.get('')28 assert res.header('content-type') == 'text/plain'29 assert res.full_status == '200 OK'30 assert 'requested page returned' in res31 res = app.get('/error')32 assert res.header('content-type') == 'text/plain'33 assert res.full_status == '200 OK'34 assert 'Page not found' in res35 res = app.get('/not_found', status=404)36 assert res.header('content-type') == 'text/plain'37 assert res.full_status == '404 Not found'38 assert 'Not found' in res39def test_forward():40 app = forward(error_docs_app, codes={404:'/error'})41 app = TestApp(RecursiveMiddleware(app))42 res = app.get('')43 assert res.header('content-type') == 'text/plain'44 assert res.full_status == '200 OK'45 assert 'requested page returned' in res46 res = app.get('/error')47 assert res.header('content-type') == 'text/plain'48 assert res.full_status == '200 OK'49 assert 'Page not found' in res50 res = app.get('/not_found', status=404)51 assert res.header('content-type') == 'text/plain'52 assert res.full_status == '404 Not found'53 # Note changed response54 assert 'Page not found' in res55def auth_required_app(environ, start_response):56 start_response('401 Unauthorized', [('content-type', 'text/plain'), ('www-authenticate', 'Basic realm="Foo"')])57 return ['Sign in!']58def auth_docs_app(environ, start_response):59 if environ['PATH_INFO'] == '/auth':60 return auth_required_app(environ, start_response)61 elif environ['PATH_INFO'] == '/auth_doc':62 start_response("200 OK", [('Content-type', 'text/html')])63 return [b'<html>Login!</html>']64 else:65 return simple_app(environ, start_response)66def test_auth_docs_app():67 wsgi_app = forward(auth_docs_app, codes={401: '/auth_doc'})68 app = TestApp(wsgi_app)69 res = app.get('/auth_doc')70 assert res.header('content-type') == 'text/html'71 res = app.get('/auth', status=401)72 assert res.header('content-type') == 'text/html'73 assert res.header('www-authenticate') == 'Basic realm="Foo"'74 assert res.body == b'<html>Login!</html>'75def test_bad_error():76 def app(environ, start_response):77 start_response('404 Not Found', [('content-type', 'text/plain')])78 return ['not found']79 app = forward(app, {404: '/404.html'})80 app = TestApp(app)81 resp = app.get('/test', expect_errors=True)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful