Skip to content
Permalink
Browse files

Merge branch 'dev' into grid_datasets

  • Loading branch information...
guerler committed Jun 8, 2017
2 parents a5d99ce + 625feb1 commit b25bf5946e50dfa9acd17cb32ed057d538da1148
@@ -9,7 +9,8 @@ var jQuery = require( 'jquery' ),
UserPreferences = require( 'mvc/user/user-preferences' ),
CustomBuilds = require( 'mvc/user/user-custom-builds' ),
Tours = require( 'mvc/tours' ),
GridView = require( 'mvc/grid/grid-view' )
GridView = require( 'mvc/grid/grid-view' ),
PageList = require( 'mvc/page/page-list' ),
Workflows = require( 'mvc/workflow/workflow' ),
WorkflowsConfigureMenu = require( 'mvc/workflow/workflow-configure-menu' );

@@ -123,7 +124,11 @@ window.app = function app( options, bootstrapped ){
},

show_pages : function( action_id ) {
this.page.display( new GridView( { url_base: Galaxy.root + 'page/list_published', dict_format: true } ) );
if ( action_id == 'list' ) {
this.page.display( new PageList.View() );
} else {
this.page.display( new GridView( { url_base: Galaxy.root + 'page/list_published', dict_format: true } ) );
}
},

