root/galaxy-central/eggs/GeneTrack-2.0.0_beta_1_dev_48da9e998f0caf01c5be731e926f4b0481f658f0-py2.6.egg/tests/populate.py

リビジョン 3, 2.3 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1"""
2Populates the active server instance with various test datasets
3"""
4import random
5from genetrack import conf, logger
6from genetrack.server.web.models import *
7from genetrack.server.web import authorize, status
8
9from django.contrib.auth.models import User
10
11# the user used to populate the data
12user = User.objects.get(email='admin')
13
14# potential project names
15project_names = [
16    'Mouse project HBB %s',
17    'Yeast mutant RAV %s',
18    'Yeast mutant RAP2 %s',
19    'Fly data DR2%s',
20    'Human HELA 16 %s',
21    'Human HELA 17 %s',
22]
23
24# generates projects
25
26def generate(n=5):
27
28    projects = []
29    for i in range(1, n):
30        name = random.choice(project_names) % i
31        info = 'some info=%s' % i
32        project = authorize.create_project(user=user, name=name, info=info)
33        projects.append(project)
34        logger.info('creating %s' % name)
35
36    # data names
37    data_names = ( 'short-good-input.gtrack', 'short-data.bed')
38   
39    # visualization names
40    track_names = ( 'differential expression', 'HELA subtract', 'Default track')
41   
42
43    # a subset of projects get data, visualization and results added to them
44    subset = projects[-1:]
45    for project in subset:
46       
47        # create some tracks for this project
48        for tname in track_names:
49            json = dict()
50            track = authorize.create_track(user=user, pid=project.id, name=tname, json=json )
51            logger.info('creating track %s' % track.name)
52       
53        assert (project.track_count(), len(track_names))
54
55        # upload some data names       
56        for name in data_names:
57            logger.info('uploading data %s' % name)
58            stream = File( open(conf.testdata(name)) )
59            data = authorize.create_data(user=user, pid=project.id, stream=stream, name=name, info='test data')
60           
61            # create some  results
62            logger.info('adding results content and image')
63            stream1 = File( open(conf.testdata('short-results.txt')) )
64            image1  = File( open(conf.testdata('readcounts.png'),'rb') )
65            result1 = authorize.create_result( user=user, data=data, content=stream1, image=image1)
66
67            image2  = File( open(conf.testdata('shift.png'), 'rb') )
68            result2 = authorize.create_result( user=user, data=data, content=None, image=image2)
69               
70if __name__ == '__main__':
71    generate()
72
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。