[views] Add GenomicRegion primary view and Update CGH-related table views, see #3323323
authorVladimir Popescu <vladimir.popescu@logilab.fr>
Mon, 25 Nov 2013 10:26:50 +0000
changeset 497 e2a2bb435d1a
parent 485 8a8eaff1d4d2
child 498 e2e5853984ff
[views] Add GenomicRegion primary view and Update CGH-related table views, see #3323323
views/primary.py
views/tableviews.py
--- a/views/primary.py	Thu Nov 14 17:10:27 2013 +0000
+++ b/views/primary.py	Mon Nov 25 10:26:50 2013 +0000
@@ -690,14 +690,12 @@
                                             'R related_measure X, X eid %(e)s',
                                             {'e': entity.eid})
         if cgh_results or mutation_results:
-            self.w(u'<div class="span3">')
             if cgh_results:
                 self.w(u'<h3>%s</h3>' % self._cw._('CGH results'))
                 self.wview('cgh-table-view', rset=cgh_results)
             if mutation_results:
                 self.w(u'<h3>%s</h3>' % self._cw._('Sequencing results'))
                 self.wview('mutation-table-view', rset=mutation_results)
-            self.w(u'</div>')
 
 
 ###############################################################################
@@ -715,20 +713,47 @@
 
     def display_main_col(self, entity):
         cgh_results = self._cw.execute('Any R WHERE R is CghResult, '
-                                       'R related_gene X, X eid %(e)s',
+                                       'R genomic_region G, G genes X, X eid %(e)s',
                                        {'e': entity.eid})
         mutation_results = self._cw.execute('Any R WHERE R is Mutation, '
                                             'R related_gene X, X eid %(e)s',
                                             {'e': entity.eid})
         if cgh_results or mutation_results:
-            self.w(u'<div class="span3">')
             if cgh_results:
                 self.w(u'<h3>%s</h3>' % self._cw._('CGH results'))
                 self.wview('gene-cgh-table-view', rset=cgh_results)
             if mutation_results:
                 self.w(u'<h3>%s</h3>' % self._cw._('Sequencing results'))
                 self.wview('gene-mutation-table-view', rset=mutation_results)
-            self.w(u'</div>')
+
+
+###############################################################################
+### GENOMIC REGION ############################################################
+###############################################################################
+class GenomicRegionPrimaryView(BrainomicsPrimaryView):
+    __select__ = BrainomicsPrimaryView.__select__ & is_instance('GenomicRegion')
+
+    def iterate_attributes(self, entity):
+        genes_rql = ('Any R WHERE R is Gene, X genes R, X eid %(e)s'
+                     % {'e': entity.eid})
+        genes_url = self._cw.build_url(rql=genes_rql)
+        fields = [
+                  (self._cw._('Start position'), entity.start),
+                  (self._cw._('Stop position'), entity.stop),
+                  (self._cw._('Width'), entity.width),
+                  (self._cw._('Cytoband start'), entity.cytoband_start),
+                  (self._cw._('Cytoband stop'), entity.cytoband_stop),
+                  (self._cw._('Chromosome'), entity.chromosome[0].view('outofcontext')),
+                  (self._cw._('Genes'), u'<a href="%s">%s</a>' % (genes_url, self._cw._('See all genes')))]
+        return fields
+
+    def display_main_col(self, entity):
+        cgh_results = self._cw.execute('Any R WHERE R is CghResult, '
+                                       'R genomic_region X, X eid %(e)s',
+                                       {'e': entity.eid})
+        if cgh_results:
+            self.w(u'<h3>%s</h3>' % self._cw._('CGH results'))
+            self.wview('region-cgh-table-view', rset=cgh_results)
 
 
 ###############################################################################
--- a/views/tableviews.py	Thu Nov 14 17:10:27 2013 +0000
+++ b/views/tableviews.py	Mon Nov 25 10:26:50 2013 +0000
@@ -31,16 +31,21 @@
 
 class CghTableView(AbstractCghTableView):
     __regid__ = 'cgh-table-view'
-    columns = ['related_gene', 'cgh_ratio']
-    column_renderers = {'related_gene': RelationColRenderer(role='subject')}
+    columns = ['genomic_region', 'cgh_ratio', 'log2_ratio', 'status', 'numprobes']
+    column_renderers = {'genomic_region': RelationColRenderer(role='subject')}
 
 
 class GeneCghTableView(AbstractCghTableView):
     __regid__ = 'gene-cgh-table-view'
-    columns = ['related_measure', 'cgh_ratio']
+    columns = ['genomic_region', 'related_measure', 'cgh_ratio', 'log2_ratio', 'status']
+    column_renderers = {'related_measure': RelationColRenderer(role='subject', vid='incontext'),
+                        'genomic_region': RelationColRenderer(role='subject', vid='incontext')}
+
+class RegionCghTableView(EntityTableView):
+    __regid__ = 'region-cgh-table-view'
+    columns = ['related_measure', 'cgh_ratio', 'log2_ratio', 'status']
     column_renderers = {'related_measure': RelationColRenderer(role='subject', vid='incontext')}
 
-
 ###############################################################################
 ### GENOMIC MEASURE - SEQUENCAGE ##############################################
 ###############################################################################