Exemple #1
0
 def get_all(self, *args, **kw):
     user = handler.user.get_user_in_session(request)
     # user attributs
     #to block to one specific user
     attributs = DBSession.query(Attributs).all()
     all_attributs = [util.to_datagrid(attribut_grid, attributs, "Attributs Table", len(attributs) > 0)]
     return dict(page='attributs', model='attribut', form_title="new attribut", items=all_attributs, value=kw)
Exemple #2
0
    def index(self, *args, **kw):
        user = handler.user.get_user_in_session(request)
        user_lab = session.get("current_lab", None)
        mail = user.email
        mail_tmp = mail.split("@")
        mail_final = mail_tmp[0] + "AT" + mail_tmp[1]
        user_TH_path = trackhubs_path() + "/" + user_lab + "/" + mail_final
        trackhubs = []
        if os.path.exists(user_TH_path):
            list_trackhubs = os.listdir(user_TH_path)
            for t in list_trackhubs:
                th_path = user_TH_path + "/" + t
                #the only one directory into at this th level is named by the assembly used for it
                for i in os.listdir(th_path):
                    path_to_test = th_path + "/" + i
                    if os.path.isdir(path_to_test):
                        assembly = i
                if not assembly:
                    break
                else:
                    #hub_url = th_path + "/hub.txt"
                    hostname = socket.gethostname().lower()
                    #because of aliasing
                    if hostname == "ptbbsrv2.epfl.ch":
                        hostname = "biorepo.epfl.ch"
                    hub_url = "http://" + hostname + url("/trackHubs/") + user_lab + "/" + mail_final + "/" + t + "/hub.txt"
                    th = Trackhub(t, 'http://genome.ucsc.edu/cgi-bin/hgTracks?hubUrl=' + hub_url + "&db=" + assembly)
                    trackhubs.append(th)

        all_trackhubs = [util.to_datagrid(TrackhubGrid(), trackhubs, " UCSC's Trackhub(s)", len(trackhubs) > 0)]

        return dict(page='trackhubs', model=trackhubs, items=all_trackhubs, value=kw)
Exemple #3
0
 def get_all(self, *args, **kw):
     user = handler.user.get_user_in_session(request)
     # user attributs
     #to block to one specific user
     attributs = DBSession.query(Attributs).all()
     all_attributs = [
         util.to_datagrid(attribut_grid, attributs, "Attributs Table",
                          len(attributs) > 0)
     ]
     return dict(page='attributs',
                 model='attribut',
                 form_title="new attribut",
                 items=all_attributs,
                 value=kw)
Exemple #4
0
    def index(self, *args, **kw):
        user = handler.user.get_user_in_session(request)
        user_lab = session.get("current_lab", None)
        admins = tg.config.get('admin.mails')
        mail = user.email
        if user_lab and mail not in admins:
            lab = DBSession.query(Labs).filter(Labs.name == user_lab).first()
            projects = [p for p in user.projects if p in lab.projects]
        elif mail in admins:
            projects = DBSession.query(Projects).all()
        else:
            projects = None

        all_projects = [util.to_datagrid(ProjectGrid(), projects, "Projects Table", len(projects) > 0)]

        return dict(page='projects', model='project', form_title="new project", items=all_projects, value=kw)
Exemple #5
0
    def index(self, *args, **kw):
        user = handler.user.get_user_in_session(request)
        user_lab = session.get("current_lab", None)
        mail = user.email
        mail_tmp = mail.split("@")
        mail_final = mail_tmp[0] + "AT" + mail_tmp[1]
        user_TH_path = trackhubs_path() + "/" + user_lab + "/" + mail_final
        trackhubs = []
        if os.path.exists(user_TH_path):
            list_trackhubs = os.listdir(user_TH_path)
            for t in list_trackhubs:
                th_path = user_TH_path + "/" + t
                #the only one directory into at this th level is named by the assembly used for it
                for i in os.listdir(th_path):
                    path_to_test = th_path + "/" + i
                    if os.path.isdir(path_to_test):
                        assembly = i
                if not assembly:
                    break
                else:
                    #hub_url = th_path + "/hub.txt"
                    hostname = socket.gethostname().lower()
                    #because of aliasing
                    if hostname == "ptbbsrv2.epfl.ch":
                        hostname = "biorepo.epfl.ch"
                    hub_url = "http://" + hostname + url(
                        "/trackHubs/"
                    ) + user_lab + "/" + mail_final + "/" + t + "/hub.txt"
                    th = Trackhub(
                        t, 'http://genome.ucsc.edu/cgi-bin/hgTracks?hubUrl=' +
                        hub_url + "&db=" + assembly)
                    trackhubs.append(th)

        all_trackhubs = [
            util.to_datagrid(TrackhubGrid(), trackhubs, " UCSC's Trackhub(s)",
                             len(trackhubs) > 0)
        ]

        return dict(page='trackhubs',
                    model=trackhubs,
                    items=all_trackhubs,
                    value=kw)
Exemple #6
0
    def index(self, *args, **kw):
        user = handler.user.get_user_in_session(request)

        user_lab = session.get("current_lab", None)
        admins = tg.config.get('admin.mails')
        mail = user.email
        if user_lab and mail not in admins:
            lab = DBSession.query(Labs).filter(Labs.name == user_lab).first()
            attributs = DBSession.query(Attributs).filter(and_(Attributs.lab_id == lab.id, Attributs.deprecated == False)).all()
            projects = [p.id for p in user.projects if p in lab.projects]
            samples = []
            for a in attributs:
                for s in a.samples:
                    if s not in samples and s.project_id in projects:
                        samples.append(s)
        elif mail in admins:
            samples = DBSession.query(Samples).all()

        all_samples = [util.to_datagrid(SampleGrid(), samples, "Samples Table", len(samples) > 0)]

        return dict(page='samples', model='sample', form_title="new sample", items=all_samples, value=kw)
Exemple #7
0
    def search_old(self, *args, **kw):
        """
        Handle the searching page
        """
        user_lab = session.get("current_lab", None)
        if user_lab:
            lab = DBSession.query(Labs).filter(Labs.name == user_lab).first()
            measurements = DBSession.query(Measurements).join(Measurements.attributs).filter(and_(Attributs.lab_id == lab.id, Attributs.deprecated == False)).distinct().all()
            searching = [SW(meas) for meas in measurements]
            search_grid, hidden_positions, positions_not_searchable = build_search_grid(measurements)

            items = [util.to_datagrid(search_grid, searching, '', grid_display=len(searching) > 0)]

            return dict(
                page='search_old',
                items=items,
                searchlists=json.dumps([hidden_positions, positions_not_searchable]),
                value=kw,
        )
        else:
            flash("Your lab is not registred, contact the administrator please", "error")
            raise redirect("./")