commit/galaxy-central: 4 new changesets
4 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/c0b08d727159/ Changeset: c0b08d727159 User: dannon Date: 2015-02-10 19:38:01+00:00 Summary: Style standardization in s3objectstore, a couple fixes. Affected #: 1 file diff -r 23df5eac97f7c05da1e06fb63a0385b1c416d535 -r c0b08d72715952fd255ff548d20d8fe8f9b00451 lib/galaxy/objectstore/s3.py --- a/lib/galaxy/objectstore/s3.py +++ b/lib/galaxy/objectstore/s3.py @@ -13,8 +13,7 @@ from datetime import datetime from galaxy.exceptions import ObjectNotFound -from galaxy.util import umask_fix_perms, string_as_bool -from galaxy.util import string_as_bool +from galaxy.util import string_as_bool, umask_fix_perms from galaxy.util.directory_hash import directory_hash_id from galaxy.util.sleeper import Sleeper from .s3_multipart_upload import multipart_upload @@ -28,7 +27,8 @@ except ImportError: boto = None -NO_BOTO_ERROR_MESSAGE = "S3/Swift object store configured, but no boto dependency available. Please install and properly configure boto or modify object store configuration." +NO_BOTO_ERROR_MESSAGE = ("S3/Swift object store configured, but no boto dependency available." + "Please install and properly configure boto or modify object store configuration.") log = logging.getLogger( __name__ ) logging.getLogger('boto').setLevel(logging.INFO) # Otherwise boto is quite noisy @@ -91,8 +91,6 @@ self.conn_path = cn_xml.get('conn_path', '/') c_xml = config_xml.findall('cache')[0] self.cache_size = float(c_xml.get('size', -1)) - self.cache_path = c_xml.get('path') - # for multipart upload self.s3server = {'access_key': self.access_key, 'secret_key': self.secret_key, @@ -102,8 +100,6 @@ 'port': self.port, 'use_rr': self.use_rr, 'conn_path': self.conn_path} - - except Exception: # Toss it back up after logging, we can't continue loading at this point. log.exception("Malformed ObjectStore Configuration XML -- unable to continue") @@ -115,23 +111,23 @@ total_size = 0 # Is this going to be too expensive of an operation to be done frequently? file_list = [] - for dirpath, dirnames, filenames in os.walk(self.staging_path): - for f in filenames: - fp = os.path.join(dirpath, f) - file_size = os.path.getsize(fp) + for dirpath, _, filenames in os.walk(self.staging_path): + for filename in filenames: + filepath = os.path.join(dirpath, filename) + file_size = os.path.getsize(filepath) total_size += file_size # Get the time given file was last accessed - last_access_time = time.localtime(os.stat(fp)[7]) + last_access_time = time.localtime(os.stat(filepath)[7]) # Compose a tuple of the access time and the file path - file_tuple = last_access_time, fp, file_size + file_tuple = last_access_time, filepath, file_size file_list.append(file_tuple) # Sort the file list (based on access time) file_list.sort() # Initiate cleaning once within 10% of the defined cache size? cache_limit = self.cache_size * 0.9 if total_size > cache_limit: - log.info("Initiating cache cleaning: current cache size: %s; clean until smaller than: %s" - % (convert_bytes(total_size), convert_bytes(cache_limit))) + log.info("Initiating cache cleaning: current cache size: %s; clean until smaller than: %s", + convert_bytes(total_size), convert_bytes(cache_limit)) # How much to delete? If simply deleting up to the cache-10% limit, # is likely to be deleting frequently and may run the risk of hitting # the limit - maybe delete additional #%? @@ -159,10 +155,10 @@ # exceed delete_this_much; start deleting from the front of the file list, # which assumes the oldest files come first on the list. deleted_amount = 0 - for i, f in enumerate(file_list): + for entry in enumerate(file_list): if deleted_amount < delete_this_much: - deleted_amount += f[2] - os.remove(f[1]) + deleted_amount += entry[2] + os.remove(entry[1]) # Debugging code for printing deleted files' stats # folder, file_name = os.path.split(f[1]) # file_date = time.strftime("%m/%d/%y %H:%M:%S", f[0]) @@ -170,7 +166,7 @@ # % (i, file_name, convert_bytes(f[2]), file_date, \ # convert_bytes(deleted_amount), convert_bytes(delete_this_much))) else: - log.debug("Cache cleaning done. Total space freed: %s" % convert_bytes(deleted_amount)) + log.debug("Cache cleaning done. Total space freed: %s", convert_bytes(deleted_amount)) return def _get_bucket(self, bucket_name): @@ -179,14 +175,14 @@ for i in range(5): try: bucket = self.conn.get_bucket(bucket_name) - log.debug("Using cloud object store with bucket '%s'" % bucket.name) + log.debug("Using cloud object store with bucket '%s'", bucket.name) return bucket except S3ResponseError: try: - log.debug("Bucket not found, creating s3 bucket with handle '%s'" % bucket_name) + log.debug("Bucket not found, creating s3 bucket with handle '%s'", bucket_name) self.conn.create_bucket(bucket_name) except S3ResponseError: - log.exception("Could not get bucket '%s', attempt %s/5" % (bucket_name, i + 1)) + log.exception("Could not get bucket '%s', attempt %s/5", bucket_name, i + 1) time.sleep(2) # All the attempts have been exhausted and connection was not established, # raise error @@ -194,10 +190,10 @@ def _fix_permissions(self, rel_path): """ Set permissions on rel_path""" - for basedir, dirs, files in os.walk(rel_path): + for basedir, _, files in os.walk(rel_path): umask_fix_perms(basedir, self.config.umask, 0777, self.config.gid) - for f in files: - path = os.path.join(basedir, f) + for filename in files: + path = os.path.join(basedir, filename) # Ignore symlinks if os.path.islink(path): continue @@ -228,10 +224,8 @@ if key: return key.size except S3ResponseError, ex: - log.error("Could not get size of key '%s' from S3: %s" % (rel_path, ex)) - except Exception, ex: - log.error("Could not get reference to the key object '%s'; returning -1 for key size: %s" % (rel_path, ex)) - return -1 + log.error("Could not get size of key '%s' from S3: %s", rel_path, ex) + return -1 def _key_exists(self, rel_path): exists = False @@ -239,8 +233,8 @@ # A hackish way of testing if the rel_path is a folder vs a file is_dir = rel_path[-1] == '/' if is_dir: - rs = self.bucket.get_all_keys(prefix=rel_path) - if len(rs) > 0: + keyresult = self.bucket.get_all_keys(prefix=rel_path) + if len(keyresult) > 0: exists = True else: exists = False @@ -248,7 +242,7 @@ key = Key(self.bucket, rel_path) exists = key.exists() except S3ResponseError, ex: - log.error("Trouble checking existence of S3 key '%s': %s" % (rel_path, ex)) + log.error("Trouble checking existence of S3 key '%s': %s", rel_path, ex) return False if rel_path[0] == '/': raise @@ -289,36 +283,36 @@ if not os.path.exists(self._get_cache_path(rel_path_dir)): os.makedirs(self._get_cache_path(rel_path_dir)) # Now pull in the file - ok = self._download(rel_path) + file_ok = self._download(rel_path) self._fix_permissions(self._get_cache_path(rel_path_dir)) - return ok + return file_ok def _transfer_cb(self, complete, total): self.transfer_progress += 10 def _download(self, rel_path): try: - log.debug("Pulling key '%s' into cache to %s" % (rel_path, self._get_cache_path(rel_path))) + log.debug("Pulling key '%s' into cache to %s", rel_path, self._get_cache_path(rel_path)) key = self.bucket.get_key(rel_path) # Test if cache is large enough to hold the new file if self.cache_size > 0 and key.size > self.cache_size: - log.critical("File %s is larger (%s) than the cache size (%s). Cannot download." - % (rel_path, key.size, self.cache_size)) + log.critical("File %s is larger (%s) than the cache size (%s). Cannot download.", + rel_path, key.size, self.cache_size) return False if self.use_axel: - log.debug("Parallel pulled key '%s' into cache to %s" % (rel_path, self._get_cache_path(rel_path))) + log.debug("Parallel pulled key '%s' into cache to %s", rel_path, self._get_cache_path(rel_path)) ncores = multiprocessing.cpu_count() url = key.generate_url(7200) ret_code = subprocess.call("axel -a -n %s '%s'" % (ncores, url)) if ret_code == 0: return True else: - log.debug("Pulled key '%s' into cache to %s" % (rel_path, self._get_cache_path(rel_path))) + log.debug("Pulled key '%s' into cache to %s", rel_path, self._get_cache_path(rel_path)) self.transfer_progress = 0 # Reset transfer progress counter key.get_contents_to_filename(self._get_cache_path(rel_path), cb=self._transfer_cb, num_cb=10) return True - except S3ResponseError, ex: - log.error("Problem downloading key '%s' from S3 bucket '%s': %s" % (rel_path, self.bucket.name, ex)) + except S3ResponseError: + log.exception("Problem downloading key '%s' from S3 bucket '%s'", rel_path, self.bucket.name) return False def _push_to_os(self, rel_path, source_file=None, from_string=None): @@ -334,14 +328,14 @@ if os.path.exists(source_file): key = Key(self.bucket, rel_path) if os.path.getsize(source_file) == 0 and key.exists(): - log.debug("Wanted to push file '%s' to S3 key '%s' but its size is 0; skipping." % (source_file, rel_path)) + log.debug("Wanted to push file '%s' to S3 key '%s' but its size is 0; skipping.", source_file, rel_path) return True if from_string: key.set_contents_from_string(from_string, reduced_redundancy=self.use_rr) - log.debug("Pushed data from string '%s' to key '%s'" % (from_string, rel_path)) + log.debug("Pushed data from string '%s' to key '%s'", from_string, rel_path) else: start_time = datetime.now() - log.debug("Pushing cache file '%s' of size %s bytes to key '%s'" % (source_file, os.path.getsize(source_file), rel_path)) + log.debug("Pushing cache file '%s' of size %s bytes to key '%s'", source_file, os.path.getsize(source_file), rel_path) mb_size = os.path.getsize(source_file) / 1e6 if mb_size < 10 or (not self.multipart): self.transfer_progress = 0 # Reset transfer progress counter @@ -352,13 +346,14 @@ else: multipart_upload(self.s3server, self.bucket, key.name, source_file, mb_size) end_time = datetime.now() - log.debug("Pushed cache file '%s' to key '%s' (%s bytes transfered in %s sec)" % (source_file, rel_path, os.path.getsize(source_file), end_time - start_time)) + log.debug("Pushed cache file '%s' to key '%s' (%s bytes transfered in %s sec)", + source_file, rel_path, os.path.getsize(source_file), end_time - start_time) return True else: - log.error("Tried updating key '%s' from source file '%s', but source file does not exist." - % (rel_path, source_file)) - except S3ResponseError, ex: - log.error("Trouble pushing S3 key '%s' from file '%s': %s" % (rel_path, source_file, ex)) + log.error("Tried updating key '%s' from source file '%s', but source file does not exist.", + rel_path, source_file) + except S3ResponseError: + log.exception("Trouble pushing S3 key '%s' from file '%s'", rel_path, source_file) return False def file_ready(self, obj, **kwargs): @@ -371,8 +366,8 @@ if self._in_cache(rel_path): if os.path.getsize(self._get_cache_path(rel_path)) == self._get_size_in_s3(rel_path): return True - log.debug("Waiting for dataset {0} to transfer from OS: {1}/{2}".format(rel_path, - os.path.getsize(self._get_cache_path(rel_path)), self._get_size_in_s3(rel_path))) + log.debug("Waiting for dataset %s to transfer from OS: %s/%s", rel_path, + os.path.getsize(self._get_cache_path(rel_path)), self._get_size_in_s3(rel_path)) return False def exists(self, obj, **kwargs): @@ -444,10 +439,10 @@ try: return os.path.getsize(self._get_cache_path(rel_path)) except OSError, ex: - log.info("Could not get size of file '%s' in local cache, will try S3. Error: %s" % (rel_path, ex)) + log.info("Could not get size of file '%s' in local cache, will try S3. Error: %s", rel_path, ex) elif self.exists(obj, **kwargs): return self._get_size_in_s3(rel_path) - log.warning("Did not find dataset '%s', returning 0 for size" % rel_path) + log.warning("Did not find dataset '%s', returning 0 for size", rel_path) return 0 def delete(self, obj, entire_dir=False, **kwargs): @@ -460,9 +455,9 @@ # but requires iterating through each individual key in S3 and deleing it. if entire_dir and extra_dir: shutil.rmtree(self._get_cache_path(rel_path)) - rs = self.bucket.get_all_keys(prefix=rel_path) - for key in rs: - log.debug("Deleting key %s" % key.name) + results = self.bucket.get_all_keys(prefix=rel_path) + for key in results: + log.debug("Deleting key %s", key.name) key.delete() return True else: @@ -470,14 +465,14 @@ os.unlink(self._get_cache_path(rel_path)) # Delete from S3 as well if self._key_exists(rel_path): - key = Key(self.bucket, rel_path) - log.debug("Deleting key %s" % key.name) - key.delete() - return True + key = Key(self.bucket, rel_path) + log.debug("Deleting key %s", key.name) + key.delete() + return True except S3ResponseError, ex: - log.error("Could not delete key '%s' from S3: %s" % (rel_path, ex)) + log.error("Could not delete key '%s' from S3: %s", rel_path, ex) except OSError, ex: - log.error('%s delete error %s' % (self._get_filename(obj, **kwargs), ex)) + log.error('%s delete error %s', self._get_filename(obj, **kwargs), ex) return False def get_data(self, obj, start=0, count=-1, **kwargs): @@ -538,7 +533,7 @@ shutil.copy2(source_file, cache_file) self._fix_permissions(cache_file) except OSError, ex: - log.error("Trouble copying source file '%s' to cache '%s': %s" % (source_file, cache_file, ex)) + log.error("Trouble copying source file '%s' to cache '%s': %s", source_file, cache_file, ex) else: source_file = self._get_cache_path(rel_path) # Update the file on S3 @@ -553,8 +548,8 @@ try: key = Key(self.bucket, rel_path) return key.generate_url(expires_in=86400) # 24hrs - except S3ResponseError, ex: - log.warning("Trouble generating URL for dataset '%s': %s" % (rel_path, ex)) + except S3ResponseError: + log.exception("Trouble generating URL for dataset '%s'", rel_path) return None def get_store_usage_percent(self): https://bitbucket.org/galaxy/galaxy-central/commits/6ac0193e7fcd/ Changeset: 6ac0193e7fcd User: dannon Date: 2015-02-10 19:38:58+00:00 Summary: Correct old reference to the wrong get_filename in s3objectstore. Affected #: 1 file diff -r c0b08d72715952fd255ff548d20d8fe8f9b00451 -r 6ac0193e7fcdff4d4e928842c88661cff8ceec0f lib/galaxy/objectstore/s3.py --- a/lib/galaxy/objectstore/s3.py +++ b/lib/galaxy/objectstore/s3.py @@ -472,7 +472,7 @@ except S3ResponseError, ex: log.error("Could not delete key '%s' from S3: %s", rel_path, ex) except OSError, ex: - log.error('%s delete error %s', self._get_filename(obj, **kwargs), ex) + log.error('%s delete error %s', self.get_filename(obj, **kwargs), ex) return False def get_data(self, obj, start=0, count=-1, **kwargs): https://bitbucket.org/galaxy/galaxy-central/commits/e9b02440691e/ Changeset: e9b02440691e User: dannon Date: 2015-02-10 19:42:02+00:00 Summary: Correctly use log.exception where appropriate in s3objectstore Affected #: 1 file diff -r 6ac0193e7fcdff4d4e928842c88661cff8ceec0f -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 lib/galaxy/objectstore/s3.py --- a/lib/galaxy/objectstore/s3.py +++ b/lib/galaxy/objectstore/s3.py @@ -223,8 +223,8 @@ key = self.bucket.get_key(rel_path) if key: return key.size - except S3ResponseError, ex: - log.error("Could not get size of key '%s' from S3: %s", rel_path, ex) + except S3ResponseError: + log.exception("Could not get size of key '%s' from S3", rel_path) return -1 def _key_exists(self, rel_path): @@ -241,8 +241,8 @@ else: key = Key(self.bucket, rel_path) exists = key.exists() - except S3ResponseError, ex: - log.error("Trouble checking existence of S3 key '%s': %s", rel_path, ex) + except S3ResponseError: + log.exception("Trouble checking existence of S3 key '%s'", rel_path) return False if rel_path[0] == '/': raise @@ -469,10 +469,10 @@ log.debug("Deleting key %s", key.name) key.delete() return True - except S3ResponseError, ex: - log.error("Could not delete key '%s' from S3: %s", rel_path, ex) - except OSError, ex: - log.error('%s delete error %s', self.get_filename(obj, **kwargs), ex) + except S3ResponseError: + log.exception("Could not delete key '%s' from S3", rel_path) + except OSError: + log.exception('%s delete error', self.get_filename(obj, **kwargs)) return False def get_data(self, obj, start=0, count=-1, **kwargs): @@ -532,8 +532,8 @@ # FIXME? Should this be a `move`? shutil.copy2(source_file, cache_file) self._fix_permissions(cache_file) - except OSError, ex: - log.error("Trouble copying source file '%s' to cache '%s': %s", source_file, cache_file, ex) + except OSError: + log.exception("Trouble copying source file '%s' to cache '%s'", source_file, cache_file) else: source_file = self._get_cache_path(rel_path) # Update the file on S3 https://bitbucket.org/galaxy/galaxy-central/commits/2f67cc204911/ Changeset: 2f67cc204911 User: dannon Date: 2015-02-10 19:42:26+00:00 Summary: Merge. Affected #: 20 files diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 client/galaxy/scripts/galaxy.base.js --- a/client/galaxy/scripts/galaxy.base.js +++ b/client/galaxy/scripts/galaxy.base.js @@ -207,33 +207,6 @@ }); } -// Alphanumeric/natural sort fn -function naturalSort(a, b) { - // setup temp-scope variables for comparison evauluation - var re = /(-?[0-9\.]+)/g, - x = a.toString().toLowerCase() || '', - y = b.toString().toLowerCase() || '', - nC = String.fromCharCode(0), - xN = x.replace( re, nC + '$1' + nC ).split(nC), - yN = y.replace( re, nC + '$1' + nC ).split(nC), - xD = (new Date(x)).getTime(), - yD = xD ? (new Date(y)).getTime() : null; - // natural sorting of dates - if ( yD ) { - if ( xD < yD ) { return -1; } - else if ( xD > yD ) { return 1; } - } - // natural sorting through split numeric strings and default strings - var oFxNcL, oFyNcL; - for ( var cLoc = 0, numS = Math.max(xN.length, yN.length); cLoc < numS; cLoc++ ) { - oFxNcL = parseFloat(xN[cLoc]) || xN[cLoc]; - oFyNcL = parseFloat(yN[cLoc]) || yN[cLoc]; - if (oFxNcL < oFyNcL) { return -1; } - else if (oFxNcL > oFyNcL) { return 1; } - } - return 0; -} - $.fn.refresh_select2 = function() { var select_elt = $(this); var options = { placeholder:'Click to select', diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 client/galaxy/scripts/mvc/collection/paired-collection-creator.js --- a/client/galaxy/scripts/mvc/collection/paired-collection-creator.js +++ b/client/galaxy/scripts/mvc/collection/paired-collection-creator.js @@ -1,8 +1,9 @@ define([ "utils/levenshtein", + "utils/natural-sort", "mvc/base-mvc", "utils/localization" -], function( levelshteinDistance, baseMVC, _l ){ +], function( levelshteinDistance, naturalSort, baseMVC, _l ){ /* ============================================================================ TODO: _adjPairedOnScrollBar @@ -236,14 +237,16 @@ _splitByFilters : function( filters ){ var fwd = [], rev = []; - this.unpaired.forEach( function( unpaired ){ + + function _addToFwdOrRev( unpaired ){ if( this._filterFwdFn( unpaired ) ){ fwd.push( unpaired ); } if( this._filterRevFn( unpaired ) ){ rev.push( unpaired ); } - }.bind( this ) ); + } + this.unpaired.forEach( _.bind( _addToFwdOrRev, this ) ); return [ fwd, rev ]; }, @@ -603,7 +606,7 @@ /** create the collection via the API * @returns {jQuery.xhr Object} the jquery ajax request */ - createList : function(){ + createList : function( name ){ var creator = this, url; if( creator.historyId ){ @@ -616,10 +619,11 @@ var ajaxData = { type : 'dataset_collection', collection_type : 'list:paired', - name : _.escape( creator.$( '.collection-name' ).val() ), + name : _.escape( name || creator.$( '.collection-name' ).val() ), element_identifiers : creator.paired.map( function( pair ){ return creator._pairToJSON( pair ); }) + }; //this.debug( JSON.stringify( ajaxData ) ); return jQuery.ajax( url, { @@ -1732,6 +1736,8 @@ //============================================================================= /** a modal version of the paired collection creator */ var pairedCollectionCreatorModal = function _pairedCollectionCreatorModal( datasets, options ){ + console.log( datasets ); + options = _.defaults( options || {}, { datasets : datasets, oncancel : function(){ Galaxy.modal.hide(); }, diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 client/galaxy/scripts/utils/natural-sort.js --- /dev/null +++ b/client/galaxy/scripts/utils/natural-sort.js @@ -0,0 +1,30 @@ +define([], function(){ +// Alphanumeric/natural sort fn +function naturalSort(a, b) { + // setup temp-scope variables for comparison evauluation + var re = /(-?[0-9\.]+)/g, + x = a.toString().toLowerCase() || '', + y = b.toString().toLowerCase() || '', + nC = String.fromCharCode(0), + xN = x.replace( re, nC + '$1' + nC ).split(nC), + yN = y.replace( re, nC + '$1' + nC ).split(nC), + xD = (new Date(x)).getTime(), + yD = xD ? (new Date(y)).getTime() : null; + // natural sorting of dates + if ( yD ) { + if ( xD < yD ) { return -1; } + else if ( xD > yD ) { return 1; } + } + // natural sorting through split numeric strings and default strings + var oFxNcL, oFyNcL; + for ( var cLoc = 0, numS = Math.max(xN.length, yN.length); cLoc < numS; cLoc++ ) { + oFxNcL = parseFloat(xN[cLoc]) || xN[cLoc]; + oFyNcL = parseFloat(yN[cLoc]) || yN[cLoc]; + if (oFxNcL < oFyNcL) { return -1; } + else if (oFxNcL > oFyNcL) { return 1; } + } + return 0; +} + +return naturalSort; +}) diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 lib/galaxy/config.py --- a/lib/galaxy/config.py +++ b/lib/galaxy/config.py @@ -19,7 +19,7 @@ from galaxy.util import string_as_bool from galaxy.util.dbkeys import GenomeBuilds from galaxy.web.formatting import expand_pretty_datetime_format - +from .version import VERSION_MAJOR log = logging.getLogger( __name__ ) @@ -63,6 +63,7 @@ # This is not a uwsgi process, or something went horribly wrong. pass + self.version_major = VERSION_MAJOR # Database related configuration self.database = resolve_path( kwargs.get( "database_file", "database/universe.sqlite" ), self.root ) self.database_connection = kwargs.get( "database_connection", False ) diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 lib/galaxy/util/pastescript/serve.py --- a/lib/galaxy/util/pastescript/serve.py +++ b/lib/galaxy/util/pastescript/serve.py @@ -559,11 +559,11 @@ if cmd == 'restart' or cmd == 'stop': result = self.stop_daemon() if result: - if cmd == 'restart': - print "Could not stop daemon; aborting" - else: - print "Could not stop daemon" - return result + print "Could not stop daemon" + # It's ok to continue trying to restart if stop_daemon returns + # a 1, otherwise shortcut and return. + if cmd == 'restart' and result != 1: + return result if cmd == 'stop': return result self.options.daemon = True diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 lib/galaxy/version.py --- /dev/null +++ b/lib/galaxy/version.py @@ -0,0 +1,1 @@ +VERSION_MAJOR = "15.03" diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 lib/galaxy/webapps/galaxy/api/configuration.py --- a/lib/galaxy/webapps/galaxy/api/configuration.py +++ b/lib/galaxy/webapps/galaxy/api/configuration.py @@ -31,6 +31,10 @@ serialization_params = self._parse_serialization_params( kwd, 'all' ) return self.get_config_dict( trans, is_admin, **serialization_params ) + @expose_api_anonymous + def version( self, trans, **kwds ): + return {"version_major": self.app.config.version_major } + def get_config_dict( self, trans, return_admin=False, view=None, keys=None, default_view='all' ): """ Return a dictionary with (a subset of) current Galaxy settings. @@ -97,6 +101,7 @@ 'nginx_upload_path' : _defaults_to( self.url_for( controller='api', action='tools' ) ), 'ftp_upload_dir' : _defaults_to( None ), 'ftp_upload_site' : _defaults_to( None ), + 'version_major' : _defaults_to( None ), } diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -222,6 +222,9 @@ webapp.mapper.resource_with_deleted( 'history', 'histories', path_prefix='/api' ) webapp.mapper.connect( '/api/histories/{history_id}/citations', action='citations', controller="histories" ) webapp.mapper.resource( 'configuration', 'configuration', path_prefix='/api' ) + webapp.mapper.connect( "configuration_version", + "/api/version", controller="configuration", + action="version", conditions=dict( method=[ "GET" ] ) ) webapp.mapper.resource( 'datatype', 'datatypes', path_prefix='/api', diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 static/scripts/galaxy.base.js --- a/static/scripts/galaxy.base.js +++ b/static/scripts/galaxy.base.js @@ -207,33 +207,6 @@ }); } -// Alphanumeric/natural sort fn -function naturalSort(a, b) { - // setup temp-scope variables for comparison evauluation - var re = /(-?[0-9\.]+)/g, - x = a.toString().toLowerCase() || '', - y = b.toString().toLowerCase() || '', - nC = String.fromCharCode(0), - xN = x.replace( re, nC + '$1' + nC ).split(nC), - yN = y.replace( re, nC + '$1' + nC ).split(nC), - xD = (new Date(x)).getTime(), - yD = xD ? (new Date(y)).getTime() : null; - // natural sorting of dates - if ( yD ) { - if ( xD < yD ) { return -1; } - else if ( xD > yD ) { return 1; } - } - // natural sorting through split numeric strings and default strings - var oFxNcL, oFyNcL; - for ( var cLoc = 0, numS = Math.max(xN.length, yN.length); cLoc < numS; cLoc++ ) { - oFxNcL = parseFloat(xN[cLoc]) || xN[cLoc]; - oFyNcL = parseFloat(yN[cLoc]) || yN[cLoc]; - if (oFxNcL < oFyNcL) { return -1; } - else if (oFxNcL > oFyNcL) { return 1; } - } - return 0; -} - $.fn.refresh_select2 = function() { var select_elt = $(this); var options = { placeholder:'Click to select', diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 static/scripts/mvc/collection/paired-collection-creator.js --- a/static/scripts/mvc/collection/paired-collection-creator.js +++ b/static/scripts/mvc/collection/paired-collection-creator.js @@ -1,8 +1,9 @@ define([ "utils/levenshtein", + "utils/natural-sort", "mvc/base-mvc", "utils/localization" -], function( levelshteinDistance, baseMVC, _l ){ +], function( levelshteinDistance, naturalSort, baseMVC, _l ){ /* ============================================================================ TODO: _adjPairedOnScrollBar @@ -236,14 +237,16 @@ _splitByFilters : function( filters ){ var fwd = [], rev = []; - this.unpaired.forEach( function( unpaired ){ + + function _addToFwdOrRev( unpaired ){ if( this._filterFwdFn( unpaired ) ){ fwd.push( unpaired ); } if( this._filterRevFn( unpaired ) ){ rev.push( unpaired ); } - }.bind( this ) ); + } + this.unpaired.forEach( _.bind( _addToFwdOrRev, this ) ); return [ fwd, rev ]; }, @@ -603,7 +606,7 @@ /** create the collection via the API * @returns {jQuery.xhr Object} the jquery ajax request */ - createList : function(){ + createList : function( name ){ var creator = this, url; if( creator.historyId ){ @@ -616,10 +619,11 @@ var ajaxData = { type : 'dataset_collection', collection_type : 'list:paired', - name : _.escape( creator.$( '.collection-name' ).val() ), + name : _.escape( name || creator.$( '.collection-name' ).val() ), element_identifiers : creator.paired.map( function( pair ){ return creator._pairToJSON( pair ); }) + }; //this.debug( JSON.stringify( ajaxData ) ); return jQuery.ajax( url, { @@ -1732,6 +1736,8 @@ //============================================================================= /** a modal version of the paired collection creator */ var pairedCollectionCreatorModal = function _pairedCollectionCreatorModal( datasets, options ){ + console.log( datasets ); + options = _.defaults( options || {}, { datasets : datasets, oncancel : function(){ Galaxy.modal.hide(); }, diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 static/scripts/packed/galaxy.base.js --- a/static/scripts/packed/galaxy.base.js +++ b/static/scripts/packed/galaxy.base.js @@ -1,1 +1,1 @@ -(function(){var b=0;var c=["ms","moz","webkit","o"];for(var a=0;a<c.length&&!window.requestAnimationFrame;++a){window.requestAnimationFrame=window[c[a]+"RequestAnimationFrame"];window.cancelRequestAnimationFrame=window[c[a]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame){window.requestAnimationFrame=function(h,e){var d=new Date().getTime();var f=Math.max(0,16-(d-b));var g=window.setTimeout(function(){h(d+f)},f);b=d+f;return g}}if(!window.cancelAnimationFrame){window.cancelAnimationFrame=function(d){clearTimeout(d)}}}());if(!Array.indexOf){Array.prototype.indexOf=function(c){for(var b=0,a=this.length;b<a;b++){if(this[b]==c){return b}}return -1}}function obj_length(c){if(c.length!==undefined){return c.length}var b=0;for(var a in c){b++}return b}$.fn.makeAbsolute=function(a){return this.each(function(){var b=$(this);var c=b.position();b.css({position:"absolute",marginLeft:0,marginTop:0,top:c.top,left:c.left,right:$(window).width()-(c.left+b.width())});if(a){b.remove().appendTo("body")}})};function make_popupmenu(b,c){var a=(b.data("menu_options"));b.data("menu_options",c);if(a){return}b.bind("click.show_popup",function(d){$(".popmenu-wrapper").remove();setTimeout(function(){var g=$("<ul class='dropdown-menu' id='"+b.attr("id")+"-menu'></ul>");var f=b.data("menu_options");if(obj_length(f)<=0){$("<li>No Options.</li>").appendTo(g)}$.each(f,function(j,i){if(i){var l=i.action||i;g.append($("<li></li>").append($("<a>").attr("href",i.url).html(j).click(l)))}else{g.append($("<li></li>").addClass("head").append($("<a href='#'></a>").html(j)))}});var h=$("<div class='popmenu-wrapper' style='position: absolute;left: 0; top: -1000;'></div>").append(g).appendTo("body");var e=d.pageX-h.width()/2;e=Math.min(e,$(document).scrollLeft()+$(window).width()-$(h).width()-5);e=Math.max(e,$(document).scrollLeft()+5);h.css({top:d.pageY,left:e})},10);setTimeout(function(){var f=function(h){$(h).bind("click.close_popup",function(){$(".popmenu-wrapper").remove();h.unbind("click.close_popup")})};f($(window.document));f($(window.top.document));for(var e=window.top.frames.length;e--;){var g=$(window.top.frames[e].document);f(g)}},50);return false})}function make_popup_menus(a){a=a||document;$(a).find("div[popupmenu]").each(function(){var b={};var d=$(this);d.find("a").each(function(){var g=$(this),i=g.get(0),e=i.getAttribute("confirm"),f=i.getAttribute("href"),h=i.getAttribute("target");if(!f){b[g.text()]=null}else{b[g.text()]={url:f,action:function(){if(!e||confirm(e)){if(h){window.open(f,h);return false}else{g.click()}}}}}});var c=$(a).find("#"+d.attr("popupmenu"));c.find("a").bind("click",function(f){f.stopPropagation();return true});make_popupmenu(c,b);c.addClass("popup");d.remove()})}function naturalSort(j,h){var p=/(-?[0-9\.]+)/g,k=j.toString().toLowerCase()||"",g=h.toString().toLowerCase()||"",l=String.fromCharCode(0),n=k.replace(p,l+"$1"+l).split(l),e=g.replace(p,l+"$1"+l).split(l),d=(new Date(k)).getTime(),o=d?(new Date(g)).getTime():null;if(o){if(d<o){return -1}else{if(d>o){return 1}}}var m,f;for(var i=0,c=Math.max(n.length,e.length);i<c;i++){m=parseFloat(n[i])||n[i];f=parseFloat(e[i])||e[i];if(m<f){return -1}else{if(m>f){return 1}}}return 0}$.fn.refresh_select2=function(){var b=$(this);var a={placeholder:"Click to select",closeOnSelect:!b.is("[MULTIPLE]"),dropdownAutoWidth:true,containerCssClass:"select2-minwidth"};return b.select2(a)};function replace_big_select_inputs(a,c,b){if(!jQuery.fn.select2){return}if(a===undefined){a=20}if(c===undefined){c=3000}b=b||$("select");b.each(function(){var e=$(this).not("[multiple]");var d=e.find("option").length;if((d<a)||(d>c)){return}if(e.hasClass("no-autocomplete")){return}e.refresh_select2()})}$.fn.make_text_editable=function(g){var d=("num_cols" in g?g.num_cols:30),c=("num_rows" in g?g.num_rows:4),e=("use_textarea" in g?g.use_textarea:false),b=("on_finish" in g?g.on_finish:null),f=("help_text" in g?g.help_text:null);var a=$(this);a.addClass("editable-text").click(function(l){if($(this).children(":input").length>0){return}a.removeClass("editable-text");var i=function(m){a.find(":input").remove();if(m!==""){a.text(m)}else{a.html("<br>")}a.addClass("editable-text");if(b){b(m)}};var h=("cur_text" in g?g.cur_text:a.text()),k,j;if(e){k=$("<textarea/>").attr({rows:c,cols:d}).text($.trim(h)).keyup(function(m){if(m.keyCode===27){i(h)}});j=$("<button/>").text("Done").click(function(){i(k.val());return false})}else{k=$("<input type='text'/>").attr({value:$.trim(h),size:d}).blur(function(){i(h)}).keyup(function(m){if(m.keyCode===27){$(this).trigger("blur")}else{if(m.keyCode===13){i($(this).val())}}m.stopPropagation()})}a.text("");a.append(k);if(j){a.append(j)}k.focus();k.select();l.stopPropagation()});if(f){a.attr("title",f).tooltip()}return a};function async_save_text(d,f,e,a,c,h,i,g,b){if(c===undefined){c=30}if(i===undefined){i=4}$("#"+d).click(function(){if($("#renaming-active").length>0){return}var l=$("#"+f),k=l.text(),j;if(h){j=$("<textarea></textarea>").attr({rows:i,cols:c}).text($.trim(k))}else{j=$("<input type='text'></input>").attr({value:$.trim(k),size:c})}j.attr("id","renaming-active");j.blur(function(){$(this).remove();l.show();if(b){b(j)}});j.keyup(function(n){if(n.keyCode===27){$(this).trigger("blur")}else{if(n.keyCode===13){var m={};m[a]=$(this).val();$(this).trigger("blur");$.ajax({url:e,data:m,error:function(){alert("Text editing for elt "+f+" failed")},success:function(o){if(o!==""){l.text(o)}else{l.html("<em>None</em>")}if(b){b(j)}}})}}});if(g){g(j)}l.hide();j.insertAfter(l);j.focus();j.select();return})}function commatize(b){b+="";var a=/(\d+)(\d{3})/;while(a.test(b)){b=b.replace(a,"$1,$2")}return b}function reset_tool_search(a){var c=$("#galaxy_tools").contents();if(c.length===0){c=$(document)}$(this).removeClass("search_active");c.find(".toolTitle").removeClass("search_match");c.find(".toolSectionBody").hide();c.find(".toolTitle").show();c.find(".toolPanelLabel").show();c.find(".toolSectionWrapper").each(function(){if($(this).attr("id")!=="recently_used_wrapper"){$(this).show()}else{if($(this).hasClass("user_pref_visible")){$(this).show()}}});c.find("#search-no-results").hide();c.find("#search-spinner").hide();if(a){var b=c.find("#tool-search-query");b.val("search tools")}}var GalaxyAsync=function(a){this.url_dict={};this.log_action=(a===undefined?false:a)};GalaxyAsync.prototype.set_func_url=function(a,b){this.url_dict[a]=b};GalaxyAsync.prototype.set_user_pref=function(a,b){var c=this.url_dict[arguments.callee];if(c===undefined){return false}$.ajax({url:c,data:{pref_name:a,pref_value:b},error:function(){return false},success:function(){return true}})};GalaxyAsync.prototype.log_user_action=function(c,b,d){if(!this.log_action){return}var a=this.url_dict[arguments.callee];if(a===undefined){return false}$.ajax({url:a,data:{action:c,context:b,params:d},error:function(){return false},success:function(){return true}})};function init_refresh_on_change(){$("select[refresh_on_change='true']").off("change").change(function(){var a=$(this),e=a.val(),d=false,c=a.attr("refresh_on_change_values");if(c){c=c.split(",");var b=a.attr("last_selected_value");if($.inArray(e,c)===-1&&$.inArray(b,c)===-1){return}}$(window).trigger("refresh_on_change");$(document).trigger("convert_to_values");a.get(0).form.submit()});$(":checkbox[refresh_on_change='true']").off("click").click(function(){var a=$(this),e=a.val(),d=false,c=a.attr("refresh_on_change_values");if(c){c=c.split(",");var b=a.attr("last_selected_value");if($.inArray(e,c)===-1&&$.inArray(b,c)===-1){return}}$(window).trigger("refresh_on_change");a.get(0).form.submit()});$("a[confirm]").off("click").click(function(){return confirm($(this).attr("confirm"))})}jQuery.fn.preventDoubleSubmission=function(){$(this).on("submit",function(b){var a=$(this);if(a.data("submitted")===true){b.preventDefault()}else{a.data("submitted",true)}});return this};$(document).ready(function(){init_refresh_on_change();if($.fn.tooltip){$(".unified-panel-header [title]").tooltip({placement:"bottom"});$("[title]").tooltip()}make_popup_menus();replace_big_select_inputs(20,1500);$("a").click(function(){var b=$(this);var c=(parent.frames&&parent.frames.galaxy_main);if((b.attr("target")=="galaxy_main")&&(!c)){var a=b.attr("href");if(a.indexOf("?")==-1){a+="?"}else{a+="&"}a+="use_panels=True";b.attr("href",a);b.attr("target","_self")}return b})}); \ No newline at end of file +(function(){var b=0;var c=["ms","moz","webkit","o"];for(var a=0;a<c.length&&!window.requestAnimationFrame;++a){window.requestAnimationFrame=window[c[a]+"RequestAnimationFrame"];window.cancelRequestAnimationFrame=window[c[a]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame){window.requestAnimationFrame=function(h,e){var d=new Date().getTime();var f=Math.max(0,16-(d-b));var g=window.setTimeout(function(){h(d+f)},f);b=d+f;return g}}if(!window.cancelAnimationFrame){window.cancelAnimationFrame=function(d){clearTimeout(d)}}}());if(!Array.indexOf){Array.prototype.indexOf=function(c){for(var b=0,a=this.length;b<a;b++){if(this[b]==c){return b}}return -1}}function obj_length(c){if(c.length!==undefined){return c.length}var b=0;for(var a in c){b++}return b}$.fn.makeAbsolute=function(a){return this.each(function(){var b=$(this);var c=b.position();b.css({position:"absolute",marginLeft:0,marginTop:0,top:c.top,left:c.left,right:$(window).width()-(c.left+b.width())});if(a){b.remove().appendTo("body")}})};function make_popupmenu(b,c){var a=(b.data("menu_options"));b.data("menu_options",c);if(a){return}b.bind("click.show_popup",function(d){$(".popmenu-wrapper").remove();setTimeout(function(){var g=$("<ul class='dropdown-menu' id='"+b.attr("id")+"-menu'></ul>");var f=b.data("menu_options");if(obj_length(f)<=0){$("<li>No Options.</li>").appendTo(g)}$.each(f,function(j,i){if(i){var l=i.action||i;g.append($("<li></li>").append($("<a>").attr("href",i.url).html(j).click(l)))}else{g.append($("<li></li>").addClass("head").append($("<a href='#'></a>").html(j)))}});var h=$("<div class='popmenu-wrapper' style='position: absolute;left: 0; top: -1000;'></div>").append(g).appendTo("body");var e=d.pageX-h.width()/2;e=Math.min(e,$(document).scrollLeft()+$(window).width()-$(h).width()-5);e=Math.max(e,$(document).scrollLeft()+5);h.css({top:d.pageY,left:e})},10);setTimeout(function(){var f=function(h){$(h).bind("click.close_popup",function(){$(".popmenu-wrapper").remove();h.unbind("click.close_popup")})};f($(window.document));f($(window.top.document));for(var e=window.top.frames.length;e--;){var g=$(window.top.frames[e].document);f(g)}},50);return false})}function make_popup_menus(a){a=a||document;$(a).find("div[popupmenu]").each(function(){var b={};var d=$(this);d.find("a").each(function(){var g=$(this),i=g.get(0),e=i.getAttribute("confirm"),f=i.getAttribute("href"),h=i.getAttribute("target");if(!f){b[g.text()]=null}else{b[g.text()]={url:f,action:function(){if(!e||confirm(e)){if(h){window.open(f,h);return false}else{g.click()}}}}}});var c=$(a).find("#"+d.attr("popupmenu"));c.find("a").bind("click",function(f){f.stopPropagation();return true});make_popupmenu(c,b);c.addClass("popup");d.remove()})}$.fn.refresh_select2=function(){var b=$(this);var a={placeholder:"Click to select",closeOnSelect:!b.is("[MULTIPLE]"),dropdownAutoWidth:true,containerCssClass:"select2-minwidth"};return b.select2(a)};function replace_big_select_inputs(a,c,b){if(!jQuery.fn.select2){return}if(a===undefined){a=20}if(c===undefined){c=3000}b=b||$("select");b.each(function(){var e=$(this).not("[multiple]");var d=e.find("option").length;if((d<a)||(d>c)){return}if(e.hasClass("no-autocomplete")){return}e.refresh_select2()})}$.fn.make_text_editable=function(g){var d=("num_cols" in g?g.num_cols:30),c=("num_rows" in g?g.num_rows:4),e=("use_textarea" in g?g.use_textarea:false),b=("on_finish" in g?g.on_finish:null),f=("help_text" in g?g.help_text:null);var a=$(this);a.addClass("editable-text").click(function(l){if($(this).children(":input").length>0){return}a.removeClass("editable-text");var i=function(m){a.find(":input").remove();if(m!==""){a.text(m)}else{a.html("<br>")}a.addClass("editable-text");if(b){b(m)}};var h=("cur_text" in g?g.cur_text:a.text()),k,j;if(e){k=$("<textarea/>").attr({rows:c,cols:d}).text($.trim(h)).keyup(function(m){if(m.keyCode===27){i(h)}});j=$("<button/>").text("Done").click(function(){i(k.val());return false})}else{k=$("<input type='text'/>").attr({value:$.trim(h),size:d}).blur(function(){i(h)}).keyup(function(m){if(m.keyCode===27){$(this).trigger("blur")}else{if(m.keyCode===13){i($(this).val())}}m.stopPropagation()})}a.text("");a.append(k);if(j){a.append(j)}k.focus();k.select();l.stopPropagation()});if(f){a.attr("title",f).tooltip()}return a};function async_save_text(d,f,e,a,c,h,i,g,b){if(c===undefined){c=30}if(i===undefined){i=4}$("#"+d).click(function(){if($("#renaming-active").length>0){return}var l=$("#"+f),k=l.text(),j;if(h){j=$("<textarea></textarea>").attr({rows:i,cols:c}).text($.trim(k))}else{j=$("<input type='text'></input>").attr({value:$.trim(k),size:c})}j.attr("id","renaming-active");j.blur(function(){$(this).remove();l.show();if(b){b(j)}});j.keyup(function(n){if(n.keyCode===27){$(this).trigger("blur")}else{if(n.keyCode===13){var m={};m[a]=$(this).val();$(this).trigger("blur");$.ajax({url:e,data:m,error:function(){alert("Text editing for elt "+f+" failed")},success:function(o){if(o!==""){l.text(o)}else{l.html("<em>None</em>")}if(b){b(j)}}})}}});if(g){g(j)}l.hide();j.insertAfter(l);j.focus();j.select();return})}function commatize(b){b+="";var a=/(\d+)(\d{3})/;while(a.test(b)){b=b.replace(a,"$1,$2")}return b}function reset_tool_search(a){var c=$("#galaxy_tools").contents();if(c.length===0){c=$(document)}$(this).removeClass("search_active");c.find(".toolTitle").removeClass("search_match");c.find(".toolSectionBody").hide();c.find(".toolTitle").show();c.find(".toolPanelLabel").show();c.find(".toolSectionWrapper").each(function(){if($(this).attr("id")!=="recently_used_wrapper"){$(this).show()}else{if($(this).hasClass("user_pref_visible")){$(this).show()}}});c.find("#search-no-results").hide();c.find("#search-spinner").hide();if(a){var b=c.find("#tool-search-query");b.val("search tools")}}var GalaxyAsync=function(a){this.url_dict={};this.log_action=(a===undefined?false:a)};GalaxyAsync.prototype.set_func_url=function(a,b){this.url_dict[a]=b};GalaxyAsync.prototype.set_user_pref=function(a,b){var c=this.url_dict[arguments.callee];if(c===undefined){return false}$.ajax({url:c,data:{pref_name:a,pref_value:b},error:function(){return false},success:function(){return true}})};GalaxyAsync.prototype.log_user_action=function(c,b,d){if(!this.log_action){return}var a=this.url_dict[arguments.callee];if(a===undefined){return false}$.ajax({url:a,data:{action:c,context:b,params:d},error:function(){return false},success:function(){return true}})};function init_refresh_on_change(){$("select[refresh_on_change='true']").off("change").change(function(){var a=$(this),e=a.val(),d=false,c=a.attr("refresh_on_change_values");if(c){c=c.split(",");var b=a.attr("last_selected_value");if($.inArray(e,c)===-1&&$.inArray(b,c)===-1){return}}$(window).trigger("refresh_on_change");$(document).trigger("convert_to_values");a.get(0).form.submit()});$(":checkbox[refresh_on_change='true']").off("click").click(function(){var a=$(this),e=a.val(),d=false,c=a.attr("refresh_on_change_values");if(c){c=c.split(",");var b=a.attr("last_selected_value");if($.inArray(e,c)===-1&&$.inArray(b,c)===-1){return}}$(window).trigger("refresh_on_change");a.get(0).form.submit()});$("a[confirm]").off("click").click(function(){return confirm($(this).attr("confirm"))})}jQuery.fn.preventDoubleSubmission=function(){$(this).on("submit",function(b){var a=$(this);if(a.data("submitted")===true){b.preventDefault()}else{a.data("submitted",true)}});return this};$(document).ready(function(){init_refresh_on_change();if($.fn.tooltip){$(".unified-panel-header [title]").tooltip({placement:"bottom"});$("[title]").tooltip()}make_popup_menus();replace_big_select_inputs(20,1500);$("a").click(function(){var b=$(this);var c=(parent.frames&&parent.frames.galaxy_main);if((b.attr("target")=="galaxy_main")&&(!c)){var a=b.attr("href");if(a.indexOf("?")==-1){a+="?"}else{a+="&"}a+="use_panels=True";b.attr("href",a);b.attr("target","_self")}return b})}); \ No newline at end of file diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 static/scripts/packed/mvc/collection/paired-collection-creator.js --- a/static/scripts/packed/mvc/collection/paired-collection-creator.js +++ b/static/scripts/packed/mvc/collection/paired-collection-creator.js @@ -1,1 +1,1 @@ -define(["utils/levenshtein","mvc/base-mvc","utils/localization"],function(g,a,d){var f=Backbone.View.extend(a.LoggableMixin).extend({tagName:"li",className:"dataset paired",initialize:function(h){this.pair=h.pair||{}},template:_.template(['<span class="forward-dataset-name flex-column"><%= pair.forward.name %></span>','<span class="pair-name-column flex-column">','<span class="pair-name"><%= pair.name %></span>',"</span>",'<span class="reverse-dataset-name flex-column"><%= pair.reverse.name %></span>'].join("")),render:function(){this.$el.attr("draggable",true).data("pair",this.pair).html(this.template({pair:this.pair})).addClass("flex-column-container");return this},events:{dragstart:"_dragstart",dragend:"_dragend",dragover:"_sendToParent",drop:"_sendToParent"},_dragstart:function(h){h.currentTarget.style.opacity="0.4";if(h.originalEvent){h=h.originalEvent}h.dataTransfer.effectAllowed="move";h.dataTransfer.setData("text/plain",JSON.stringify(this.pair));this.$el.parent().trigger("pair.dragstart",[this])},_dragend:function(h){h.currentTarget.style.opacity="1.0";this.$el.parent().trigger("pair.dragend",[this])},_sendToParent:function(h){this.$el.parent().trigger(h)},toString:function(){return"PairView("+this.pair.name+")"}});var e=Backbone.View.extend(a.LoggableMixin).extend({className:"collection-creator flex-row-container",initialize:function(h){h=_.defaults(h,{datasets:[],filters:this.DEFAULT_FILTERS,automaticallyPair:true,matchPercentage:1,strategy:"lcs"});this.initialList=h.datasets;this.historyId=h.historyId;this.filters=this.commonFilters[h.filters]||this.commonFilters[this.DEFAULT_FILTERS];if(_.isArray(h.filters)){this.filters=h.filters}this.automaticallyPair=h.automaticallyPair;this.matchPercentage=h.matchPercentage;this.strategy=this.strategies[h.strategy]||this.strategies[this.DEFAULT_STRATEGY];if(_.isFunction(h.strategy)){this.strategy=h.strategy}this.removeExtensions=true;this.oncancel=h.oncancel;this.oncreate=h.oncreate;this.autoscrollDist=h.autoscrollDist||24;this.unpairedPanelHidden=false;this.pairedPanelHidden=false;this.$dragging=null;this._setUpBehaviors();this._dataSetUp()},commonFilters:{none:["",""],illumina:["_1","_2"]},DEFAULT_FILTERS:"illumina",strategies:{lcs:"autoPairLCSs",levenshtein:"autoPairLevenshtein"},DEFAULT_STRATEGY:"lcs",_dataSetUp:function(){this.paired=[];this.unpaired=[];this.selectedIds=[];this._sortInitialList();this._ensureIds();this.unpaired=this.initialList.slice(0);if(this.automaticallyPair){this.autoPair();this.once("rendered:initial",function(){this.trigger("autopair")})}},_sortInitialList:function(){this._sortDatasetList(this.initialList)},_sortDatasetList:function(h){h.sort(function(j,i){return naturalSort(j.name,i.name)});return h},_ensureIds:function(){this.initialList.forEach(function(h){if(!h.hasOwnProperty("id")){h.id=_.uniqueId()}});return this.initialList},_splitByFilters:function(j){var i=[],h=[];this.unpaired.forEach(function(k){if(this._filterFwdFn(k)){i.push(k)}if(this._filterRevFn(k)){h.push(k)}}.bind(this));return[i,h]},_filterFwdFn:function(i){var h=new RegExp(this.filters[0]);return h.test(i.name)},_filterRevFn:function(i){var h=new RegExp(this.filters[1]);return h.test(i.name)},_addToUnpaired:function(i){var h=function(j,l){if(j===l){return j}var k=Math.floor((l-j)/2)+j,m=naturalSort(i.name,this.unpaired[k].name);if(m<0){return h(j,k)}else{if(m>0){return h(k+1,l)}}while(this.unpaired[k]&&this.unpaired[k].name===i.name){k++}return k}.bind(this);this.unpaired.splice(h(0,this.unpaired.length),0,i)},autoPair:function(i){i=i||this.strategy;var h=this.simpleAutoPair();h=h.concat(this[i].call(this));return h},simpleAutoPair:function(){var o=0,m,s=this._splitByFilters(),h=s[0],r=s[1],q,u,k=false,t=[];while(o<h.length){var n=h[o];q=n.name.replace(this.filters[0],"");k=false;for(m=0;m<r.length;m++){var p=r[m];u=p.name.replace(this.filters[1],"");if(n!==p&&q===u){k=true;var l=this._pair(h.splice(o,1)[0],r.splice(m,1)[0],{silent:true});t.push(l);break}}if(!k){o+=1}}return t},autoPairLevenshtein:function(){var p=0,n,u=this._splitByFilters(),h=u[0],s=u[1],r,x,k,t,l,v=[];while(p<h.length){var o=h[p];r=o.name.replace(this.filters[0],"");l=Number.MAX_VALUE;for(n=0;n<s.length;n++){var q=s[n];x=q.name.replace(this.filters[1],"");if(o!==q){if(r===x){t=n;l=0;break}k=levenshteinDistance(r,x);if(k<l){t=n;l=k}}}var w=1-(l/(Math.max(r.length,x.length)));if(w>=this.matchPercentage){var m=this._pair(h.splice(p,1)[0],s.splice(t,1)[0],{silent:true});v.push(m);if(h.length<=0||s.length<=0){return v}}else{p+=1}}return v},autoPairLCSs:function(){var n=0,l,u=this._splitByFilters(),h=u[0],s=u[1],r,y,x,t,p,v=[];if(!h.length||!s.length){return v}while(n<h.length){var m=h[n];r=m.name.replace(this.filters[0],"");p=0;for(l=0;l<s.length;l++){var q=s[l];y=q.name.replace(this.filters[1],"");if(m!==q){if(r===y){t=l;p=r.length;break}var o=this._naiveStartingAndEndingLCS(r,y);x=o.length;if(x>p){t=l;p=x}}}var w=p/(Math.min(r.length,y.length));if(w>=this.matchPercentage){var k=this._pair(h.splice(n,1)[0],s.splice(t,1)[0],{silent:true});v.push(k);if(h.length<=0||s.length<=0){return v}}else{n+=1}}return v},_naiveStartingAndEndingLCS:function(m,k){var n="",o="",l=0,h=0;while(l<m.length&&l<k.length){if(m[l]!==k[l]){break}n+=m[l];l+=1}if(l===m.length){return m}if(l===k.length){return k}l=(m.length-1);h=(k.length-1);while(l>=0&&h>=0){if(m[l]!==k[h]){break}o=[m[l],o].join("");l-=1;h-=1}return n+o},_pair:function(j,h,i){i=i||{};var k=this._createPair(j,h,i.name);this.paired.push(k);this.unpaired=_.without(this.unpaired,j,h);if(!i.silent){this.trigger("pair:new",k)}return k},_createPair:function(j,h,i){if(!(j&&h)||(j===h)){throw new Error("Bad pairing: "+[JSON.stringify(j),JSON.stringify(h)])}i=i||this._guessNameForPair(j,h);return{forward:j,name:i,reverse:h}},_guessNameForPair:function(j,h,k){k=(k!==undefined)?(k):(this.removeExtensions);var i=this._naiveStartingAndEndingLCS(j.name.replace(this.filters[0],""),h.name.replace(this.filters[1],""));if(k){var l=i.lastIndexOf(".");if(l>0){i=i.slice(0,l)}}return i||(j.name+" & "+h.name)},_unpair:function(i,h){h=h||{};if(!i){throw new Error("Bad pair: "+JSON.stringify(i))}this.paired=_.without(this.paired,i);this._addToUnpaired(i.forward);this._addToUnpaired(i.reverse);if(!h.silent){this.trigger("pair:unpair",[i])}return i},unpairAll:function(){var h=[];while(this.paired.length){h.push(this._unpair(this.paired[0],{silent:true}))}this.trigger("pair:unpair",h)},_pairToJSON:function(h){return{collection_type:"paired",src:"new_collection",name:h.name,element_identifiers:[{name:"forward",id:h.forward.id,src:"hda"},{name:"reverse",id:h.reverse.id,src:"hda"}]}},createList:function(){var j=this,i;if(j.historyId){i="/api/histories/"+this.historyId+"/contents/dataset_collections"}var h={type:"dataset_collection",collection_type:"list:paired",name:_.escape(j.$(".collection-name").val()),element_identifiers:j.paired.map(function(k){return j._pairToJSON(k)})};return jQuery.ajax(i,{type:"POST",contentType:"application/json",dataType:"json",data:JSON.stringify(h)}).fail(function(m,k,l){j._ajaxErrHandler(m,k,l)}).done(function(k,l,m){j.trigger("collection:created",k,l,m);if(typeof j.oncreate==="function"){j.oncreate.call(this,k,l,m)}})},_ajaxErrHandler:function(k,h,j){this.error(k,h,j);var i=d("An error occurred while creating this collection");if(k){if(k.readyState===0&&k.status===0){i+=": "+d("Galaxy could not be reached and may be updating.")+d(" Try again in a few minutes.")}else{if(k.responseJSON){i+="<br /><pre>"+JSON.stringify(k.responseJSON)+"</pre>"}else{i+=": "+j}}}creator._showAlert(i,"alert-danger")},render:function(h,i){this.$el.empty().html(e.templates.main());this._renderHeader(h);this._renderMiddle(h);this._renderFooter(h);this._addPluginComponents();this.trigger("rendered",this);return this},_renderHeader:function(i,j){var h=this.$(".header").empty().html(e.templates.header()).find(".help-content").prepend($(e.templates.helpContent()));this._renderFilters();return h},_renderFilters:function(){return this.$(".forward-column .column-header input").val(this.filters[0]).add(this.$(".reverse-column .column-header input").val(this.filters[1]))},_renderMiddle:function(i,j){var h=this.$(".middle").empty().html(e.templates.middle());if(this.unpairedPanelHidden){this.$(".unpaired-columns").hide()}else{if(this.pairedPanelHidden){this.$(".paired-columns").hide()}}this._renderUnpaired();this._renderPaired();return h},_renderUnpaired:function(m,n){var k=this,l,i,h=[],j=this._splitByFilters();this.$(".forward-column .title").text([j[0].length,d("unpaired forward")].join(" "));this.$(".forward-column .unpaired-info").text(this._renderUnpairedDisplayStr(this.unpaired.length-j[0].length));this.$(".reverse-column .title").text([j[1].length,d("unpaired reverse")].join(" "));this.$(".reverse-column .unpaired-info").text(this._renderUnpairedDisplayStr(this.unpaired.length-j[1].length));this.$(".unpaired-columns .column-datasets").empty();this.$(".autopair-link").toggle(this.unpaired.length!==0);if(this.unpaired.length===0){this._renderUnpairedEmpty();return}i=j[1].map(function(p,o){if((j[0][o]!==undefined)&&(j[0][o]!==p)){h.push(k._renderPairButton())}return k._renderUnpairedDataset(p)});l=j[0].map(function(o){return k._renderUnpairedDataset(o)});if(!l.length&&!i.length){this._renderUnpairedNotShown();return}this.$(".unpaired-columns .forward-column .column-datasets").append(l).add(this.$(".unpaired-columns .paired-column .column-datasets").append(h)).add(this.$(".unpaired-columns .reverse-column .column-datasets").append(i));this._adjUnpairedOnScrollbar()},_renderUnpairedDisplayStr:function(h){return["(",h," ",d("filtered out"),")"].join("")},_renderUnpairedDataset:function(h){return $("<li/>").attr("id","dataset-"+h.id).addClass("dataset unpaired").attr("draggable",true).addClass(h.selected?"selected":"").append($("<span/>").addClass("dataset-name").text(h.name)).data("dataset",h)},_renderPairButton:function(){return $("<li/>").addClass("dataset unpaired").append($("<span/>").addClass("dataset-name").text(d("Pair these datasets")))},_renderUnpairedEmpty:function(){var h=$('<div class="empty-message"></div>').text("("+d("no remaining unpaired datasets")+")");this.$(".unpaired-columns .paired-column .column-datasets").empty().prepend(h);return h},_renderUnpairedNotShown:function(){var h=$('<div class="empty-message"></div>').text("("+d("no datasets were found matching the current filters")+")");this.$(".unpaired-columns .paired-column .column-datasets").empty().prepend(h);return h},_adjUnpairedOnScrollbar:function(){var k=this.$(".unpaired-columns").last(),l=this.$(".unpaired-columns .reverse-column .dataset").first();if(!l.size()){return}var h=k.offset().left+k.outerWidth(),j=l.offset().left+l.outerWidth(),i=Math.floor(h)-Math.floor(j);this.$(".unpaired-columns .forward-column").css("margin-left",(i>0)?i:0)},_renderPaired:function(i,j){this.$(".paired-column-title .title").text([this.paired.length,d("paired")].join(" "));this.$(".unpair-all-link").toggle(this.paired.length!==0);if(this.paired.length===0){this._renderPairedEmpty();return}else{this.$(".remove-extensions-link").show()}this.$(".paired-columns .column-datasets").empty();var h=this;this.paired.forEach(function(m,k){var l=new f({pair:m});h.$(".paired-columns .column-datasets").append(l.render().$el).append(['<button class="unpair-btn">','<span class="fa fa-unlink" title="',d("Unpair"),'"></span>',"</button>"].join(""))})},_renderPairedEmpty:function(){var h=$('<div class="empty-message"></div>').text("("+d("no paired datasets yet")+")");this.$(".paired-columns .column-datasets").empty().prepend(h);return h},_renderFooter:function(i,j){var h=this.$(".footer").empty().html(e.templates.footer());this.$(".remove-extensions").prop("checked",this.removeExtensions);if(typeof this.oncancel==="function"){this.$(".cancel-create.btn").show()}return h},_addPluginComponents:function(){this._chooseFiltersPopover(".choose-filters-link");this.$(".help-content i").hoverhighlight(".collection-creator","rgba( 64, 255, 255, 1.0 )")},_chooseFiltersPopover:function(h){function i(l,k){return['<button class="filter-choice btn" ','data-forward="',l,'" data-reverse="',k,'">',d("Forward"),": ",l,", ",d("Reverse"),": ",k,"</button>"].join("")}var j=$(_.template(['<div class="choose-filters">','<div class="help">',d("Choose from the following filters to change which unpaired reads are shown in the display"),":</div>",i("_1","_2"),i("_R1","_R2"),"</div>"].join(""))({}));return this.$(h).popover({container:".collection-creator",placement:"bottom",html:true,content:j})},_validationWarning:function(i,h){var j="validation-warning";if(i==="name"){i=this.$(".collection-name").add(this.$(".collection-name-prompt"));this.$(".collection-name").focus().select()}if(h){i=i||this.$("."+j);i.removeClass(j)}else{i.addClass(j)}},_setUpBehaviors:function(){this.once("rendered",function(){this.trigger("rendered:initial",this)});this.on("pair:new",function(){this._renderUnpaired();this._renderPaired();this.$(".paired-columns").scrollTop(8000000)});this.on("pair:unpair",function(h){this._renderUnpaired();this._renderPaired();this.splitView()});this.on("filter-change",function(){this.filters=[this.$(".forward-unpaired-filter input").val(),this.$(".reverse-unpaired-filter input").val()];this._renderFilters();this._renderUnpaired()});this.on("autopair",function(){this._renderUnpaired();this._renderPaired();var h,i=null;if(this.paired.length){i="alert-success";h=this.paired.length+" "+d("pairs created");if(!this.unpaired.length){h+=": "+d("all datasets have been successfully paired");this.hideUnpaired();this.$(".collection-name").focus()}}else{h=d("Could not automatically create any pairs from the given dataset names")}this._showAlert(h,i)});return this},events:{"click .more-help":"_clickMoreHelp","click .less-help":"_clickLessHelp","click .header .alert button":"_hideAlert","click .forward-column .column-title":"_clickShowOnlyUnpaired","click .reverse-column .column-title":"_clickShowOnlyUnpaired","click .unpair-all-link":"_clickUnpairAll","change .forward-unpaired-filter input":function(h){this.trigger("filter-change")},"focus .forward-unpaired-filter input":function(h){$(h.currentTarget).select()},"click .autopair-link":"_clickAutopair","click .choose-filters .filter-choice":"_clickFilterChoice","click .clear-filters-link":"_clearFilters","change .reverse-unpaired-filter input":function(h){this.trigger("filter-change")},"focus .reverse-unpaired-filter input":function(h){$(h.currentTarget).select()},"click .forward-column .dataset.unpaired":"_clickUnpairedDataset","click .reverse-column .dataset.unpaired":"_clickUnpairedDataset","click .paired-column .dataset.unpaired":"_clickPairRow","click .unpaired-columns":"clearSelectedUnpaired","mousedown .unpaired-columns .dataset":"_mousedownUnpaired","click .paired-column-title":"_clickShowOnlyPaired","mousedown .flexible-partition-drag":"_startPartitionDrag","click .paired-columns .dataset.paired":"selectPair","click .paired-columns":"clearSelectedPaired","click .paired-columns .pair-name":"_clickPairName","click .unpair-btn":"_clickUnpair","dragover .paired-columns .column-datasets":"_dragoverPairedColumns","drop .paired-columns .column-datasets":"_dropPairedColumns","pair.dragstart .paired-columns .column-datasets":"_pairDragstart","pair.dragend .paired-columns .column-datasets":"_pairDragend","change .remove-extensions":function(h){this.toggleExtensions()},"change .collection-name":"_changeName","keydown .collection-name":"_nameCheckForEnter","click .cancel-create":function(h){if(typeof this.oncancel==="function"){this.oncancel.call(this)}},"click .create-collection":"_clickCreate"},_clickMoreHelp:function(h){this.$(".main-help").addClass("expanded");this.$(".more-help").hide()},_clickLessHelp:function(h){this.$(".main-help").removeClass("expanded");this.$(".more-help").show()},_showAlert:function(i,h){h=h||"alert-danger";this.$(".main-help").hide();this.$(".header .alert").attr("class","alert alert-dismissable").addClass(h).show().find(".alert-message").html(i)},_hideAlert:function(h){this.$(".main-help").show();this.$(".header .alert").hide()},_clickShowOnlyUnpaired:function(h){if(this.$(".paired-columns").is(":visible")){this.hidePaired()}else{this.splitView()}},_clickShowOnlyPaired:function(h){if(this.$(".unpaired-columns").is(":visible")){this.hideUnpaired()}else{this.splitView()}},hideUnpaired:function(h,i){this.unpairedPanelHidden=true;this.pairedPanelHidden=false;this._renderMiddle(h,i)},hidePaired:function(h,i){this.unpairedPanelHidden=false;this.pairedPanelHidden=true;this._renderMiddle(h,i)},splitView:function(h,i){this.unpairedPanelHidden=this.pairedPanelHidden=false;this._renderMiddle(h,i);return this},_clickUnpairAll:function(h){this.unpairAll()},_clickAutopair:function(h){this.autoPair();this.trigger("autopair")},_clickFilterChoice:function(i){var h=$(i.currentTarget);this.$(".forward-unpaired-filter input").val(h.data("forward"));this.$(".reverse-unpaired-filter input").val(h.data("reverse"));this._hideChooseFilters();this.trigger("filter-change")},_hideChooseFilters:function(){this.$(".choose-filters-link").popover("hide");this.$(".popover").css("display","none")},_clearFilters:function(h){this.$(".forward-unpaired-filter input").val("");this.$(".reverse-unpaired-filter input").val("");this.trigger("filter-change")},_clickUnpairedDataset:function(h){h.stopPropagation();return this.toggleSelectUnpaired($(h.currentTarget))},toggleSelectUnpaired:function(j,i){i=i||{};var k=j.data("dataset"),h=i.force!==undefined?i.force:!j.hasClass("selected");if(!j.size()||k===undefined){return j}if(h){j.addClass("selected");if(!i.waitToPair){this.pairAllSelected()}}else{j.removeClass("selected")}return j},pairAllSelected:function(i){i=i||{};var j=this,k=[],h=[],l=[];j.$(".unpaired-columns .forward-column .dataset.selected").each(function(){k.push($(this).data("dataset"))});j.$(".unpaired-columns .reverse-column .dataset.selected").each(function(){h.push($(this).data("dataset"))});k.length=h.length=Math.min(k.length,h.length);k.forEach(function(n,m){try{l.push(j._pair(n,h[m],{silent:true}))}catch(o){j.error(o)}});if(l.length&&!i.silent){this.trigger("pair:new",l)}return l},clearSelectedUnpaired:function(){this.$(".unpaired-columns .dataset.selected").removeClass("selected")},_mousedownUnpaired:function(j){if(j.shiftKey){var i=this,h=$(j.target).addClass("selected"),k=function(l){i.$(l.target).filter(".dataset").addClass("selected")};h.parent().on("mousemove",k);$(document).one("mouseup",function(l){h.parent().off("mousemove",k);i.pairAllSelected()})}},_clickPairRow:function(j){var k=$(j.currentTarget).index(),i=$(".unpaired-columns .forward-column .dataset").eq(k).data("dataset"),h=$(".unpaired-columns .reverse-column .dataset").eq(k).data("dataset");this._pair(i,h)},_startPartitionDrag:function(i){var h=this,l=i.pageY;$("body").css("cursor","ns-resize");h.$(".flexible-partition-drag").css("color","black");function k(m){h.$(".flexible-partition-drag").css("color","");$("body").css("cursor","").unbind("mousemove",j)}function j(m){var n=m.pageY-l;if(!h.adjPartition(n)){$("body").trigger("mouseup")}h._adjUnpairedOnScrollbar();l+=n}$("body").mousemove(j);$("body").one("mouseup",k)},adjPartition:function(i){var h=this.$(".unpaired-columns"),j=this.$(".paired-columns"),k=parseInt(h.css("height"),10),l=parseInt(j.css("height"),10);k=Math.max(10,k+i);l=l-i;var m=i<0;if(m){if(this.unpairedPanelHidden){return false}else{if(k<=10){this.hideUnpaired();return false}}}else{if(this.unpairedPanelHidden){h.show();this.unpairedPanelHidden=false}}if(!m){if(this.pairedPanelHidden){return false}else{if(l<=15){this.hidePaired();return false}}}else{if(this.pairedPanelHidden){j.show();this.pairedPanelHidden=false}}h.css({height:k+"px",flex:"0 0 auto"});return true},selectPair:function(h){h.stopPropagation();$(h.currentTarget).toggleClass("selected")},clearSelectedPaired:function(h){this.$(".paired-columns .dataset.selected").removeClass("selected")},_clickPairName:function(k){k.stopPropagation();var m=$(k.currentTarget),j=m.parent().parent(),i=j.index(".dataset.paired"),l=this.paired[i],h=prompt("Enter a new name for the pair:",l.name);if(h){l.name=h;l.customizedName=true;m.text(l.name)}},_clickUnpair:function(i){var h=Math.floor($(i.currentTarget).index(".unpair-btn"));this._unpair(this.paired[h])},_dragoverPairedColumns:function(k){k.preventDefault();var i=this.$(".paired-columns .column-datasets");this._checkForAutoscroll(i,k.originalEvent.clientY);var j=this._getNearestPairedDatasetLi(k.originalEvent.clientY);$(".paired-drop-placeholder").remove();var h=$('<div class="paired-drop-placeholder"></div>');if(!j.size()){i.append(h)}else{j.before(h)}},_checkForAutoscroll:function(h,n){var l=2;var m=h.offset(),k=h.scrollTop(),i=n-m.top,j=(m.top+h.outerHeight())-n;if(i>=0&&i<this.autoscrollDist){h.scrollTop(k-l)}else{if(j>=0&&j<this.autoscrollDist){h.scrollTop(k+l)}}},_getNearestPairedDatasetLi:function(o){var l=4,j=this.$(".paired-columns .column-datasets li").toArray();for(var k=0;k<j.length;k++){var n=$(j[k]),m=n.offset().top,h=Math.floor(n.outerHeight()/2)+l;if(m+h>o&&m-h<o){return n}}return $()},_dropPairedColumns:function(i){i.preventDefault();i.dataTransfer.dropEffect="move";var h=this._getNearestPairedDatasetLi(i.originalEvent.clientY);if(h.size()){this.$dragging.insertBefore(h)}else{this.$dragging.insertAfter(this.$(".paired-columns .unpair-btn").last())}this._syncPairsToDom();return false},_syncPairsToDom:function(){var h=[];this.$(".paired-columns .dataset.paired").each(function(){h.push($(this).data("pair"))});this.paired=h;this._renderPaired()},_pairDragstart:function(i,j){j.$el.addClass("selected");var h=this.$(".paired-columns .dataset.selected");this.$dragging=h},_pairDragend:function(h,i){$(".paired-drop-placeholder").remove();this.$dragging=null},toggleExtensions:function(i){var h=this;h.removeExtensions=(i!==undefined)?(i):(!h.removeExtensions);_.each(h.paired,function(j){if(j.customizedName){return}j.name=h._guessNameForPair(j.forward,j.reverse)});h._renderPaired();h._renderFooter()},_changeName:function(h){this._validationWarning("name",!!this._getName())},_nameCheckForEnter:function(h){if(h.keyCode===13){this._clickCreate()}},_getName:function(){return _.escape(this.$(".collection-name").val())},_clickCreate:function(i){var h=this._getName();if(!h){this._validationWarning("name")}else{this.createList()}},_printList:function(i){var h=this;_.each(i,function(j){if(i===h.paired){h._printPair(j)}else{}})},_printPair:function(h){this.debug(h.forward.name,h.reverse.name,": ->",h.name)},toString:function(){return"PairedCollectionCreator"}});e.templates=e.templates||{main:_.template(['<div class="header flex-row no-flex"></div>','<div class="middle flex-row flex-row-container"></div>','<div class="footer flex-row no-flex">'].join("")),header:_.template(['<div class="main-help well clear">','<a class="more-help" href="javascript:void(0);">',d("More help"),"</a>",'<div class="help-content">','<a class="less-help" href="javascript:void(0);">',d("Less"),"</a>","</div>","</div>",'<div class="alert alert-dismissable">','<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>','<span class="alert-message"></span>',"</div>",'<div class="column-headers vertically-spaced flex-column-container">','<div class="forward-column flex-column column">','<div class="column-header">','<div class="column-title">','<span class="title">',d("Unpaired forward"),"</span>",'<span class="title-info unpaired-info"></span>',"</div>",'<div class="unpaired-filter forward-unpaired-filter pull-left">','<input class="search-query" placeholder="',d("Filter this list"),'" />',"</div>","</div>","</div>",'<div class="paired-column flex-column no-flex column">','<div class="column-header">','<a class="choose-filters-link" href="javascript:void(0)">',d("Choose filters"),"</a>",'<a class="clear-filters-link" href="javascript:void(0);">',d("Clear filters"),"</a><br />",'<a class="autopair-link" href="javascript:void(0);">',d("Auto-pair"),"</a>","</div>","</div>",'<div class="reverse-column flex-column column">','<div class="column-header">','<div class="column-title">','<span class="title">',d("Unpaired reverse"),"</span>",'<span class="title-info unpaired-info"></span>',"</div>",'<div class="unpaired-filter reverse-unpaired-filter pull-left">','<input class="search-query" placeholder="',d("Filter this list"),'" />',"</div>","</div>","</div>","</div>"].join("")),middle:_.template(['<div class="unpaired-columns flex-column-container scroll-container flex-row">','<div class="forward-column flex-column column">','<ol class="column-datasets"></ol>',"</div>",'<div class="paired-column flex-column no-flex column">','<ol class="column-datasets"></ol>',"</div>",'<div class="reverse-column flex-column column">','<ol class="column-datasets"></ol>',"</div>","</div>",'<div class="flexible-partition">','<div class="flexible-partition-drag" title="',d("Drag to change"),'"></div>','<div class="column-header">','<div class="column-title paired-column-title">','<span class="title"></span>',"</div>",'<a class="unpair-all-link" href="javascript:void(0);">',d("Unpair all"),"</a>","</div>","</div>",'<div class="paired-columns flex-column-container scroll-container flex-row">','<ol class="column-datasets"></ol>',"</div>"].join("")),footer:_.template(['<div class="attributes clear">','<div class="clear">','<label class="remove-extensions-prompt pull-right">',d("Remove file extensions from pair names"),"?",'<input class="remove-extensions pull-right" type="checkbox" />',"</label>","</div>",'<div class="clear">','<input class="collection-name form-control pull-right" ','placeholder="',d("Enter a name for your new list"),'" />','<div class="collection-name-prompt pull-right">',d("Name"),":</div>","</div>","</div>",'<div class="actions clear vertically-spaced">','<div class="other-options pull-left">','<button class="cancel-create btn" tabindex="-1">',d("Cancel"),"</button>",'<div class="create-other btn-group dropup">','<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">',d("Create a different kind of collection"),' <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">','<li><a href="#">',d("Create a <i>single</i> pair"),"</a></li>",'<li><a href="#">',d("Create a list of <i>unpaired</i> datasets"),"</a></li>","</ul>","</div>","</div>",'<div class="main-options pull-right">','<button class="create-collection btn btn-primary">',d("Create list"),"</button>","</div>","</div>"].join("")),helpContent:_.template(["<p>",d(["Collections of paired datasets are ordered lists of dataset pairs (often forward and reverse reads). ","These collections can be passed to tools and workflows in order to have analyses done on each member of ","the entire group. This interface allows you to create a collection, choose which datasets are paired, ","and re-order the final collection."].join("")),"</p>","<p>",d(['Unpaired datasets are shown in the <i data-target=".unpaired-columns">unpaired section</i> ',"(hover over the underlined words to highlight below). ",'Paired datasets are shown in the <i data-target=".paired-columns">paired section</i>.',"<ul>To pair datasets, you can:","<li>Click a dataset in the ",'<i data-target=".unpaired-columns .forward-column .column-datasets,','.unpaired-columns .forward-column">forward column</i> ',"to select it then click a dataset in the ",'<i data-target=".unpaired-columns .reverse-column .column-datasets,','.unpaired-columns .reverse-column">reverse column</i>.',"</li>",'<li>Click one of the "Pair these datasets" buttons in the ','<i data-target=".unpaired-columns .paired-column .column-datasets,','.unpaired-columns .paired-column">middle column</i> ',"to pair the datasets in a particular row.","</li>",'<li>Click <i data-target=".autopair-link">"Auto-pair"</i> ',"to have your datasets automatically paired based on name.","</li>","</ul>"].join("")),"</p>","<p>",d(["<ul>You can filter what is shown in the unpaired sections by:","<li>Entering partial dataset names in either the ",'<i data-target=".forward-unpaired-filter input">forward filter</i> or ','<i data-target=".reverse-unpaired-filter input">reverse filter</i>.',"</li>","<li>Choosing from a list of preset filters by clicking the ",'<i data-target=".choose-filters-link">"Choose filters" link</i>.',"</li>","<li>Entering regular expressions to match dataset names. See: ",'<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expres..."',' target="_blank">MDN\'s JavaScript Regular Expression Tutorial</a>. ',"Note: forward slashes (\\) are not needed.","</li>","<li>Clearing the filters by clicking the ",'<i data-target=".clear-filters-link">"Clear filters" link</i>.',"</li>","</ul>"].join("")),"</p>","<p>",d(["To unpair individual dataset pairs, click the ",'<i data-target=".unpair-btn">unpair buttons ( <span class="fa fa-unlink"></span> )</i>. ','Click the <i data-target=".unpair-all-link">"Unpair all" link</i> to unpair all pairs.'].join("")),"</p>","<p>",d(['You can include or remove the file extensions (e.g. ".fastq") from your pair names by toggling the ','<i data-target=".remove-extensions-prompt">"Remove file extensions from pair names?"</i> control.'].join("")),"</p>","<p>",d(['Once your collection is complete, enter a <i data-target=".collection-name">name</i> and ','click <i data-target=".create-collection">"Create list"</i>. ',"(Note: you do not have to pair all unpaired datasets to finish.)"].join("")),"</p>"].join(""))};(function(){jQuery.fn.extend({hoverhighlight:function h(j,i){j=j||"body";if(!this.size()){return this}$(this).each(function(){var l=$(this),k=l.data("target");if(k){l.mouseover(function(m){$(k,j).css({background:i})}).mouseout(function(m){$(k).css({background:""})})}});return this}})}());var b=function c(j,h){h=_.defaults(h||{},{datasets:j,oncancel:function(){Galaxy.modal.hide()},oncreate:function(){Galaxy.modal.hide();Galaxy.currHistoryPanel.refreshContents()}});if(!window.Galaxy||!Galaxy.modal){throw new Error("Galaxy or Galaxy.modal not found")}var i=new e(h).render();Galaxy.modal.show({title:"Create a collection of paired datasets",body:i.$el,width:"80%",height:"800px",closing_events:true});window.PCC=i;return i};return{PairedCollectionCreator:e,pairedCollectionCreatorModal:b}}); \ No newline at end of file +define(["utils/levenshtein","utils/natural-sort","mvc/base-mvc","utils/localization"],function(h,g,a,d){var f=Backbone.View.extend(a.LoggableMixin).extend({tagName:"li",className:"dataset paired",initialize:function(i){this.pair=i.pair||{}},template:_.template(['<span class="forward-dataset-name flex-column"><%= pair.forward.name %></span>','<span class="pair-name-column flex-column">','<span class="pair-name"><%= pair.name %></span>',"</span>",'<span class="reverse-dataset-name flex-column"><%= pair.reverse.name %></span>'].join("")),render:function(){this.$el.attr("draggable",true).data("pair",this.pair).html(this.template({pair:this.pair})).addClass("flex-column-container");return this},events:{dragstart:"_dragstart",dragend:"_dragend",dragover:"_sendToParent",drop:"_sendToParent"},_dragstart:function(i){i.currentTarget.style.opacity="0.4";if(i.originalEvent){i=i.originalEvent}i.dataTransfer.effectAllowed="move";i.dataTransfer.setData("text/plain",JSON.stringify(this.pair));this.$el.parent().trigger("pair.dragstart",[this])},_dragend:function(i){i.currentTarget.style.opacity="1.0";this.$el.parent().trigger("pair.dragend",[this])},_sendToParent:function(i){this.$el.parent().trigger(i)},toString:function(){return"PairView("+this.pair.name+")"}});var e=Backbone.View.extend(a.LoggableMixin).extend({className:"collection-creator flex-row-container",initialize:function(i){i=_.defaults(i,{datasets:[],filters:this.DEFAULT_FILTERS,automaticallyPair:true,matchPercentage:1,strategy:"lcs"});this.initialList=i.datasets;this.historyId=i.historyId;this.filters=this.commonFilters[i.filters]||this.commonFilters[this.DEFAULT_FILTERS];if(_.isArray(i.filters)){this.filters=i.filters}this.automaticallyPair=i.automaticallyPair;this.matchPercentage=i.matchPercentage;this.strategy=this.strategies[i.strategy]||this.strategies[this.DEFAULT_STRATEGY];if(_.isFunction(i.strategy)){this.strategy=i.strategy}this.removeExtensions=true;this.oncancel=i.oncancel;this.oncreate=i.oncreate;this.autoscrollDist=i.autoscrollDist||24;this.unpairedPanelHidden=false;this.pairedPanelHidden=false;this.$dragging=null;this._setUpBehaviors();this._dataSetUp()},commonFilters:{none:["",""],illumina:["_1","_2"]},DEFAULT_FILTERS:"illumina",strategies:{lcs:"autoPairLCSs",levenshtein:"autoPairLevenshtein"},DEFAULT_STRATEGY:"lcs",_dataSetUp:function(){this.paired=[];this.unpaired=[];this.selectedIds=[];this._sortInitialList();this._ensureIds();this.unpaired=this.initialList.slice(0);if(this.automaticallyPair){this.autoPair();this.once("rendered:initial",function(){this.trigger("autopair")})}},_sortInitialList:function(){this._sortDatasetList(this.initialList)},_sortDatasetList:function(i){i.sort(function(k,j){return g(k.name,j.name)});return i},_ensureIds:function(){this.initialList.forEach(function(i){if(!i.hasOwnProperty("id")){i.id=_.uniqueId()}});return this.initialList},_splitByFilters:function(l){var k=[],i=[];function j(m){if(this._filterFwdFn(m)){k.push(m)}if(this._filterRevFn(m)){i.push(m)}}this.unpaired.forEach(_.bind(j,this));return[k,i]},_filterFwdFn:function(j){var i=new RegExp(this.filters[0]);return i.test(j.name)},_filterRevFn:function(j){var i=new RegExp(this.filters[1]);return i.test(j.name)},_addToUnpaired:function(j){var i=function(k,m){if(k===m){return k}var l=Math.floor((m-k)/2)+k,n=g(j.name,this.unpaired[l].name);if(n<0){return i(k,l)}else{if(n>0){return i(l+1,m)}}while(this.unpaired[l]&&this.unpaired[l].name===j.name){l++}return l}.bind(this);this.unpaired.splice(i(0,this.unpaired.length),0,j)},autoPair:function(j){j=j||this.strategy;var i=this.simpleAutoPair();i=i.concat(this[j].call(this));return i},simpleAutoPair:function(){var p=0,n,t=this._splitByFilters(),k=t[0],s=t[1],r,v,l=false,u=[];while(p<k.length){var o=k[p];r=o.name.replace(this.filters[0],"");l=false;for(n=0;n<s.length;n++){var q=s[n];v=q.name.replace(this.filters[1],"");if(o!==q&&r===v){l=true;var m=this._pair(k.splice(p,1)[0],s.splice(n,1)[0],{silent:true});u.push(m);break}}if(!l){p+=1}}return u},autoPairLevenshtein:function(){var q=0,o,v=this._splitByFilters(),k=v[0],t=v[1],s,y,l,u,m,w=[];while(q<k.length){var p=k[q];s=p.name.replace(this.filters[0],"");m=Number.MAX_VALUE;for(o=0;o<t.length;o++){var r=t[o];y=r.name.replace(this.filters[1],"");if(p!==r){if(s===y){u=o;m=0;break}l=levenshteinDistance(s,y);if(l<m){u=o;m=l}}}var x=1-(m/(Math.max(s.length,y.length)));if(x>=this.matchPercentage){var n=this._pair(k.splice(q,1)[0],t.splice(u,1)[0],{silent:true});w.push(n);if(k.length<=0||t.length<=0){return w}}else{q+=1}}return w},autoPairLCSs:function(){var o=0,m,v=this._splitByFilters(),k=v[0],t=v[1],s,z,y,u,q,w=[];if(!k.length||!t.length){return w}while(o<k.length){var n=k[o];s=n.name.replace(this.filters[0],"");q=0;for(m=0;m<t.length;m++){var r=t[m];z=r.name.replace(this.filters[1],"");if(n!==r){if(s===z){u=m;q=s.length;break}var p=this._naiveStartingAndEndingLCS(s,z);y=p.length;if(y>q){u=m;q=y}}}var x=q/(Math.min(s.length,z.length));if(x>=this.matchPercentage){var l=this._pair(k.splice(o,1)[0],t.splice(u,1)[0],{silent:true});w.push(l);if(k.length<=0||t.length<=0){return w}}else{o+=1}}return w},_naiveStartingAndEndingLCS:function(n,l){var o="",p="",m=0,k=0;while(m<n.length&&m<l.length){if(n[m]!==l[m]){break}o+=n[m];m+=1}if(m===n.length){return n}if(m===l.length){return l}m=(n.length-1);k=(l.length-1);while(m>=0&&k>=0){if(n[m]!==l[k]){break}p=[n[m],p].join("");m-=1;k-=1}return o+p},_pair:function(k,i,j){j=j||{};var l=this._createPair(k,i,j.name);this.paired.push(l);this.unpaired=_.without(this.unpaired,k,i);if(!j.silent){this.trigger("pair:new",l)}return l},_createPair:function(k,i,j){if(!(k&&i)||(k===i)){throw new Error("Bad pairing: "+[JSON.stringify(k),JSON.stringify(i)])}j=j||this._guessNameForPair(k,i);return{forward:k,name:j,reverse:i}},_guessNameForPair:function(k,i,l){l=(l!==undefined)?(l):(this.removeExtensions);var j=this._naiveStartingAndEndingLCS(k.name.replace(this.filters[0],""),i.name.replace(this.filters[1],""));if(l){var m=j.lastIndexOf(".");if(m>0){j=j.slice(0,m)}}return j||(k.name+" & "+i.name)},_unpair:function(j,i){i=i||{};if(!j){throw new Error("Bad pair: "+JSON.stringify(j))}this.paired=_.without(this.paired,j);this._addToUnpaired(j.forward);this._addToUnpaired(j.reverse);if(!i.silent){this.trigger("pair:unpair",[j])}return j},unpairAll:function(){var i=[];while(this.paired.length){i.push(this._unpair(this.paired[0],{silent:true}))}this.trigger("pair:unpair",i)},_pairToJSON:function(i){return{collection_type:"paired",src:"new_collection",name:i.name,element_identifiers:[{name:"forward",id:i.forward.id,src:"hda"},{name:"reverse",id:i.reverse.id,src:"hda"}]}},createList:function(k){var l=this,j;if(l.historyId){j="/api/histories/"+this.historyId+"/contents/dataset_collections"}var i={type:"dataset_collection",collection_type:"list:paired",name:_.escape(k||l.$(".collection-name").val()),element_identifiers:l.paired.map(function(m){return l._pairToJSON(m)})};return jQuery.ajax(j,{type:"POST",contentType:"application/json",dataType:"json",data:JSON.stringify(i)}).fail(function(o,m,n){l._ajaxErrHandler(o,m,n)}).done(function(m,n,o){l.trigger("collection:created",m,n,o);if(typeof l.oncreate==="function"){l.oncreate.call(this,m,n,o)}})},_ajaxErrHandler:function(l,i,k){this.error(l,i,k);var j=d("An error occurred while creating this collection");if(l){if(l.readyState===0&&l.status===0){j+=": "+d("Galaxy could not be reached and may be updating.")+d(" Try again in a few minutes.")}else{if(l.responseJSON){j+="<br /><pre>"+JSON.stringify(l.responseJSON)+"</pre>"}else{j+=": "+k}}}creator._showAlert(j,"alert-danger")},render:function(i,j){this.$el.empty().html(e.templates.main());this._renderHeader(i);this._renderMiddle(i);this._renderFooter(i);this._addPluginComponents();this.trigger("rendered",this);return this},_renderHeader:function(j,k){var i=this.$(".header").empty().html(e.templates.header()).find(".help-content").prepend($(e.templates.helpContent()));this._renderFilters();return i},_renderFilters:function(){return this.$(".forward-column .column-header input").val(this.filters[0]).add(this.$(".reverse-column .column-header input").val(this.filters[1]))},_renderMiddle:function(j,k){var i=this.$(".middle").empty().html(e.templates.middle());if(this.unpairedPanelHidden){this.$(".unpaired-columns").hide()}else{if(this.pairedPanelHidden){this.$(".paired-columns").hide()}}this._renderUnpaired();this._renderPaired();return i},_renderUnpaired:function(n,o){var l=this,m,j,i=[],k=this._splitByFilters();this.$(".forward-column .title").text([k[0].length,d("unpaired forward")].join(" "));this.$(".forward-column .unpaired-info").text(this._renderUnpairedDisplayStr(this.unpaired.length-k[0].length));this.$(".reverse-column .title").text([k[1].length,d("unpaired reverse")].join(" "));this.$(".reverse-column .unpaired-info").text(this._renderUnpairedDisplayStr(this.unpaired.length-k[1].length));this.$(".unpaired-columns .column-datasets").empty();this.$(".autopair-link").toggle(this.unpaired.length!==0);if(this.unpaired.length===0){this._renderUnpairedEmpty();return}j=k[1].map(function(q,p){if((k[0][p]!==undefined)&&(k[0][p]!==q)){i.push(l._renderPairButton())}return l._renderUnpairedDataset(q)});m=k[0].map(function(p){return l._renderUnpairedDataset(p)});if(!m.length&&!j.length){this._renderUnpairedNotShown();return}this.$(".unpaired-columns .forward-column .column-datasets").append(m).add(this.$(".unpaired-columns .paired-column .column-datasets").append(i)).add(this.$(".unpaired-columns .reverse-column .column-datasets").append(j));this._adjUnpairedOnScrollbar()},_renderUnpairedDisplayStr:function(i){return["(",i," ",d("filtered out"),")"].join("")},_renderUnpairedDataset:function(i){return $("<li/>").attr("id","dataset-"+i.id).addClass("dataset unpaired").attr("draggable",true).addClass(i.selected?"selected":"").append($("<span/>").addClass("dataset-name").text(i.name)).data("dataset",i)},_renderPairButton:function(){return $("<li/>").addClass("dataset unpaired").append($("<span/>").addClass("dataset-name").text(d("Pair these datasets")))},_renderUnpairedEmpty:function(){var i=$('<div class="empty-message"></div>').text("("+d("no remaining unpaired datasets")+")");this.$(".unpaired-columns .paired-column .column-datasets").empty().prepend(i);return i},_renderUnpairedNotShown:function(){var i=$('<div class="empty-message"></div>').text("("+d("no datasets were found matching the current filters")+")");this.$(".unpaired-columns .paired-column .column-datasets").empty().prepend(i);return i},_adjUnpairedOnScrollbar:function(){var l=this.$(".unpaired-columns").last(),m=this.$(".unpaired-columns .reverse-column .dataset").first();if(!m.size()){return}var i=l.offset().left+l.outerWidth(),k=m.offset().left+m.outerWidth(),j=Math.floor(i)-Math.floor(k);this.$(".unpaired-columns .forward-column").css("margin-left",(j>0)?j:0)},_renderPaired:function(j,k){this.$(".paired-column-title .title").text([this.paired.length,d("paired")].join(" "));this.$(".unpair-all-link").toggle(this.paired.length!==0);if(this.paired.length===0){this._renderPairedEmpty();return}else{this.$(".remove-extensions-link").show()}this.$(".paired-columns .column-datasets").empty();var i=this;this.paired.forEach(function(n,l){var m=new f({pair:n});i.$(".paired-columns .column-datasets").append(m.render().$el).append(['<button class="unpair-btn">','<span class="fa fa-unlink" title="',d("Unpair"),'"></span>',"</button>"].join(""))})},_renderPairedEmpty:function(){var i=$('<div class="empty-message"></div>').text("("+d("no paired datasets yet")+")");this.$(".paired-columns .column-datasets").empty().prepend(i);return i},_renderFooter:function(j,k){var i=this.$(".footer").empty().html(e.templates.footer());this.$(".remove-extensions").prop("checked",this.removeExtensions);if(typeof this.oncancel==="function"){this.$(".cancel-create.btn").show()}return i},_addPluginComponents:function(){this._chooseFiltersPopover(".choose-filters-link");this.$(".help-content i").hoverhighlight(".collection-creator","rgba( 64, 255, 255, 1.0 )")},_chooseFiltersPopover:function(i){function j(m,l){return['<button class="filter-choice btn" ','data-forward="',m,'" data-reverse="',l,'">',d("Forward"),": ",m,", ",d("Reverse"),": ",l,"</button>"].join("")}var k=$(_.template(['<div class="choose-filters">','<div class="help">',d("Choose from the following filters to change which unpaired reads are shown in the display"),":</div>",j("_1","_2"),j("_R1","_R2"),"</div>"].join(""))({}));return this.$(i).popover({container:".collection-creator",placement:"bottom",html:true,content:k})},_validationWarning:function(j,i){var k="validation-warning";if(j==="name"){j=this.$(".collection-name").add(this.$(".collection-name-prompt"));this.$(".collection-name").focus().select()}if(i){j=j||this.$("."+k);j.removeClass(k)}else{j.addClass(k)}},_setUpBehaviors:function(){this.once("rendered",function(){this.trigger("rendered:initial",this)});this.on("pair:new",function(){this._renderUnpaired();this._renderPaired();this.$(".paired-columns").scrollTop(8000000)});this.on("pair:unpair",function(i){this._renderUnpaired();this._renderPaired();this.splitView()});this.on("filter-change",function(){this.filters=[this.$(".forward-unpaired-filter input").val(),this.$(".reverse-unpaired-filter input").val()];this._renderFilters();this._renderUnpaired()});this.on("autopair",function(){this._renderUnpaired();this._renderPaired();var i,j=null;if(this.paired.length){j="alert-success";i=this.paired.length+" "+d("pairs created");if(!this.unpaired.length){i+=": "+d("all datasets have been successfully paired");this.hideUnpaired();this.$(".collection-name").focus()}}else{i=d("Could not automatically create any pairs from the given dataset names")}this._showAlert(i,j)});return this},events:{"click .more-help":"_clickMoreHelp","click .less-help":"_clickLessHelp","click .header .alert button":"_hideAlert","click .forward-column .column-title":"_clickShowOnlyUnpaired","click .reverse-column .column-title":"_clickShowOnlyUnpaired","click .unpair-all-link":"_clickUnpairAll","change .forward-unpaired-filter input":function(i){this.trigger("filter-change")},"focus .forward-unpaired-filter input":function(i){$(i.currentTarget).select()},"click .autopair-link":"_clickAutopair","click .choose-filters .filter-choice":"_clickFilterChoice","click .clear-filters-link":"_clearFilters","change .reverse-unpaired-filter input":function(i){this.trigger("filter-change")},"focus .reverse-unpaired-filter input":function(i){$(i.currentTarget).select()},"click .forward-column .dataset.unpaired":"_clickUnpairedDataset","click .reverse-column .dataset.unpaired":"_clickUnpairedDataset","click .paired-column .dataset.unpaired":"_clickPairRow","click .unpaired-columns":"clearSelectedUnpaired","mousedown .unpaired-columns .dataset":"_mousedownUnpaired","click .paired-column-title":"_clickShowOnlyPaired","mousedown .flexible-partition-drag":"_startPartitionDrag","click .paired-columns .dataset.paired":"selectPair","click .paired-columns":"clearSelectedPaired","click .paired-columns .pair-name":"_clickPairName","click .unpair-btn":"_clickUnpair","dragover .paired-columns .column-datasets":"_dragoverPairedColumns","drop .paired-columns .column-datasets":"_dropPairedColumns","pair.dragstart .paired-columns .column-datasets":"_pairDragstart","pair.dragend .paired-columns .column-datasets":"_pairDragend","change .remove-extensions":function(i){this.toggleExtensions()},"change .collection-name":"_changeName","keydown .collection-name":"_nameCheckForEnter","click .cancel-create":function(i){if(typeof this.oncancel==="function"){this.oncancel.call(this)}},"click .create-collection":"_clickCreate"},_clickMoreHelp:function(i){this.$(".main-help").addClass("expanded");this.$(".more-help").hide()},_clickLessHelp:function(i){this.$(".main-help").removeClass("expanded");this.$(".more-help").show()},_showAlert:function(j,i){i=i||"alert-danger";this.$(".main-help").hide();this.$(".header .alert").attr("class","alert alert-dismissable").addClass(i).show().find(".alert-message").html(j)},_hideAlert:function(i){this.$(".main-help").show();this.$(".header .alert").hide()},_clickShowOnlyUnpaired:function(i){if(this.$(".paired-columns").is(":visible")){this.hidePaired()}else{this.splitView()}},_clickShowOnlyPaired:function(i){if(this.$(".unpaired-columns").is(":visible")){this.hideUnpaired()}else{this.splitView()}},hideUnpaired:function(i,j){this.unpairedPanelHidden=true;this.pairedPanelHidden=false;this._renderMiddle(i,j)},hidePaired:function(i,j){this.unpairedPanelHidden=false;this.pairedPanelHidden=true;this._renderMiddle(i,j)},splitView:function(i,j){this.unpairedPanelHidden=this.pairedPanelHidden=false;this._renderMiddle(i,j);return this},_clickUnpairAll:function(i){this.unpairAll()},_clickAutopair:function(i){this.autoPair();this.trigger("autopair")},_clickFilterChoice:function(j){var i=$(j.currentTarget);this.$(".forward-unpaired-filter input").val(i.data("forward"));this.$(".reverse-unpaired-filter input").val(i.data("reverse"));this._hideChooseFilters();this.trigger("filter-change")},_hideChooseFilters:function(){this.$(".choose-filters-link").popover("hide");this.$(".popover").css("display","none")},_clearFilters:function(i){this.$(".forward-unpaired-filter input").val("");this.$(".reverse-unpaired-filter input").val("");this.trigger("filter-change")},_clickUnpairedDataset:function(i){i.stopPropagation();return this.toggleSelectUnpaired($(i.currentTarget))},toggleSelectUnpaired:function(k,j){j=j||{};var l=k.data("dataset"),i=j.force!==undefined?j.force:!k.hasClass("selected");if(!k.size()||l===undefined){return k}if(i){k.addClass("selected");if(!j.waitToPair){this.pairAllSelected()}}else{k.removeClass("selected")}return k},pairAllSelected:function(j){j=j||{};var k=this,l=[],i=[],m=[];k.$(".unpaired-columns .forward-column .dataset.selected").each(function(){l.push($(this).data("dataset"))});k.$(".unpaired-columns .reverse-column .dataset.selected").each(function(){i.push($(this).data("dataset"))});l.length=i.length=Math.min(l.length,i.length);l.forEach(function(o,n){try{m.push(k._pair(o,i[n],{silent:true}))}catch(p){k.error(p)}});if(m.length&&!j.silent){this.trigger("pair:new",m)}return m},clearSelectedUnpaired:function(){this.$(".unpaired-columns .dataset.selected").removeClass("selected")},_mousedownUnpaired:function(k){if(k.shiftKey){var j=this,i=$(k.target).addClass("selected"),l=function(m){j.$(m.target).filter(".dataset").addClass("selected")};i.parent().on("mousemove",l);$(document).one("mouseup",function(m){i.parent().off("mousemove",l);j.pairAllSelected()})}},_clickPairRow:function(k){var l=$(k.currentTarget).index(),j=$(".unpaired-columns .forward-column .dataset").eq(l).data("dataset"),i=$(".unpaired-columns .reverse-column .dataset").eq(l).data("dataset");this._pair(j,i)},_startPartitionDrag:function(j){var i=this,m=j.pageY;$("body").css("cursor","ns-resize");i.$(".flexible-partition-drag").css("color","black");function l(n){i.$(".flexible-partition-drag").css("color","");$("body").css("cursor","").unbind("mousemove",k)}function k(n){var o=n.pageY-m;if(!i.adjPartition(o)){$("body").trigger("mouseup")}i._adjUnpairedOnScrollbar();m+=o}$("body").mousemove(k);$("body").one("mouseup",l)},adjPartition:function(j){var i=this.$(".unpaired-columns"),k=this.$(".paired-columns"),l=parseInt(i.css("height"),10),m=parseInt(k.css("height"),10);l=Math.max(10,l+j);m=m-j;var n=j<0;if(n){if(this.unpairedPanelHidden){return false}else{if(l<=10){this.hideUnpaired();return false}}}else{if(this.unpairedPanelHidden){i.show();this.unpairedPanelHidden=false}}if(!n){if(this.pairedPanelHidden){return false}else{if(m<=15){this.hidePaired();return false}}}else{if(this.pairedPanelHidden){k.show();this.pairedPanelHidden=false}}i.css({height:l+"px",flex:"0 0 auto"});return true},selectPair:function(i){i.stopPropagation();$(i.currentTarget).toggleClass("selected")},clearSelectedPaired:function(i){this.$(".paired-columns .dataset.selected").removeClass("selected")},_clickPairName:function(l){l.stopPropagation();var n=$(l.currentTarget),k=n.parent().parent(),j=k.index(".dataset.paired"),m=this.paired[j],i=prompt("Enter a new name for the pair:",m.name);if(i){m.name=i;m.customizedName=true;n.text(m.name)}},_clickUnpair:function(j){var i=Math.floor($(j.currentTarget).index(".unpair-btn"));this._unpair(this.paired[i])},_dragoverPairedColumns:function(l){l.preventDefault();var j=this.$(".paired-columns .column-datasets");this._checkForAutoscroll(j,l.originalEvent.clientY);var k=this._getNearestPairedDatasetLi(l.originalEvent.clientY);$(".paired-drop-placeholder").remove();var i=$('<div class="paired-drop-placeholder"></div>');if(!k.size()){j.append(i)}else{k.before(i)}},_checkForAutoscroll:function(i,o){var m=2;var n=i.offset(),l=i.scrollTop(),j=o-n.top,k=(n.top+i.outerHeight())-o;if(j>=0&&j<this.autoscrollDist){i.scrollTop(l-m)}else{if(k>=0&&k<this.autoscrollDist){i.scrollTop(l+m)}}},_getNearestPairedDatasetLi:function(p){var m=4,k=this.$(".paired-columns .column-datasets li").toArray();for(var l=0;l<k.length;l++){var o=$(k[l]),n=o.offset().top,j=Math.floor(o.outerHeight()/2)+m;if(n+j>p&&n-j<p){return o}}return $()},_dropPairedColumns:function(j){j.preventDefault();j.dataTransfer.dropEffect="move";var i=this._getNearestPairedDatasetLi(j.originalEvent.clientY);if(i.size()){this.$dragging.insertBefore(i)}else{this.$dragging.insertAfter(this.$(".paired-columns .unpair-btn").last())}this._syncPairsToDom();return false},_syncPairsToDom:function(){var i=[];this.$(".paired-columns .dataset.paired").each(function(){i.push($(this).data("pair"))});this.paired=i;this._renderPaired()},_pairDragstart:function(j,k){k.$el.addClass("selected");var i=this.$(".paired-columns .dataset.selected");this.$dragging=i},_pairDragend:function(i,j){$(".paired-drop-placeholder").remove();this.$dragging=null},toggleExtensions:function(j){var i=this;i.removeExtensions=(j!==undefined)?(j):(!i.removeExtensions);_.each(i.paired,function(k){if(k.customizedName){return}k.name=i._guessNameForPair(k.forward,k.reverse)});i._renderPaired();i._renderFooter()},_changeName:function(i){this._validationWarning("name",!!this._getName())},_nameCheckForEnter:function(i){if(i.keyCode===13){this._clickCreate()}},_getName:function(){return _.escape(this.$(".collection-name").val())},_clickCreate:function(j){var i=this._getName();if(!i){this._validationWarning("name")}else{this.createList()}},_printList:function(j){var i=this;_.each(j,function(k){if(j===i.paired){i._printPair(k)}else{}})},_printPair:function(i){this.debug(i.forward.name,i.reverse.name,": ->",i.name)},toString:function(){return"PairedCollectionCreator"}});e.templates=e.templates||{main:_.template(['<div class="header flex-row no-flex"></div>','<div class="middle flex-row flex-row-container"></div>','<div class="footer flex-row no-flex">'].join("")),header:_.template(['<div class="main-help well clear">','<a class="more-help" href="javascript:void(0);">',d("More help"),"</a>",'<div class="help-content">','<a class="less-help" href="javascript:void(0);">',d("Less"),"</a>","</div>","</div>",'<div class="alert alert-dismissable">','<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>','<span class="alert-message"></span>',"</div>",'<div class="column-headers vertically-spaced flex-column-container">','<div class="forward-column flex-column column">','<div class="column-header">','<div class="column-title">','<span class="title">',d("Unpaired forward"),"</span>",'<span class="title-info unpaired-info"></span>',"</div>",'<div class="unpaired-filter forward-unpaired-filter pull-left">','<input class="search-query" placeholder="',d("Filter this list"),'" />',"</div>","</div>","</div>",'<div class="paired-column flex-column no-flex column">','<div class="column-header">','<a class="choose-filters-link" href="javascript:void(0)">',d("Choose filters"),"</a>",'<a class="clear-filters-link" href="javascript:void(0);">',d("Clear filters"),"</a><br />",'<a class="autopair-link" href="javascript:void(0);">',d("Auto-pair"),"</a>","</div>","</div>",'<div class="reverse-column flex-column column">','<div class="column-header">','<div class="column-title">','<span class="title">',d("Unpaired reverse"),"</span>",'<span class="title-info unpaired-info"></span>',"</div>",'<div class="unpaired-filter reverse-unpaired-filter pull-left">','<input class="search-query" placeholder="',d("Filter this list"),'" />',"</div>","</div>","</div>","</div>"].join("")),middle:_.template(['<div class="unpaired-columns flex-column-container scroll-container flex-row">','<div class="forward-column flex-column column">','<ol class="column-datasets"></ol>',"</div>",'<div class="paired-column flex-column no-flex column">','<ol class="column-datasets"></ol>',"</div>",'<div class="reverse-column flex-column column">','<ol class="column-datasets"></ol>',"</div>","</div>",'<div class="flexible-partition">','<div class="flexible-partition-drag" title="',d("Drag to change"),'"></div>','<div class="column-header">','<div class="column-title paired-column-title">','<span class="title"></span>',"</div>",'<a class="unpair-all-link" href="javascript:void(0);">',d("Unpair all"),"</a>","</div>","</div>",'<div class="paired-columns flex-column-container scroll-container flex-row">','<ol class="column-datasets"></ol>',"</div>"].join("")),footer:_.template(['<div class="attributes clear">','<div class="clear">','<label class="remove-extensions-prompt pull-right">',d("Remove file extensions from pair names"),"?",'<input class="remove-extensions pull-right" type="checkbox" />',"</label>","</div>",'<div class="clear">','<input class="collection-name form-control pull-right" ','placeholder="',d("Enter a name for your new list"),'" />','<div class="collection-name-prompt pull-right">',d("Name"),":</div>","</div>","</div>",'<div class="actions clear vertically-spaced">','<div class="other-options pull-left">','<button class="cancel-create btn" tabindex="-1">',d("Cancel"),"</button>",'<div class="create-other btn-group dropup">','<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">',d("Create a different kind of collection"),' <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">','<li><a href="#">',d("Create a <i>single</i> pair"),"</a></li>",'<li><a href="#">',d("Create a list of <i>unpaired</i> datasets"),"</a></li>","</ul>","</div>","</div>",'<div class="main-options pull-right">','<button class="create-collection btn btn-primary">',d("Create list"),"</button>","</div>","</div>"].join("")),helpContent:_.template(["<p>",d(["Collections of paired datasets are ordered lists of dataset pairs (often forward and reverse reads). ","These collections can be passed to tools and workflows in order to have analyses done on each member of ","the entire group. This interface allows you to create a collection, choose which datasets are paired, ","and re-order the final collection."].join("")),"</p>","<p>",d(['Unpaired datasets are shown in the <i data-target=".unpaired-columns">unpaired section</i> ',"(hover over the underlined words to highlight below). ",'Paired datasets are shown in the <i data-target=".paired-columns">paired section</i>.',"<ul>To pair datasets, you can:","<li>Click a dataset in the ",'<i data-target=".unpaired-columns .forward-column .column-datasets,','.unpaired-columns .forward-column">forward column</i> ',"to select it then click a dataset in the ",'<i data-target=".unpaired-columns .reverse-column .column-datasets,','.unpaired-columns .reverse-column">reverse column</i>.',"</li>",'<li>Click one of the "Pair these datasets" buttons in the ','<i data-target=".unpaired-columns .paired-column .column-datasets,','.unpaired-columns .paired-column">middle column</i> ',"to pair the datasets in a particular row.","</li>",'<li>Click <i data-target=".autopair-link">"Auto-pair"</i> ',"to have your datasets automatically paired based on name.","</li>","</ul>"].join("")),"</p>","<p>",d(["<ul>You can filter what is shown in the unpaired sections by:","<li>Entering partial dataset names in either the ",'<i data-target=".forward-unpaired-filter input">forward filter</i> or ','<i data-target=".reverse-unpaired-filter input">reverse filter</i>.',"</li>","<li>Choosing from a list of preset filters by clicking the ",'<i data-target=".choose-filters-link">"Choose filters" link</i>.',"</li>","<li>Entering regular expressions to match dataset names. See: ",'<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expres..."',' target="_blank">MDN\'s JavaScript Regular Expression Tutorial</a>. ',"Note: forward slashes (\\) are not needed.","</li>","<li>Clearing the filters by clicking the ",'<i data-target=".clear-filters-link">"Clear filters" link</i>.',"</li>","</ul>"].join("")),"</p>","<p>",d(["To unpair individual dataset pairs, click the ",'<i data-target=".unpair-btn">unpair buttons ( <span class="fa fa-unlink"></span> )</i>. ','Click the <i data-target=".unpair-all-link">"Unpair all" link</i> to unpair all pairs.'].join("")),"</p>","<p>",d(['You can include or remove the file extensions (e.g. ".fastq") from your pair names by toggling the ','<i data-target=".remove-extensions-prompt">"Remove file extensions from pair names?"</i> control.'].join("")),"</p>","<p>",d(['Once your collection is complete, enter a <i data-target=".collection-name">name</i> and ','click <i data-target=".create-collection">"Create list"</i>. ',"(Note: you do not have to pair all unpaired datasets to finish.)"].join("")),"</p>"].join(""))};(function(){jQuery.fn.extend({hoverhighlight:function i(k,j){k=k||"body";if(!this.size()){return this}$(this).each(function(){var m=$(this),l=m.data("target");if(l){m.mouseover(function(n){$(l,k).css({background:j})}).mouseout(function(n){$(l).css({background:""})})}});return this}})}());var b=function c(k,i){console.log(k);i=_.defaults(i||{},{datasets:k,oncancel:function(){Galaxy.modal.hide()},oncreate:function(){Galaxy.modal.hide();Galaxy.currHistoryPanel.refreshContents()}});if(!window.Galaxy||!Galaxy.modal){throw new Error("Galaxy or Galaxy.modal not found")}var j=new e(i).render();Galaxy.modal.show({title:"Create a collection of paired datasets",body:j.$el,width:"80%",height:"800px",closing_events:true});window.PCC=j;return j};return{PairedCollectionCreator:e,pairedCollectionCreatorModal:b}}); \ No newline at end of file diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 static/scripts/packed/utils/natural-sort.js --- /dev/null +++ b/static/scripts/packed/utils/natural-sort.js @@ -0,0 +1,1 @@ +define([],function(){function a(j,h){var p=/(-?[0-9\.]+)/g,k=j.toString().toLowerCase()||"",g=h.toString().toLowerCase()||"",l=String.fromCharCode(0),n=k.replace(p,l+"$1"+l).split(l),e=g.replace(p,l+"$1"+l).split(l),d=(new Date(k)).getTime(),o=d?(new Date(g)).getTime():null;if(o){if(d<o){return -1}else{if(d>o){return 1}}}var m,f;for(var i=0,c=Math.max(n.length,e.length);i<c;i++){m=parseFloat(n[i])||n[i];f=parseFloat(e[i])||e[i];if(m<f){return -1}else{if(m>f){return 1}}}return 0}return a}); \ No newline at end of file diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 static/scripts/utils/natural-sort.js --- /dev/null +++ b/static/scripts/utils/natural-sort.js @@ -0,0 +1,30 @@ +define([], function(){ +// Alphanumeric/natural sort fn +function naturalSort(a, b) { + // setup temp-scope variables for comparison evauluation + var re = /(-?[0-9\.]+)/g, + x = a.toString().toLowerCase() || '', + y = b.toString().toLowerCase() || '', + nC = String.fromCharCode(0), + xN = x.replace( re, nC + '$1' + nC ).split(nC), + yN = y.replace( re, nC + '$1' + nC ).split(nC), + xD = (new Date(x)).getTime(), + yD = xD ? (new Date(y)).getTime() : null; + // natural sorting of dates + if ( yD ) { + if ( xD < yD ) { return -1; } + else if ( xD > yD ) { return 1; } + } + // natural sorting through split numeric strings and default strings + var oFxNcL, oFyNcL; + for ( var cLoc = 0, numS = Math.max(xN.length, yN.length); cLoc < numS; cLoc++ ) { + oFxNcL = parseFloat(xN[cLoc]) || xN[cLoc]; + oFyNcL = parseFloat(yN[cLoc]) || yN[cLoc]; + if (oFxNcL < oFyNcL) { return -1; } + else if (oFxNcL > oFyNcL) { return 1; } + } + return 0; +} + +return naturalSort; +}) diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 templates/webapps/galaxy/root/index.mako --- a/templates/webapps/galaxy/root/index.mako +++ b/templates/webapps/galaxy/root/index.mako @@ -152,6 +152,12 @@ currPanel.connectToQuotaMeter( Galaxy.quotaMeter ); currPanel.loadCurrentHistory(); Galaxy.currHistoryPanel = currPanel; + +currPanel.once( 'rendered', function(){ + currPanel.showSelectors(); + currPanel.selectAll(); + _.last( currPanel.actionsPopup.options ).func(); +}); }); }); </script> diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 test/qunit/test-common.js --- a/test/qunit/test-common.js +++ b/test/qunit/test-common.js @@ -72,7 +72,6 @@ }); - function bridge_phantomjs( QUnit ) { // Needed because the grunt task will attempt to inject this bridge assuming // QUnit is loaded directly - not using require.js. diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 test/qunit/test-data/paired-collection-creator.data.js --- /dev/null +++ b/test/qunit/test-data/paired-collection-creator.data.js @@ -0,0 +1,153 @@ +define([], function(){ +// ============================================================================ +// plain 3 step job chain +var datasets1 = [ + { name: 'SET1-01_1.fastq' }, + { name: 'SET1-01_2.fastq' }, + { name: 'SET1-02_1.fastq' }, + { name: 'SET1-02_2.fastq' }, + { name: 'SET1-03_1.fastq' }, + { name: 'SET1-03_2.fastq' }, + { name: 'SET1-04_1.fastq' }, + { name: 'SET1-04_2.fastq' }, + { name: 'SET1-05_1.fastq' }, + { name: 'SET1-05_2.fastq' }, + { name: 'SET1-06_1.fastq' }, + { name: 'SET1-06_2.fastq' }, + { name: 'SET1-07_1.fastq' }, + { name: 'SET1-07_2.fastq' } +]; + +var datasets1CreateRequestJSON = { + "type": "dataset_collection", + "collection_type": "list:paired", + "name": "Heres a collection", + "element_identifiers": [ + { + "collection_type": "paired", + "src": "new_collection", + "name": "SET1-07", + "element_identifiers": [ + { + "name": "forward", + "id": "2", + "src": "hda" + }, + { + "name": "reverse", + "id": "3", + "src": "hda" + } + ] + }, + { + "collection_type": "paired", + "src": "new_collection", + "name": "SET1-06", + "element_identifiers": [ + { + "name": "forward", + "id": "4", + "src": "hda" + }, + { + "name": "reverse", + "id": "5", + "src": "hda" + } + ] + }, + { + "collection_type": "paired", + "src": "new_collection", + "name": "SET1-05", + "element_identifiers": [ + { + "name": "forward", + "id": "6", + "src": "hda" + }, + { + "name": "reverse", + "id": "7", + "src": "hda" + } + ] + }, + { + "collection_type": "paired", + "src": "new_collection", + "name": "SET1-04", + "element_identifiers": [ + { + "name": "forward", + "id": "8", + "src": "hda" + }, + { + "name": "reverse", + "id": "9", + "src": "hda" + } + ] + }, + { + "collection_type": "paired", + "src": "new_collection", + "name": "SET1-03", + "element_identifiers": [ + { + "name": "forward", + "id": "10", + "src": "hda" + }, + { + "name": "reverse", + "id": "11", + "src": "hda" + } + ] + }, + { + "collection_type": "paired", + "src": "new_collection", + "name": "SET1-02", + "element_identifiers": [ + { + "name": "forward", + "id": "12", + "src": "hda" + }, + { + "name": "reverse", + "id": "13", + "src": "hda" + } + ] + }, + { + "collection_type": "paired", + "src": "new_collection", + "name": "SET1-01", + "element_identifiers": [ + { + "name": "forward", + "id": "14", + "src": "hda" + }, + { + "name": "reverse", + "id": "15", + "src": "hda" + } + ] + } + ] +}; + +// ============================================================================ + return { + _1 : datasets1, + _1requestJSON : datasets1CreateRequestJSON + }; +}); diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 test/qunit/tests/graph.js --- a/test/qunit/tests/graph.js +++ b/test/qunit/tests/graph.js @@ -1,11 +1,8 @@ -// This file isn't really testing anything useful yet, it is just testing -// (or demonstrating) qunit+backbone interactions. define([ "utils/graph", "jquery", "sinon-qunit" ], function( GRAPH, $, sinon ){ - console.debug( '' ); /*globals equal ok, test module expect deepEqual strictEqual */ "use strict"; diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 test/qunit/tests/paired-collection-creator.html --- /dev/null +++ b/test/qunit/tests/paired-collection-creator.html @@ -0,0 +1,10 @@ +<!doctype html> +<!-- Minimal outline test page for a requirejs+qunit testing setup, + test environment is bootstrapped in test-common.js --> +<html> + <head> + <script data-main="../test-common" src="../scripts/libs/require.js"></script> + </head> + <body> + </body> +</html> diff -r e9b02440691ebe3b1e22e973e61fc10bdfbc0990 -r 2f67cc2049113ace6bccb701c545fd1ec35fb013 test/qunit/tests/paired-collection-creator.js --- /dev/null +++ b/test/qunit/tests/paired-collection-creator.js @@ -0,0 +1,78 @@ +define([ + "mvc/collection/paired-collection-creator", + "test-data/paired-collection-creator.data", + "jquery", + "sinon-qunit" +], function( + PAIRED_COLLECTION_CREATOR, + // why am I yelling? + DATA, + $, + sinon +){ + /*globals equal test module expect deepEqual strictEqual throws ok */ + "use strict"; + var PCC = PAIRED_COLLECTION_CREATOR.PairedCollectionCreator; + + module( "Galaxy client app tests" ); + + test( "Creator base/empty construction/initializiation defaults", function() { + var pcc = new PCC([]); + ok( pcc instanceof PCC ); + ok( pcc.hasOwnProperty( 'options' ) && typeof pcc.options === 'object' ); + deepEqual( pcc.options.filters, pcc.DEFAULT_FILTERS ); + ok( pcc.options.automaticallyPair ); + equal( pcc.options.matchPercentage, 1.0 ); + equal( pcc.options.strategy, 'lcs' ); + }); + + test( "Creator construction/initializiation with datasets", function() { + var pcc = new PCC({ + datasets : DATA._1 + }); + //pcc.initialList.forEach( function( dataset, i ){ + // console.log( i + ':\n' + JSON.stringify( dataset ) ); + //}); + // pcc maintains the original list - which, in this case, is already sorted + deepEqual( pcc.initialList, DATA._1 ); + // datasets 1 has no ids, so the pcc will create them + ok( _.every( pcc.initialList, function( dataset ){ + return dataset.id; + })); + // datasets 1 is very easy to auto pair + equal( pcc.unpaired.length, 0 ); + equal( pcc.paired.length, pcc.initialList.length / 2 ); + }); + + //TODO: + // filters: clearing, setting via popover, regex + // partition: maximize paired, maximize unpaired, split evenly + // pairing: manually pairing and unpairing + // misc: renaming pairs, removing file extensions + + test( "Collection creation", function() { + var pcc = new PCC({ + datasets : DATA._1, + historyId : 'fakeHistoryId' + }), + server = sinon.fakeServer.create(); + + var requestJSON; + server.respondWith( 'POST', '/api/histories/fakeHistoryId/contents/dataset_collections', function( request ){ + requestJSON = JSON.parse( request.requestBody ); + request.respond( + 200, + { "Content-Type": "application/json" }, + JSON.stringify({ + fakeResponse: 'yes' + }) + ); + }); + + console.debug( 'requestBody:', JSON.stringify( requestJSON, null, ' ' ) ); + pcc.createList( 'Heres a collection' ); + server.respond(); + deepEqual( requestJSON, DATA._1requestJSON ); + }); + +}); 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)
-
commits-noreply@bitbucket.org