Skip to content

Commit

Permalink
Merge branch 'dev' into remove_samples_000
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Oct 4, 2017
2 parents 81f111c + 562465f commit 2919221
Show file tree
Hide file tree
Showing 86 changed files with 2,450 additions and 589 deletions.
15 changes: 14 additions & 1 deletion client/galaxy/scripts/mvc/history/history-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ var HistoryView = _super.extend(
// control contents/behavior based on where (and in what context) the panel is being used
/** where should pages from links be displayed? (default to new tab/window) */
this.linkTarget = attributes.linkTarget || '_blank';

/** timeout id for detailed fetch of collection counts, etc... */
this.detailedFetchTimeoutId = null;
},

/** create and return a collection for when none is initially passed */
Expand All @@ -89,9 +92,18 @@ var HistoryView = _super.extend(
if( this.model ){
this.model.clearUpdateTimeout();
}
this._clearDetailedFetchTimeout();
return this;
},

/** clear the timeout and the cached timeout id */
_clearDetailedFetchTimeout : function(){
if( this.detailedFetchTimeoutId ){
clearTimeout( this.detailedFetchTimeoutId );
this.detailedFetchTimeoutId = null;
}
},

/** create any event listeners for the panel
* @fires: rendered:initial on the first render
* @fires: empty-history when switching to a history with no contents or creating a new history
Expand All @@ -105,7 +117,8 @@ var HistoryView = _super.extend(
'loading-done' : function(){
var self = this;
// after the initial load, decorate with more time consuming fields (like HDCA element_counts)
_.delay( function(){
self.detailedFetchTimeoutId = _.delay( function(){
self.detailedFetchTimeoutId = null;
self.model.contents.fetchCollectionCounts();
}, self.FETCH_COLLECTION_COUNTS_DELAY );
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ var FolderListView = Backbone.View.extend({
'</ol>',

// FOLDER CONTENT
'<table data-library-id="<%- parent_library_id %>" id="folder_table" class="grid table table-condensed">',
'<table data-library-id="<%- parent_library_id %>" class="grid table table-condensed">',
'<thead>',
'<th class="button_heading"></th>',
'<th style="text-align: center; width: 20px; " title="Check to select all datasets"><input id="select-all-checkboxes" style="margin: 0;" type="checkbox"></th>',
Expand Down
14 changes: 9 additions & 5 deletions client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ var FolderToolbarView = Backbone.View.extend({

// show bulk import modal
modalBulkImport : function(){
var checkedValues = $('#folder_table').find(':checked');
if(checkedValues.length === 0){
var $checkedValues = this.findCheckedRows();
if($checkedValues.length === 0){
mod_toastr.info('You must select some datasets first.');
} else {
var that = this;
Expand Down Expand Up @@ -268,7 +268,7 @@ var FolderToolbarView = Backbone.View.extend({
processImportToHistory: function( history_id, history_name ){
var dataset_ids = [];
var folder_ids = [];
$('#folder_table').find(':checked').each(function(){
this.findCheckedRows().each(function(){
var row_id = $(this).closest('tr').data('id');
if (row_id.substring(0,1) == 'F'){
folder_ids.push(row_id);
Expand Down Expand Up @@ -323,7 +323,7 @@ var FolderToolbarView = Backbone.View.extend({
download : function( folder_id, format ){
var dataset_ids = [];
var folder_ids = [];
$( '#folder_table' ).find( ':checked' ).each( function(){
this.findCheckedRows().each( function(){
var row_id = $(this).closest('tr').data('id');
if (row_id.substring(0,1) == 'F'){
folder_ids.push(row_id);
Expand Down Expand Up @@ -997,7 +997,7 @@ var FolderToolbarView = Backbone.View.extend({
deleteSelectedItems: function(){
var dataset_ids = [];
var folder_ids = [];
var $checkedValues = $('#folder_table').find(':checked');
var $checkedValues = this.findCheckedRows();
if($checkedValues.length === 0){
mod_toastr.info('You must select at least one item for deletion.');
} else {
Expand Down Expand Up @@ -1116,6 +1116,10 @@ var FolderToolbarView = Backbone.View.extend({
}
},

findCheckedRows: function(){
return $('#folder_list_body').find(':checked');
},

templateToolBar: function(){
return _.template([
// container start
Expand Down
26 changes: 17 additions & 9 deletions client/galaxy/scripts/onload.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,21 @@ $(document).ready( function() {
}
}

// Load all webhooks with the type 'onload'
$.getJSON( Galaxy.root + 'api/webhooks/onload/all', function(webhooks) {
_.each(webhooks, function(webhook) {
if (webhook.activate && webhook.script) {
$('<script/>', {type: 'text/javascript'}).text(webhook.script).appendTo('head');
$('<style/>', {type: 'text/css'}).text(webhook.styles).appendTo('head');
}
});
});
function onloadWebhooks() {
if (Galaxy.root !== undefined){
// Load all webhooks with the type 'onload'
$.getJSON( Galaxy.root + 'api/webhooks/onload/all', function(webhooks) {
_.each(webhooks, function(webhook) {
if (webhook.activate && webhook.script) {
$('<script/>', {type: 'text/javascript'}).text(webhook.script).appendTo('head');
$('<style/>', {type: 'text/css'}).text(webhook.styles).appendTo('head');
}
});
});
}
else {
setTimeout(onloadWebhooks, 100);
}
}
onloadWebhooks();
});
2 changes: 2 additions & 0 deletions config/datatypes_conf.xml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
<datatype extension="sf3" type="galaxy.datatypes.proteomics:Sf3" display_in_upload="true" />
<datatype extension="cps" type="galaxy.datatypes.binary:Binary" subclass="true" display_in_upload="true" />
<datatype extension="ct" type="galaxy.datatypes.tabular:ConnectivityTable" display_in_upload="true"/>
<datatype extension="postgresql" type="galaxy.datatypes.binary:PostgresqlArchive" subclass="True" display_in_upload="True"/>
<datatype extension="searchgui_archive" type="galaxy.datatypes.binary:SearchGuiArchive" display_in_upload="true"/>
<datatype extension="fast5.tar" type="galaxy.datatypes.binary:Fast5Archive" display_in_upload="true"/>
<datatype extension="fast5.tar.gz" type="galaxy.datatypes.binary:Fast5ArchiveGz" display_in_upload="true"/>
Expand Down Expand Up @@ -679,6 +680,7 @@
<sniffer type="galaxy.datatypes.binary:Fast5ArchiveGz" />
<sniffer type="galaxy.datatypes.binary:Fast5ArchiveBz2" />
<sniffer type="galaxy.datatypes.binary:Fast5Archive" />
<sniffer type="galaxy.datatypes.binary:PostgresqlArchive"/>
<sniffer type="galaxy.datatypes.triples:Rdf"/>
<sniffer type="galaxy.datatypes.blast:BlastXml"/>
<sniffer type="galaxy.datatypes.xml:Phyloxml"/>
Expand Down
3 changes: 2 additions & 1 deletion config/galaxy.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ nglims_config_file = tool-data/nglims.yaml

# Verbosity of console log messages. Acceptable values can be found here:
# https://docs.python.org/2/library/logging.html#logging-levels
# A custom debug level of "TRACE" is available for even more verbosity.
#log_level = DEBUG

# Print database operations to the server log (warning, quite verbose!).
Expand Down Expand Up @@ -978,7 +979,7 @@ use_interactive = True
# Galaxy encodes various internal values when these values will be output in
# some format (for example, in a URL or cookie). You should set a key to be
# used by the algorithm that encodes and decodes these values. It can be any
# string.
# string up to 448 bits long.
# One simple way to generate a value for this is with the shell command:
# python -c 'import time; print time.time()' | md5sum | cut -f 1 -d ' '
#id_secret = USING THE DEFAULT IS NOT SECURE!
Expand Down
14 changes: 0 additions & 14 deletions lib/galaxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,3 @@

from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)


# compat: BadZipFile introduced in Python 2.7
import zipfile
if not hasattr(zipfile, 'BadZipFile'):
zipfile.BadZipFile = zipfile.error

# compat: patch to add the NullHandler class to logging
import logging
if not hasattr(logging, 'NullHandler'):
class NullHandler(logging.Handler):
def emit(self, record):
pass
logging.NullHandler = NullHandler
2 changes: 1 addition & 1 deletion lib/galaxy/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def shutdown(self):

def configure_fluent_log(self):
if self.config.fluent_log:
from galaxy.util.log.fluent_log import FluentTraceLogger
from galaxy.util.logging.fluent_log import FluentTraceLogger
self.trace_logger = FluentTraceLogger('galaxy', self.config.fluent_host, self.config.fluent_port)
else:
self.trace_logger = None
Expand Down
2 changes: 2 additions & 0 deletions lib/galaxy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from galaxy.util import string_as_bool
from galaxy.util import unicodify
from galaxy.util.dbkeys import GenomeBuilds
from galaxy.util.logging import LOGLV_TRACE
from galaxy.web.formatting import expand_pretty_datetime_format
from galaxy.web.stack import register_postfork_function
from .version import VERSION_MAJOR
Expand Down Expand Up @@ -876,6 +877,7 @@ def configure_logging(config):
or a simple dictionary of configuration variables.
"""
# Get root logger
logging.addLevelName(LOGLV_TRACE, "TRACE")
root = logging.getLogger()
# PasteScript will have already configured the logger if the
# 'loggers' section was found in the config file, otherwise we do
Expand Down
53 changes: 53 additions & 0 deletions lib/galaxy/datatypes/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,59 @@ def sniff(self, filename):
OxliGraphLabels)


class PostgresqlArchive(CompressedArchive):
"""
Class describing a Postgresql database packed into a tar archive
>>> from galaxy.datatypes.sniff import get_test_fname
>>> fname = get_test_fname( 'postgresql_fake.tar.bz2' )
>>> PostgresqlArchive().sniff( fname )
True
>>> fname = get_test_fname( 'test.fast5.tar' )
>>> PostgresqlArchive().sniff( fname )
False
"""
MetadataElement(name="version", default=None, param=MetadataParameter, desc="PostgreSQL database version",
readonly=True, visible=True, no_value=None)
file_ext = "postgresql"

def set_meta(self, dataset, overwrite=True, **kwd):
super(PostgresqlArchive, self).set_meta(dataset, overwrite=overwrite, **kwd)
try:
if dataset and tarfile.is_tarfile(dataset.file_name):
with tarfile.open(dataset.file_name, 'r') as temptar:
pg_version_file = temptar.extractfile('postgresql/db/PG_VERSION')
dataset.metadata.version = pg_version_file.read().strip()
except Exception as e:
log.warning('%s, set_meta Exception: %s', self, e)

def sniff(self, filename):
if filename and tarfile.is_tarfile(filename):
try:
with tarfile.open(filename, 'r') as temptar:
return 'postgresql/db/PG_VERSION' in temptar.getnames()
except Exception as e:
log.warning('%s, sniff Exception: %s', self, e)
return False

def set_peek(self, dataset, is_multi_byte=False):
if not dataset.dataset.purged:
dataset.peek = "PostgreSQL Archive (%s)" % (nice_size(dataset.get_size()))
dataset.blurb = "PostgreSQL version %s" % (dataset.metadata.version or 'unknown')
else:
dataset.peek = 'file does not exist'
dataset.blurb = 'file purged from disk'

def display_peek(self, dataset):
try:
return dataset.peek
except:
return "PostgreSQL Archive (%s)" % (nice_size(dataset.get_size()))


Binary.register_sniffable_binary_format("postgresql_archiv", "postgresql", PostgresqlArchive)


class Fast5Archive(CompressedArchive):
"""
Class describing a FAST5 archive
Expand Down
75 changes: 53 additions & 22 deletions lib/galaxy/datatypes/molecules.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def count_lines(filename, non_empty=False):

class GenericMolFile(data.Text):
"""
abstract class for most of the molecule files
Abstract class for most of the molecule files.
"""
MetadataElement(name="number_of_molecules", default=0, desc="Number of molecules", readonly=True, visible=True, optional=True, no_value=0)

Expand Down Expand Up @@ -92,26 +92,53 @@ def sniff(self, filename):
"""
Try to guess if the file is a SDF2 file.
An SDfile (structure-data file) can contain multiple compounds.
Each compound starts with a block in V2000 or V3000 molfile format,
which ends with a line equal to 'M END'.
This is followed by a non-structural data block, which ends with a line
equal to '$$$$'.
>>> from galaxy.datatypes.sniff import get_test_fname
>>> fname = get_test_fname('drugbank_drugs.sdf')
>>> SDF().sniff(fname)
True
>>> fname = get_test_fname('drugbank_drugs.cml')
>>> fname = get_test_fname('github88.v3k.sdf')
>>> SDF().sniff(fname)
True
>>> fname = get_test_fname('chebi_57262.v3k.mol')
>>> SDF().sniff(fname)
False
"""
counter = count_special_lines("^M\s*END", filename) + count_special_lines("^\$\$\$\$", filename)
if counter > 0 and counter % 2 == 0:
return True
else:
return False
m_end_found = False
limit = 10000
idx = 0
with open(filename) as in_file:
for line in in_file:
idx += 1
line = line.rstrip('\n\r')
if idx < 4:
continue
elif idx == 4:
if len(line) != 39 or not(line.endswith(' V2000') or
line.endswith(' V3000')):
return False
elif not m_end_found:
if line == 'M END':
m_end_found = True
elif line == '$$$$':
return True
if idx == limit:
break
return False

def set_meta(self, dataset, **kwd):
"""
Set the number of molecules in dataset.
"""
dataset.metadata.number_of_molecules = count_special_lines("^\$\$\$\$", dataset.file_name)
dataset.metadata.number_of_molecules = count_special_lines("^\$\$\$\$$", dataset.file_name)

def split(cls, input_datasets, subdir_generator_function, split_params):
"""
Expand Down Expand Up @@ -180,10 +207,17 @@ def sniff(self, filename):
>>> MOL2().sniff(fname)
False
"""
if count_special_lines("@<TRIPOS>MOLECULE", filename) > 0:
return True
else:
return False
limit = 60
idx = 0
with open(filename) as in_file:
for line in in_file:
line = line.rstrip('\n\r')
if line == '@<TRIPOS>MOLECULE':
return True
idx += 1
if idx == limit:
break
return False

def set_meta(self, dataset, **kwd):
"""
Expand Down Expand Up @@ -716,16 +750,13 @@ def sniff(self, filename):
>>> CML().sniff(fname)
True
"""
handle = open(filename)
line = handle.readline()
if line.strip() != '<?xml version="1.0"?>':
handle.close()
return False
line = handle.readline()
if line.strip().find('http://www.xml-cml.org/schema') == -1:
handle.close()
return False
handle.close()
with open(filename) as handle:
line = handle.readline()
if line.strip() != '<?xml version="1.0"?>':
return False
line = handle.readline()
if line.strip().find('http://www.xml-cml.org/schema') == -1:
return False
return True

def split(cls, input_datasets, subdir_generator_function, split_params):
Expand Down

0 comments on commit 2919221

Please sign in to comment.