def generate(n=5): projects = [] for i in range(1, n): name = random.choice(project_names) % i info = 'some info=%s' % i project = authorize.create_project(user=user, name=name, info=info) projects.append(project) logger.info('creating %s' % name) # data names data_names = ('short-good-input.gtrack', 'short-data.bed') # visualization names track_names = ('differential expression', 'HELA subtract', 'Default track') # a subset of projects get data, visualization and results added to them subset = projects[-1:] for project in subset: # create some tracks for this project for tname in track_names: json = dict() track = authorize.create_track(user=user, pid=project.id, name=tname, json=json) logger.info('creating track %s' % track.name) assert (project.track_count(), len(track_names)) # upload some data names for name in data_names: logger.info('uploading data %s' % name) stream = File(open(conf.testdata(name))) data = authorize.create_data(user=user, pid=project.id, stream=stream, name=name, info='test data') # create some results logger.info('adding results content and image') stream1 = File(open(conf.testdata('short-results.txt'))) image1 = File(open(conf.testdata('readcounts.png'), 'rb')) result1 = authorize.create_result(user=user, data=data, content=stream1, image=image1) image2 = File(open(conf.testdata('shift.png'), 'rb')) result2 = authorize.create_result(user=user, data=data, content=None, image=image2)
def test_tabs2genetrack(self): "Testing bed2genetrack transformation" from genetrack.scripts import tabs2genetrack inpfile = conf.testdata('short-data.bed', verify=True) outfile = conf.tempdata('short-data.genetrack') tabs2genetrack.transform(inpfile, outfile, format='BED')
def setUp(self): "Setting up the tests database for data insert" self.old_name = settings.DATABASE_NAME utils.setup_test_environment() connection.creation.create_test_db(verbosity=0, autoclobber=True) options = util.Params(test_mode=True, delete_everything=False, flush=False, verbosity=0) fname = conf.testdata('test-users.csv') initializer.load_users(fname, options)
def generate(n=5): projects = [] for i in range(1, n): name = random.choice(project_names) % i info = 'some info=%s' % i project = authorize.create_project(user=user, name=name, info=info) projects.append(project) logger.info('creating %s' % name) # data names data_names = ( 'short-good-input.gtrack', 'short-data.bed') # visualization names track_names = ( 'differential expression', 'HELA subtract', 'Default track') # a subset of projects get data, visualization and results added to them subset = projects[-1:] for project in subset: # create some tracks for this project for tname in track_names: json = dict() track = authorize.create_track(user=user, pid=project.id, name=tname, json=json ) logger.info('creating track %s' % track.name) assert (project.track_count(), len(track_names)) # upload some data names for name in data_names: logger.info('uploading data %s' % name) stream = File( open(conf.testdata(name)) ) data = authorize.create_data(user=user, pid=project.id, stream=stream, name=name, info='test data') # create some results logger.info('adding results content and image') stream1 = File( open(conf.testdata('short-results.txt')) ) image1 = File( open(conf.testdata('readcounts.png'),'rb') ) result1 = authorize.create_result( user=user, data=data, content=stream1, image=image1) image2 = File( open(conf.testdata('shift.png'), 'rb') ) result2 = authorize.create_result( user=user, data=data, content=None, image=image2)
def test_data_uploads(self): # data upload test name = 'Upload-test-name' self.create_project(name) tc.follow(name) # find the project id url = tc.follow('Edit') pid = url.split("/")[-2] tc.go("/data/upload/simple/%s/" % pid) # search for then add Demo User to this project tc.formfile("1", "File1", conf.testdata('short-data.bed')) tc.formfile("1", "File2", conf.testdata('short-good-input.gtrack')) tc.formfile("1", "File3", conf.testdata('readcounts.png')) tc.submit() # verify uploads tc.find("short-data.bed") tc.find("short-good-input.gtrack") tc.find("readcounts.png") # visit the dataset tc.follow("short-good-input.gtrack") tc.find("waiting") # edit the dataset tc.follow("Edit") tc.fv("1", "name", "short-good-input.gtrack") tc.fv("1", "info", "extra-info") tc.submit() tc.find("extra-info") # upload two results for it tc.follow("Add results") tc.formfile("1", "content", conf.testdata('short-data.bed')) tc.formfile("1", "image", conf.testdata('readcounts.png')) tc.submit() tc.follow("short-data.bed") tc.back() # upload one image tc.follow("Add results") tc.formfile("1", "image", conf.testdata('shift.png')) tc.submit() tc.follow("shift.png") tc.back() # back to project view tc.follow("Project view") self.delete_project(name)
def test_data_uploads(self): # data upload test name = 'Upload-test-name' self.create_project(name) tc.follow(name) # find the project id url = tc.follow('Edit') pid = url.split("/")[-2] tc.go("/data/upload/simple/%s/" % pid) # search for then add Demo User to this project tc.formfile("1", "File1", conf.testdata('short-data.bed') ) tc.formfile("1", "File2", conf.testdata('short-good-input.gtrack') ) tc.formfile("1", "File3", conf.testdata('readcounts.png') ) tc.submit() # verify uploads tc.find("short-data.bed") tc.find("short-good-input.gtrack") tc.find("readcounts.png") # visit the dataset tc.follow("short-good-input.gtrack") tc.find("waiting") # edit the dataset tc.follow("Edit") tc.fv("1", "name", "short-good-input.gtrack" ) tc.fv("1", "info","extra-info" ) tc.submit() tc.find("extra-info") # upload two results for it tc.follow("Add results") tc.formfile("1", "content", conf.testdata('short-data.bed') ) tc.formfile("1", "image", conf.testdata('readcounts.png') ) tc.submit() tc.follow("short-data.bed") tc.back() # upload one image tc.follow("Add results") tc.formfile("1", "image", conf.testdata('shift.png') ) tc.submit() tc.follow("shift.png") tc.back() # back to project view tc.follow("Project view") self.delete_project(name)
def test_data_creation(self): """ Create datasets """ # it seems that importing it earlier messes up the test database setup from genetrack.server.web import authorize john = User.objects.get(username='******') project = authorize.create_project(user=john, name="Test project") stream = File( open(conf.testdata('test-users.csv')) ) data = authorize.create_data(user=john, pid=project.id, stream=stream, name="Test data") # project counts update project = authorize.get_project(user=john, pid=project.id) self.assertEqual(project.data_count, 1) # testing data deletion authorize.delete_data(user=john, pid=project.id, dids=[data.id]) project = authorize.get_project(user=john, pid=project.id) self.assertEqual(project.data_count, 0)
def test_data_creation(self): """ Create datasets """ # it seems that importing it earlier messes up the test database setup from genetrack.server.web import authorize john = User.objects.get(username='******') project = authorize.create_project(user=john, name="Test project") stream = File(open(conf.testdata('test-users.csv'))) data = authorize.create_data(user=john, pid=project.id, stream=stream, name="Test data") # project counts update project = authorize.get_project(user=john, pid=project.id) self.assertEqual(project.data_count, 1) # testing data deletion authorize.delete_data(user=john, pid=project.id, dids=[data.id]) project = authorize.get_project(user=john, pid=project.id) self.assertEqual(project.data_count, 0)
) return parser if __name__ == '__main__': import optparse parser = option_parser() options, args = parser.parse_args() logger.disable(options.verbosity) from genetrack import conf # trigger test mode if options.test: options.inpname = conf.testdata('test-hdflib-input.gtrack') options.outname = conf.testdata('predictions.bed') # missing input file name if not options.inpname and not options.outname: parser.print_help() else: print 'Sigma = %s' % options.sigma print 'Minimum peak = %s' % options.level print 'Peak-to-peak = %s' % options.exclude predict(options.inpname, options.outname, options)
import pkg_resources pkg_resources.require("GeneTrack") from genetrack.scripts import peakpred from genetrack import logger if __name__ == "__main__": parser = peakpred.option_parser() options, args = parser.parse_args() logger.disable(options.verbosity) from genetrack import conf # trigger test mode if options.test: options.inpname = conf.testdata('test-hdflib-input.gtrack') options.outname = conf.testdata('predictions.bed') # missing input file name if not options.inpname and not options.outname: parser.print_help() else: print 'Sigma = %s' % options.sigma print 'Minimum peak = %s' % options.level print 'Peak-to-peak = %s' % options.exclude peakpred.predict(options.inpname, options.outname, options)