commit/galaxy-central: jgoecks: Improve dataset fetching in visualizations.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/ebd30e5e9120/ changeset: ebd30e5e9120 user: jgoecks date: 2012-06-13 18:57:41 summary: Improve dataset fetching in visualizations. affected #: 3 files diff -r 5a3c60aca201a3cefc1baef1f945043afc52a3be -r ebd30e5e9120181833621fc9710c1066ad3f9aa7 lib/galaxy/visualization/tracks/data_providers.py --- a/lib/galaxy/visualization/tracks/data_providers.py +++ b/lib/galaxy/visualization/tracks/data_providers.py @@ -965,7 +965,7 @@ f = open( self.original_dataset.file_name ) return f, BigBedFile(file=f) -class BigWigDataProvider (BBIDataProvider ): +class BigWigDataProvider ( BBIDataProvider ): def _get_dataset( self ): if self.converted_dataset is not None: f = open( self.converted_dataset.file_name ) diff -r 5a3c60aca201a3cefc1baef1f945043afc52a3be -r ebd30e5e9120181833621fc9710c1066ad3f9aa7 lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -468,10 +468,7 @@ def pack_track( track_dict ): dataset_id = track_dict['dataset_id'] hda_ldda = track_dict.get('hda_ldda', 'hda') - if hda_ldda == "hda": - dataset = self.get_dataset( trans, dataset_id, check_ownership=False, check_accessible=True ) - else: - dataset = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( dataset_id ) + dataset = self.get_hda_or_ldda( trans, hda_ldda, dataset_id ) try: prefs = track_dict['prefs'] @@ -545,6 +542,13 @@ return config + def get_hda_or_ldda( self, trans, hda_ldda, dataset_id ): + """ Returns either HDA or LDDA for hda/ldda and id combination. """ + if hda_ldda == "hda": + return self.get_dataset( trans, dataset_id, check_ownership=False, check_accessible=True ) + else: + return trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( dataset_id ) ) + # -- Helper functions -- def _create_visualization( self, trans, title, type, dbkey, slug=None, annotation=None ): diff -r 5a3c60aca201a3cefc1baef1f945043afc52a3be -r ebd30e5e9120181833621fc9710c1066ad3f9aa7 lib/galaxy/web/controllers/tracks.py --- a/lib/galaxy/web/controllers/tracks.py +++ b/lib/galaxy/web/controllers/tracks.py @@ -177,17 +177,22 @@ @web.json def add_track_async(self, trans, hda_id=None, ldda_id=None): + # Get dataset. if hda_id: hda_ldda = "hda" - dataset = self.get_dataset( trans, hda_id, check_ownership=False, check_accessible=True ) + dataset_id = hda_id elif ldda_id: hda_ldda = "ldda" - dataset = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( ldda_id ) ) + dataset_id = ldda_id + dataset = self.get_hda_or_ldda( trans, hda_ldda, dataset_id ) + + # Get data provider. track_type, _ = dataset.datatype.get_track_type() track_data_provider_class = get_data_provider( original_dataset=dataset ) track_data_provider = track_data_provider_class( original_dataset=dataset ) - track = { + # Get track definition. + return { "track_type": track_type, "name": dataset.name, "hda_ldda": hda_ldda, @@ -197,16 +202,17 @@ "tool": get_tool_def( trans, dataset ), "tool_state": {} } - return track @web.json def bookmarks_from_dataset( self, trans, hda_id=None, ldda_id=None ): if hda_id: hda_ldda = "hda" - dataset = self.get_dataset( trans, hda_id, check_ownership=False, check_accessible=True ) + dataset_id = hda_id elif ldda_id: hda_ldda = "ldda" - dataset = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( ldda_id ) ) + dataset_id = ldda_id + dataset = self.get_hda_or_ldda( trans, hda_ldda, dataset_id ) + rows = [] if isinstance( dataset.datatype, Bed ): data = RawBedDataProvider( original_dataset=dataset ).get_iterator() @@ -482,7 +488,7 @@ @web.require_login( "use Galaxy visualizations", use_panels=True ) def paramamonster( self, trans, hda_ldda, dataset_id ): # Get dataset. - dataset = self._get_dataset( trans, hda_ldda, dataset_id ) + dataset = self.get_hda_or_ldda( trans, hda_ldda, dataset_id ) return trans.fill_template_mako( "visualization/paramamonster.mako", dataset=dataset, tool=self.app.toolbox.tools_by_id[ 'cufflinks' ].to_dict( trans, for_display=True ) ) @@ -491,7 +497,7 @@ @web.require_login( "use Galaxy visualizations", use_panels=True ) def circster( self, trans, hda_ldda, dataset_id ): # Get dataset. - dataset = self._get_dataset( trans, hda_ldda, dataset_id ) + dataset = self.get_hda_or_ldda( trans, hda_ldda, dataset_id ) # Get genome info. dbkey = dataset.dbkey @@ -535,11 +541,4 @@ # Store msg. data_sources_dict[ source_type ] = { "name" : data_source, "message": msg } - return data_sources_dict - - def _get_dataset( self, trans, hda_ldda, dataset_id ): - """ Returns either HDA or LDDA for hda/ldda and id combination. """ - if hda_ldda == "hda": - return self.get_dataset( trans, dataset_id, check_ownership=False, check_accessible=True ) - else: - return trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( dataset_id ) ) \ No newline at end of file + return data_sources_dict \ No newline at end of file Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket