galaxy-dev
Threads by month
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- 10007 discussions
26 May '09
details: http://www.bx.psu.edu/hg/galaxy/rev/48e4b965545b
changeset: 2416:48e4b965545b
user: Greg Von Kuster <greg(a)bx.psu.edu>
date: Tue May 26 14:32:18 2009 -0400
description:
Bug fixes for the new security and libraries functional tests.
3 file(s) affected in this change:
lib/galaxy/web/controllers/admin.py
test/base/twilltestcase.py
test/functional/test_security_and_libraries.py
diffs (253 lines):
diff -r 386e245f8076 -r 48e4b965545b lib/galaxy/web/controllers/admin.py
--- a/lib/galaxy/web/controllers/admin.py Thu May 21 15:48:39 2009 -0400
+++ b/lib/galaxy/web/controllers/admin.py Tue May 26 14:32:18 2009 -0400
@@ -875,14 +875,21 @@
library_folder.deleted = True
library_folder.purged = True
library_folder.flush()
- purge_folder( library.root_folder )
- library.purged = True
- library.flush()
- msg = "Library '%s' and all of its contents have been purged, datasets will be removed from disk via the cleanup_datasets script" % library.name
- return trans.response.send_redirect( web.url_for( controller='admin',
- action='deleted_libraries',
- msg=util.sanitize_text( msg ),
- messagetype='done' ) )
+ if not library.deleted:
+ msg = "Library '%s' has not been marked deleted, so it cannot be purged" % ( library.name )
+ return trans.response.send_redirect( web.url_for( controller='admin',
+ action='browse_libraries',
+ msg=util.sanitize_text( msg ),
+ messagetype='error' ) )
+ else:
+ purge_folder( library.root_folder )
+ library.purged = True
+ library.flush()
+ msg = "Library '%s' and all of its contents have been purged, datasets will be removed from disk via the cleanup_datasets script" % library.name
+ return trans.response.send_redirect( web.url_for( controller='admin',
+ action='deleted_libraries',
+ msg=util.sanitize_text( msg ),
+ messagetype='done' ) )
@web.expose
@web.require_admin
def folder( self, trans, id, library_id, **kwd ):
@@ -1545,7 +1552,7 @@
messagetype=messagetype )
@web.expose
@web.require_admin
- def info_template( self, trans, library_id, id=None, num_fields=0, folder_id=None, ldda_id=None, library_dataset_id=None, **kwd ):
+ def info_template( self, trans, library_id, id=None, num_fields=0, folder_id=None, ldda_id=None, library_dataset_id=None, **kwd ):
params = util.Params( kwd )
msg = util.restore_text( params.get( 'msg', '' ) )
messagetype = params.get( 'messagetype', 'done' )
diff -r 386e245f8076 -r 48e4b965545b test/base/twilltestcase.py
--- a/test/base/twilltestcase.py Thu May 21 15:48:39 2009 -0400
+++ b/test/base/twilltestcase.py Tue May 26 14:32:18 2009 -0400
@@ -855,9 +855,14 @@
tc.fv( '1', 'new_element_name_0', ele_name_0 )
tc.fv( '1', 'new_element_name_1', ele_name_1 )
tc.submit( 'new_info_template_button' )
+ self.check_page_for_string( 'The new information template has been created.' )
self.home()
- def add_library_info_template_element( self, library_id, template_id, template_name, ele_name_1, ele_desc_1,
- ele_name_2, ele_desc_2, new_ele_name='Fubar', new_ele_desc='This is the Fubar compnent' ):
+ def add_library_info_template_element( self, library_id, template_id, template_name,
+ ele_field_name_1, ele_name_1,
+ ele_field_desc_1, ele_desc_1,
+ ele_field_name_2, ele_name_2,
+ ele_field_desc_2, ele_desc_2,
+ new_ele_name='Fubar', new_ele_desc='This is the Fubar compnent' ):
"""Add a new element to an existing library info template"""
self.home()
url = "%s/admin/info_template?library_id=%s&id=%s&edit_template=True&num_fields=1&edit_info_template_button=Save" % \
@@ -868,10 +873,10 @@
tc.fv( '1', 'id', template_id )
tc.fv( '1', 'set_num_fields', '0' )
tc.fv( '1', 'name', template_name )
- tc.fv( '1', 'element_name_1', ele_name_1 )
- tc.fv( '1', 'element_description_1', ele_desc_1 )
- tc.fv( '1', 'element_name_2', ele_name_2 )
- tc.fv( '1', 'element_description_2', ele_desc_2 )
+ tc.fv( '1', ele_field_name_1, ele_name_1 )
+ tc.fv( '1', ele_field_desc_1, ele_desc_1 )
+ tc.fv( '1', ele_field_name_2, ele_name_2 )
+ tc.fv( '1', ele_field_desc_2, ele_desc_2 )
tc.fv( '1', 'new_element_name_0', new_ele_name )
tc.fv( '1', 'new_element_description_0', new_ele_desc )
tc.submit( 'edit_info_template_button' )
@@ -888,7 +893,8 @@
tc.fv( '2', ele_2_field_name, ele_2_contents )
tc.submit( 'create_new_info_button' )
self.home()
- def edit_library_info_template( self, library_id, id, name, name_1, desc_1, name_2, desc_2 ):
+ def edit_library_info_template( self, library_id, id, name, ele_name_1, name_1,
+ ele_desc_1, desc_1, ele_name_2, name_2, ele_desc_2, desc_2 ):
"""Edit an existing library info template"""
self.home()
url = "%s/admin/info_template?library_id=%s&id=%s&edit_template=True" % ( self.url, library_id, id )
@@ -897,10 +903,10 @@
tc.fv( '1', 'id', id )
tc.fv( '1', 'set_num_fields', '0' )
tc.fv( '1', 'name', name )
- tc.fv( '1', 'element_name_1', name_1 )
- tc.fv( '1', 'element_description_1', desc_1 )
- tc.fv( '1', 'element_name_2', name_2 )
- tc.fv( '1', 'element_description_2', desc_2 )
+ tc.fv( '1', ele_name_1, name_1 )
+ tc.fv( '1', ele_desc_1, desc_1 )
+ tc.fv( '1', ele_name_2, name_2 )
+ tc.fv( '1', ele_desc_2, desc_2 )
tc.submit( 'edit_info_template_button' )
check_str = "Information template '%s' has been updated" % name
self.check_page_for_string( check_str )
@@ -988,7 +994,6 @@
for pi in permissions_in:
key = '%s_in' % pi
url ="%s&%s=%s" % ( url, key, str( role_id ) )
- print url
self.home()
self.visit_url( "%s/%s" % ( self.url, url ) )
check_str = "Permissions updated for dataset '%s'" % ldda_name
@@ -1046,12 +1051,7 @@
dbkey='hg18', message='', check_template_str1='', check_template_str2='', check_template_str3='' ):
"""Upload new version(s) of a dataset"""
self.home()
- filename = self.get_filename( filename )
-
- url = "%s/admin/library_dataset_dataset_association?upload_option=upload_file&library_id=%s&folder_id=%s&replace_id=%s&message=%s" % \
- ( self.url, library_id, folder_id, library_dataset_id, message )
- print "####url: ", url
-
+ filename = self.get_filename( filename )
self.visit_url( "%s/admin/library_dataset_dataset_association?upload_option=upload_file&library_id=%s&folder_id=%s&replace_id=%s&message=%s" % \
( self.url, library_id, folder_id, library_dataset_id, message ) )
self.check_page_for_string( 'Upload files' )
diff -r 386e245f8076 -r 48e4b965545b test/functional/test_security_and_libraries.py
--- a/test/functional/test_security_and_libraries.py Thu May 21 15:48:39 2009 -0400
+++ b/test/functional/test_security_and_libraries.py Tue May 26 14:32:18 2009 -0400
@@ -515,17 +515,30 @@
info_permissions.sort()
assert actions == info_permissions, "Permissions for library_item_info id %s not correctly inherited from library %s" \
% ( library_item_info.id, library_one.name )
- # Need the current library_item_info_element.id
- last_library_item_info_element_id = galaxy.model.LibraryItemInfoElement.query() \
- .order_by( desc( galaxy.model.LibraryItemInfoElement.table.c.id ) ).first()
- if last_library_item_info_element_id is None:
- last_library_item_info_element_id = 0
+ element_ids = []
+ if library_one.library_info_associations:
+ # We have a set of LibraryItemInfoElements
+ last_library_item_info_element = galaxy.model.LibraryItemInfoElement.query() \
+ .order_by( desc( galaxy.model.LibraryItemInfoElement.table.c.id ) ).first()
+ if not last_library_item_info_element:
+ element_ids.append( 0 )
+ element_ids.append( 1 )
+ else:
+ element_ids.append( last_library_item_info_element.id + 1 )
+ element_ids.append( last_library_item_info_element.id + 2 )
+ else:
+ # We only have a set of LibraryItemInfoTemplateElements
+ for ele in library_one_template.elements:
+ element_ids.append( ele.id )
+ element_ids.sort()
# Add information to the library using the template
- ele_1_field_name = "info_element_%s_%s" % ( str( library_one_template.id ), str( last_library_item_info_element_id + 1 ) )
+ ele_1_field_name = "info_element_%s_%s" % ( str( library_one_template.id ), str( element_ids[0] ) )
ele_1_contents = 'hello'
- ele_2_field_name = "info_element_%s_%s" % ( str( library_one_template.id ), str( last_library_item_info_element_id + 2 ) )
+ ele_2_field_name = "info_element_%s_%s" % ( str( library_one_template.id ), str( element_ids[1] ) )
ele_2_contents = 'world'
- self.edit_library_info( str( library_one.id ), library_one.name, ele_1_field_name, ele_1_contents, ele_2_field_name, ele_2_contents )
+ self.edit_library_info( str( library_one.id ), library_one.name,
+ ele_1_field_name, ele_1_contents,
+ ele_2_field_name, ele_2_contents )
self.home()
self.visit_url( '%s/admin/library?id=%s&information=True' % ( self.url, str( library_one.id ) ) )
self.check_page_for_string( ele_1_contents )
@@ -536,11 +549,17 @@
self.check_page_for_string( ele_2_contents )
# Edit the template
new_name = 'Library Template 1 renamed'
+ new_ele_name_1_field = "element_name_%s" % element_ids[0]
new_ele_name_1 = 'wind'
+ new_ele_desc_1_field = "element_description_%s" % element_ids[0]
ele_desc_1 = 'This is the wind component'
+ new_ele_name_2_field = "element_name_%s" % element_ids[1]
new_ele_name_2 = 'bag'
+ new_ele_desc_2_field = "element_description_%s" % element_ids[1]
ele_desc_2 = 'This is the bag component'
- self.edit_library_info_template( str( library_one.id ), library_one_template.id, new_name, new_ele_name_1, ele_desc_1, new_ele_name_2, ele_desc_2 )
+ self.edit_library_info_template( str( library_one.id ), library_one_template.id, new_name,
+ new_ele_name_1_field, new_ele_name_1, new_ele_desc_1_field, ele_desc_1,
+ new_ele_name_2_field, new_ele_name_2, new_ele_desc_2_field, ele_desc_2 )
self.home()
self.visit_url( '%s/admin/library?id=%s&information=True' % ( self.url, str( library_one.id ) ) )
self.check_page_for_string( new_ele_name_1 )
@@ -692,20 +711,34 @@
self.home()
def test_105_add_template_element( self ):
"""Testing adding a new element to an existing library template"""
+ library_one_template.refresh()
+ element_ids = []
+ for ele in library_one_template.elements:
+ element_ids.append( ele.id )
+ element_ids.sort()
+
name = 'Library Template 1 renamed'
+ ele_field_name_1 = "element_name_%s" % element_ids[0]
ele_name_1 = 'wind'
+ ele_field_desc_1 = "element_description_%s" % element_ids[0]
ele_desc_1 = 'This is the wind component'
+ ele_field_name_2 = "element_name_%s" % element_ids[1]
ele_name_2 = 'bag'
+ ele_field_desc_2 = "element_description_%s" % element_ids[1]
ele_desc_2 = 'This is the bag component'
new_ele_name = 'Fubar'
new_ele_desc = 'This is the Fubar component'
- library_one_template.refresh()
+
self.add_library_info_template_element( str( library_one.id ),
str( library_one_template.id ),
library_one_template.name,
+ ele_field_name_1,
ele_name_1,
+ ele_field_desc_1,
ele_desc_1,
+ ele_field_name_2,
ele_name_2,
+ ele_field_desc_2,
ele_desc_2,
new_ele_name=new_ele_name,
new_ele_desc=new_ele_desc )
@@ -1601,11 +1634,13 @@
self.undelete_role( str( role_two.id ), role_two.name )
def test_270_purge_library( self ):
"""Testing purging a library"""
+ self.home()
+ self.delete_library_item( str( library_one.id ), str( library_one.id ), library_one.name, library_item_type='library' )
self.purge_library( str( library_one.id ), library_one.name )
# Make sure the library was purged
library_one.refresh()
- if not library_one.purged:
- raise AssertionError( 'The library id %s named "%s" has not been marked as purged.' % ( str( library_one.id ), library_one.name ) )
+ if not ( library_one.deleted and library_one.purged ):
+ raise AssertionError( 'The library id %s named "%s" has not been marked as deleted and purged.' % ( str( library_one.id ), library_one.name ) )
def check_folder( library_folder ):
for folder in library_folder.folders:
folder.refresh()
@@ -1635,15 +1670,6 @@
check_folder( library_one.root_folder )
def test_275_reset_data_for_later_test_runs( self ):
"""Reseting data to enable later test runs to pass"""
- ##################
- # Eliminate all templates and info associations
- ##################
- for lia in library_one.library_info_associations:
- lia.delete()
- lia.flush()
- for lita in library_one.library_info_template_associations:
- lita.delete()
- lita.flush()
##################
# Eliminate all non-private roles
##################
1
0
26 May '09
details: http://www.bx.psu.edu/hg/galaxy/rev/76890d7fb3dd
changeset: 2417:76890d7fb3dd
user: Greg Von Kuster <greg(a)bx.psu.edu>
date: Tue May 26 14:59:40 2009 -0400
description:
Eliminate the problematic GeneTrack eggs from eggs.ini.
1 file(s) affected in this change:
eggs.ini
diffs (33 lines):
diff -r 48e4b965545b -r 76890d7fb3dd eggs.ini
--- a/eggs.ini Tue May 26 14:32:18 2009 -0400
+++ b/eggs.ini Tue May 26 14:59:40 2009 -0400
@@ -24,7 +24,6 @@
threadframe = 0.2
guppy = 0.1.8
numpy = 1.2.1
-tables = 2.1.1
[eggs:noplatform]
Beaker = 0.5
@@ -52,7 +51,6 @@
wsgiref = 0.1.2
Babel = 0.9.4
wchartype = 0.1
-GeneTrack = 1.0.3
; extra version information
[tags]
@@ -63,7 +61,6 @@
flup = .dev_r2311
bx_python = _dev_r4bf1f32e6b76
nose = .dev_r101
-tables = _hdf5_1.8.2_lzo_2.03_bzip2_1.0.5_static
; source location, necessary for scrambling
[source]
@@ -103,5 +100,3 @@
wsgiref = http://pypi.python.org/packages/source/w/wsgiref/wsgiref-0.1.2.zip
Babel = http://ftp.edgewall.com/pub/babel/Babel-0.9.4.zip
wchartype = http://ginstrom.com/code/wchartype-0.1.zip
-tables = http://www.pytables.org/download/stable/tables-2.1.1.tar.gz ftp://ftp.hdfgroup.org/HDF5/current/src/hdf5-1.8.2.tar.gz http://www.oberhumer.com/opensource/lzo/download/lzo-2.03.tar.gz http://www.bzip.org/1.0.5/bzip2-1.0.5.tar.gz
-GeneTrack = http://genetrack.googlecode.com/files/GeneTrack-1.0.3.zip http://dalchemy.com/opensource/formkit/FormKit_0.9b2.tar.gz
1
0
26 May '09
details: http://www.bx.psu.edu/hg/galaxy/rev/386e245f8076
changeset: 2415:386e245f8076
user: Greg Von Kuster <greg(a)bx.psu.edu>
date: Thu May 21 15:48:39 2009 -0400
description:
Bug fixes and new functional tests for library features that were missing them.
17 file(s) affected in this change:
lib/galaxy/model/__init__.py
lib/galaxy/web/controllers/admin.py
lib/galaxy/web/controllers/library.py
templates/admin/library/browse_library.mako
templates/admin/library/common.mako
templates/admin/library/edit_info_template.mako
templates/admin/library/folder_info.mako
templates/admin/library/ldda_edit_info.mako
templates/admin/library/new_info_template.mako
templates/library/browse_library.mako
templates/library/common.mako
templates/library/edit_info_template.mako
templates/library/ldda_edit_info.mako
templates/library/library_dataset_info.mako
templates/library/new_info_template.mako
test/base/twilltestcase.py
test/functional/test_security_and_libraries.py
diffs (2528 lines):
diff -r 1a82088aac38 -r 386e245f8076 lib/galaxy/model/__init__.py
--- a/lib/galaxy/model/__init__.py Thu May 21 11:32:25 2009 -0400
+++ b/lib/galaxy/model/__init__.py Thu May 21 15:48:39 2009 -0400
@@ -300,6 +300,9 @@
class LibraryItemInfoPermissions( object ):
def __init__( self, action, library_item, role ):
+ # LIBRARY_ADD -> Not Applicable
+ # LIBRARY_MODIFY -> Can modify LibraryItemInfoElement.contents
+ # LIBRARY_MANAGE -> Can change permissions on LibraryItemInfo
self.action = action
if isinstance( library_item, LibraryItemInfo ):
self.library_item_info = library_item
@@ -309,6 +312,9 @@
class LibraryItemInfoTemplatePermissions( object ):
def __init__( self, action, library_item, role ):
+ # LIBRARY_ADD -> Not Applicable
+ # LIBRARY_MODIFY -> Can add or delete LibraryItemInfoTemplateElements
+ # LIBRARY_MANAGE -> Can change permissions on LibraryItemInfoTemplate
self.action = action
if isinstance( library_item, LibraryItemInfoTemplate ):
self.library_item_info_template = library_item
@@ -673,7 +679,9 @@
self.description = description
self.root_folder = root_folder
def get_library_item_info_templates( self, template_list=[], restrict=False ):
- if self.library_info_template_associations:
+ # We only want the next available template in the inheritable hierarchy, so we'll only extend
+ # template_list if it is empty
+ if not template_list and self.library_info_template_associations:
template_list.extend( [ lita.library_item_info_template for lita in self.library_info_template_associations if lita.library_item_info_template not in template_list ] )
return template_list
@@ -696,11 +704,13 @@
self.item_count += 1
def get_library_item_info_templates( self, template_list=[], restrict=False ):
# If restrict is True, we'll return only those templates directly associated with this Folder
- if self.library_folder_info_template_associations:
+ # We only want the next available template in the inheritable hierarchy, so we'll only extend
+ # template_list if it is empty
+ if not template_list and self.library_folder_info_template_associations:
template_list.extend( [ lfita.library_item_info_template for lfita in self.library_folder_info_template_associations if lfita.library_item_info_template not in template_list ] )
- if restrict not in [ 'True', True ] and self.parent:
+ if not template_list and restrict not in [ 'True', True ] and self.parent:
self.parent.get_library_item_info_templates( template_list )
- elif restrict not in [ 'True', True, 'folder' ] and self.library_root:
+ elif not template_list and restrict not in [ 'True', True, 'folder' ] and self.library_root:
for library_root in self.library_root:
library_root.get_library_item_info_templates( template_list )
return template_list
@@ -759,9 +769,11 @@
purged = property( get_purged, set_purged )
def get_library_item_info_templates( self, template_list=[], restrict=False ):
# If restrict is True, we'll return only those templates directly associated with this LibraryDataset
- if self.library_dataset_info_template_associations:
+ # We only want the next available template in the inheritable hierarchy, so we'll only extend
+ # template_list if it is empty
+ if not template_list and self.library_dataset_info_template_associations:
template_list.extend( [ ldita.library_item_info_template for ldita in self.library_dataset_info_template_associations if ldita.library_item_info_template not in template_list ] )
- if restrict not in [ 'True', True ]:
+ if not template_list and restrict not in [ 'True', True ]:
self.folder.get_library_item_info_templates( template_list, restrict )
return template_list
@@ -828,9 +840,12 @@
return
def get_library_item_info_templates( self, template_list=[], restrict=False ):
# If restrict is True, we'll return only those templates directly associated with this LibraryDatasetDatasetAssociation
- if self.library_dataset_dataset_info_template_associations:
+ # We only want the next available template in the inheritable hierarchy, so we'll only extend
+ # template_list if it is empty
+ if not template_list and self.library_dataset_dataset_info_template_associations:
template_list.extend( [ lddita.library_item_info_template for lddita in self.library_dataset_dataset_info_template_associations if lddita.library_item_info_template not in template_list ] )
- self.library_dataset.get_library_item_info_templates( template_list, restrict )
+ if not template_list:
+ self.library_dataset.get_library_item_info_templates( template_list, restrict )
return template_list
class LibraryInfoTemplateAssociation( object ):
@@ -902,11 +917,22 @@
class LibraryItemInfo( object ):
def __init__( self, user=None ):
self.user = user
- def get_element_by_template_element( self, template_element ):
+ def get_element_by_template_element( self, template_element, create_element=False ):
for element in self.elements:
if element.library_item_info_template_element == template_element:
return element
- raise 'element not found'
+ if create_element:
+ # Template elements may have been added to the template after the
+ # library item initially inherited it, so we'll add the additional
+ # element to the library item
+ element = LibraryItemInfoElement()
+ element.library_item_info_template_element = template_element
+ element.library_item_info = self
+ element.flush()
+ self.elements.append( element )
+ return element
+ else:
+ return None
class LibraryItemInfoElement( object ):
pass
diff -r 1a82088aac38 -r 386e245f8076 lib/galaxy/web/controllers/admin.py
--- a/lib/galaxy/web/controllers/admin.py Thu May 21 11:32:25 2009 -0400
+++ b/lib/galaxy/web/controllers/admin.py Thu May 21 15:48:39 2009 -0400
@@ -848,32 +848,6 @@
show_deleted=True )
@web.expose
@web.require_admin
- def undelete_library( self, trans, **kwd ):
- params = util.Params( kwd )
- library = trans.app.model.Library.get( int( params.id ) )
- def undelete_folder( library_folder ):
- for folder in library_folder.folders:
- folder.refresh()
- undelete_folder( folder )
- library_folder.refresh()
- for library_dataset in library_folder.datasets:
- library_dataset.refresh()
- ldda = library_dataset.library_dataset_dataset_association
- if ldda:
- ldda.refresh()
- ldda.deleted = False
- ldda.flush()
- library_dataset.deleted = False
- library_dataset.flush()
- library_folder.deleted = False
- library_folder.flush()
- undelete_folder( library.root_folder )
- library.deleted = False
- library.flush()
- msg = "Library '%s' and all of its contents have been marked not deleted" % library.name
- return trans.response.send_redirect( web.url_for( action='browse_libraries', msg=util.sanitize_text( msg ), messagetype='done' ) )
- @web.expose
- @web.require_admin
def purge_library( self, trans, **kwd ):
params = util.Params( kwd )
library = trans.app.model.Library.get( int( params.id ) )
@@ -1104,7 +1078,7 @@
last_used_build = folder.genome_build
replace_id = params.get( 'replace_id', None )
if replace_id:
- replace_dataset = trans.app.model.LibraryDataset.get( params.get( 'replace_id', None ) )
+ replace_dataset = trans.app.model.LibraryDataset.get( int( replace_id ) )
if not last_used_build:
last_used_build = replace_dataset.library_dataset_dataset_association.dbkey
else:
@@ -1197,6 +1171,8 @@
permissions = {}
accessible = False
for k, v in trans.app.model.Dataset.permitted_actions.items():
+ # TODO: need to handle case where a user has the DATASET_MANAGE_PERMISSIONS permission, but not
+ # the DATASET_ACCESS permission, making the former useless. Need to display a warning message.
in_roles = [ trans.app.model.Role.get( x ) for x in util.listify( params.get( k + '_in', [] ) ) ]
# At least 1 user must have every role associated with this dataset, or the dataset is inaccessible
if v == trans.app.security_agent.permitted_actions.DATASET_ACCESS:
@@ -1381,6 +1357,8 @@
permissions = {}
accessible = False
for k, v in trans.app.model.Dataset.permitted_actions.items():
+ # TODO: need to handle case where a user has the DATASET_MANAGE_PERMISSIONS permission, but not
+ # the DATASET_ACCESS permission, making the former useless. Need to display a warning message.
in_roles = [ trans.app.model.Role.get( x ) for x in util.listify( params.get( k + '_in', [] ) ) ]
# At least 1 user must have every role associated with this dataset, or the dataset is inaccessible
if v == trans.app.security_agent.permitted_actions.DATASET_ACCESS:
@@ -1567,7 +1545,7 @@
messagetype=messagetype )
@web.expose
@web.require_admin
- def info_template( self, trans, library_id, id=None, num_fields=0, folder_id=None, ldda_id=None, library_dataset_id=None, **kwd ):
+ def info_template( self, trans, library_id, id=None, num_fields=0, folder_id=None, ldda_id=None, library_dataset_id=None, **kwd ):
params = util.Params( kwd )
msg = util.restore_text( params.get( 'msg', '' ) )
messagetype = params.get( 'messagetype', 'done' )
@@ -1646,7 +1624,7 @@
liit.description = util.restore_text( params.get( 'description', '' ) )
liit.flush()
# Inherit the template's permissions from the library_item
- trans.app.security_agent.copy_library_permissions( liit, library_item )
+ trans.app.security_agent.copy_library_permissions( library_item, liit )
# Create template association
if folder_id:
liit_assoc = trans.app.model.LibraryFolderInfoTemplateAssociation()
@@ -1694,7 +1672,13 @@
msg=msg,
messagetype=messagetype )
elif action == 'edit_template':
- if params.get( 'edit_info_template_button', False ):
+ define_or_save = 'define'
+ edit_info_template_button = params.get( 'edit_info_template_button', False )
+ if edit_info_template_button:
+ if edit_info_template_button == 'Define fields':
+ define_or_save = 'save'
+ else:
+ define_or_save = 'define'
# Save changes to existing attributes, only set name if nonempty/nonNone is passed, but always set description
name = params.get( 'name', None )
if name:
@@ -1702,7 +1686,7 @@
library_item.description = params.get( 'description', '' )
library_item.flush()
# Save changes to exisiting elements
- for elem_id in params.get( 'element_ids', [] ):
+ for elem_id in util.listify( params.get( 'element_ids', [] ) ):
liit_element = trans.app.model.LibraryItemInfoTemplateElement.get( elem_id )
name = params.get( 'element_name_%s' % elem_id, None )
if name:
@@ -1721,7 +1705,7 @@
if elem_name:
library_item.add_element( name=elem_name, description=elem_description )
library_item.refresh()
- msg = 'Information template %s has been updated' % library_item.name
+ msg = "Information template '%s' has been updated" % library_item.name
return trans.fill_template( "/admin/library/edit_info_template.mako",
liit=library_item,
num_fields=num_fields,
@@ -1731,6 +1715,7 @@
folder_id=folder_id,
library_item_name=library_item.name,
library_item_desc=library_item_desc,
+ define_or_save=define_or_save,
msg=msg,
messagetype=messagetype )
elif action == 'permissions':
@@ -1771,6 +1756,8 @@
library_item = trans.app.model.LibraryDatasetDatasetAssociation.get( library_item_id )
# This response_action method requires a folder_id
folder_id = library_item.library_dataset.folder.id
+ elif library_item_type == 'library_item_info_elememt':
+ library_item = trans.app.model.LibraryItemInfoElement.get( library_item_id )
else:
msg = "Invalid library item type ( %s ) specified, id ( %s )" % ( str( library_item_type ), str( library_item_id ) )
return trans.response.send_redirect( web.url_for( controller='admin',
@@ -1869,6 +1856,7 @@
action='library_item_info',
library_id=library_id,
id=id,
+ library_item_id=library_item_id,
library_item_type=library_item_type,
permissions=True,
msg=util.sanitize_text( msg ),
@@ -1977,10 +1965,14 @@
msg = 'Bad library_item_type specified: %s' % str( library_item_type )
messagetype = 'error'
else:
+ if library_item_type == 'library_dataset':
+ library_item_desc = 'Dataset'
+ else:
+ library_item_desc = library_item_type.capitalize()
library_item = library_item_types[ library_item_type ].get( int( library_item_id ) )
library_item.deleted = True
library_item.flush()
- msg = util.sanitize_text( "%s '%s' has been marked deleted" % ( library_item_type, library_item.name ) )
+ msg = util.sanitize_text( "%s '%s' has been marked deleted" % ( library_item_desc, library_item.name ) )
messagetype = 'done'
if library_item_type == 'library':
return self.browse_libraries( trans, msg=msg, messagetype=messagetype )
@@ -1997,14 +1989,18 @@
msg = 'Bad library_item_type specified: %s' % str( library_item_type )
messagetype = 'error'
else:
+ if library_item_type == 'library_dataset':
+ library_item_desc = 'Dataset'
+ else:
+ library_item_desc = library_item_type.capitalize()
library_item = library_item_types[ library_item_type ].get( int( library_item_id ) )
if library_item.purged:
- msg = '%s %s has been purged, so it cannot be undeleted' % ( library_item_type, library_item.name )
+ msg = '%s %s has been purged, so it cannot be undeleted' % ( library_item_desc, library_item.name )
messagetype = 'error'
else:
library_item.deleted = False
library_item.flush()
- msg = util.sanitize_text( "%s '%s' has been marked undeleted" % ( library_item_type, library_item.name ) )
+ msg = util.sanitize_text( "%s '%s' has been marked undeleted" % ( library_item_desc, library_item.name ) )
messagetype = 'done'
if library_item_type == 'library':
return self.browse_libraries( trans, msg=msg, messagetype=messagetype )
diff -r 1a82088aac38 -r 386e245f8076 lib/galaxy/web/controllers/library.py
--- a/lib/galaxy/web/controllers/library.py Thu May 21 11:32:25 2009 -0400
+++ b/lib/galaxy/web/controllers/library.py Thu May 21 15:48:39 2009 -0400
@@ -1169,7 +1169,13 @@
msg=msg,
messagetype=messagetype )
elif action == 'edit_template':
- if params.get( 'edit_info_template_button', False ):
+ define_or_save = 'define'
+ edit_info_template_button = params.get( 'edit_info_template_button', False )
+ if edit_info_template_button:
+ if edit_info_template_button == 'Define fields':
+ define_or_save = 'save'
+ else:
+ define_or_save = 'define'
# Save changes to existing attributes, only set name if nonempty/nonNone is passed, but always set description
name = params.get( 'name', None )
if name:
@@ -1177,7 +1183,7 @@
library_item.description = params.get( 'description', '' )
library_item.flush()
# Save changes to exisiting elements
- for elem_id in params.get( 'element_ids', [] ):
+ for elem_id in util.listify( params.get( 'element_ids', [] ) ):
liit_element = trans.app.model.LibraryItemInfoTemplateElement.get( elem_id )
name = params.get( 'element_name_%s' % elem_id, None )
if name:
@@ -1206,6 +1212,7 @@
folder_id=folder_id,
library_item_name=library_item.name,
library_item_desc=library_item_desc,
+ define_or_save=define_or_save,
msg=msg,
messagetype=messagetype )
elif action == 'permissions':
@@ -1246,6 +1253,8 @@
library_item = trans.app.model.LibraryDatasetDatasetAssociation.get( library_item_id )
# This response_action method requires a folder_id
folder_id = library_item.library_dataset.folder.id
+ elif library_item_type == 'library_item_info_elememt':
+ library_item = trans.app.model.LibraryItemInfoElement.get( library_item_id )
else:
msg = "Invalid library item type ( %s ) specified, id ( %s )" % ( str( library_item_type ), str( library_item_id ) )
return trans.response.send_redirect( web.url_for( controller='library',
@@ -1339,17 +1348,18 @@
trans.app.security_agent.set_all_library_permissions( library_item.library_item_info, permissions )
library_item.library_item_info.refresh()
library_item.refresh()
- msg = "Permissions updated for field '%s'" % library_item.name
+ msg = "Permissions updated for field '%s'" % library_item.library_item_info_template_element.name
return trans.response.send_redirect( web.url_for( controller='library',
action='library_item_info',
library_id=library_id,
id=id,
+ library_item_id=library_item_id,
library_item_type=library_item_type,
permissions=True,
msg=util.sanitize_text( msg ),
messagetype='done' ) )
return trans.fill_template( '/library/info_permissions.mako',
- library_item_info_element=library_item_info_element,
+ library_item_info_element=library_item,
library_id=library_id,
msg=msg,
messagetype=messagetype )
diff -r 1a82088aac38 -r 386e245f8076 templates/admin/library/browse_library.mako
--- a/templates/admin/library/browse_library.mako Thu May 21 11:32:25 2009 -0400
+++ b/templates/admin/library/browse_library.mako Thu May 21 15:48:39 2009 -0400
@@ -115,7 +115,8 @@
%if folder.library_folder_info_template_associations:
<% template = folder.get_library_item_info_templates( template_list=[], restrict=True )[0] %>
<a class="action-button" href="${h.url_for( controller='admin', action='info_template', library_id=library_id, id=template.id, edit_template=True )}">Edit this folder's information template</a>
- %else:
+ %elif not folder.library_folder_info_associations:
+ ## Only allow adding a new template to the folder if a previously inherited template has not already been used
<a class="action-button" href="${h.url_for( controller='admin', action='info_template', library_id=library_id, folder_id=folder.id, new_template=True )}">Add an information template to this folder</a>
%endif
<a class="action-button" href="${h.url_for( controller='admin', action='folder', permissions=True, id=folder.id, library_id=library_id )}">Edit this folder's permissions</a>
diff -r 1a82088aac38 -r 386e245f8076 templates/admin/library/common.mako
--- a/templates/admin/library/common.mako Thu May 21 11:32:25 2009 -0400
+++ b/templates/admin/library/common.mako Thu May 21 15:48:39 2009 -0400
@@ -84,11 +84,10 @@
elif isinstance( library_item, trans.app.model.LibraryDatasetDatasetAssociation ):
library_item_type = 'library_dataset_dataset_association'
library_item_desc = 'library dataset'
- library_item_info_associations = library_item.library_dataset_dataset_info_associations
- elif isinstance( library_item, trans.app.model.LibraryItemInfoElement ):
- library_item_type = 'library_item_info'
- library_item_desc = 'information'
- library_item_info_associations = None
+ if library_item.library_dataset_dataset_info_associations:
+ library_item_info_associations = library_item.library_dataset_dataset_info_associations
+ elif library_item.library_dataset_dataset_info_template_associations:
+ library_item_info_associations = library_item.library_dataset_dataset_info_template_associations
%>
%if library_item_info_associations:
<p/>
@@ -100,17 +99,18 @@
<input type="hidden" name="library_item_type" value="${library_item_type}"/>
%for library_item_info_association in library_item_info_associations:
%for template_element in library_item_info_association.library_item_info.library_item_info_template.elements:
- <% element = library_item_info_association.library_item_info.get_element_by_template_element( template_element ) %>
+ <% element = library_item_info_association.library_item_info.get_element_by_template_element( template_element, create_element=True ) %>
<input type="hidden" name="id" value="${element.id}"/>
<div class="form-row">
- <label>
- ${template_element.name}:
- <a id="element-${element.id}-popup" class="popup-arrow" style="display: none;">▼</a>
- <div popupmenu="element-${element.id}-popup">
- <a class="action-button" href="${h.url_for( controller='admin', action='library_item_info', library_id=library_id, id=element.id, library_item_type='library_item_info_elememt', permissions=True )}">Edit this information's permissions</a>
- </div>
- </label>
- <textarea name="info_element_${element.id}" rows="3" cols="35">${element.contents}</textarea>
+ <label>${template_element.name}:</label>
+ %if element.contents:
+ <textarea name="info_element_${element.id}" rows="3" cols="35">${element.contents}</textarea>
+ %else:
+ <textarea name="info_element_${element.id}" rows="3" cols="35"></textarea>
+ %endif
+ <div class="toolParamHelp" style="clear: both;">
+ ${template_element.description}
+ </div>
<div style="clear: both"></div>
</div>
%endfor
@@ -145,11 +145,10 @@
elif isinstance( library_item, trans.app.model.LibraryDatasetDatasetAssociation ):
library_item_type = 'library_dataset_dataset_association'
library_item_desc = 'library dataset'
- library_item_info_associations = library_item.library_dataset_dataset_info_associations
- elif isinstance( library_item, trans.app.model.LibraryItemInfoElement ):
- library_item_type = 'library_item_info'
- library_item_desc = 'information'
- library_item_info_associations = None
+ if library_item.library_dataset_dataset_info_associations:
+ library_item_info_associations = library_item.library_dataset_dataset_info_associations
+ elif library_item.library_dataset_dataset_info_template_associations:
+ library_item_info_associations = library_item.library_dataset_dataset_info_template_associations
%>
%if library_item_info_associations:
<p/>
@@ -158,11 +157,16 @@
<div class="toolFormBody">
%for library_item_info_association in library_item_info_associations:
%for template_element in library_item_info_association.library_item_info.library_item_info_template.elements:
- <% element = library_item_info_association.library_item_info.get_element_by_template_element( template_element ) %>
+ <% element = library_item_info_association.library_item_info.get_element_by_template_element( template_element, create_element=True ) %>
<div class="form-row">
<label>${template_element.name}:</label>
- <div style="float: left; width: 250px; margin-right: 10px;">
- ${element.contents}
+ %if element.contents:
+ <div style="float: left; width: 250px; margin-right: 10px;">
+ ${element.contents}
+ </div>
+ %endif
+ <div class="toolParamHelp" style="clear: both;">
+ ${template_element.description}
</div>
<div style="clear: both"></div>
</div>
diff -r 1a82088aac38 -r 386e245f8076 templates/admin/library/edit_info_template.mako
--- a/templates/admin/library/edit_info_template.mako Thu May 21 11:32:25 2009 -0400
+++ b/templates/admin/library/edit_info_template.mako Thu May 21 15:48:39 2009 -0400
@@ -24,12 +24,12 @@
<input type="hidden" name="id" value="${liit.id}"/>
<input type="hidden" name="set_num_fields" value="${num_fields}"/>
<div class="form-row">
- <b>Template name:</b>
+ <label>Template name:</label>
<input type="text" name="name" value="${liit.name}" size="40"/>
<div style="clear: both"></div>
</div>
<div class="form-row">
- <b>Template description (optional):</b>
+ <label>Template description (optional):</label>
<input type="text" name="description" value="${liit.description}" size="40"/>
<div style="clear: both"></div>
</div>
@@ -39,9 +39,9 @@
%for template_element in liit.elements:
<input type="hidden" name="element_ids" value="${template_element.id}"/>
<div class="form-row">
- <b>Field label:</b>
+ <label>Field label:</label>
<input type="text" name="element_name_${template_element.id}" value="${template_element.name}" size="40"/>
- <b>Field help text (optional):</b>
+ <label>Field help text (optional):</label>
<input type="text" name="element_description_${template_element.id}" value="${template_element.description}" size="40"/>
<div style="clear: both"></div>
</div>
@@ -50,22 +50,26 @@
<div class="form-row">
<div class="toolFormTitle">Additional field ${1+element_count}</div>
<div class="form-row">
- <b>Field label:</b>
+ <label>Field label:</label>
<input type="text" name="new_element_name_${element_count}" value="" size="40"/>
- <b>Field help text (optional):</b>
+ <label>Field help text (optional):</label>
<input type="text" name="new_element_description_${element_count}" value="" size="40"/>
<div style="clear: both"></div>
</div>
</div>
%endfor
- <div class="form-row">
- <label>Add additional fields:</label>
- <div style="float: left; width: 250px; margin-right: 10px;">
- <input type="text" name="num_fields" value="0" size="3"/>
+ %if define_or_save == 'define':
+ <div class="form-row">
+ <label>Add additional fields:</label>
+ <div style="float: left; width: 250px; margin-right: 10px;">
+ <input type="text" name="num_fields" value="0" size="3"/>
+ </div>
+ <div style="clear: both"></div>
</div>
- <div style="clear: both"></div>
- </div>
- <input type="submit" name="edit_info_template_button" value="Save"/>
+ <input type="submit" name="edit_info_template_button" value="Define fields"/>
+ %else:
+ <input type="submit" name="edit_info_template_button" value="Save"/>
+ %endif
</div>
</form>
</div>
diff -r 1a82088aac38 -r 386e245f8076 templates/admin/library/folder_info.mako
--- a/templates/admin/library/folder_info.mako Thu May 21 11:32:25 2009 -0400
+++ b/templates/admin/library/folder_info.mako Thu May 21 15:48:39 2009 -0400
@@ -43,5 +43,6 @@
%elif folder.library_folder_info_template_associations:
${render_available_templates( folder, library_id, restrict=True )}
%else:
+ ## Look for any inheritable templates
${render_available_templates( folder, library_id, restrict=False )}
%endif
diff -r 1a82088aac38 -r 386e245f8076 templates/admin/library/ldda_edit_info.mako
--- a/templates/admin/library/ldda_edit_info.mako Thu May 21 11:32:25 2009 -0400
+++ b/templates/admin/library/ldda_edit_info.mako Thu May 21 15:48:39 2009 -0400
@@ -56,7 +56,11 @@
<div class="form-row">
<label>Message:</label>
<div style="float: left; width: 250px; margin-right: 10px;">
- <textarea name="message" rows="3" cols="35">${ldda.message}</textarea>
+ %if ldda.message:
+ <textarea name="message" rows="3" cols="35">${ldda.message}</textarea>
+ %else:
+ <textarea name="message" rows="3" cols="35"></textarea>
+ %endif
</div>
<div class="toolParamHelp" style="clear: both;">
This information will be displayed in the library browser
diff -r 1a82088aac38 -r 386e245f8076 templates/admin/library/new_info_template.mako
--- a/templates/admin/library/new_info_template.mako Thu May 21 11:32:25 2009 -0400
+++ b/templates/admin/library/new_info_template.mako Thu May 21 15:48:39 2009 -0400
@@ -54,13 +54,8 @@
</div>
<div class="toolFormBody">
<div class="form-row">
- <label>Add additional template fields:</label>
- <div style="float: left; width: 250px; margin-right: 10px;">
- <input type="text" name="num_fields" value="0" size="3"/>
- </div>
- <div style="clear: both"></div>
+ <input type="submit" name="new_info_template_button" value="Save"/>
</div>
- <input type="submit" name="new_info_template_button" value="Save"/>
</div>
</form>
</div>
diff -r 1a82088aac38 -r 386e245f8076 templates/library/browse_library.mako
--- a/templates/library/browse_library.mako Thu May 21 11:32:25 2009 -0400
+++ b/templates/library/browse_library.mako Thu May 21 15:48:39 2009 -0400
@@ -105,26 +105,26 @@
</script>
<![endif]>
-<%def name="render_folder( parent, parent_pad, created_ldda_ids, library_id )">
+<%def name="render_folder( folder, folder_pad, created_ldda_ids, library_id )">
<%
def show_folder():
- if trans.app.security_agent.check_folder_contents( trans.user, parent ) or trans.app.security_agent.show_library_item( trans.user, parent ):
+ if trans.app.security_agent.check_folder_contents( trans.user, folder ) or trans.app.security_agent.show_library_item( trans.user, folder ):
return True
return False
if not show_folder:
return ""
- root_folder = not parent.parent
+ root_folder = not folder.parent
if root_folder:
- pad = parent_pad
+ pad = folder_pad
else:
- pad = parent_pad + 20
- if parent_pad == 0:
+ pad = folder_pad + 20
+ if folder_pad == 0:
expander = "/static/images/silk/resultset_bottom.png"
- folder = "/static/images/silk/folder_page.png"
+ folder_img = "/static/images/silk/folder_page.png"
subfolder = False
else:
expander = "/static/images/silk/resultset_next.png"
- folder = "/static/images/silk/folder.png"
+ folder_img = "/static/images/silk/folder.png"
subfolder = True
created_ldda_id_list = util.listify( created_ldda_ids )
if created_ldda_id_list:
@@ -134,34 +134,35 @@
<li class="folderRow libraryOrFolderRow" style="padding-left: ${pad}px;">
<input type="checkbox" class="folderCheckbox" style="float: left;"/>
<div class="rowTitle">
- <span class="expandLink"><img src="${h.url_for( expander )}" class="expanderIcon"/><img src="${h.url_for( folder )}" class="rowIcon"/>
- ${parent.name}
- %if parent.description:
- <i>- ${parent.description}</i>
+ <span class="expandLink"><img src="${h.url_for( expander )}" class="expanderIcon"/><img src="${h.url_for( folder_img )}" class="rowIcon"/>
+ ${folder.name}
+ %if folder.description:
+ <i>- ${folder.description}</i>
%endif
- <a id="folder-${parent.id}-popup" class="popup-arrow" style="display: none;">▼</a>
- <div popupmenu="folder-${parent.id}-popup">
- %if trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_ADD, library_item=parent ):
- <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library_id, folder_id=parent.id )}">Add datasets to this folder</a>
- <a class="action-button" href="${h.url_for( controller='library', action='folder', new=True, id=parent.id, library_id=library_id )}">Create a new sub-folder in this folder</a>
+ <a id="folder_img-${folder.id}-popup" class="popup-arrow" style="display: none;">▼</a>
+ <div popupmenu="folder_img-${folder.id}-popup">
+ %if trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_ADD, library_item=folder ):
+ <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder.id )}">Add datasets to this folder</a>
+ <a class="action-button" href="${h.url_for( controller='library', action='folder', new=True, id=folder.id, library_id=library_id )}">Create a new sub-folder in this folder</a>
%endif
- %if trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_MODIFY, library_item=parent ):
- <a class="action-button" href="${h.url_for( controller='library', action='folder', information=True, id=parent.id, library_id=library_id )}">Edit this folder's information</a>
+ %if trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_MODIFY, library_item=folder ):
+ <a class="action-button" href="${h.url_for( controller='library', action='folder', information=True, id=folder.id, library_id=library_id )}">Edit this folder's information</a>
%else:
- <a class="action-button" href="${h.url_for( controller='library', action='folder', information=True, id=parent.id, library_id=library_id )}">View this folder's information</a>
+ <a class="action-button" href="${h.url_for( controller='library', action='folder', information=True, id=folder.id, library_id=library_id )}">View this folder's information</a>
%endif
- %if parent.library_folder_info_template_associations:
- %if trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_MODIFY, library_item=parent ):
- <% template = parent.get_library_item_info_templates( template_list=[], restrict=True )[0] %>
+ %if folder.library_folder_info_template_associations:
+ %if trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_MODIFY, library_item=folder ):
+ <% template = folder.get_library_item_info_templates( template_list=[], restrict=True )[0] %>
<a class="action-button" href="${h.url_for( controller='library', action='info_template', library_id=library.id, id=template.id, edit_template=True )}">Edit this folder's information template</a>
%endif
- %else:
- %if trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_ADD, library_item=parent ):
- <a class="action-button" href="${h.url_for( controller='library', action='info_template', library_id=library.id, folder_id=parent.id, new_template=True )}">Add an information template to this folder</a>
+ %elif not folder.library_folder_info_associations:
+ ## Only allow adding a new template to the folder if a previously inherited template has not already been used
+ %if trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_ADD, library_item=folder ):
+ <a class="action-button" href="${h.url_for( controller='library', action='info_template', library_id=library.id, folder_id=folder.id, new_template=True )}">Add an information template to this folder</a>
%endif
%endif
- %if trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_MANAGE, library_item=parent ):
- <a class="action-button" href="${h.url_for( controller='library', action='folder', permissions=True, id=parent.id, library_id=library_id )}">Edit this folder's permissions</a>
+ %if trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_MANAGE, library_item=folder ):
+ <a class="action-button" href="${h.url_for( controller='library', action='folder', permissions=True, id=folder.id, library_id=library_id )}">Edit this folder's permissions</a>
%endif
</div>
</div>
@@ -172,10 +173,10 @@
%else:
<ul>
%endif
- %for folder in name_sorted( parent.active_folders ):
- ${render_folder( folder, pad, created_ldda_ids, library_id )}
+ %for child_folder in name_sorted( folder.active_folders ):
+ ${render_folder( child_folder, pad, created_ldda_ids, library_id )}
%endfor
- %for library_dataset in name_sorted( parent.active_datasets ):
+ %for library_dataset in name_sorted( folder.active_datasets ):
<%
selected = created_ldda_ids and library_dataset.library_dataset_dataset_association.id in created_ldda_ids
%>
diff -r 1a82088aac38 -r 386e245f8076 templates/library/common.mako
--- a/templates/library/common.mako Thu May 21 11:32:25 2009 -0400
+++ b/templates/library/common.mako Thu May 21 15:48:39 2009 -0400
@@ -80,11 +80,10 @@
elif isinstance( library_item, trans.app.model.LibraryDatasetDatasetAssociation ):
library_item_type = 'library_dataset_dataset_association'
library_item_desc = 'library dataset'
- library_item_info_associations = library_item.library_dataset_dataset_info_associations
- elif isinstance( library_item, trans.app.model.LibraryItemInfoElement ):
- library_item_type = 'library_item_info'
- library_item_desc = 'information'
- library_item_info_associations = None
+ if library_item.library_dataset_dataset_info_associations:
+ library_item_info_associations = library_item.library_dataset_dataset_info_associations
+ elif library_item.library_dataset_dataset_info_template_associations:
+ library_item_info_associations = library_item.library_dataset_dataset_info_template_associations
%>
%if library_item_info_associations:
<p/>
@@ -94,44 +93,28 @@
<form name="edit_info" action="${h.url_for( controller='library', action='library_item_info', library_id=library_id, edit_info=True )}" method="post">
<input type="hidden" name="library_item_id" value="${library_item.id}"/>
<input type="hidden" name="library_item_type" value="${library_item_type}"/>
- <% render_submit_button = False %>
%for library_item_info_association in library_item_info_associations:
%for template_element in library_item_info_association.library_item_info.library_item_info_template.elements:
- <% element = library_item_info_association.library_item_info.get_element_by_template_element( template_element ) %>
+ <% element = library_item_info_association.library_item_info.get_element_by_template_element( template_element, create_element=True ) %>
<input type="hidden" name="id" value="${element.id}"/>
- <%
- can_add = trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_ADD, library_item=element.library_item_info )
- can_modify = trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_MODIFY, library_item=element.library_item_info )
- can_manage = trans.app.security_agent.allow_action( trans.user, trans.app.security_agent.permitted_actions.LIBRARY_MANAGE, library_item=element.library_item_info )
- %>
<div class="form-row">
- %if can_manage:
- <label>
- ${template_element.name}:
- <a id="element-${element.id}-popup" class="popup-arrow" style="display: none;">▼</a>
- <div popupmenu="element-${element.id}-popup">
- <a class="action-button" href="${h.url_for( controller='admin', action='library_item_info', library_id=library_id, id=element.id, library_item_type='library_item_info_elememt', permissions=True )}">Edit this information's permissions</a>
- </div>
- </label>
+ <label>${template_element.name}:</label>
+ %if element.contents:
+ <textarea name="info_element_${element.id}" rows="3" cols="35">${element.contents}</textarea>
%else:
- <label>${template_element.name}:</label>
+ <textarea name="info_element_${element.id}" rows="3" cols="35"></textarea>
%endif
- %if can_modify:
- <textarea name="info_element_${element.id}" rows="3" cols="35">${element.contents}</textarea>
- <% render_submit_button = True %>
- %else:
- ${element.contents}
- %endif
+ <div class="toolParamHelp" style="clear: both;">
+ ${template_element.description}
+ </div>
<div style="clear: both"></div>
</div>
%endfor
<div style="clear: both"></div>
%endfor
- %if render_submit_button:
- <div class="form-row">
- <input type="submit" name="edit_info_button" value="Save"/>
- </div>
- %endif
+ <div class="form-row">
+ <input type="submit" name="edit_info_button" value="Save"/>
+ </div>
</form>
</div>
</div>
@@ -158,11 +141,10 @@
elif isinstance( library_item, trans.app.model.LibraryDatasetDatasetAssociation ):
library_item_type = 'library_dataset_dataset_association'
library_item_desc = 'library dataset'
- library_item_info_associations = library_item.library_dataset_dataset_info_associations
- elif isinstance( library_item, trans.app.model.LibraryItemInfoElement ):
- library_item_type = 'library_item_info'
- library_item_desc = 'information'
- library_item_info_associations = None
+ if library_item.library_dataset_dataset_info_associations:
+ library_item_info_associations = library_item.library_dataset_dataset_info_associations
+ elif library_item.library_dataset_dataset_info_template_associations:
+ library_item_info_associations = library_item.library_dataset_dataset_info_template_associations
%>
%if library_item_info_associations:
<p/>
@@ -171,11 +153,14 @@
<div class="toolFormBody">
%for library_item_info_association in library_item_info_associations:
%for template_element in library_item_info_association.library_item_info.library_item_info_template.elements:
- <% element = library_item_info_association.library_item_info.get_element_by_template_element( template_element ) %>
+ <% element = library_item_info_association.library_item_info.get_element_by_template_element( template_element, create_element=True ) %>
<div class="form-row">
<label>${template_element.name}:</label>
<div style="float: left; width: 250px; margin-right: 10px;">
${element.contents}
+ </div>
+ <div class="toolParamHelp" style="clear: both;">
+ ${template_element.description}
</div>
<div style="clear: both"></div>
</div>
diff -r 1a82088aac38 -r 386e245f8076 templates/library/edit_info_template.mako
--- a/templates/library/edit_info_template.mako Thu May 21 11:32:25 2009 -0400
+++ b/templates/library/edit_info_template.mako Thu May 21 15:48:39 2009 -0400
@@ -27,12 +27,12 @@
<input type="hidden" name="id" value="${liit.id}"/>
<input type="hidden" name="set_num_fields" value="${num_fields}"/>
<div class="form-row">
- <b>Template name:</b>
+ <label>Template name:</label>
<input type="text" name="name" value="${liit.name}" size="40"/>
<div style="clear: both"></div>
</div>
<div class="form-row">
- <b>Template description (optional):</b>
+ <label>Template description (optional):</label>
<input type="text" name="description" value="${liit.description}" size="40"/>
<div style="clear: both"></div>
</div>
@@ -42,9 +42,9 @@
%for template_element in liit.elements:
<input type="hidden" name="element_ids" value="${template_element.id}"/>
<div class="form-row">
- <b>Field label:</b>
+ <label>Field label:</label>
<input type="text" name="element_name_${template_element.id}" value="${template_element.name}" size="40"/>
- <b>Field help text (optional):</b>
+ <label>Field help text (optional):</label>
<input type="text" name="element_description_${template_element.id}" value="${template_element.description}" size="40"/>
<div style="clear: both"></div>
</div>
@@ -53,22 +53,26 @@
<div class="form-row">
<div class="toolFormTitle">Additional field ${1+element_count}</div>
<div class="form-row">
- <b>Field label:</b>
+ <label>Field label:</label>
<input type="text" name="new_element_name_${element_count}" value="" size="40"/>
- <b>Field help text (optional):</b>
+ <label>Field help text (optional):</label>
<input type="text" name="new_element_description_${element_count}" value="" size="40"/>
<div style="clear: both"></div>
</div>
</div>
%endfor
- <div class="form-row">
- <label>Add additional fields:</label>
- <div style="float: left; width: 250px; margin-right: 10px;">
- <input type="text" name="num_fields" value="0" size="3"/>
+ %if define_or_save == 'define':
+ <div class="form-row">
+ <label>Add additional fields:</label>
+ <div style="float: left; width: 250px; margin-right: 10px;">
+ <input type="text" name="num_fields" value="0" size="3"/>
+ </div>
+ <div style="clear: both"></div>
</div>
- <div style="clear: both"></div>
- </div>
- <input type="submit" name="edit_info_template_button" value="Save"/>
+ <input type="submit" name="edit_info_template_button" value="Define fields"/>
+ %else:
+ <input type="submit" name="edit_info_template_button" value="Save"/>
+ %endif
</div>
</form>
%else:
diff -r 1a82088aac38 -r 386e245f8076 templates/library/ldda_edit_info.mako
--- a/templates/library/ldda_edit_info.mako Thu May 21 11:32:25 2009 -0400
+++ b/templates/library/ldda_edit_info.mako Thu May 21 15:48:39 2009 -0400
@@ -56,7 +56,11 @@
<div class="form-row">
<label>Message:</label>
<div style="float: left; width: 250px; margin-right: 10px;">
- <textarea name="message" rows="3" cols="35">${ldda.message}</textarea>
+ %if ldda.message:
+ <textarea name="message" rows="3" cols="35">${ldda.message}</textarea>
+ %else:
+ <textarea name="message" rows="3" cols="35"></textarea>
+ %endif
</div>
<div class="toolParamHelp" style="clear: both;">
This information will be displayed in the library browser
@@ -116,7 +120,7 @@
<p/>
%else:
<div class="toolForm">
- <div class="toolFormTitle">View attributes of ${ldda.name}</div>
+ <div class="toolFormTitle">View information about ${ldda.name}</div>
<div class="toolFormBody">
<div class="form-row">
<b>Name:</b> ${ldda.name}
diff -r 1a82088aac38 -r 386e245f8076 templates/library/library_dataset_info.mako
--- a/templates/library/library_dataset_info.mako Thu May 21 11:32:25 2009 -0400
+++ b/templates/library/library_dataset_info.mako Thu May 21 15:48:39 2009 -0400
@@ -47,7 +47,7 @@
</div>
%else:
<div class="toolForm">
- <div class="toolFormTitle">View attributes of ${library_dataset.name}</div>
+ <div class="toolFormTitle">View information about ${library_dataset.name}</div>
<div class="toolFormBody">
<div class="form-row">
<b>Name:</b> ${library_dataset.name}
diff -r 1a82088aac38 -r 386e245f8076 templates/library/new_info_template.mako
--- a/templates/library/new_info_template.mako Thu May 21 11:32:25 2009 -0400
+++ b/templates/library/new_info_template.mako Thu May 21 15:48:39 2009 -0400
@@ -55,13 +55,8 @@
</div>
<div class="toolFormBody">
<div class="form-row">
- <label>Add additional template fields:</label>
- <div style="float: left; width: 250px; margin-right: 10px;">
- <input type="text" name="num_fields" value="0" size="3"/>
- </div>
- <div style="clear: both"></div>
+ <input type="submit" name="new_info_template_button" value="Save"/>
</div>
- <input type="submit" name="new_info_template_button" value="Save"/>
</div>
</form>
%else:
diff -r 1a82088aac38 -r 386e245f8076 test/base/twilltestcase.py
--- a/test/base/twilltestcase.py Thu May 21 11:32:25 2009 -0400
+++ b/test/base/twilltestcase.py Thu May 21 15:48:39 2009 -0400
@@ -816,6 +816,19 @@
tc.fv( "1", "2", description ) # form field 1 is the field named name...
tc.submit( "create_library_button" )
self.home()
+ def set_library_permissions( self, library_id, library_name, role_id, permissions_in, permissions_out ):
+ url = "admin/library?id=%s&permissions=True&update_roles_button=Save" % ( library_id )
+ for po in permissions_out:
+ key = '%s_out' % po
+ url ="%s&%s=%s" % ( url, key, str( role_id ) )
+ for pi in permissions_in:
+ key = '%s_in' % pi
+ url ="%s&%s=%s" % ( url, key, str( role_id ) )
+ self.home()
+ self.visit_url( "%s/%s" % ( self.url, url ) )
+ check_str = "Permissions updated for library '%s'" % library_name
+ self.check_page_for_string( check_str )
+ self.home()
def rename_library( self, library_id, old_name, name='Library One Renamed', description='This is Library One Re-described' ):
"""Rename a library"""
self.home()
@@ -829,16 +842,71 @@
check_str = "Library '%s' has been renamed to '%s'" % ( old_name, name )
self.check_page_for_string( check_str )
self.home()
- def add_library_info_template( self, library_id, library_name ):
+ def add_library_info_template( self, library_id, library_name, num_fields='2', name='Library Template 1', ele_name_0='Foo', ele_name_1='Doh' ):
"""Add a new info template to a library"""
self.home()
url = "%s/admin/info_template?library_id=%s&new_template=True&num_fields=2&create_info_template_button=Go" % ( self.url, library_id )
- self.home()
self.visit_url( url )
check_str = "Create a new information template for library '%s'" % library_name
self.check_page_for_string ( check_str )
- # TODO: finish this...
- def add_folder_info_template( self, library_id, library_name, folder_id, folder_name ):
+ tc.fv( '1', 'library_id', library_id )
+ tc.fv( '1', 'set_num_fields', num_fields )
+ tc.fv( '1', 'name', name )
+ tc.fv( '1', 'new_element_name_0', ele_name_0 )
+ tc.fv( '1', 'new_element_name_1', ele_name_1 )
+ tc.submit( 'new_info_template_button' )
+ self.home()
+ def add_library_info_template_element( self, library_id, template_id, template_name, ele_name_1, ele_desc_1,
+ ele_name_2, ele_desc_2, new_ele_name='Fubar', new_ele_desc='This is the Fubar compnent' ):
+ """Add a new element to an existing library info template"""
+ self.home()
+ url = "%s/admin/info_template?library_id=%s&id=%s&edit_template=True&num_fields=1&edit_info_template_button=Save" % \
+ ( self.url, library_id, template_id )
+ self.visit_url( url )
+ check_str = "Edit template '%s'" % template_name
+ self.check_page_for_string ( check_str )
+ tc.fv( '1', 'id', template_id )
+ tc.fv( '1', 'set_num_fields', '0' )
+ tc.fv( '1', 'name', template_name )
+ tc.fv( '1', 'element_name_1', ele_name_1 )
+ tc.fv( '1', 'element_description_1', ele_desc_1 )
+ tc.fv( '1', 'element_name_2', ele_name_2 )
+ tc.fv( '1', 'element_description_2', ele_desc_2 )
+ tc.fv( '1', 'new_element_name_0', new_ele_name )
+ tc.fv( '1', 'new_element_description_0', new_ele_desc )
+ tc.submit( 'edit_info_template_button' )
+ check_str = "Information template '%s' has been updated" % template_name
+ self.check_page_for_string( check_str )
+ self.home()
+ def edit_library_info( self, library_id, library_name, ele_1_field_name, ele_1_contents, ele_2_field_name, ele_2_contents ):
+ """Add information to a library using an existing template with 2 elements"""
+ self.home()
+ self.visit_url( "%s/admin/library?information=True&id=%s" % ( self.url, library_id ) )
+ check_str = 'Other information about library %s' % library_name
+ self.check_page_for_string( check_str )
+ tc.fv( '2', ele_1_field_name, ele_1_contents )
+ tc.fv( '2', ele_2_field_name, ele_2_contents )
+ tc.submit( 'create_new_info_button' )
+ self.home()
+ def edit_library_info_template( self, library_id, id, name, name_1, desc_1, name_2, desc_2 ):
+ """Edit an existing library info template"""
+ self.home()
+ url = "%s/admin/info_template?library_id=%s&id=%s&edit_template=True" % ( self.url, library_id, id )
+ self.visit_url( url )
+ self.check_page_for_string ( 'Edit template' )
+ tc.fv( '1', 'id', id )
+ tc.fv( '1', 'set_num_fields', '0' )
+ tc.fv( '1', 'name', name )
+ tc.fv( '1', 'element_name_1', name_1 )
+ tc.fv( '1', 'element_description_1', desc_1 )
+ tc.fv( '1', 'element_name_2', name_2 )
+ tc.fv( '1', 'element_description_2', desc_2 )
+ tc.submit( 'edit_info_template_button' )
+ check_str = "Information template '%s' has been updated" % name
+ self.check_page_for_string( check_str )
+ self.home()
+ def add_folder_info_template( self, library_id, library_name, folder_id, folder_name, num_fields='2',
+ name='Folder Template 1', ele_name_0='Fu', ele_help_0='', ele_name_1='Bar', ele_help_1='' ):
"""Add a new info template to a folder"""
self.home()
url = "%s/admin/info_template?library_id=%s&folder_id=%s&new_template=True&num_fields=2&create_info_template_button=Go" % \
@@ -847,7 +915,16 @@
self.visit_url( url )
check_str = "Create a new information template for folder '%s'" % folder_name
self.check_page_for_string ( check_str )
- # TODO: finish this...
+ tc.fv( '1', 'library_id', library_id )
+ tc.fv( '1', 'folder_id', folder_id )
+ tc.fv( '1', 'set_num_fields', num_fields )
+ tc.fv( '1', 'name', name )
+ tc.fv( '1', 'new_element_name_0', ele_name_0 )
+ tc.fv( '1', 'new_element_description_0', ele_help_0.replace( '+', ' ' ) )
+ tc.fv( '1', 'new_element_name_1', ele_name_1 )
+ tc.fv( '1', 'new_element_description_1', ele_help_1.replace( '+', ' ' ) )
+ tc.submit( 'new_info_template_button' )
+ self.home()
def add_folder( self, library_id, folder_id, name='Folder One', description='NThis is Folder One' ):
"""Create a new folder"""
self.home()
@@ -870,16 +947,27 @@
check_str = "Folder '%s' has been renamed to '%s'" % ( old_name, name )
self.check_page_for_string( check_str )
self.home()
- def add_library_dataset( self, filename, library_id, folder_id, folder_name, file_format='auto', dbkey='hg18', roles=[], message='', root=False ):
+ def add_library_dataset( self, filename, library_id, folder_id, folder_name, file_format='auto',
+ dbkey='hg18', roles=[], message='', root=False, check_template_str1='', check_template_str2='',
+ check_template_str3='' ):
"""Add a dataset to a folder"""
filename = self.get_filename( filename )
self.home()
- self.visit_url( "%s/admin/library_dataset_dataset_association?upload_option=upload_file&library_id=%s&folder_id=%s&message=%s" % ( self.url, library_id, folder_id, message ) )
+ self.visit_url( "%s/admin/library_dataset_dataset_association?upload_option=upload_file&library_id=%s&folder_id=%s&message=%s" % \
+ ( self.url, library_id, folder_id, message ) )
self.check_page_for_string( 'Upload files' )
+ # If we've been sent some template labels, make sure they are included in the upload form
+ if check_template_str1:
+ self.check_page_for_string( check_template_str1 )
+ if check_template_str2:
+ self.check_page_for_string( check_template_str2 )
+ if check_template_str3:
+ self.check_page_for_string( check_template_str3 )
tc.fv( "1", "folder_id", folder_id )
tc.formfile( "1", "file_data", filename )
tc.fv( "1", "file_format", file_format )
tc.fv( "1", "dbkey", dbkey )
+ tc.fv( "1", "message", message.replace( '+', ' ' ) )
for role_id in roles:
tc.fv( "1", "roles", role_id ) # form field 7 is the select list named out_groups, note the buttons...
tc.submit( "new_dataset_button" )
@@ -887,6 +975,125 @@
check_str = "Added 1 datasets to the library '%s' ( each is selected )." % folder_name
else:
check_str = "Added 1 datasets to the folder '%s' ( each is selected )." % folder_name
+ self.check_page_for_string( check_str )
+ self.home()
+ def set_library_dataset_permissions( self, library_id, folder_id, ldda_id, ldda_name, role_id, permissions_in, permissions_out ):
+ url = "admin/library_dataset_dataset_association?library_id=%s&folder_id=%s&&id=%s&permissions=True&update_roles_button=Save" % \
+ ( library_id, folder_id, ldda_id )
+ #role_ids = util.listify( role_ids )
+ #for role_id in role_ids:
+ for po in permissions_out:
+ key = '%s_out' % po
+ url ="%s&%s=%s" % ( url, key, str( role_id ) )
+ for pi in permissions_in:
+ key = '%s_in' % pi
+ url ="%s&%s=%s" % ( url, key, str( role_id ) )
+ print url
+ self.home()
+ self.visit_url( "%s/%s" % ( self.url, url ) )
+ check_str = "Permissions updated for dataset '%s'" % ldda_name
+ self.check_page_for_string( check_str )
+ self.home()
+ def edit_ldda_template_element_info( self, library_id, folder_id, ldda_id, ldda_name, ele_1_field_name,
+ ele_1_contents, ele_2_field_name, ele_2_contents, ele_1_help='', ele_2_help='',
+ ele_3_field_name='', ele_3_contents='', ele_3_help='' ):
+ """Edit library_dataset_dataset_association template element information"""
+ self.home()
+ self.visit_url( "%s/admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \
+ ( self.url, library_id, folder_id, ldda_id ) )
+ check_str = 'Edit attributes of %s' % ldda_name
+ self.check_page_for_string( check_str )
+ ele_1_contents = ele_1_contents.replace( '+', ' ' )
+ ele_2_contents = ele_2_contents.replace( '+', ' ' )
+ tc.fv( '4', ele_1_field_name, ele_1_contents )
+ tc.fv( '4', ele_2_field_name, ele_2_contents.replace( '+', ' ' ) )
+ if ele_3_field_name and ele_3_contents:
+ ele_3_contents = ele_3_contents.replace( '+', ' ' )
+ tc.fv( '4', ele_3_field_name, ele_3_contents )
+ tc.submit( 'edit_info_button' )
+ self.check_page_for_string( 'This is the latest version of this library dataset' )
+ self.check_page_for_string( 'The information has been updated.' )
+ self.check_page_for_string( ele_1_contents )
+ self.check_page_for_string( ele_2_contents )
+ if ele_3_field_name and ele_3_contents:
+ self.check_page_for_string( ele_3_contents )
+ if ele_1_help:
+ check_str = ele_1_help.replace( '+', ' ' )
+ self.check_page_for_string( check_str )
+ self.check_page_for_string( ele_2_contents )
+ if ele_2_help:
+ check_str = ele_2_help.replace( '+', ' ' )
+ self.check_page_for_string( check_str )
+ if ele_2_help:
+ check_str = ele_3_help.replace( '+', ' ' )
+ self.check_page_for_string( check_str )
+ self.home()
+ def edit_ldda_attribute_info( self, library_id, folder_id, ldda_id, ldda_name, new_ldda_name ):
+ """Edit library_dataset_dataset_association attribute information"""
+ self.home()
+ self.visit_url( "%s/admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \
+ ( self.url, library_id, folder_id, ldda_id ) )
+ check_str = 'Edit attributes of %s' % ldda_name
+ self.check_page_for_string( check_str )
+ tc.fv( '1', 'name', new_ldda_name )
+ tc.submit( 'save' )
+ check_str = 'Attributes updated for library dataset %s' % new_ldda_name
+ self.check_page_for_string( check_str )
+ check_str = 'Edit attributes of %s' % new_ldda_name
+ self.check_page_for_string( check_str )
+ self.home()
+ def upload_new_dataset_version( self, filename, library_id, folder_id, folder_name, library_dataset_id, ldda_name, file_format='auto',
+ dbkey='hg18', message='', check_template_str1='', check_template_str2='', check_template_str3='' ):
+ """Upload new version(s) of a dataset"""
+ self.home()
+ filename = self.get_filename( filename )
+
+ url = "%s/admin/library_dataset_dataset_association?upload_option=upload_file&library_id=%s&folder_id=%s&replace_id=%s&message=%s" % \
+ ( self.url, library_id, folder_id, library_dataset_id, message )
+ print "####url: ", url
+
+ self.visit_url( "%s/admin/library_dataset_dataset_association?upload_option=upload_file&library_id=%s&folder_id=%s&replace_id=%s&message=%s" % \
+ ( self.url, library_id, folder_id, library_dataset_id, message ) )
+ self.check_page_for_string( 'Upload files' )
+ self.check_page_for_string( 'You are currently selecting a new file to replace' )
+ self.check_page_for_string( ldda_name )
+ # If we've been sent some template labels, make sure they are included in the upload form
+ if check_template_str1:
+ self.check_page_for_string( check_template_str1 )
+ if check_template_str2:
+ self.check_page_for_string( check_template_str2 )
+ if check_template_str3:
+ self.check_page_for_string( check_template_str3 )
+ tc.formfile( "1", "file_data", filename )
+ tc.fv( "1", "file_format", file_format )
+ tc.fv( "1", "dbkey", dbkey )
+ tc.fv( "1", "message", message.replace( '+', ' ' ) )
+ tc.submit( "new_dataset_button" )
+ check_str = "Added 1 dataset versions to the library dataset '%s' in the folder '%s'." % ( ldda_name, folder_name )
+ self.check_page_for_string( check_str )
+ self.home()
+ def upload_new_dataset_versions( self, library_id, folder_id, folder_name, library_dataset_id, ldda_name, file_format='auto',
+ dbkey='hg18', message='', check_template_str1='', check_template_str2='', check_template_str3='' ):
+ """Upload new version(s) of a dataset using a directory of files"""
+ self.home()
+ self.visit_url( "%s/admin/library_dataset_dataset_association?upload_option=upload_directory&library_id=%s&folder_id=%s&replace_id=%s" \
+ % ( self.url, library_id, folder_id, library_dataset_id ) )
+ self.check_page_for_string( 'Upload a directory of files' )
+ self.check_page_for_string( 'You are currently selecting a new file to replace' )
+ # If we've been sent some template labels, make sure they are included in the upload form
+ if check_template_str1:
+ self.check_page_for_string( check_template_str1 )
+ if check_template_str2:
+ self.check_page_for_string( check_template_str2 )
+ if check_template_str3:
+ self.check_page_for_string( check_template_str3 )
+ tc.fv( "1", "file_format", file_format )
+ tc.fv( "1", "dbkey", dbkey )
+ tc.fv( "1", "message", message.replace( '+', ' ' ) )
+ library_dir = "%s" % self.file_dir
+ tc.fv( "1", "server_dir", "library" )
+ tc.submit( "new_dataset_button" )
+ check_str = "Added 3 dataset versions to the library dataset '%s' in the folder '%s'." % ( ldda_name, folder_name )
self.check_page_for_string( check_str )
self.home()
def add_history_datasets_to_library( self, library_id, folder_id, folder_name, hda_id, root=False ):
@@ -900,15 +1107,24 @@
check_str = "Added 1 datasets to the folder '%s' ( each is selected )." % folder_name
self.check_page_for_string( check_str )
self.home()
- def add_datasets_from_library_dir( self, library_id, folder_id, folder_name, file_format='auto', dbkey='hg18', roles_tuple=[], root=False ):
+ def add_datasets_from_library_dir( self, library_id, folder_id, folder_name, file_format='auto', dbkey='hg18', roles_tuple=[],
+ message='', root=False, check_template_str1='', check_template_str2='', check_template_str3='' ):
"""Add a directory of datasets to a folder"""
# roles is a list of tuples: [ ( role_id, role_description ) ]
self.home()
self.visit_url( "%s/admin/library_dataset_dataset_association?upload_option=upload_directory&library_id=%s&folder_id=%s" % ( self.url, library_id, folder_id ) )
self.check_page_for_string( 'Upload a directory of files' )
+ # If we've been sent some template labels, make sure they are included in the upload form
+ if check_template_str1:
+ self.check_page_for_string( check_template_str1 )
+ if check_template_str2:
+ self.check_page_for_string( check_template_str2 )
+ if check_template_str3:
+ self.check_page_for_string( check_template_str3 )
tc.fv( "1", "folder_id", folder_id )
tc.fv( "1", "file_format", file_format )
tc.fv( "1", "dbkey", dbkey )
+ tc.fv( "1", "message", message.replace( '+', ' ' ) )
library_dir = "%s" % self.file_dir
tc.fv( "1", "server_dir", "library" )
for role_tuple in roles_tuple:
@@ -920,18 +1136,28 @@
check_str = "Added 3 datasets to the folder '%s' ( each is selected )." % folder_name
self.check_page_for_string( check_str )
self.home()
- def mark_library_deleted( self, library_id, library_name ):
- """Mark a library as deleted"""
+ def delete_library_item( self, library_id, library_item_id, library_item_name, library_item_type='library_dataset' ):
+ """Mark a library item as deleted"""
self.home()
- self.visit_url( "%s/admin/library?id=%s&delete=True" % ( self.url, library_id ) )
- check_str = "Library '%s' and all of its contents have been marked deleted" % library_name
+ self.visit_url( "%s/admin/delete_library_item?library_id=%s&library_item_id=%s&library_item_type=%s" \
+ % ( self.url, library_id, library_item_id, library_item_type ) )
+ if library_item_type == 'library_dataset':
+ library_item_desc = 'Dataset'
+ else:
+ library_item_desc = library_item_type.capitalize()
+ check_str = "%s '%s' has been marked deleted" % ( library_item_desc, library_item_name )
self.check_page_for_string( check_str )
self.home()
- def undelete_library( self, library_id, library_name ):
- """Mark a library as not deleted"""
+ def undelete_library_item( self, library_id, library_item_id, library_item_name, library_item_type='library_dataset' ):
+ """Mark a library item as deleted"""
self.home()
- self.visit_url( "%s/admin/undelete_library?id=%s" % ( self.url, library_id ) )
- check_str = "Library '%s' and all of its contents have been marked not deleted" % library_name
+ self.visit_url( "%s/admin/undelete_library_item?library_id=%s&library_item_id=%s&library_item_type=%s" \
+ % ( self.url, library_id, library_item_id, library_item_type ) )
+ if library_item_type == 'library_dataset':
+ library_item_desc = 'Dataset'
+ else:
+ library_item_desc = library_item_type.capitalize()
+ check_str = "%s '%s' has been marked undeleted" % ( library_item_desc, library_item_name )
self.check_page_for_string( check_str )
self.home()
def purge_library( self, library_id, library_name ):
diff -r 1a82088aac38 -r 386e245f8076 test/functional/test_security_and_libraries.py
--- a/test/functional/test_security_and_libraries.py Thu May 21 11:32:25 2009 -0400
+++ b/test/functional/test_security_and_libraries.py Thu May 21 15:48:39 2009 -0400
@@ -40,6 +40,15 @@
global admin_user
admin_user = galaxy.model.User.filter( galaxy.model.User.table.c.email=='test(a)bx.psu.edu' ).first()
assert admin_user is not None, 'Problem retrieving user with email "test(a)bx.psu.edu" from the database'
+ # Get the admin user's privat role for later use
+ global admin_user_private_role
+ admin_user_private_role = None
+ for role in admin_user.all_roles():
+ if role.name == admin_user.email and role.description == 'Private Role for %s' % admin_user.email:
+ admin_user_private_role = role
+ break
+ if not admin_user_private_role:
+ raise AssertionError( "Private role not found for user '%s'" % admin_user.email )
# Make sure DefaultUserPermissions are correct
if len( admin_user.default_permissions ) > 1:
raise AssertionError( '%d DefaultUserPermissions were created for %s when their account was created ( should have been 1 )' \
@@ -168,14 +177,14 @@
actions_in = [ 'manage permissions' ]
permissions_out = [ 'DATASET_ACCESS' ]
actions_out = [ 'access' ]
- private_role = None
+ regular_user2_private_role = None
for role in regular_user2.all_roles():
if role.name == regular_user2.email and role.description == 'Private Role for %s' % regular_user2.email:
- private_role = role
+ regular_user2_private_role = role
break
- if not private_role:
+ if not regular_user2_private_role:
raise AssertionError( "Private role not found for user '%s'" % regular_user2.email )
- role_id = str( private_role.id )
+ role_id = str( regular_user2_private_role.id )
# Change DefaultHistoryPermissions for the current history
self.history_set_default_permissions( permissions_out=permissions_out, permissions_in=permissions_in, role_id=role_id )
if len( latest_history.default_permissions ) != len( actions_in ):
@@ -283,11 +292,12 @@
"""Testing undeleting a user account"""
self.undelete_user( user_id=regular_user3.id, email=regular_user3.email )
def test_045_create_role( self ):
- """Testing creating new role with 3 members, then renaming it"""
+ """Testing creating new role with 3 members ( and a new group named the same ), then renaming the role"""
name = 'Role One'
description = "This is Role Ones description"
user_ids=[ str( admin_user.id ), str( regular_user1.id ), str( regular_user3.id ) ]
- self.create_role( name=name, description=description, in_user_ids=user_ids, in_group_ids=[], private_role=admin_user.email )
+ self.create_role( name=name, description=description, in_user_ids=user_ids, in_group_ids=[],
+ create_group_for_role='yes', private_role=admin_user.email )
# Get the role object for later tests
global role_one
role_one = galaxy.model.Role.filter( galaxy.model.Role.table.c.name==name ).first()
@@ -308,6 +318,12 @@
if len( user.roles ) != 2:
raise AssertionError( '%d UserRoleAssociations are associated with user %s ( should be 2 )' \
% ( len( user.roles ), user.email ) )
+ # Make sure the group was created
+ self.home()
+ self.visit_page( 'admin/groups' )
+ self.check_page_for_string( name )
+ global group_zero
+ group_zero = galaxy.model.Group.filter( galaxy.model.Group.table.c.name==name ).first()
# Rename the role
rename = "Role One's been Renamed"
redescription="This is Role One's Re-described"
@@ -430,7 +446,7 @@
if len( admin_user.roles ) != 5:
raise AssertionError( '%d UserRoleAssociations are associated with %s ( should be 5 )' % ( len( admin_user.roles ), admin_user.email ) )
def test_070_create_library( self ):
- """Testing creating a new library, then renaming it and renaming the root folder"""
+ """Testing creating a new library, then renaming it"""
name = "Library One's Name"
description = "This is Library One's description"
self.create_library( name=name, description=description )
@@ -443,6 +459,12 @@
galaxy.model.Library.table.c.description==description,
galaxy.model.Library.table.c.deleted==False ) ).first()
assert library_one is not None, 'Problem retrieving library named "%s" from the database' % name
+ # Set permissions on the library, sort for later testing
+ permissions_in = [ k for k, v in galaxy.model.Library.permitted_actions.items() ]
+ permissions_out = []
+ # Role one members are: admin_user, regular_user1, regular_user3. Each of these users will be permitted to
+ # LIBRARY_ADD, LIBRARY_MODIFY, LIBRARY_MANAGE for library items.
+ self.set_library_permissions( str( library_one.id ), library_one.name, str( role_one.id ), permissions_in, permissions_out )
# Rename the library
rename = "Library One's been Renamed"
redescription = "This is Library One's Re-described"
@@ -455,9 +477,149 @@
library_one.refresh()
self.rename_library( str( library_one.id ), library_one.name, name=name, description=description )
library_one.refresh()
- def test_075_add_new_folder_to_root_folder( self ):
+ def test_075_library_template_features( self ):
+ """Testing adding a template to a library, along with template features on the admin side"""
+ actions = [ v.action for k, v in galaxy.model.Library.permitted_actions.items() ]
+ actions.sort()
+ # Add a new information template to the library
+ template_name = 'Library Template 1'
+ ele_name_0 = 'Foo'
+ ele_name_1 = 'Doh'
+ self.add_library_info_template( library_one.id, library_one.name, name=template_name, num_fields='2', ele_name_0=ele_name_0, ele_name_1=ele_name_1 )
+ self.home()
+ self.visit_url( '%s/admin/library?id=%s&information=True' % ( self.url, str( library_one.id ) ) )
+ self.check_page_for_string( ele_name_0 )
+ self.check_page_for_string( ele_name_1 )
+ self.home()
+ # Get the template for later testing
+ global library_one_template
+ library_one_template = galaxy.model.LibraryItemInfoTemplate.query().order_by( desc( galaxy.model.LibraryItemInfoTemplate.table.c.id ) ).first()
+ assert library_one_template is not None, 'Problem retrieving LibraryItemInfoTemplate for library named "%s" from the database' % str( library_one.name )
+ # Make sure the library permissions were inherited by the template
+ template_permissions = galaxy.model.LibraryItemInfoTemplatePermissions \
+ .query() \
+ .filter( galaxy.model.LibraryItemInfoTemplatePermissions.table.c.library_item_info_template_id == library_one_template.id ) \
+ .order_by( desc( galaxy.model.LibraryItemInfoTemplatePermissions.table.c.id ) ) \
+ .limit( 3 ) \
+ .all()
+ template_permissions = [ litp_obj.action for litp_obj in template_permissions ]
+ template_permissions.sort()
+ assert actions == template_permissions, "Template permissions for template %s not correctly inherited from library %s" \
+ % ( library_one_template.name, library_one.name )
+ # Make sure that the library permissions were inherited by each of the template elements
+ for library_item_info in library_one_template.library_item_infos:
+ info_permissions = galaxy.model.LibraryItemInfoPermissions \
+ .filter( galaxy.model.LibraryItemInfoPermissions.table.c.library_item_info_id == library_item_info.id ) \
+ .all()
+ info_permissions = [ liip_obj.action for liip_obj in info_permissions ]
+ info_permissions.sort()
+ assert actions == info_permissions, "Permissions for library_item_info id %s not correctly inherited from library %s" \
+ % ( library_item_info.id, library_one.name )
+ # Need the current library_item_info_element.id
+ last_library_item_info_element_id = galaxy.model.LibraryItemInfoElement.query() \
+ .order_by( desc( galaxy.model.LibraryItemInfoElement.table.c.id ) ).first()
+ if last_library_item_info_element_id is None:
+ last_library_item_info_element_id = 0
+ # Add information to the library using the template
+ ele_1_field_name = "info_element_%s_%s" % ( str( library_one_template.id ), str( last_library_item_info_element_id + 1 ) )
+ ele_1_contents = 'hello'
+ ele_2_field_name = "info_element_%s_%s" % ( str( library_one_template.id ), str( last_library_item_info_element_id + 2 ) )
+ ele_2_contents = 'world'
+ self.edit_library_info( str( library_one.id ), library_one.name, ele_1_field_name, ele_1_contents, ele_2_field_name, ele_2_contents )
+ self.home()
+ self.visit_url( '%s/admin/library?id=%s&information=True' % ( self.url, str( library_one.id ) ) )
+ self.check_page_for_string( ele_1_contents )
+ self.check_page_for_string( ele_2_contents )
+ self.home()
+ self.visit_url( '%s/admin/library?id=%s&information=True' % ( self.url, str( library_one.id ) ) )
+ self.check_page_for_string( ele_1_contents )
+ self.check_page_for_string( ele_2_contents )
+ # Edit the template
+ new_name = 'Library Template 1 renamed'
+ new_ele_name_1 = 'wind'
+ ele_desc_1 = 'This is the wind component'
+ new_ele_name_2 = 'bag'
+ ele_desc_2 = 'This is the bag component'
+ self.edit_library_info_template( str( library_one.id ), library_one_template.id, new_name, new_ele_name_1, ele_desc_1, new_ele_name_2, ele_desc_2 )
+ self.home()
+ self.visit_url( '%s/admin/library?id=%s&information=True' % ( self.url, str( library_one.id ) ) )
+ self.check_page_for_string( new_ele_name_1 )
+ self.check_page_for_string( ele_desc_1 )
+ self.check_page_for_string( ele_1_contents )
+ self.check_page_for_string( new_ele_name_2 )
+ self.check_page_for_string( ele_desc_2 )
+ self.check_page_for_string( ele_2_contents )
+ def test_080_add_public_dataset_to_root_folder( self ):
+ """Testing adding a public dataset to the root folder"""
+ actions = [ v.action for k, v in galaxy.model.Library.permitted_actions.items() ]
+ actions.sort()
+ message = 'Testing adding a public dataset to the root folder'
+ self.add_library_dataset( '1.bed',
+ str( library_one.id ),
+ str( library_one.root_folder.id ),
+ library_one.root_folder.name,
+ file_format='bed',
+ dbkey='hg18',
+ message=message.replace( ' ', '+' ),
+ root=True )
+ global ldda_one
+ ldda_one = galaxy.model.LibraryDatasetDatasetAssociation.query() \
+ .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first()
+ assert ldda_one is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_one from the database'
+ self.home()
+ self.visit_url( '%s/admin/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
+ self.check_page_for_string( "1.bed" )
+ self.check_page_for_string( message )
+ self.check_page_for_string( admin_user.email )
+ # Make sure the library permissions were inherited to the library_dataset_dataset_association
+ ldda_permissions = galaxy.model.LibraryDatasetDatasetAssociationPermissions \
+ .filter( galaxy.model.LibraryDatasetDatasetAssociationPermissions.table.c.library_dataset_dataset_association_id == ldda_one.id ) \
+ .all()
+ ldda_permissions = [ lddap_obj.action for lddap_obj in ldda_permissions ]
+ ldda_permissions.sort()
+ assert actions == ldda_permissions, "Permissions for ldda id %s not correctly inherited from library %s" \
+ % ( ldda_one.id, library_one.name )
+ # Make sure DatasetPermissions are correct - default is 'manage permissions'
+ if len( ldda_one.dataset.actions ) > 1:
+ raise AssertionError( '%d DatasetPermissionss were created for dataset id %d when it was created ( should have been 1 )' \
+ % ( len( ldda_one.dataset.actions ), ldda_one.dataset.id ) )
+ dp = galaxy.model.DatasetPermissions.filter( galaxy.model.DatasetPermissions.table.c.dataset_id==ldda_one.dataset.id ).first()
+ if not dp.action == galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action:
+ raise AssertionError( 'The DatasetPermissions.action for dataset id %d is "%s", but it should be "manage permissions"' \
+ % ( ldda_one.dataset.id, dp.action ) )
+ # Make sure the library template was inherited by the ldda
+ self.home()
+ self.visit_url( "%s/admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \
+ ( self.url, str( library_one.id ), str( library_one.root_folder.id ), str( ldda_one.id ) ) )
+ self.check_page_for_string( 'wind' )
+ self.check_page_for_string( 'This is the wind component' )
+ self.check_page_for_string( 'bag' )
+ self.check_page_for_string( 'This is the bag component' )
+ # Make sure other users can access the dataset from the Libraries view
+ self.logout()
+ self.login( email=regular_user2.email )
+ self.home()
+ self.visit_url( '%s/library/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
+ self.check_page_for_string( "1.bed" )
+ self.logout()
+ self.login( email=admin_user.email )
+ self.home()
+ def test_085_editing_dataset_information( self ):
+ """Testing editing dataset template element information"""
+ # Need the current library_item_info_element.id
+ last_library_item_info_element = galaxy.model.LibraryItemInfoElement.query() \
+ .order_by( desc( galaxy.model.LibraryItemInfoElement.table.c.id ) ).first()
+ global ldda_one_ele_2_field_name
+ ldda_one_ele_2_field_name = "info_element_%s" % str( last_library_item_info_element.id )
+ ele_2_contents = 'pipe'
+ global ldda_one_ele_1_field_name
+ ldda_one_ele_1_field_name = "info_element_%s" % ( str( last_library_item_info_element.id - 1 ) )
+ ele_1_contents = 'blown'
+ self.edit_ldda_template_element_info( str( library_one.id ), str( library_one.root_folder.id ), str( ldda_one.id ),
+ ldda_one.name, ldda_one_ele_1_field_name, ele_1_contents, ldda_one_ele_2_field_name, ele_2_contents )
+ self.home()
+ def test_090_add_new_folder_to_root_folder( self ):
"""Testing adding a folder to a library root folder"""
- self.login( email = 'test(a)bx.psu.edu' )
root_folder = library_one.root_folder
name = "Root Folder's Folder One"
description = "This is the root folder's Folder One"
@@ -466,23 +628,238 @@
folder_one = galaxy.model.LibraryFolder.filter( and_( galaxy.model.LibraryFolder.table.c.parent_id==root_folder.id,
galaxy.model.LibraryFolder.table.c.name==name,
galaxy.model.LibraryFolder.table.c.description==description ) ).first()
- assert folder_one is not None, 'Problem retrieving library folder named "Folder One" from the database'
+ assert folder_one is not None, 'Problem retrieving library folder named "%s" from the database' % name
self.home()
self.visit_url( '%s/admin/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
self.check_page_for_string( name )
self.check_page_for_string( description )
- def test_080_add_dataset_with_private_role_restriction_to_folder( self ):
- """Testing adding a dataset with a private role restriction to a folder"""
- # Add a dataset restricted by regular_user1 private role
- message ='This+is+a+test'
- self.add_library_dataset( '1.bed',
+ # Make sure the library template is inherited
+ self.home()
+ self.visit_url( '%s/admin/folder?id=%s&library_id=%s&information=True' % ( self.url, str( folder_one.id ), str( library_one.id ) ) )
+ self.check_page_for_string( 'wind' )
+ self.check_page_for_string( 'This is the wind component' )
+ self.check_page_for_string( 'bag' )
+ self.check_page_for_string( 'This is the bag component' )
+ self.home()
+ def test_095_add_folder_template( self ):
+ """Testing adding a new folder template to a folder"""
+ # Add a new information template to the folder
+ template_name = 'Folder Template 1'
+ ele_name_0 = 'Fu'
+ ele_help_0 = 'This is the Fu component'.replace( ' ', '+' )
+ ele_name_1 = 'Bar'
+ ele_help_1 = 'This is the Bar component'.replace( ' ', '+' )
+ self.home()
+ self.add_folder_info_template( str( library_one.id ), library_one.name, str( folder_one.id ), folder_one.name,
+ name=template_name, num_fields='2', ele_name_0=ele_name_0, ele_help_0=ele_help_0,
+ ele_name_1=ele_name_1, ele_help_1=ele_help_1 )
+ self.home()
+ self.visit_url( '%s/admin/folder?id=%s&library_id=%s&information=True' % ( self.url, str( folder_one.id ), str( library_one.id ) ) )
+ self.check_page_for_string( ele_name_0 )
+ check_str = ele_help_0.replace( '+', ' ' )
+ self.check_page_for_string( check_str )
+ self.check_page_for_string( ele_name_1 )
+ check_str = ele_help_1.replace( '+', ' ' )
+ self.check_page_for_string( check_str )
+ self.home()
+ def test_100_add_subfolder_to_folder( self ):
+ """Testing adding a folder to a library folder"""
+ name = "Folder One's Subfolder"
+ description = "This is the Folder One's subfolder"
+ self.add_folder( str( library_one.id ), str( folder_one.id ), name=name, description=description )
+ global subfolder_one
+ subfolder_one = galaxy.model.LibraryFolder.filter( and_( galaxy.model.LibraryFolder.table.c.parent_id==folder_one.id,
+ galaxy.model.LibraryFolder.table.c.name==name,
+ galaxy.model.LibraryFolder.table.c.description==description ) ).first()
+ assert subfolder_one is not None, 'Problem retrieving library folder named "Folder Ones Subfolder" from the database'
+ self.home()
+ self.visit_url( '%s/admin/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
+ self.check_page_for_string( name )
+ self.check_page_for_string( description )
+ # Make sure the parent folder's template is inherited
+ self.home()
+ self.visit_url( '%s/admin/folder?id=%s&library_id=%s&information=True' % ( self.url, str( folder_one.id ), str( library_one.id ) ) )
+ self.check_page_for_string( 'Fu' )
+ self.check_page_for_string( 'This is the Fu component' )
+ self.check_page_for_string( 'Bar' )
+ self.check_page_for_string( 'This is the Bar component' )
+ # Make sure the library template is not inherited
+ try:
+ self.check_page_for_string( 'wind' )
+ raise AssertionError( 'Library template inherited by folder when it should not have been.' )
+ except:
+ pass
+ self.home()
+ def test_105_add_template_element( self ):
+ """Testing adding a new element to an existing library template"""
+ name = 'Library Template 1 renamed'
+ ele_name_1 = 'wind'
+ ele_desc_1 = 'This is the wind component'
+ ele_name_2 = 'bag'
+ ele_desc_2 = 'This is the bag component'
+ new_ele_name = 'Fubar'
+ new_ele_desc = 'This is the Fubar component'
+ library_one_template.refresh()
+ self.add_library_info_template_element( str( library_one.id ),
+ str( library_one_template.id ),
+ library_one_template.name,
+ ele_name_1,
+ ele_desc_1,
+ ele_name_2,
+ ele_desc_2,
+ new_ele_name=new_ele_name,
+ new_ele_desc=new_ele_desc )
+ # Make sure the new template element shows up on the existing library info page
+ self.home()
+ self.visit_url( '%s/admin/library?id=%s&information=True' % ( self.url, str( library_one.id ) ) )
+ self.check_page_for_string( library_one.name )
+ self.check_page_for_string( library_one.description )
+ self.check_page_for_string( 'wind' )
+ self.check_page_for_string( 'hello' )
+ self.check_page_for_string( 'This is the wind component' )
+ self.check_page_for_string( 'bag' )
+ self.check_page_for_string( 'world' )
+ self.check_page_for_string( 'This is the bag component' )
+ self.check_page_for_string( 'Fubar' )
+ self.check_page_for_string( 'This is the Fubar component' )
+ # Make sure the new template element does not show up on existing info pages for folder_one since it has its own template
+ self.home()
+ self.visit_url( '%s/admin/folder?id=%s&library_id=%s&information=True' % ( self.url, str( folder_one.id ), str( library_one.id ) ) )
+ self.check_page_for_string( 'Fu' )
+ self.check_page_for_string( 'This is the Fu component' )
+ self.check_page_for_string( 'Bar' )
+ self.check_page_for_string( 'This is the Bar component' )
+ try:
+ self.check_page_for_string( 'Fubar' )
+ raise AssertionError( 'Changed library template inherited by folder "%s" when folder had an associated template of its own' )
+ except:
+ pass
+ # Make sure the new template element shows up on existing info pages for ldda_one since it is contained in the root folder
+ self.home()
+ self.visit_url( "%s/admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \
+ ( self.url, str( library_one.id ), str( folder_one.id ), str( ldda_one.id ) ) )
+ # Visiting the above page will have resulted in the creation of a new LibraryItemInfoElement, so we'll retrieve it
+ # for later use
+ last_library_item_info_element = galaxy.model.LibraryItemInfoElement.query() \
+ .order_by( desc( galaxy.model.LibraryItemInfoElement.table.c.id ) ).first()
+ global ldda_one_ele_3_field_name
+ ldda_one_ele_3_field_name = "info_element_%s" % str( last_library_item_info_element.id )
+ self.check_page_for_string( 'wind' )
+ self.check_page_for_string( 'This is the wind component' )
+ self.check_page_for_string( 'bag' )
+ self.check_page_for_string( 'This is the bag component' )
+ self.check_page_for_string( 'Fubar' )
+ self.check_page_for_string( 'This is the Fubar component' )
+ self.home()
+ def test_110_add_2nd_new_folder_to_root_folder( self ):
+ """Testing adding a 2nd folder to a library root folder"""
+ root_folder = library_one.root_folder
+ name = "Folder Two"
+ description = "This is the root folder's Folder Two"
+ self.add_folder( str( library_one.id ), str( root_folder.id ), name=name, description=description )
+ global folder_two
+ folder_two = galaxy.model.LibraryFolder.filter( and_( galaxy.model.LibraryFolder.table.c.parent_id==root_folder.id,
+ galaxy.model.LibraryFolder.table.c.name==name,
+ galaxy.model.LibraryFolder.table.c.description==description ) ).first()
+ assert folder_two is not None, 'Problem retrieving library folder named "%s" from the database' % name
+ self.home()
+ self.visit_url( '%s/admin/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
+ self.check_page_for_string( name )
+ self.check_page_for_string( description )
+ # Make sure the changed library template is inherited to the new folder
+ self.home()
+ self.visit_url( '%s/admin/folder?id=%s&library_id=%s&information=True' % ( self.url, str( folder_two.id ), str( library_one.id ) ) )
+ self.check_page_for_string( 'wind' )
+ self.check_page_for_string( 'This is the wind component' )
+ self.check_page_for_string( 'bag' )
+ self.check_page_for_string( 'This is the bag component' )
+ self.check_page_for_string( 'Fubar' )
+ self.check_page_for_string( 'This is the Fubar component' )
+ self.home()
+ def test_115_add_public_dataset_to_root_folders_2nd_subfolder( self ):
+ """Testing adding a public dataset to the root folder's 2nd sub-folder"""
+ actions = [ v.action for k, v in galaxy.model.Library.permitted_actions.items() ]
+ actions.sort()
+ message = "Testing adding a public dataset to the folder named %s" % folder_two.name
+ self.add_library_dataset( '2.bed',
str( library_one.id ),
- str( folder_one.id ),
- folder_one.name,
+ str( folder_two.id ),
+ folder_two.name,
file_format='bed',
dbkey='hg18',
- roles=[ str( regular_user1_private_role.id ) ],
- message=message,
+ message=message.replace( ' ', '+' ),
+ root=False )
+ global ldda_two
+ ldda_two = galaxy.model.LibraryDatasetDatasetAssociation.query() \
+ .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first()
+ assert ldda_two is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_two from the database'
+ self.home()
+ self.visit_url( '%s/admin/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
+ self.check_page_for_string( "2.bed" )
+ self.check_page_for_string( message )
+ self.check_page_for_string( admin_user.email )
+ def test_120_add_template_to_root_folders_2nd_subfolder( self ):
+ """Testing adding a template to the root folder's 2nd sub-folder"""
+ # Before adding the folder template, the inherited library template should be displayed
+ self.home()
+ self.visit_url( "%s/admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \
+ ( self.url, str( library_one.id ), str( folder_two.id ), str( ldda_two.id ) ) )
+ self.check_page_for_string( 'wind' )
+ self.check_page_for_string( 'This is the wind component' )
+ self.check_page_for_string( 'bag' )
+ self.check_page_for_string( 'This is the bag component' )
+ self.check_page_for_string( 'Fubar' )
+ self.check_page_for_string( 'This is the Fubar component' )
+ self.home()
+ # Add a new folde template
+ template_name = 'Folder 2 Template'
+ ele_name_0 = 'kill'
+ ele_help_0 = 'This is the kill component'.replace( ' ', '+' )
+ ele_name_1 = 'bill'
+ ele_help_1 = 'This is the bill component'.replace( ' ', '+' )
+ self.home()
+ self.add_folder_info_template( str( library_one.id ), library_one.name, str( folder_two.id ), folder_two.name,
+ name=template_name, num_fields='2', ele_name_0=ele_name_0, ele_help_0=ele_help_0,
+ ele_name_1=ele_name_1, ele_help_1=ele_help_1 )
+ # Make sure the new template id displayed on the folder information page
+ self.home()
+ self.visit_url( '%s/admin/folder?id=%s&library_id=%s&information=True' % ( self.url, str( folder_two.id ), str( library_one.id ) ) )
+ self.check_page_for_string( ele_name_0 )
+ check_str = ele_help_0.replace( '+', ' ' )
+ self.check_page_for_string( check_str )
+ self.check_page_for_string( ele_name_1 )
+ check_str = ele_help_1.replace( '+', ' ' )
+ self.check_page_for_string( check_str )
+ # The library dataset ldda_two had previously inherited the library template prior to the new folder template
+ # being introduced, so the library template should still be displayed on the ldda information page
+ self.home()
+ self.visit_url( "%s/admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \
+ ( self.url, str( library_one.id ), str( folder_two.id ), str( ldda_two.id ) ) )
+ self.check_page_for_string( 'wind' )
+ self.check_page_for_string( 'This is the wind component' )
+ self.check_page_for_string( 'bag' )
+ self.check_page_for_string( 'This is the bag component' )
+ self.check_page_for_string( 'Fubar' )
+ self.check_page_for_string( 'This is the Fubar component' )
+ # Make sure the new folder template is not displayed
+ try:
+ self.check_page_for_string( 'kill' )
+ raise AssertionError( 'New folder template elements incorrectly included in information page for ldda "%s"' % ldda_two.name )
+ except:
+ pass
+ self.home()
+ def test_125_add_2nd_public_dataset_to_root_folders_2nd_subfolder( self ):
+ """Testing adding a 2nd public dataset to the root folder's 2nd sub-folder"""
+ actions = [ v.action for k, v in galaxy.model.Library.permitted_actions.items() ]
+ actions.sort()
+ message = "Testing adding a 2nd public dataset to the folder named %s" % folder_two.name
+ self.add_library_dataset( '3.bed',
+ str( library_one.id ),
+ str( folder_two.id ),
+ folder_two.name,
+ file_format='bed',
+ dbkey='hg18',
+ message=message.replace( ' ', '+' ),
root=False )
global ldda_three
ldda_three = galaxy.model.LibraryDatasetDatasetAssociation.query() \
@@ -490,11 +867,67 @@
assert ldda_three is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_three from the database'
self.home()
self.visit_url( '%s/admin/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
- self.check_page_for_string( "1.bed" )
+ self.check_page_for_string( "3.bed" )
+ self.check_page_for_string( message )
self.check_page_for_string( admin_user.email )
- def test_085_accessing_dataset_with_private_role_restriction( self ):
+ def test_130_editing_dataset_information_with_new_folder_template( self ):
+ """Testing editing dataset template element information with new inherited folder template"""
+ # Need the current library_item_info_element.id
+ last_library_item_info_element = galaxy.model.LibraryItemInfoElement.query() \
+ .order_by( desc( galaxy.model.LibraryItemInfoElement.table.c.id ) ).first()
+ # Make sure the changed inherited template is included in the ldda information
+ ele_2_field_name = "info_element_%s" % str( last_library_item_info_element.id )
+ ele_2_contents = 'II'
+ ele_2_help = 'This is the bill component'
+ ele_1_field_name = "info_element_%s" % ( str( last_library_item_info_element.id - 1 ) )
+ ele_1_contents = 'Volume'
+ ele_1_help = 'This is the kill component'
+ self.edit_ldda_template_element_info( str( library_one.id ), str( folder_two.id ), str( ldda_three.id ),
+ ldda_three.name, ele_1_field_name, ele_1_contents, ele_2_field_name, ele_2_contents,
+ ele_1_help=ele_1_help, ele_2_help=ele_2_help )
+ self.home()
+ def test_135_add_dataset_with_private_role_restriction_to_folder( self ):
+ """Testing adding a dataset with a private role restriction to a folder"""
+ # Add a dataset restricted by the following:
+ # DATASET_MANAGE_PERMISSIONS = "test(a)bx.psu.edu" via DefaultUserPermissions
+ # DATASET_ACCESS = "regular_user1" private role via this test method
+ # LIBRARY_ADD = "Role One" via inheritance from parent folder
+ # LIBRARY_MODIFY = "Role One" via inheritance from parent folder
+ # LIBRARY_MANAGE = "Role One" via inheritance from parent folder
+ # "Role One" members are: test(a)bx.psu.edu, test1(a)bx.psu.edu, test3(a)bx.psu.edu
+ # This means that only user test1(a)bx.psu.edu can see the dataset from the Libraries view
+ #
+ # TODO: this demonstrates a weakness in our logic: If test(a)bx.psu.edu cannot
+ # access the dataset from the Libraries view, then the DATASET_MANAGE_PERMISSIONS
+ # setting is useless if test(a)bx.psu.edu is not an admin. This should be corrected,
+ # by displaying a warning message on the permissions form.
+ message ='This is a test of the fourth dataset uploaded'
+ ele_name_0 = 'Fu'
+ ele_name_1 = 'Bar'
+ self.add_library_dataset( '4.bed',
+ str( library_one.id ),
+ str( folder_one.id ),
+ folder_one.name,
+ file_format='bed',
+ dbkey='hg18',
+ roles=[ str( regular_user1_private_role.id ) ],
+ message=message.replace( ' ', '+' ),
+ root=False,
+ check_template_str1=ele_name_0,
+ check_template_str2=ele_name_1 )
+ global ldda_four
+ ldda_four = galaxy.model.LibraryDatasetDatasetAssociation.query() \
+ .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first()
+ assert ldda_four is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_four from the database'
+ self.home()
+ self.visit_url( '%s/admin/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
+ self.check_page_for_string( "4.bed" )
+ self.check_page_for_string( message )
+ self.check_page_for_string( admin_user.email )
+ self.home()
+ def test_140_accessing_dataset_with_private_role_restriction( self ):
"""Testing accessing a dataset with a private role restriction"""
- # admin_user should not be able to see 1.bed from the analysis view's access librarys
+ # admin_user should not be able to see 2.bed from the analysis view's access libraries
self.home()
self.visit_url( '%s/library/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
try:
@@ -502,21 +935,21 @@
raise AssertionError( '%s can see library folder %s when it contains only datasets restricted by role %s' \
% ( admin_user.email, folder_one.name, regular_user1_private_role.description ) )
except:
- pass # This is the behavior we want
+ pass
try:
- self.check_page_for_string( '1.bed' )
- raise AssertionError( '%s can see dataset 1.bed in library folder %s when it was restricted by role %s' \
+ self.check_page_for_string( '4.bed' )
+ raise AssertionError( '%s can see dataset 4.bed in library folder %s when it was restricted by role %s' \
% ( admin_user.email, folder_one.name, regular_user1_private_role.description ) )
except:
- pass # This is the behavior we want
+ pass
self.logout()
- # regular_user1 should be able to see 1.bed from the analysis view's access librarys
+ # regular_user1 should be able to see 4.bed from the analysis view's access librarys
# since it was associated with regular_user1's private role
self.login( email='test1(a)bx.psu.edu' )
self.home()
self.visit_url( '%s/library/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
self.check_page_for_string( folder_one.name )
- self.check_page_for_string( '1.bed' )
+ self.check_page_for_string( '4.bed' )
self.logout()
# regular_user2 should not be able to see 1.bed from the analysis view's access librarys
self.login( email='test2(a)bx.psu.edu' )
@@ -525,82 +958,139 @@
raise AssertionError( '%s can see library folder %s when it contains only datasets restricted by role %s' \
% ( regular_user2.email, folder_one.name, regular_user1_private_role.description ) )
except:
- pass # This is the behavior we want
+ pass
try:
- self.check_page_for_string( '1.bed' )
- raise AssertionError( '%s can see dataset 1.bed in library folder %s when it was restricted by role %s' \
+ self.check_page_for_string( '4.bed' )
+ raise AssertionError( '%s can see dataset 4.bed in library folder %s when it was restricted by role %s' \
% ( regular_user2.email, folder_one.name, regular_user1_private_role.description ) )
except:
- pass # This is the behavior we want
+ pass
self.logout()
- # regular_user3 should not be able to see 1.bed from the analysis view's access librarys
+ # regular_user3 should not be able to see 2.bed from the analysis view's access librarys
self.login( email='test3(a)bx.psu.edu' )
try:
self.check_page_for_string( folder_one.name )
raise AssertionError( '%s can see library folder %s when it contains only datasets restricted by role %s' \
% ( regular_user3.email, folder_one.name, regular_user1_private_role.description ) )
except:
- pass # This is the behavior we want
+ pass
try:
- self.check_page_for_string( '1.bed' )
- raise AssertionError( '%s can see dataset 1.bed in library folder %s when it was restricted by role %s' \
+ self.check_page_for_string( '4.bed' )
+ raise AssertionError( '%s can see dataset 4.bed in library folder %s when it was restricted by role %s' \
% ( regular_user3.email, folder_one.name, regular_user1_private_role.description ) )
except:
pass # This is the behavior we want
self.logout()
- def test_090_add_dataset_with_role_restriction_to_folder( self ):
- """Testing adding a dataset with a role restriction to a folder"""
+ self.login( email=admin_user.email )
+ self.home()
+ def test_145_change_dataset_access_permission( self ):
+ """Testing changing the access permission on a dataset with a private role restriction"""
+ # We need admin_user to be able to access 2.bed
+ permissions_in = [ k for k, v in galaxy.model.Dataset.permitted_actions.items() ] + \
+ [ k for k, v in galaxy.model.Library.permitted_actions.items() ]
+ permissions_out = []
+ role_ids = "%s,%s" % ( str( role_one.id ), str( admin_user_private_role.id ) )
+ self.set_library_dataset_permissions( str( library_one.id ), str( folder_one.id ), str( ldda_four.id ), ldda_four.name,
+ role_ids, permissions_in, permissions_out )
+ # admin_user should now be able to see 4.bed from the analysis view's access libraries
+ self.home()
+ self.visit_url( '%s/library/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
+ self.check_page_for_string( ldda_four.name )
+ self.home()
+ def test_150_editing_restricted_datasets_information( self ):
+ """Testing editing a restricted library dataset's template element information"""
+ ele_1_contents = ''
+ ele_2_contents = ''
+ ele_3_contents = 'Adding Fubar text'
+ self.edit_ldda_template_element_info( str( library_one.id ), str( library_one.root_folder.id ), str( ldda_one.id ),
+ ldda_one.name, ldda_one_ele_1_field_name, ele_1_contents, ldda_one_ele_2_field_name, ele_2_contents,
+ ele_1_help='This is the wind component'.replace( ' ', '+' ),
+ ele_2_help='This is the bag component'.replace( ' ', '+' ),
+ ele_3_field_name=ldda_one_ele_3_field_name, ele_3_contents=ele_3_contents.replace( ' ', '+' ) )
+ # Check the updated information from the libraries view
+ self.home()
+ self.visit_url( '%s/library/library_dataset_dataset_association?info=True&library_id=%s&folder_id=%s&id=%s' \
+ % ( self.url, str( library_one.id ), str( library_one.root_folder.id ), str( ldda_one.id ) ) )
+ self.check_page_for_string( ele_3_contents )
+ try:
+ self.check_page_for_string( 'blown' )
+ raise AssertionError( 'Element contents were not correctly eliminated when the information was edited for ldda %s' % ldda_one.name)
+ except:
+ pass
+ self.home()
+ def test_155_add_dataset_with_role_associated_with_group_and_users( self ):
+ """Testing adding a dataset with a role that is associated with a group and users"""
self.login( email='test(a)bx.psu.edu' )
# Add a dataset restricted by role_two, which is currently associated as follows:
# groups: group_two
# users: test(a)bx.psu.edu, test1(a)bx.psu.edu via group_two
- message ='This+is+a+test'
- self.add_library_dataset( '2.bed',
+ message = 'Testing adding a dataset with a role that is associated with a group and users'
+ ele_name_0 = 'Fu'
+ ele_name_1 = 'Bar'
+ self.add_library_dataset( '5.bed',
str( library_one.id ),
str( folder_one.id ),
folder_one.name,
file_format='bed',
dbkey='hg17',
roles=[ str( role_two.id ) ],
- message=message,
- root=False )
- global ldda_two
- ldda_two = galaxy.model.LibraryDatasetDatasetAssociation.query() \
+ message=message.replace( ' ', '+' ),
+ root=False,
+ check_template_str1=ele_name_0,
+ check_template_str2=ele_name_1 )
+ global ldda_five
+ ldda_five = galaxy.model.LibraryDatasetDatasetAssociation.query() \
.order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first()
- assert ldda_two is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_two from the database'
+ assert ldda_five is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_five from the database'
self.home()
self.visit_url( '%s/admin/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
- self.check_page_for_string( "2.bed" )
+ self.check_page_for_string( "5.bed" )
+ self.check_page_for_string( message )
self.check_page_for_string( admin_user.email )
- def test_095_accessing_datasets_with_role_restriction( self ):
- """Testing accessing a dataset with a role restriction"""
- # admin_user should be able to see 2.bed since she is associated with role_two
+ self.home()
+ def test_160_accessing_dataset_with_role_associated_with_group_and_users( self ):
+ """Testing accessing a dataset with a role that is associated with a group and users"""
+ # admin_user should be able to see 5.bed since she is associated with role_two
self.home()
self.visit_url( '%s/library/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
- self.check_page_for_string( "2.bed" )
+ self.check_page_for_string( "5.bed" )
self.check_page_for_string( admin_user.email )
self.logout()
- # regular_user1 should be able to see 2.bed since she is associated with group_two
+ # regular_user1 should be able to see 5.bed since she is associated with group_two
self.login( email = 'test1(a)bx.psu.edu' )
self.home()
self.visit_url( '%s/library/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
self.check_page_for_string( folder_one.name )
- self.check_page_for_string( '2.bed' )
+ self.check_page_for_string( '5.bed' )
self.check_page_for_string( admin_user.email )
- # Check the permissions on the dataset - should be 'access', which only allows viewing the information
+ # Check the permissions on the dataset 5.bed - they are as folows:
+ # DATASET_MANAGE_PERMISSIONS = test(a)bx.psu.edu
+ # DATASET_ACCESS = Role Two
+ # Role Two associations: test(a)bx.psu.edu and Group Two
+ # Group Two members: Role One, Role Two, test1(a)bx.psu.edu
+ # Role One associations: test(a)bx.psu.edu, test1(a)bx.psu.edu, test3(a)bx.psu.edu
+ # LIBRARY_ADD = Role One
+ # Role One aassociations: test(a)bx.psu.edu, test1(a)bx.psu.edu, test3(a)bx.psu.edu
+ # LIBRARY_MODIFY = Role One
+ # Role One aassociations: test(a)bx.psu.edu, test1(a)bx.psu.edu, test3(a)bx.psu.edu
+ # LIBRARY_MANAGE = Role One
+ # Role One aassociations: test(a)bx.psu.edu, test1(a)bx.psu.edu, test3(a)bx.psu.edu
self.home()
- self.visit_url( '%s/library/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s' % ( self.url, str( library_one.id ), str( folder_one.id ), str( ldda_two.id ) ) )
- self.check_page_for_string( '2.bed' )
+ self.visit_url( '%s/library/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s' \
+ % ( self.url, str( library_one.id ), str( folder_one.id ), str( ldda_five.id ) ) )
+ self.check_page_for_string( '5.bed' )
self.check_page_for_string( 'This is the latest version of this library dataset' )
- self.check_page_for_string( 'View attributes of 2.bed' )
+ # Current user test1(a)bx.psu.edu has Role One, which has the LIBRARY_MODIFY permission
+ self.check_page_for_string( 'Edit attributes of 5.bed' )
self.home()
# Test importing the restricted dataset into a history, can't use the
# ~/admin/libraries form as twill barfs on it so we'll simulate the form submission
# by going directly to the form action
- self.visit_url( '%s/library/datasets?do_action=add&ldda_ids=%d&library_id=%s' % ( self.url, ldda_two.id, str( library_one.id ) ) )
+ self.visit_url( '%s/library/datasets?do_action=add&ldda_ids=%d&library_id=%s' \
+ % ( self.url, ldda_five.id, str( library_one.id ) ) )
self.check_page_for_string( '1 dataset(s) have been imported into your history' )
self.logout()
- # regular_user2 should not be able to see 2.bed
+ # regular_user2 should not be able to see 5.bed
self.login( email = 'test2(a)bx.psu.edu' )
self.home()
self.visit_url( '%s/library/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
@@ -609,96 +1099,35 @@
raise AssertionError( '%s can see library folder %s when it contains only datasets restricted by role %s' \
% ( regular_user2.email, folder_one.name, regular_user1_private_role.description ) )
except:
- pass # This is the behavior we want
+ pass
try:
- self.check_page_for_string( '2.bed' )
- raise AssertionError( '%s can see dataset 2.bed in library folder %s when it was restricted by role %s' \
+ self.check_page_for_string( '5.bed' )
+ raise AssertionError( '%s can see dataset 5.bed in library folder %s when it was restricted by role %s' \
% ( regular_user2.email, folder_one.name, regular_user1_private_role.description ) )
except:
- pass # This is the behavior we want
- # regular_user3 should not be able to see 2.bed
+ pass
+ # regular_user3 should not be able to see folder_one ( even though it does not contain any datasets that she
+ # can access ) since she has Role One, and Role One has all library permissions ( see above ).
self.login( email = 'test3(a)bx.psu.edu' )
self.home()
self.visit_url( '%s/library/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
+ self.check_page_for_string( folder_one.name )
+ # regular_user3 should not be able to see 5.bed since users must have every role associated
+ # with the dataset in order to access it, and regular_user3 isnot associated with Role Two
try:
- self.check_page_for_string( folder_one.name )
- raise AssertionError( '%s can see library folder %s when it contains only datasets restricted by role %s' \
+ self.check_page_for_string( '5.bed' )
+ raise AssertionError( '%s can see dataset 5.bed in library folder %s when it was restricted by role %s' \
% ( regular_user3.email, folder_one.name, regular_user1_private_role.description ) )
except:
- pass # This is the behavior we want
- try:
- self.check_page_for_string( '2.bed' )
- raise AssertionError( '%s can see dataset 2.bed in library folder %s when it was restricted by role %s' \
- % ( regular_user3.email, folder_one.name, regular_user1_private_role.description ) )
- except:
- pass # This is the behavior we want
+ pass
self.logout()
- def test_100_add_public_dataset_to_root_folder( self ):
- """Testing adding a public dataset to a library root folder"""
self.login( email='test(a)bx.psu.edu' )
- folder = library_one.root_folder
- message ='This+is+a+test'
- self.add_library_dataset( '3.bed',
- str( library_one.id ),
- str( folder.id ),
- folder.name,
- file_format='bed',
- dbkey='hg16',
- roles=[],
- message=message,
- root=True )
- global ldda_three
- ldda_three = galaxy.model.LibraryDatasetDatasetAssociation.query() \
- .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first()
- assert ldda_three is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_three from the database'
- self.visit_page( 'admin/browse_library?id=%s' % ( str( library_one.id ) ) )
- self.check_page_for_string( "3.bed" )
- self.check_page_for_string( admin_user.email )
- self.logout()
- def test_105_access_public_library_dataset( self ):
- """Testing accessing a public library dataset"""
- # regular_user1 should not be able to see 3.bed
- self.login( email = 'test1(a)bx.psu.edu' )
- self.home()
- self.visit_url( '%s/library/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
- self.check_page_for_string( library_one.name )
- self.check_page_for_string( '3.bed' )
- self.check_page_for_string( admin_user.email )
- self.logout()
- # regular_user2 should not be able to see 3.bed
- self.login( email = 'test2(a)bx.psu.edu' )
- self.home()
- self.visit_url( '%s/library/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
- self.check_page_for_string( library_one.name )
- self.check_page_for_string( '3.bed' )
- self.check_page_for_string( admin_user.email )
- self.logout()
- # regular_user3 should not be able to see 3.bed
- self.login( email = 'test3(a)bx.psu.edu' )
- self.home()
- self.visit_url( '%s/library/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
- self.check_page_for_string( library_one.name )
- self.check_page_for_string( '3.bed' )
- self.check_page_for_string( admin_user.email )
- # Test selecting "View this dataset's information"
- self.home()
- self.visit_url( '%s/library/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s' % ( self.url, str( library_one.id ), str( folder_one.id ), str( ldda_three.id ) ) )
- self.check_page_for_string( '3.bed' )
- self.check_page_for_string( 'This is the latest version of this library dataset' )
- self.check_page_for_string( 'View attributes of 3.bed' )
- # Test importing a library dataset into a history
- self.home()
- self.visit_url( '%s/library/datasets?library_id=%s&do_action=add&ldda_ids=%d' % ( self.url, str( library_one.id ), ldda_three.id ) )
- self.check_page_for_string( '1 dataset(s) have been imported into your history' )
- self.logout()
- def test_110_copy_dataset_from_history_to_root_folder( self ):
- """Testing copying a dataset from the current history to a library root folder"""
- folder = library_one.root_folder
- self.login( email='test(a)bx.psu.edu' )
+ def test_165_copy_dataset_from_history_to_subfolder( self ):
+ """Testing copying a dataset from the current history to a subfolder"""
self.new_history()
- self.upload_file( "1.bed" )
+ self.upload_file( "6.bed" )
latest_hda = galaxy.model.HistoryDatasetAssociation.query().order_by( desc( galaxy.model.HistoryDatasetAssociation.table.c.create_time ) ).first()
- self.add_history_datasets_to_library( str( library_one.id ), str( folder.id ), folder.name, str( latest_hda.id ), root=True )
+ self.add_history_datasets_to_library( str( library_one.id ), str( subfolder_one.id ), subfolder_one.name, str( latest_hda.id ), root=False )
# Test for DatasetPermissionss, the default setting is "manage permissions"
last_dataset_created = galaxy.model.Dataset.query().order_by( desc( galaxy.model.Dataset.table.c.create_time ) ).first()
dps = galaxy.model.DatasetPermissions.filter( galaxy.model.DatasetPermissions.table.c.dataset_id==last_dataset_created.id ).all()
@@ -708,14 +1137,145 @@
raise AssertionError( 'More than 1 DatasetPermissionss created for dataset id: %d' % last_dataset_created.id )
for dp in dps:
if not dp.action == 'manage permissions':
- raise AssertionError( 'DatasetPermissions.action "%s" is not the DefaultHistoryPermission setting of "manage permissions"' % \
- str( dp.action ) )
- def test_115_add_datasets_from_library_dir( self ):
- """Testing adding 3 datasets from a library directory to a folder"""
+ raise AssertionError( 'DatasetPermissions.action "%s" is not the DefaultHistoryPermission setting of "manage permissions"' \
+ % str( dp.action ) )
+ global ldda_six
+ ldda_six = galaxy.model.LibraryDatasetDatasetAssociation.query() \
+ .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first()
+ assert ldda_six is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_six from the database'
+ # Make sure the correct template was inherited
+ self.home()
+ self.visit_url( "%s/admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \
+ ( self.url, str( library_one.id ), str( subfolder_one.id ), str( ldda_six.id ) ) )
+ self.check_page_for_string( 'Fu' )
+ self.check_page_for_string( 'This is the Fu component' )
+ self.check_page_for_string( 'Bar' )
+ self.check_page_for_string( 'This is the Bar component' )
+ def test_170_editing_dataset_attribute_info( self ):
+ """Testing editing a datasets attribute information"""
+ new_ldda_name = '6.bed ( version 1 )'
+ self.edit_ldda_attribute_info( str( library_one.id ), str( subfolder_one.id ), str( ldda_six.id ), ldda_six.name, new_ldda_name )
+ self.home()
+ ldda_six.refresh()
+ self.visit_url( '%s/admin/browse_library?id=%s' % ( self.url, str( library_one.id ) ) )
+ self.check_page_for_string( ldda_six.name )
+ self.home()
+ def test_175_uploading_new_dataset_version( self ):
+ """Testing uploading a new version of a dataset"""
+ message = 'Testing uploading a new version of a dataset'
+ self.upload_new_dataset_version( '6.bed',
+ str( library_one.id ),
+ str( subfolder_one.id ),
+ str( subfolder_one.name ),
+ str( ldda_six.library_dataset.id ),
+ ldda_six.name,
+ file_format='auto',
+ dbkey='hg18',
+ message=message.replace( ' ', '+' ),
+ check_template_str1='Fu',
+ check_template_str2='Bar' )
+ global ldda_six_version_two
+ ldda_six_version_two = galaxy.model.LibraryDatasetDatasetAssociation.query() \
+ .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first()
+ assert ldda_six_version_two is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_six_version_two from the database'
+ self.home()
+ self.visit_url( "%s/admin/library_dataset_dataset_association?info=True&library_id=%s&folder_id=%s&id=%s" % \
+ ( self.url, str( library_one.id ), str( subfolder_one.id ), str( ldda_six_version_two.id ) ) )
+ self.check_page_for_string( 'This is the latest version of this library dataset' )
+ # Make sure the correct template was inherited
+ self.check_page_for_string( 'Fu' )
+ self.check_page_for_string( 'This is the Fu component' )
+ self.check_page_for_string( 'Bar' )
+ self.check_page_for_string( 'This is the Bar component' )
+ check_str = 'Expired versions of %s' % ldda_six_version_two.name
+ self.check_page_for_string( check_str )
+ self.check_page_for_string( ldda_six.name )
+ self.home()
+ # Make sure th permissions are the same
+ ldda_six.refresh()
+ if len( ldda_six.actions ) != len( ldda_six_version_two.actions ):
+ raise AssertionError( 'ldda "%s" actions "%s" != ldda "%s" actions "%s"' \
+ % ( ldda_six.name, str( ldda_six.actions ),
+ ldda_six_version_two.name, str( ldda_six_version_two.actions ) ) )
+ if len( ldda_six.library_dataset.actions ) != len( ldda_six_version_two.library_dataset.actions ):
+ raise AssertionError( 'ldda.library_dataset "%s" actions "%s" != ldda.library_dataset "%s" actions "%s"' \
+ % ( ldda_six.name, str( ldda_six.library_dataset.actions ), ldda_six_version_two.name, str( ldda_six_version_two.library_dataset.actions ) ) )
+ if len( ldda_six.dataset.actions ) != len( ldda_six_version_two.dataset.actions ):
+ raise AssertionError( 'ldda.dataset "%s" actions "%s" != ldda.dataset "%s" actions "%s"' \
+ % ( ldda_six.name, str( ldda_six.dataset.actions ), ldda_six_version_two.name, str( ldda_six_version_two.dataset.actions ) ) )
+ # Check the previous version
+ self.visit_url( "%s/admin/library_dataset_dataset_association?info=True&library_id=%s&folder_id=%s&id=%s" % \
+ ( self.url, str( library_one.id ), str( subfolder_one.id ), str( ldda_six.id ) ) )
+ self.check_page_for_string( 'This is an expired version of this library dataset' )
+ self.home()
+ def test_180_uploading_new_dataset_versions( self ):
+ """Testing uploading new versions of a dataset using a directory of files"""
+ message = 'Testing uploading new versions of a dataset using a directory of files'
+ ldda_six_version_two.refresh()
+ self.upload_new_dataset_versions( str( library_one.id ),
+ str( subfolder_one.id ),
+ str( subfolder_one.name ),
+ str( ldda_six_version_two.library_dataset.id ),
+ ldda_six_version_two.name,
+ file_format='auto',
+ dbkey='hg18',
+ message=message.replace( ' ', '+' ),
+ check_template_str1='Fu',
+ check_template_str2='Bar' )
+ global ldda_six_version_five
+ ldda_six_version_five = galaxy.model.LibraryDatasetDatasetAssociation.query() \
+ .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first()
+ assert ldda_six_version_five is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_six_version_five from the database'
+ self.home()
+ self.visit_url( "%s/admin/library_dataset_dataset_association?info=True&library_id=%s&folder_id=%s&id=%s" % \
+ ( self.url, str( library_one.id ), str( subfolder_one.id ), str( ldda_six_version_five.id ) ) )
+ self.check_page_for_string( 'This is the latest version of this library dataset' )
+ # Make sure the correct template was inherited
+ self.check_page_for_string( 'Fu' )
+ self.check_page_for_string( 'This is the Fu component' )
+ self.check_page_for_string( 'Bar' )
+ self.check_page_for_string( 'This is the Bar component' )
+ check_str = 'Expired versions of %s' % ldda_six_version_five.name
+ self.check_page_for_string( check_str )
+ self.check_page_for_string( ldda_six.name )
+ self.home()
+ # Make sure th permissions are the same
+ ldda_six.refresh()
+ if len( ldda_six.actions ) != len( ldda_six_version_five.actions ):
+ raise AssertionError( 'ldda "%s" actions "%s" != ldda "%s" actions "%s"' \
+ % ( ldda_six.name, str( ldda_six.actions ),
+ ldda_six_version_five.name, str( ldda_six_version_five.actions ) ) )
+ if len( ldda_six.library_dataset.actions ) != len( ldda_six_version_five.library_dataset.actions ):
+ raise AssertionError( 'ldda.library_dataset "%s" actions "%s" != ldda.library_dataset "%s" actions "%s"' \
+ % ( ldda_six.name, str( ldda_six.library_dataset.actions ), ldda_six_version_five.name, str( ldda_six_version_five.library_dataset.actions ) ) )
+ if len( ldda_six.dataset.actions ) != len( ldda_six_version_five.dataset.actions ):
+ raise AssertionError( 'ldda.dataset "%s" actions "%s" != ldda.dataset "%s" actions "%s"' \
+ % ( ldda_six.name, str( ldda_six.dataset.actions ), ldda_six_version_five.name, str( ldda_six_version_five.dataset.actions ) ) )
+ # Check the previous version
+ self.visit_url( "%s/admin/library_dataset_dataset_association?info=True&library_id=%s&folder_id=%s&id=%s" % \
+ ( self.url, str( library_one.id ), str( subfolder_one.id ), str( ldda_six_version_two.id ) ) )
+ self.check_page_for_string( 'This is an expired version of this library dataset' )
+ self.home()
+ def test_185_upload_datasets_from_library_dir( self ):
+ """Testing uploading 3 datasets from a library directory to a root folder"""
+ message = 'This is a test for uploading a directory of files'
roles_tuple = [ ( str( role_one.id ), role_one.name ) ]
- self.add_datasets_from_library_dir( str( library_one.id ), str( folder_one.id ), folder_one.name, roles_tuple=roles_tuple, root=False )
- def test_120_change_permissions_on_datasets_imported_from_library( self ):
- """Testing changing the permissions on library datasets imported into a history"""
+ self.add_datasets_from_library_dir( str( library_one.id ),
+ str( library_one.root_folder.id ),
+ library_one.root_folder.name,
+ roles_tuple=roles_tuple,
+ message=message.replace( '+', ' ' ),
+ root=True,
+ check_template_str1='wind',
+ check_template_str2='bag',
+ check_template_str3='Fubar' )
+ self.home()
+ self.visit_page( 'admin/browse_library?id=%s' % ( str( library_one.id ) ) )
+ self.check_page_for_string( admin_user.email )
+ self.check_page_for_string( message )
+ self.home()
+ def test_190_change_permissions_on_datasets_uploaded_from_library_dir( self ):
+ """Testing changing the permissions on datasets uploaded from a directory"""
# It would be nice if twill functioned such that the above test resulted in a
# form with the uploaded datasets selected, but it does not ( they're not checked ),
# so we'll have to simulate this behavior ( not ideal ) for the 'edit' action. We
@@ -807,21 +1367,22 @@
self.check_page_for_string( check_str )
raise AssertionError( '%s incorrectly has DATASET_MANAGE_PERMISSIONS on datasets imported from a library' % admin_user.email )
except:
- pass # This is the behavior we want
+ pass
try:
# This should no longer be possible
self.check_page_for_string( 'Role members can manage the roles associated with this dataset' )
raise AssertionError( '%s incorrectly has DATASET_MANAGE_PERMISSIONS on datasets imported from a library' % admin_user.email )
except:
- pass # This is the behavior we want
+ pass
try:
# This should no longer be possible
self.check_page_for_string( 'Role members can import this dataset into their history for analysis' )
raise AssertionError( '%s incorrectly has DATASET_MANAGE_PERMISSIONS on datasets imported from a library' % admin_user.email )
except:
- pass # This is the behavior we want
+ pass
check_edit_page2( latest_3_lddas )
- def test_125_mark_group_deleted( self ):
+ self.home()
+ def test_195_mark_group_deleted( self ):
"""Testing marking a group as deleted"""
self.home()
self.visit_url( '%s/admin/groups' % self.url )
@@ -835,13 +1396,13 @@
raise AssertionError( '%s incorrectly lost all members when it was marked as deleted.' % group_two.name )
if not group_two.roles:
raise AssertionError( '%s incorrectly lost all role associations when it was marked as deleted.' % group_two.name )
- def test_130_undelete_group( self ):
+ def test_200_undelete_group( self ):
"""Testing undeleting a deleted group"""
self.undelete_group( str( group_two.id ), group_two.name )
group_two.refresh()
if group_two.deleted:
raise AssertionError( '%s was not correctly marked as not deleted.' % group_two.name )
- def test_135_mark_role_deleted( self ):
+ def test_205_mark_role_deleted( self ):
"""Testing marking a role as deleted"""
self.home()
self.visit_url( '%s/admin/roles' % self.url )
@@ -855,83 +1416,90 @@
raise AssertionError( '%s incorrectly lost all user associations when it was marked as deleted.' % role_two.name )
if not role_two.groups:
raise AssertionError( '%s incorrectly lost all group associations when it was marked as deleted.' % role_two.name )
- def test_140_undelete_role( self ):
+ def test_210_undelete_role( self ):
"""Testing undeleting a deleted role"""
self.undelete_role( str( role_two.id ), role_two.name )
- def test_145_mark_library_deleted( self ):
+ def test_215_mark_dataset_deleted( self ):
+ """Testing marking a library dataset as deleted"""
+ self.home()
+ self.delete_library_item( str( library_one.id ), str( ldda_two.library_dataset.id ), ldda_two.name, library_item_type='library_dataset' )
+ self.home()
+ self.visit_page( 'admin/browse_library?id=%s' % ( str( library_one.id ) ) )
+ try:
+ # 2.bed was only contained in the library in 1 place, so it should no longer display
+ self.check_page_for_string( ldda_two.name )
+ raise AssertionError( "Dataset '%s' is incorrectly displayed in the library after it has been deleted." % ldda_two.name )
+ except:
+ pass
+ self.home()
+ def test_220_display_deleted_dataset( self ):
+ """Testing displaying deleted dataset"""
+ self.home()
+ self.visit_url( "%s/admin/browse_library?id=%s&show_deleted=True" % ( self.url, str( library_one.id ) ) )
+ self.check_page_for_string( ldda_two.name )
+ self.home()
+ def test_225_hide_deleted_dataset( self ):
+ """Testing hiding deleted dataset"""
+ self.home()
+ self.visit_url( "%s/admin/browse_library?id=%s&show_deleted=False" % ( self.url, str( library_one.id ) ) )
+ try:
+ self.check_page_for_string( ldda_two.name )
+ raise AssertionError( "Dataset '%s' is incorrectly displayed in the library after it has been deleted." % ldda_two.name )
+ except:
+ pass
+ self.home()
+ def test_230_mark_folder_deleted( self ):
+ """Testing marking a library folder as deleted"""
+ self.home()
+ self.delete_library_item( str( library_one.id ), str( folder_two.id ), folder_two.name, library_item_type='folder' )
+ self.home()
+ self.visit_page( 'admin/browse_library?id=%s' % ( str( library_one.id ) ) )
+ try:
+ self.check_page_for_string( folder_two.name )
+ raise AssertionError( "Folder '%s' is incorrectly displayed in the library after it has been deleted." % folder_two.name )
+ except:
+ pass
+ self.home()
+ def test_230_mark_folder_undeleted( self ):
+ """Testing marking a library folder as undeleted"""
+ self.home()
+ self.undelete_library_item( str( library_one.id ), str( folder_two.id ), folder_two.name, library_item_type='folder' )
+ self.home()
+ self.visit_page( 'admin/browse_library?id=%s' % ( str( library_one.id ) ) )
+ self.check_page_for_string( folder_two.name )
+ try:
+ # 2.bed was deleted before the folder was deleted, so state should have been saved. In order
+ # fro 2.bed to be displayed, it would itself have to be marked undeleted.
+ self.check_page_for_string( ldda_two.name )
+ raise AssertionError( "Dataset '%s' is incorrectly displayed in the library after parent folder was undeleted." % ldda_two.name )
+ except:
+ pass
+ self.home()
+ def test_235_mark_library_deleted( self ):
"""Testing marking a library as deleted"""
- # TODO: this needs to be re-engineered...
- self.mark_library_deleted( str( library_one.id ), library_one.name )
- # Make sure the library was deleted
- library_one.refresh()
- if not library_one.deleted:
- raise AssertionError( 'The library id %s named "%s" has not been marked as deleted.' % ( str( library_one.id ), library_one.name ) )
- def check_folder( library_folder ):
- for folder in library_folder.folders:
- folder.refresh()
- # Make sure all of the library_folders are deleted
- if not folder.deleted:
- raise AssertionError( 'The library_folder named "%s" has not been marked as deleted ( library.id: %s ).' % \
- ( folder.name, str( library_one.id ) ) )
- check_folder( folder )
- # Make sure all of the LibraryDatasets and associated objects are deleted
- library_folder.refresh()
- for library_dataset in library_folder.datasets:
- library_dataset.refresh()
- ldda = library_dataset.library_dataset_dataset_association
- if ldda:
- ldda.refresh()
- if not ldda.deleted:
- raise AssertionError( 'The library_dataset_dataset_association id %s named "%s" has not been marked as deleted ( library.id: %s ).' % \
- ( str( ldda.id ), ldda.name, str( library_one.id ) ) )
- # Make sure none of the datasets have been deleted since that should occur only when the library is purged
- ldda.dataset.refresh()
- if ldda.dataset.deleted:
- raise AssertionError( 'The dataset with id "%s" has been marked as deleted when it should not have been.' % ldda.dataset.id )
- if not library_dataset.deleted:
- raise AssertionError( 'The library_dataset id %s named "%s" has not been marked as deleted ( library.id: %s ).' % \
- ( str( library_dataset.id ), library_dataset.name, str( library_one.id ) ) )
- check_folder( library_one.root_folder )
- def test_150_undelete_library( self ):
- """Testing marking a library as not deleted"""
- self.undelete_library( str( library_one.id ), library_one.name )
- # Make sure the library is undeleted
- library_one.refresh()
- if library_one.deleted:
- raise AssertionError( 'The library id %s named "%s" has not been marked as undeleted.' % ( str( library_one.id ), library_one.name ) )
- def check_folder( library_folder ):
- for folder in library_folder.folders:
- folder.refresh()
- # Make sure all of the library_folders are undeleted
- if folder.deleted:
- raise AssertionError( 'The library_folder id %s named "%s" has not been marked as undeleted ( library.id: %s ).' % \
- ( str( folder.id ), folder.name, str( library_one.id ) ) )
- check_folder( folder )
- # Make sure all of the LibraryDatasets and associated objects are undeleted
- library_folder.refresh()
- for library_dataset in library_folder.datasets:
- library_dataset.refresh()
- ldda = library_dataset.library_dataset_dataset_association
- if ldda:
- ldda.refresh()
- if ldda.deleted:
- raise AssertionError( 'The library_dataset_dataset_association id %s named "%s" has not been marked as undeleted ( library.id: %s ).' % \
- ( str( ldda.id ), ldda.name, str( library_one.id ) ) )
- # Make sure all of the datasets have been undeleted
- if ldda.dataset.deleted:
- raise AssertionError( 'The dataset with id "%s" has not been marked as undeleted.' % ldda.dataset.id )
- if library_dataset.deleted:
- raise AssertionError( 'The library_dataset id %s named "%s" has not been marked as undeleted ( library.id: %s ).' % \
- ( str( library_dataset.id ), library_dataset.name, str( library_one.id ) ) )
- check_folder( library_one.root_folder )
- # Mark library as deleted again so we can test purging it
- self.mark_library_deleted( str( library_one.id ), library_one.name )
- # Make sure the library is deleted again
- library_one.refresh()
- if not library_one.deleted:
- raise AssertionError( 'The library id %s named "%s" has not been marked as deleted after it was undeleted.' % \
- ( str( library_one.id ), library_one.name ) )
- def test_155_purge_user( self ):
+ self.home()
+ # First mark folder_two as deleted to further test state saving when we undelete the library
+ self.delete_library_item( str( library_one.id ), str( folder_two.id ), folder_two.name, library_item_type='folder' )
+ self.delete_library_item( str( library_one.id ), str( library_one.id ), library_one.name, library_item_type='library' )
+ self.home()
+ self.visit_page( 'admin/deleted_libraries' )
+ self.check_page_for_string( library_one.name )
+ self.home()
+ def test_240_mark_library_undeleted( self ):
+ """Testing marking a library as undeleted"""
+ self.home()
+ self.undelete_library_item( str( library_one.id ), str( library_one.id ), library_one.name, library_item_type='library' )
+ self.home()
+ self.visit_page( 'admin/browse_library?id=%s' % ( str( library_one.id ) ) )
+ self.check_page_for_string( library_one.name )
+ try:
+ # folder_two was marked deleted before the library was deleted, so it should not be displayed
+ self.check_page_for_string( folder_two.name )
+ raise AssertionError( "Deleted folder '%s' is incorrectly displayed in the library after the library was undeleted." % folder_two.name )
+ except:
+ pass
+ self.home()
+ def test_245_purge_user( self ):
"""Testing purging a user account"""
self.mark_user_deleted( user_id=regular_user3.id, email=regular_user3.email )
self.purge_user( str( regular_user3.id ), regular_user3.email )
@@ -976,7 +1544,7 @@
role = galaxy.model.Role.get( ura.role_id )
if role.type != 'private':
raise AssertionError( 'UserRoleAssociations for user %s are not related with the private role.' % regular_user3.email )
- def test_160_manually_unpurge_user( self ):
+ def test_250_manually_unpurge_user( self ):
"""Testing manually un-purging a user account"""
# Reset the user for later test runs. The user's private Role and DefaultUserPermissions for that role
# should have been preserved, so all we need to do is reset purged and deleted.
@@ -984,7 +1552,7 @@
regular_user3.purged = False
regular_user3.deleted = False
regular_user3.flush()
- def test_165_purge_group( self ):
+ def test_255_purge_group( self ):
"""Testing purging a group"""
group_id = str( group_two.id )
self.mark_group_deleted( group_id, group_two.name )
@@ -999,7 +1567,7 @@
raise AssertionError( "Purging the group did not delete the GroupRoleAssociations for group_id '%s'" % group_id )
# Undelete the group for later test runs
self.undelete_group( group_id, group_two.name )
- def test_170_purge_role( self ):
+ def test_260_purge_role( self ):
"""Testing purging a role"""
role_id = str( role_two.id )
self.mark_role_deleted( role_id, role_two.name )
@@ -1024,14 +1592,14 @@
dp = galaxy.model.DatasetPermissions.filter( galaxy.model.DatasetPermissions.table.c.role_id == role_id ).all()
if dp:
raise AssertionError( "Purging the role did not delete the DatasetPermissionss for role_id '%s'" % role_id )
- def test_175_manually_unpurge_role( self ):
+ def test_265_manually_unpurge_role( self ):
"""Testing manually un-purging a role"""
# Manually unpurge, then undelete the role for later test runs
# TODO: If we decide to implement the GUI feature for un-purging a role, replace this with a method call
role_two.purged = False
role_two.flush()
self.undelete_role( str( role_two.id ), role_two.name )
- def test_180_purge_library( self ):
+ def test_270_purge_library( self ):
"""Testing purging a library"""
self.purge_library( str( library_one.id ), library_one.name )
# Make sure the library was purged
@@ -1065,8 +1633,17 @@
raise AssertionError( 'The library_dataset id %s named "%s" has not been marked as deleted.' % \
( str( library_dataset.id ), library_dataset.name ) )
check_folder( library_one.root_folder )
- def test_185_reset_data_for_later_test_runs( self ):
+ def test_275_reset_data_for_later_test_runs( self ):
"""Reseting data to enable later test runs to pass"""
+ ##################
+ # Eliminate all templates and info associations
+ ##################
+ for lia in library_one.library_info_associations:
+ lia.delete()
+ lia.flush()
+ for lita in library_one.library_info_template_associations:
+ lita.delete()
+ lita.flush()
##################
# Eliminate all non-private roles
##################
@@ -1080,7 +1657,7 @@
##################
# Eliminate all groups
##################
- for group in [ group_one, group_two ]:
+ for group in [ group_zero, group_one, group_two ]:
self.mark_group_deleted( str( group.id ), group.name )
self.purge_group( str( group.id ), group.name )
# Manually delete the group from the database
1
0
Hello,
I've updated the unix-tools package.
http://hannonlab.cshl.edu/galaxy_unix_tools/
1. Created a combined "Find and Replace" tool, which works on both lines
or columns, and allows simple string or regular expressions find&replace.
The purpose of this tool is to give users a way to replace text in
tabular text files. Without it, users needs to save the file, and
perform the replacements in excel. Being a Perl script, it works on
large files with millions of lines (on which excel chokes).
A usage example would be:
Find all words in column 2 which starts with a digit, and add a "chr"
prefix, effectively converting those drosophila "4L" chromosomes into
"chr4L".
see screen shot at:
http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html#find_and_replace
2. Select lines by Word-List tool.
This tool accepts two files: one which will be filtered,
the other contains a list of words to match.
If a line from the first file matches one of the words from the other
file - it is printed to the output dataset.
This tool allows similar functionality as the "advanced filter" option
in excel.
While it is possible to achieve same functionally by building a regular
expression and using Galaxy's native "select" tool - using this tool is
easier and more intuitive (IMHO).
Further more, this tool can be used as part of a workflow.
A usage workflow example:
Get the DM3 repeat masker track from UCSC,
Group by CLASS + count,
Sort descending by count,
Select first 10 lines,
Cut first column (this is the word list to filter by).
Then use this tool to filter the repeat masker file with the words in
the word list.
Result -
full information for the top ten classes from the repeat masker track.
see screen shot at:
http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html#grep_word_list
Comments are welcomed,
Gordon.
1
0
bug with output files_path property dataset ID when Galaxy has shared histories
by Hermida, Leandro 22 May '09
by Hermida, Leandro 22 May '09
22 May '09
Hello,
I've developed a few tools for Galaxy and I think I ran into a bug that
even exists in the latest version. As you know a Galaxy server
maintains the same external dataset ID (i.e. viewable in the web URLs)
to the filesystem internal dataset ID (i.e. names in
database/files/000/) if no user in the Galaxy server has yet shared any
histories (and their datasets). But once sharing starts the external
dataset IDs start differing from the internal dataset ID, and they are
always higher and Galaxy maintains this transparently. But this
behavior seems to be broken with the output files_path property.
If you have a tool which uses the output files_path property like this
one I have:
<command interpreter="perl">search.pl $query_list $output1
$output1.files_path</command>
On my test server I've shared one history with a single dataset. So my
external-internal offset is 1. The above tool then produces the
following command:
perl /home/hermida/galaxy/galaxy_dist/tools/omics_data_miner/search.pl
/home/hermida/galaxy/galaxy_dist/database/files/000/dataset_28.dat
/home/hermida/galaxy/galaxy_dist/database/files/000/dataset_31.dat
/home/hermida/galaxy/galaxy_dist/database/tmp/dataset_32_files
Galaxy is not generating the correct files_path, it should end in
dataset_31_files not 32. This bug causes the tool to completely break
when you are trying to view your output in the browser and I tried to
circumvent the bug with symlinking magic but it can't fix the problem
because symlinks start stepping on existing directories once you run the
tool more than once.
Thanks for any help on how to fix the problem,
Leandro
2
5
21 May '09
details: http://www.bx.psu.edu/hg/galaxy/rev/a54fd974365d
changeset: 2413:a54fd974365d
user: Dan Blankenberg <dan(a)bx.psu.edu>
date: Thu May 21 10:17:56 2009 -0400
description:
More fixes for DrilLDownParameter. Make SelectToolParameterWrapper context aware.
3 file(s) affected in this change:
lib/galaxy/tools/__init__.py
lib/galaxy/tools/actions/__init__.py
lib/galaxy/tools/parameters/basic.py
diffs (55 lines):
diff -r b818e6dff427 -r a54fd974365d lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py Thu May 21 09:40:21 2009 -0400
+++ b/lib/galaxy/tools/__init__.py Thu May 21 10:17:56 2009 -0400
@@ -1168,7 +1168,7 @@
tool = self,
name = input.name )
elif isinstance( input, SelectToolParameter ):
- input_values[ input.name ] = SelectToolParameterWrapper( input, input_values[ input.name ], self.app )
+ input_values[ input.name ] = SelectToolParameterWrapper( input, input_values[ input.name ], self.app, other_values = param_dict )
else:
input_values[ input.name ] = InputValueWrapper( input, input_values[ input.name ], param_dict )
# HACK: only wrap if check_values is not false, this deals with external
@@ -1515,12 +1515,13 @@
Wraps a SelectTooParameter so that __str__ returns the selected value, but all other
attributes are accessible.
"""
- def __init__( self, input, value, app ):
+ def __init__( self, input, value, app, other_values={} ):
self.input = input
self.value = value
self.input.value_label = input.value_to_display_text( value, app )
+ self._other_values = other_values
def __str__( self ):
- return self.input.to_param_dict_string( self.value )
+ return self.input.to_param_dict_string( self.value, other_values = self._other_values )
def __getattr__( self, key ):
return getattr( self.input, key )
diff -r b818e6dff427 -r a54fd974365d lib/galaxy/tools/actions/__init__.py
--- a/lib/galaxy/tools/actions/__init__.py Thu May 21 09:40:21 2009 -0400
+++ b/lib/galaxy/tools/actions/__init__.py Thu May 21 10:17:56 2009 -0400
@@ -101,7 +101,7 @@
tool = tool,
name = input.name )
elif isinstance( input, SelectToolParameter ):
- input_values[ input.name ] = galaxy.tools.SelectToolParameterWrapper( input, input_values[ input.name ], tool.app )
+ input_values[ input.name ] = galaxy.tools.SelectToolParameterWrapper( input, input_values[ input.name ], tool.app, other_values = incoming )
else:
input_values[ input.name ] = galaxy.tools.InputValueWrapper( input, input_values[ input.name ], incoming )
out_data = {}
diff -r b818e6dff427 -r a54fd974365d lib/galaxy/tools/parameters/basic.py
--- a/lib/galaxy/tools/parameters/basic.py Thu May 21 09:40:21 2009 -0400
+++ b/lib/galaxy/tools/parameters/basic.py Thu May 21 10:17:56 2009 -0400
@@ -1028,7 +1028,10 @@
# are not dynamic
if self.is_dynamic:
if value:
- rval = [ value ]
+ if isinstance( value, list ):
+ rval = value
+ else:
+ rval = [ value ]
else:
rval = []
else:
1
0
21 May '09
details: http://www.bx.psu.edu/hg/galaxy/rev/1a82088aac38
changeset: 2414:1a82088aac38
user: Nate Coraor <nate(a)bx.psu.edu>
date: Thu May 21 11:32:25 2009 -0400
description:
Move files_path to the job working directory and fix ugly bugs that broke files_path.
2 file(s) affected in this change:
lib/galaxy/jobs/__init__.py
lib/galaxy/tools/__init__.py
diffs (89 lines):
diff -r a54fd974365d -r 1a82088aac38 lib/galaxy/jobs/__init__.py
--- a/lib/galaxy/jobs/__init__.py Thu May 21 10:17:56 2009 -0400
+++ b/lib/galaxy/jobs/__init__.py Thu May 21 11:32:25 2009 -0400
@@ -351,7 +351,7 @@
incoming['userId'] = userId
incoming['userEmail'] = userEmail
# Build params, done before hook so hook can use
- param_dict = self.tool.build_param_dict( incoming, inp_data, out_data, self.get_output_fnames() )
+ param_dict = self.tool.build_param_dict( incoming, inp_data, out_data, self.get_output_fnames(), self.working_directory )
# Certain tools require tasks to be completed prior to job execution
# ( this used to be performed in the "exec_before_job" hook, but hooks are deprecated ).
if self.tool.tool_type is not None:
@@ -529,7 +529,7 @@
param_dict = dict( [ ( p.name, p.value ) for p in job.parameters ] ) # why not re-use self.param_dict here? ##dunno...probably should, this causes tools.parameters.basic.UnvalidatedValue to be used in following methods instead of validated and transformed values during i.e. running workflows
param_dict = self.tool.params_from_strings( param_dict, self.app )
# Check for and move associated_files
- self.tool.collect_associated_files(out_data)
+ self.tool.collect_associated_files(out_data, self.working_directory)
# Create generated output children and primary datasets and add to param_dict
collected_datasets = {'children':self.tool.collect_child_datasets(out_data),'primary':self.tool.collect_primary_datasets(out_data)}
param_dict.update({'__collected_datasets__':collected_datasets})
@@ -596,7 +596,7 @@
job = model.Job.get( self.job_id )
if self.app.config.outputs_to_working_directory:
self.output_paths = []
- for name, data in [ ( da.name, da.dataset ) for da in job.output_datasets ]:
+ for name, data in [ ( da.name, da.dataset.dataset ) for da in job.output_datasets ]:
false_path = os.path.abspath( os.path.join( self.working_directory, "galaxy_dataset_%d.dat" % data.id ) )
self.output_paths.append( DatasetPath( data.file_name, false_path ) )
else:
diff -r a54fd974365d -r 1a82088aac38 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py Thu May 21 10:17:56 2009 -0400
+++ b/lib/galaxy/tools/__init__.py Thu May 21 11:32:25 2009 -0400
@@ -1140,7 +1140,7 @@
message = e.message
return message
- def build_param_dict( self, incoming, input_datasets, output_datasets, output_paths ):
+ def build_param_dict( self, incoming, input_datasets, output_datasets, output_paths, job_working_directory ):
"""
Build the dictionary of parameters for substituting into the command
line. Each value is wrapped in a `InputValueWrapper`, which allows
@@ -1191,22 +1191,22 @@
if data:
for child in data.children:
param_dict[ "_CHILD___%s___%s" % ( name, child.designation ) ] = DatasetFilenameWrapper( child )
- for name, data in output_datasets.items():
+ for name, hda in output_datasets.items():
# Write outputs to the working directory (for security purposes) if desired.
if self.app.config.outputs_to_working_directory:
try:
- false_path = [ dp.false_path for dp in output_paths if dp.real_path == data.file_name ][0]
- param_dict[name] = DatasetFilenameWrapper( data, false_path = false_path )
+ false_path = [ dp.false_path for dp in output_paths if dp.real_path == hda.file_name ][0]
+ param_dict[name] = DatasetFilenameWrapper( hda, false_path = false_path )
open( false_path, 'w' ).close()
except IndexError:
log.warning( "Unable to determine alternate path for writing job outputs, outputs will be written to their real paths" )
- param_dict[name] = DatasetFilenameWrapper( data )
+ param_dict[name] = DatasetFilenameWrapper( hda )
else:
- param_dict[name] = DatasetFilenameWrapper( data )
+ param_dict[name] = DatasetFilenameWrapper( hda )
# Provide access to a path to store additional files
# TODO: path munging for cluster/dataset server relocatability
- param_dict[name].files_path = os.path.abspath(os.path.join(self.app.config.new_file_path, "dataset_%s_files" % (data.id) ))
- for child in data.children:
+ param_dict[name].files_path = os.path.abspath(os.path.join( job_working_directory, "dataset_%s_files" % (hda.dataset.id) ))
+ for child in hda.children:
param_dict[ "_CHILD___%s___%s" % ( name, child.designation ) ] = DatasetFilenameWrapper( child )
# We add access to app here, this allows access to app.config, etc
param_dict['__app__'] = RawObjectWrapper( self.app )
@@ -1394,12 +1394,12 @@
data.set_peek()
data.flush()
- def collect_associated_files( self, output ):
- for name, outdata in output.items():
- temp_file_path = os.path.join( self.app.config.new_file_path, "dataset_%s_files" % ( outdata.id ) )
+ def collect_associated_files( self, output, job_working_directory ):
+ for name, hda in output.items():
+ temp_file_path = os.path.join( job_working_directory, "dataset_%s_files" % ( hda.dataset.id ) )
try:
if len( os.listdir( temp_file_path ) ) > 0:
- store_file_path = os.path.join( os.path.join( self.app.config.file_path, *directory_hash_id( outdata.id ) ), "dataset_%d_files" % outdata.id )
+ store_file_path = os.path.join( os.path.join( self.app.config.file_path, *directory_hash_id( hda.dataset.id ) ), "dataset_%d_files" % hda.dataset.id )
shutil.move( temp_file_path, store_file_path )
except:
continue
1
0
21 May '09
details: http://www.bx.psu.edu/hg/galaxy/rev/49d90967d0b8
changeset: 2411:49d90967d0b8
user: Nate Coraor <nate(a)bx.psu.edu>
date: Fri May 15 16:19:23 2009 -0400
description:
Add UCSC Archaea support for the remote user pass-thru
1 file(s) affected in this change:
lib/galaxy/web/framework/middleware/remoteuser.py
diffs (48 lines):
diff -r a8d4ab6b6dd3 -r 49d90967d0b8 lib/galaxy/web/framework/middleware/remoteuser.py
--- a/lib/galaxy/web/framework/middleware/remoteuser.py Thu May 14 12:55:14 2009 -0400
+++ b/lib/galaxy/web/framework/middleware/remoteuser.py Fri May 15 16:19:23 2009 -0400
@@ -35,7 +35,7 @@
</html>
"""
-UCSC_SERVERS = (
+UCSC_MAIN_SERVERS = (
'hgw1.cse.ucsc.edu',
'hgw2.cse.ucsc.edu',
'hgw3.cse.ucsc.edu',
@@ -45,23 +45,30 @@
'hgw7.cse.ucsc.edu',
'hgw8.cse.ucsc.edu',
)
+UCSC_ARCHAEA_SERVERS = (
+ 'lowepub.cse.ucsc.edu',
+)
class RemoteUser( object ):
def __init__( self, app, maildomain=None, ucsc_display_sites=[] ):
self.app = app
self.maildomain = maildomain
- self.allow_ucsc = False
- if len( ucsc_display_sites ):
- self.allow_ucsc = True
+ self.allow_ucsc_main = False
+ self.allow_ucsc_archaea = False
+ if 'main' in ucsc_display_sites or 'test' in ucsc_display_sites:
+ self.allow_ucsc_main = True
+ if 'archaea' in ucsc_display_sites:
+ self.allow_ucsc_archaea = True
def __call__( self, environ, start_response ):
# Allow through UCSC if the UCSC display links are enabled
- if self.allow_ucsc and environ.has_key( 'REMOTE_ADDR' ):
+ if ( self.allow_ucsc_main or self.allow_ucsc_archaea ) and environ.has_key( 'REMOTE_ADDR' ):
try:
host = socket.gethostbyaddr( environ[ 'REMOTE_ADDR' ] )[0]
except( socket.error, socket.herror, socket.gaierror, socket.timeout ):
# in the event of a lookup failure, deny access
host = None
- if host in UCSC_SERVERS:
+ if ( self.allow_ucsc_main and host in UCSC_MAIN_SERVERS ) or \
+ ( self.allow_ucsc_archaea and host in UCSC_ARCHAEA_SERVERS ):
environ[ 'HTTP_REMOTE_USER' ] = 'ucsc_browser_display(a)example.org'
return self.app( environ, start_response )
# Apache sets REMOTE_USER to the string '(null)' when using the
1
0
21 May '09
details: http://www.bx.psu.edu/hg/galaxy/rev/b818e6dff427
changeset: 2412:b818e6dff427
user: Dan Blankenberg <dan(a)bx.psu.edu>
date: Thu May 21 09:40:21 2009 -0400
description:
Fix for DrillDownParameter type and compatibility with SelectToolParameter's old dynamic options and late
validation
1 file(s) affected in this change:
lib/galaxy/tools/parameters/basic.py
diffs (11 lines):
diff -r 49d90967d0b8 -r b818e6dff427 lib/galaxy/tools/parameters/basic.py
--- a/lib/galaxy/tools/parameters/basic.py Fri May 15 16:19:23 2009 -0400
+++ b/lib/galaxy/tools/parameters/basic.py Thu May 21 09:40:21 2009 -0400
@@ -882,6 +882,7 @@
from_file = os.path.join( tool.app.config.tool_data_path, from_file )
elem = XML( "<root>%s</root>" % open( from_file ).read() )
self.is_dynamic = False
+ self.dynamic_options = None #backwards compatibility with SelectToolParameter's old dynamic options and late validation
self.options = []
self.filtered = {}
if elem.find( 'filter' ):
1
0
21 May '09
details: http://www.bx.psu.edu/hg/galaxy/rev/a8d4ab6b6dd3
changeset: 2410:a8d4ab6b6dd3
user: Dan Blankenberg <dan(a)bx.psu.edu>
date: Thu May 14 12:55:14 2009 -0400
description:
Add the ability for the tabular join tool to fill in empty columns.
Working tests are needed.
2 file(s) affected in this change:
tools/filters/join.py
tools/filters/joiner.xml
diffs (235 lines):
diff -r 25d736f5cbf7 -r a8d4ab6b6dd3 tools/filters/join.py
--- a/tools/filters/join.py Wed May 13 21:54:45 2009 -0400
+++ b/tools/filters/join.py Thu May 14 12:55:14 2009 -0400
@@ -8,8 +8,21 @@
"""
-import optparse, os, sys, tempfile, struct
+import optparse, os, sys, tempfile, struct
import psyco_full
+
+try:
+ simple_json_exception = None
+ from galaxy import eggs
+ from galaxy.util.bunch import Bunch
+ from galaxy.util import stringify_dictionary_keys
+ import pkg_resources
+ pkg_resources.require("simplejson")
+ import simplejson
+except Exception, e:
+ simplejson_exception = e
+ simplejson = None
+
class OffsetList:
def __init__( self, filesize = 0, fmt = None ):
@@ -235,7 +248,22 @@
for offset in self.buffered_offsets[identifier]:
yield self.index.get_line_by_offset( offset )
-def join_files( filename1, column1, filename2, column2, out_filename, split = None, buffer = 1000000, keep_unmatched = False, keep_partial = False, index_depth = 3 ):
+
+def fill_empty_columns( line, split, fill_values ):
+ if not fill_values:
+ return line
+ filled_columns = []
+ for i, field in enumerate( line.split( split ) ):
+ if field or i >= len( fill_values ):
+ filled_columns.append( field )
+ else:
+ filled_columns.append( fill_values[i] )
+ if len( fill_values ) > len( filled_columns ):
+ filled_columns.extend( fill_values[ len( filled_columns ) : ] )
+ return split.join( filled_columns )
+
+
+def join_files( filename1, column1, filename2, column2, out_filename, split = None, buffer = 1000000, keep_unmatched = False, keep_partial = False, index_depth = 3, fill_options = None ):
#return identifier based upon line
def get_identifier_by_line( line, column, split = None ):
if isinstance( line, str ):
@@ -243,6 +271,8 @@
if column < len( fields ):
return fields[column]
return None
+ if fill_options is None:
+ fill_options = Bunch( fill_unjoined_only = True, file1_columns = None, file2_columns = None )
out = open( out_filename, 'w+b' )
index = BufferedIndex( filename2, column2, split, buffer, index_depth )
for line1 in open( filename1, 'rb' ):
@@ -250,12 +280,21 @@
if identifier:
written = False
for line2 in index.get_lines_by_identifier( identifier ):
- out.write( "%s%s%s\n" % ( line1.rstrip( '\r\n' ), split, line2.rstrip( '\r\n' ) ) )
+ if not fill_options.fill_unjoined_only:
+ out.write( "%s%s%s\n" % ( fill_empty_columns( line1.rstrip( '\r\n' ), split, fill_options.file1_columns ), split, fill_empty_columns( line2.rstrip( '\r\n' ), split, fill_options.file2_columns ) ) )
+ else:
+ out.write( "%s%s%s\n" % ( line1.rstrip( '\r\n' ), split, line2.rstrip( '\r\n' ) ) )
written = True
if not written and keep_unmatched:
- out.write( "%s\n" % ( line1.rstrip( '\r\n' ) ) )
+ out.write( fill_empty_columns( line1.rstrip( '\r\n' ), split, fill_options.file1_columns ) )
+ if fill_options:
+ out.write( fill_empty_columns( "", split, fill_options.file2_columns ) )
+ out.write( "\n" )
elif keep_partial:
- out.write( "%s\n" % ( line1.rstrip( '\r\n' ) ) )
+ out.write( fill_empty_columns( line1.rstrip( '\r\n' ), split, fill_options.file1_columns ) )
+ if fill_options:
+ out.write( fill_empty_columns( "", split, fill_options.file2_columns ) )
+ out.write( "\n" )
out.close()
def main():
@@ -284,8 +323,32 @@
dest='keep_unmatched',
default=False,
help='Keep rows in first input which are not joined with the second input.')
+ parser.add_option(
+ '-f','--fill_options_file',
+ dest='fill_options_file',
+ type='str',default=None,
+ help='Fill empty columns with a values from a JSONified file.')
+
options, args = parser.parse_args()
+
+ fill_options = None
+ if options.fill_options_file is not None:
+ try:
+ if simplejson is None:
+ raise simplejson_exception
+ fill_options = Bunch( **stringify_dictionary_keys( simplejson.load( open( options.fill_options_file ) ) ) ) #simplejson.load( open( options.fill_options_file ) )
+ except Exception, e:
+ print "Warning: Ignoring fill options due to simplejson error (%s)." % e
+ if fill_options is None:
+ fill_options = Bunch()
+ if 'fill_unjoined_only' not in fill_options:
+ fill_options.fill_unjoined_only = True
+ if 'file1_columns' not in fill_options:
+ fill_options.file1_columns = None
+ if 'file2_columns' not in fill_options:
+ fill_options.file2_columns = None
+
try:
filename1 = args[0]
@@ -300,6 +363,6 @@
#Character for splitting fields and joining lines
split = "\t"
- return join_files( filename1, column1, filename2, column2, out_filename, split, options.buffer, options.keep_unmatched, options.keep_partial, options.index_depth )
+ return join_files( filename1, column1, filename2, column2, out_filename, split, options.buffer, options.keep_unmatched, options.keep_partial, options.index_depth, fill_options = fill_options )
if __name__ == "__main__": main()
diff -r 25d736f5cbf7 -r a8d4ab6b6dd3 tools/filters/joiner.xml
--- a/tools/filters/joiner.xml Wed May 13 21:54:45 2009 -0400
+++ b/tools/filters/joiner.xml Thu May 14 12:55:14 2009 -0400
@@ -1,6 +1,6 @@
-<tool id="join1" name="Join two Queries" version="2.0.0">
+<tool id="join1" name="Join two Queries" version="2.0.1">
<description>side by side on a specified field</description>
- <command interpreter="python">join.py $input1 $input2 $field1 $field2 $out_file1 $unmatched $partial --index_depth=3 --buffer=50000000</command>
+ <command interpreter="python">join.py $input1 $input2 $field1 $field2 $out_file1 $unmatched $partial --index_depth=3 --buffer=50000000 --fill_options_file=$fill_options_file</command>
<inputs>
<param format="tabular" name="input1" type="data" label="Join"/>
<param name="field1" label="using column" type="data_column" data_ref="input1" />
@@ -14,7 +14,66 @@
<option value="-p">Yes</option>
<option value="" selected="true">No</option>
</param>
+ <conditional name="fill_empty_columns">
+ <param name="fill_empty_columns_switch" type="select" label="Fill empty columns">
+ <option value="no_fill" selected="True">No</option>
+ <option value="fill_empty">Yes</option>
+ </param>
+ <when value="no_fill">
+ <!-- do nothing -->
+ </when>
+ <when value="fill_empty">
+ <param type="select" name="fill_columns_by" label="Only fill unjoined rows">
+ <option value="fill_unjoined_only" selected="True">Yes</option>
+ <option value="fill_all">No</option>
+ </param>
+ <conditional name="do_fill_empty_columns">
+ <param name="column_fill_type" type="select" label="Fill Columns by">
+ <option value="single_fill_value" selected="True">Single fill value</option>
+ <option value="fill_value_by_column">Values by column</option>
+ </param>
+ <when value="single_fill_value">
+ <param type="text" name="fill_value" label="Fill value" value="."/>
+ </when>
+ <when value="fill_value_by_column">
+ <repeat name="column_fill1" title="Fill Column for Input 1">
+ <param name="column_number1" label="Column" type="data_column" data_ref="input1" />
+ <param type="text" name="fill_value1" value="."/>
+ </repeat>
+ <repeat name="column_fill2" title="Fill Column for Input 2">
+ <param name="column_number2" label="Column" type="data_column" data_ref="input2" />
+ <param type="text" name="fill_value2" value="."/>
+ </repeat>
+ </when>
+ </conditional>
+ </when>
+ </conditional>
</inputs>
+ <configfiles>
+ <configfile name="fill_options_file"><%
+import simplejson
+%>#set $__fill_options = {}
+#if $fill_empty_columns['fill_empty_columns_switch'] == 'fill_empty':
+#set $__fill_options['fill_unjoined_only'] = $fill_empty_columns['fill_columns_by'].value == 'fill_unjoined_only'
+#if $fill_empty_columns['do_fill_empty_columns']['column_fill_type'] == 'single_fill_value':
+#set $__start_fill = $fill_empty_columns['do_fill_empty_columns']['fill_value'].value
+#else:
+#set $__start_fill = ""
+#end if
+#set $__fill_options['file1_columns'] = [ $__start_fill for i in range( int( $input1.metadata.columns ) ) ]
+#set $__fill_options['file2_columns'] = [ $__start_fill for i in range( int( $input2.metadata.columns ) ) ]
+#if $fill_empty_columns['do_fill_empty_columns']['column_fill_type'] == 'fill_value_by_column':
+#for column_fill1 in $fill_empty_columns['do_fill_empty_columns']['column_fill1']:
+#set $__fill_options['file1_columns'][ int( column_fill1['column_number1'].value ) - 1 ] = column_fill1['fill_value1'].value
+#end for
+#for column_fill2 in $fill_empty_columns['do_fill_empty_columns']['column_fill2']:
+#set $__fill_options['file2_columns'][ int( column_fill2['column_number2'].value ) - 1 ] = column_fill2['fill_value2'].value
+#end for
+#end if
+#end if
+${simplejson.dumps( __fill_options )}
+ </configfile>
+ </configfiles>
<outputs>
<data format="input" name="out_file1" metadata_source="input1" />
</outputs>
@@ -26,6 +85,7 @@
<param name="field2" value="2"/>
<param name="unmatched" value=""/>
<param name="partial" value=""/>
+ <param name="fill_empty_columns_switch" value="no_fill"/>
<output name="out_file1" file="joiner_out1.bed"/>
</test>
<test>
@@ -35,8 +95,22 @@
<param name="field2" value="2"/>
<param name="unmatched" value="Yes"/>
<param name="partial" value="Yes"/>
+ <param name="fill_empty_columns_switch" value="no_fill"/>
<output name="out_file1" file="joiner_out2.bed"/>
</test>
+<!--this throws an exception in the test framework - we need tests for the fill empty columns enhancements <test>
+ <param name="input1" value="1.bed"/>
+ <param name="input2" value="2.bed"/>
+ <param name="field1" value="2"/>
+ <param name="field2" value="2"/>
+ <param name="unmatched" value="Yes"/>
+ <param name="partial" value="Yes"/>
+ <param name="fill_empty_columns_switch" value="fill_empty"/>
+ <param name="fill_columns_by" value="fill_all"/>
+ <param name="column_fill_type" value="single_fill_value"/>
+ <param name="fill_value" value="~"/>
+ <output name="out_file1" file="joiner_out3.bed"/>
+ </test>-->
</tests>
<help>
1
0