コード例 #1
0
def edit(request, pid):
    "Updates or creates a project"
    user = request.user

    form = ProjectForm(request.POST)

    if form.is_valid():
        # incoming data
        get = form.cleaned_data.get
        if pid == "new":
            project = authorize.create_project(user=user, name=get("name"), info=get("info"))
            user.message_set.create(message="Project created")
            return html.redirect("/project/list/")
        else:
            authorize.update_project(user=user, pid=pid, name=get("name"), info=get("info"))
            user.message_set.create(message="Project updated")
            return html.redirect("/project/view/%s/" % pid)
    else:
        # no form data sent
        if pid == "new":
            title = "Create New Project"
            form = ProjectForm()
        else:
            title = "Edit Project"
            project = authorize.get_project(user=user, pid=pid)
            form = ProjectForm(dict(name=project.name, info=project.info))
        return html.template(request=request, name="project-edit.html", pid=pid, title=title, form=form)
コード例 #2
0
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)
コード例 #3
0
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)
コード例 #4
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)
コード例 #5
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)