show_workflows : function(){
@@ -275,7 +275,7 @@ var Collection = Backbone.Collection.extend({
target : '_top'
},{
title : _l('Saved Pages'),
url : 'page/list',
url : 'pages/list',
target : '_top'
}]
};
@@ -656,7 +656,7 @@ return Backbone.View.extend({
var insert = self.grid.get('insert');

// request new configuration
var json = self.dict_format ? response_text.embedded_grid || response_text : $.parseJSON(response_text);
var json = self.dict_format ? response_text : $.parseJSON(response_text);

// update
json.embedded = embedded;
@@ -0,0 +1,56 @@
/** This class renders the page list. */
define( [ 'utils/utils', 'mvc/grid/grid-view' ], function( Utils, GridView ) {
var View = Backbone.View.extend({
initialize: function( options ) {
var self = this;
this.setElement( $( '<div/>' ) );
this.model = new Backbone.Model();
Utils.get({
url : Galaxy.root + 'page/list',
success : function( response ) {
response[ 'dict_format' ] = true;
self.model.set( response );
self.render();
}
});
},

render: function() {
var grid = new GridView( this.model.attributes );
this.$el.empty().append( grid.$el );
this.$el.append( this._templateShared() );
},

_templateShared: function() {
var $tmpl = $( '<div>' +
'<h2>Pages shared with you by others</h2>' +
'</div>' );
var options = this.model.attributes;
if ( options.shared_by_others && options.shared_by_others.length > 0 ) {
var $table = $( '<table class="colored" border="0" cellspacing="0" cellpadding="0" width="100%">' +
'<tr class="header">' +
'<th>Title</th>' +
'<th>Owner</th>' +
'</tr>' +
'</table>' );
_.each( options.shared_by_others, function( page, index ) {
var display_url = Galaxy.root + 'page/display_by_username_and_slug?username=' + page.username + '&slug=' + page.slug;
$table.append( '<tr>' +
'<td>' +
'<a href="' + display_url + '">' + _.escape( page.title ) + '</a>' +
'</td>' +
'<td>' + _.escape( page.username ) + '</td>' +
'</tr>' );
});
$tmpl.append( $table );
} else {
$tmpl.append( 'No pages have been shared with you.' );
}
return $tmpl;
}
});

return {
View: View
}
});
@@ -602,11 +602,18 @@
<datatype extension="maskinfo-asn1-binary" type="galaxy.datatypes.binary:GenericAsn1Binary" mimetype="application/octet-stream" subclass="true" display_in_upload="true" />
<datatype extension="pssm-asn1" type="galaxy.datatypes.data:GenericAsn1" mimetype="text/plain" subclass="true" display_in_upload="true" />
<!-- PlantTribes datatypes -->
<datatype extension="ptalign" type="galaxy.datatypes.text:PlantTribesMultipleSequenceAlignment" />
<datatype extension="ptortho" type="galaxy.datatypes.text:PlantTribesOrtho" />
<datatype extension="ptorthocs" type="galaxy.datatypes.text:PlantTribesOrthoCodingSequence" />
<datatype extension="pttree" type="galaxy.datatypes.text:PlantTribesPhylogeneticTree" />
<datatype extension="smat" type="galaxy.datatypes.text:Smat" display_in_upload="true" />
<datatype extension="ptalign" type="galaxy.datatypes.plant_tribes:PlantTribesMultipleSequenceAlignment" />
<datatype extension="ptalignca" type="galaxy.datatypes.plant_tribes:PlantTribesMultipleSequenceAlignmentCodonAlignment" />
<datatype extension="ptaligntrimmed" type="galaxy.datatypes.plant_tribes:PlantTribesMultipleSequenceAlignmentTrimmed" />
<datatype extension="ptaligntrimmedca" type="galaxy.datatypes.plant_tribes:PlantTribesMultipleSequenceAlignmentTrimmedCodonAlignment" />
<datatype extension="ptalignfiltered" type="galaxy.datatypes.plant_tribes:PlantTribesMultipleSequenceAlignmentFiltered" />
<datatype extension="ptalignfilteredca" type="galaxy.datatypes.plant_tribes:PlantTribesMultipleSequenceAlignmentFilteredCodonAlignment" />
<datatype extension="ptortho" type="galaxy.datatypes.plant_tribes:PlantTribesOrtho" />
<datatype extension="ptorthocs" type="galaxy.datatypes.plant_tribes:PlantTribesOrthoCodingSequence" />
<datatype extension="ptphylip" type="galaxy.datatypes.plant_tribes:PlantTribesPhylip" />
<datatype extension="pttgf" type="galaxy.datatypes.plant_tribes:PlantTribesTargetedGeneFamilies" />
<datatype extension="pttree" type="galaxy.datatypes.plant_tribes:PlantTribesPhylogeneticTree" />
<datatype extension="smat" type="galaxy.datatypes.plant_tribes:Smat" display_in_upload="true" />
</registration>
<sniffers>
<!--
@@ -616,7 +623,7 @@
defined format first, followed by next-most rigidly defined,
and so on.
-->
<sniffer type="galaxy.datatypes.text:Smat"/>
<sniffer type="galaxy.datatypes.plant_tribes:Smat"/>
<sniffer type="galaxy.datatypes.mothur:Sabund"/>
<sniffer type="galaxy.datatypes.mothur:Otu"/>
<sniffer type="galaxy.datatypes.mothur:GroupAbund"/>
@@ -349,10 +349,10 @@ paste.app_factory = galaxy.web.buildapp:app_factory

# Interactive environment plugins root directory: where to look for interactive
# environment plugins. By default none will be loaded. Set to
# config/plugins/interactive_environments to load Galaxy's stock plugins
# (currently just Jupyter). These will require Docker to be configured and
# have security considerations, so proceed with caution. The path is relative to the
# Galaxy root dir. To use an absolute path begin the path with '/'. This is a comma
# config/plugins/interactive_environments to load Galaxy's stock plugins.
# These will require Docker to be configured and have security considerations,
# so proceed with caution. The path is relative to the Galaxy root dir. To use
# an absolute path begin the path with '/'. This is a comma
# separated list.
#interactive_environment_plugins_directory =

@@ -367,7 +367,28 @@ def display_data(self, trans, data, preview=False, filename=None, to_ext=None, *
file_path = trans.app.object_store.get_filename(data.dataset, extra_dir='dataset_%s_files' % data.dataset.id, alt_name=filename)
if os.path.exists( file_path ):
if os.path.isdir( file_path ):
return trans.show_error_message( "Directory listing is not allowed." ) # TODO: Reconsider allowing listing of directories?
tmp_fh = tempfile.NamedTemporaryFile(delete=False)
tmp_file_name = tmp_fh.name
dir_items = sorted(os.listdir(file_path))
base_path, item_name = os.path.split(file_path)
tmp_fh.write('<html><head><h3>Directory %s contents: %d items</h3></head>\n' % (item_name, len(dir_items)))
tmp_fh.write('<body><p/><table cellpadding="2">\n')
for index, fname in enumerate(dir_items):
if index % 2 == 0:
bgcolor = '#D8D8D8'
else:
bgcolor = '#FFFFFF'
# Can't have an href link here because there is no route
# defined for files contained within multiple subdirectory
# levels of the primary dataset. Something like this is
# close, but not quite correct:
# href = url_for(controller='dataset', action='display',
# dataset_id=trans.security.encode_id(data.dataset.id),
# preview=preview, filename=fname, to_ext=to_ext)
tmp_fh.write('<tr bgcolor="%s"><td>%s</td></tr>\n' % (bgcolor, fname))
tmp_fh.write('</table></body></html>\n')
tmp_fh.close()
return open(tmp_file_name)
mime = mimetypes.guess_type( file_path )[0]
if not mime:
try:
@@ -0,0 +1,213 @@
import logging
import os
import re

from galaxy.datatypes.data import get_file_peek, Text
from galaxy.datatypes.metadata import MetadataElement, MetadataParameter
from galaxy.datatypes.text import Html
from galaxy.util import nice_size

log = logging.getLogger(__name__)


class Smat(Text):
file_ext = "smat"

def display_peek(self, dataset):
try:
return dataset.peek
except:
return "ESTScan scores matrices (%s)" % (nice_size(dataset.get_size()))

def set_peek(self, dataset, is_multi_byte=False):
if not dataset.dataset.purged:
dataset.peek = get_file_peek(dataset.file_name, is_multi_byte=is_multi_byte)
dataset.blurb = "ESTScan scores matrices"
else:
dataset.peek = 'file does not exist'
dataset.blurb = 'file purged from disc'

def sniff(self, filename):
"""
The use of ESTScan implies the creation of scores matrices which
reflect the codons preferences in the studied organisms. The
ESTScan package includes scripts for generating these files. The
output of these scripts consists of the matrices, one for each
isochor, and which look like this:
FORMAT: hse_4is.conf CODING REGION 6 3 1 s C+G: 0 44
-1 0 2 -2
2 1 -8 0
>>> from galaxy.datatypes.sniff import get_test_fname
>>> fname = get_test_fname('test_space.txt')
>>> Smat().sniff(fname)
False
>>> fname = get_test_fname('test_tab.bed')
>>> Smat().sniff(fname)
False
>>> fname = get_test_fname('1.smat')
>>> Smat().sniff(fname)
True
"""
line_no = 0
with open(filename, "r") as fh:
for line in fh:
line_no += 1
if line_no > 10000:
return True
if line_no == 1 and not line.startswith('FORMAT'):
# The first line is always the start of a format section.
return False
if not line.startswith('FORMAT'):
if line.find('\t') >= 0:
# Smat files are not tabular.
return False
items = line.split()
if len(items) != 4:
return False
for item in items:
# Make sure each item is an integer.
if re.match(r"[-+]?\d+$", item) is None:
return False
return True


class PlantTribes(Html):
"""
PlantTribes abstract class.
"""
composite_type = 'basic'
MetadataElement(name="num_files", default=0, desc="Number of files in files_path directory", param=MetadataParameter, readonly=True, visible=False, no_value=0)

def set_meta(self, dataset, overwrite=True, **kwd):
try:
efp = dataset.extra_files_path
if os.path.exists(efp):
dataset.metadata.num_files = len(os.listdir(efp))
except Exception as e:
log.warning("set_meta fname: %s %s" % (dataset.file_name if dataset and dataset.file_name else 'Unkwown', str(e)))


class PlantTribesOrtho(PlantTribes):
"""
PlantTribes sequences classified into precomputed, orthologous gene family
clusters.
"""
file_ext = "ptortho"

def set_peek(self, dataset, is_multi_byte=False):
super(PlantTribesOrtho, self).set_peek(dataset, is_multi_byte=is_multi_byte)
dataset.blurb = "Proteins orthogroup fasta files: %d items" % dataset.metadata.num_files


class PlantTribesOrthoCodingSequence(PlantTribes):
"""
PlantTribes sequences classified into precomputed, orthologous gene family
clusters and corresponding coding sequences.
"""
file_ext = "ptorthocs"

def set_peek(self, dataset, is_multi_byte=False):
super(PlantTribesOrthoCodingSequence, self).set_peek(dataset, is_multi_byte=is_multi_byte)
dataset.blurb = "Protein and coding sequences orthogroup fasta files: %d items" % dataset.metadata.num_files


class PlantTribesTargetedGeneFamilies(PlantTribes):
"""
PlantTribes targeted gene families.
"""
file_ext = "pttgf"

def set_peek(self, dataset, is_multi_byte=False):
super(PlantTribesTargetedGeneFamilies, self).set_peek(dataset, is_multi_byte=is_multi_byte)
dataset.blurb = "Targeted gene families"


class PlantTribesPhylogeneticTree(PlantTribes):
"""
PlantTribes multiple sequence alignments and inferred maximum likelihood
phylogenies for orthogroups.
"""
file_ext = "pttree"

def set_peek(self, dataset, is_multi_byte=False):
super(PlantTribesPhylogeneticTree, self).set_peek(dataset, is_multi_byte=is_multi_byte)
dataset.blurb = "Phylogenetic trees: %d items" % dataset.metadata.num_files


class PlantTribesPhylip(PlantTribes):
"""
PlantTribes orthogroup phylip multiple sequence alignments.
"""
file_ext = "ptphylip"

def set_peek(self, dataset, is_multi_byte=False):
super(PlantTribesPhylip, self).set_peek(dataset, is_multi_byte=is_multi_byte)
dataset.blurb = "Orthogroup phylip multiple sequence alignments: %d items" % dataset.metadata.num_files


class PlantTribesMultipleSequenceAlignment(PlantTribes):
"""
PlantTribes multiple sequence alignments.
"""
file_ext = "ptalign"

def set_peek(self, dataset, is_multi_byte=False):
super(PlantTribesMultipleSequenceAlignment, self).set_peek(dataset, is_multi_byte=is_multi_byte)
dataset.blurb = "Proteins orthogroup alignments: %d items" % dataset.metadata.num_files


class PlantTribesMultipleSequenceAlignmentCodonAlignment(PlantTribes):
"""
PlantTribes multiple sequence alignments with codon alignments.
"""
file_ext = "ptalignca"

def set_peek(self, dataset, is_multi_byte=False):
super(PlantTribesMultipleSequenceAlignmentCodonAlignment, self).set_peek(dataset, is_multi_byte=is_multi_byte)
dataset.blurb = "Protein and coding sequences orthogroup alignments: %d items" % dataset.metadata.num_files


class PlantTribesMultipleSequenceAlignmentTrimmed(PlantTribes):
"""
PlantTribes trimmed multiple sequence alignments.
"""
file_ext = "ptaligntrimmed"

def set_peek(self, dataset, is_multi_byte=False):
super(PlantTribesMultipleSequenceAlignmentTrimmed, self).set_peek(dataset, is_multi_byte=is_multi_byte)
dataset.blurb = "Trimmed proteins orthogroup alignments: %d items" % dataset.metadata.num_files


class PlantTribesMultipleSequenceAlignmentTrimmedCodonAlignment(PlantTribes):
"""
PlantTribes trimmed multiple sequence alignments with codon alignments.
"""
file_ext = "ptaligntrimmedca"

def set_peek(self, dataset, is_multi_byte=False):
super(PlantTribesMultipleSequenceAlignmentTrimmedCodonAlignment, self).set_peek(dataset, is_multi_byte=is_multi_byte)
dataset.blurb = "Trimmed protein and coding sequences orthogroup alignments: %d items" % dataset.metadata.num_files


class PlantTribesMultipleSequenceAlignmentFiltered(PlantTribes):
"""
PlantTribes filtered multiple sequence alignments.
"""
file_ext = "ptalignfiltered"

def set_peek(self, dataset, is_multi_byte=False):
super(PlantTribesMultipleSequenceAlignmentFiltered, self).set_peek(dataset, is_multi_byte=is_multi_byte)
dataset.blurb = "Filtered proteins orthogroup alignments: %d items" % dataset.metadata.num_files


class PlantTribesMultipleSequenceAlignmentFilteredCodonAlignment(PlantTribes):
"""
PlantTribes filtered multiple sequence alignments with codon alignments.
"""
file_ext = "ptalignfilteredca"

def set_peek(self, dataset, is_multi_byte=False):
super(PlantTribesMultipleSequenceAlignmentFilteredCodonAlignment, self).set_peek(dataset, is_multi_byte=is_multi_byte)
dataset.blurb = "Filtered protein and coding sequences orthogroup alignments: %d items" % dataset.metadata.num_files

0 comments on commit b25bf59

Please sign in to comment.
You can’t perform that action at this time.