[views] Discard Gene primary view. Provide uicfg Brainomics primary view customization instead (related to #3340591)
authorVladimir Popescu <vladimir.popescu@logilab.fr>
Mon, 20 Jan 2014 13:18:57 +0000
changeset 640 3b8b2078c21c
parent 639 f7bc10589e3e
child 641 1f4953c40332
[views] Discard Gene primary view. Provide uicfg Brainomics primary view customization instead (related to #3340591)
views/primary.py
views/uicfg.py
--- a/views/primary.py	Mon Jan 20 13:04:36 2014 +0000
+++ b/views/primary.py	Mon Jan 20 13:18:57 2014 +0000
@@ -314,35 +314,6 @@
 
 
 ###############################################################################
-### GENE ######################################################################
-###############################################################################
-class GenePrimaryView(BrainomicsPrimaryView):
-    __select__ = BrainomicsPrimaryView.__select__ & is_instance('Gene')
-
-    def render_entity_attributes(self, entity):
-        fields = [(self._cw._('Identifier'), entity.gene_id),
-                  (self._cw._('Start position'), entity.start_position),
-                  (self._cw._('Stop position'), entity.stop_position),
-                  (self._cw._('Chromosomes'), '; '.join(chrom.view('incontext') for chrom in entity.chromosomes))]
-        return fields
-
-    def render_entity_relations(self, entity):
-        cgh_results = self._cw.execute('Any R WHERE R is CghResult, '
-                                       '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:
-            if cgh_results:
-                self.w(u'<h3>%s</h3>' % self._cw._('CGH results'))
-                self.wview('gene-genmeas-table-view', rset=cgh_results)
-            if mutation_results:
-                self.w(u'<h3>%s</h3>' % self._cw._('Sequencing results'))
-                self.wview('gene-genmeas-table-view', rset=mutation_results)
-
-
-###############################################################################
 ### GENOMIC REGION ############################################################
 ###############################################################################
 class GenomicRegionPrimaryView(BrainomicsPrimaryView):
--- a/views/uicfg.py	Mon Jan 20 13:04:36 2014 +0000
+++ b/views/uicfg.py	Mon Jan 20 13:18:57 2014 +0000
@@ -172,3 +172,22 @@
                     {'label': _('Results'), 'vid': 'genmeas-table-view'})
 
 
+###############################################################################
+### GENE ######################################################################
+###############################################################################
+# XXX for Gene: could not:
+#     - properly reach CghResults; we reach GenomicRegion instead
+# Chromosomes
+_pvs.tag_subject_of(('Gene', 'chromosomes', '*'), 'attributes')
+_pvdc.tag_subject_of(('Gene', 'chromosomes', '*'),
+                     {'vid': 'incontext', 'label': _('Chromosomes')})
+# CGH results
+_pvs.tag_object_of(('*', 'genes', 'Gene'), 'attributes') # GenomicRegion
+_pvdc.tag_object_of(('*', 'genes', 'Gene'),
+                    {'label': _('CGH results'), 'vid': 'table'})
+# Sequencing results
+_pvs.tag_object_of(('*', 'related_gene', 'Gene'), 'attributes') # Mutation
+_pvdc.tag_object_of(('*', 'related_gene', 'Gene'),
+                    {'label': _('Sequencing results'),
+                     'vid': 'gene-genmeas-table-view'})
+