changeset 11:3a6db127d400 draft

Deleted selected files
author ric
date Tue, 27 Sep 2016 04:12:37 -0400
parents a06251a4625b
children 46f08bb8dd68
files galaxy-tools/biobank/updater/discard_from_collection.py galaxy-tools/biobank/updater/discard_from_collection.xml
diffstat 2 files changed, 0 insertions(+), 207 deletions(-) [+]
line wrap: on
line diff
--- a/galaxy-tools/biobank/updater/discard_from_collection.py	Mon Sep 26 09:27:16 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-import csv, argparse, sys, os
-
-from bl.vl.kb import KnowledgeBase as KB
-import bl.vl.utils.ome_utils as vlu
-from bl.vl.utils import get_logger, LOG_LEVELS
-
-COLLECTION_TYPES = {'VesselsCollection' : 'VesselsCollectionItem',
-                    'DataCollection'    : 'DataCollectionItem'}
-
-def make_parser():
-    parser = argparse.ArgumentParser(description='remove elements from a Vessels or Data Collection')
-    parser.add_argument('--logfile', type=str, help='log file (default=stderr)')
-    parser.add_argument('--loglevel', type=str, choices=LOG_LEVELS,
-                        help='logger level', default='INFO')
-    parser.add_argument('-H', '--host', type=str, help='omero hostname')
-    parser.add_argument('-U', '--user', type=str, help='omero user')
-    parser.add_argument('-P', '--passwd', type=str, help='omero password')
-    parser.add_argument('-I', '--ifile', type=str, required=True,
-                        help='list of collection items that will be removed')
-    parser.add_argument('--collection_type', type=str, required=True,
-                        choices=COLLECTION_TYPES.keys(),
-                        help='type of the collection')
-    parser.add_argument('--collection_label', type=str, required=True,
-                        help='label of the collection')
-
-    return parser
-
-def load_collection(coll_type, coll_label, kb):
-    query = 'SELECT coll FROM %s coll WHERE coll.label = :coll_label' % coll_type
-    coll = kb.find_all_by_query(query, {'coll_label' : coll_label})
-    return coll[0] if len(coll) > 0 else None
-
-def load_collection_items(collection, coll_type, kb):
-    if COLLECTION_TYPES[coll_type] == 'VesselsCollectionItem':
-        citems = kb.get_vessels_collection_items(collection)
-    elif COLLECTION_TYPES[coll_type] == 'DataCollectionItem':
-        citems =  kb.get_data_collection_items(collection)
-    else:
-        raise ValueError('Unknown data collection type %s' % COLLECTION_TYPES[coll_type])
-    ci_map = {}
-    for ci in citems:
-        ci_map[ci.id] = ci
-    return ci_map
-
-
-def main(argv):
-    parser = make_parser()
-    args = parser.parse_args(argv)
-
-    logger = get_logger('discard_from_collection', level=args.loglevel,
-                        filename=args.logfile)
-
-    try:
-        host   = args.host or vlu.ome_host()
-        user   = args.user or vlu.ome_user()
-        passwd = args.passwd or vlu.ome_passwd()
-    except ValueError, ve:
-        logger.critical(ve)
-        sys.exit(ve)
-
-    kb = KB(driver='omero')(host, user, passwd)
-    logger.info('Loading collection %s from %s' % (args.collection_label,
-                                                    args.collection_type))
-    coll = load_collection(args.collection_type, args.collection_label, kb)
-    if not coll:
-        msg = 'No %s found with label %s' % (args.collection_type,
-                                             args.collection_label)
-        logger.error(msg)
-        sys.exit(msg)
-    logger.info('Loading items from collection')
-    coll_items = load_collection_items(coll, args.collection_type, kb)
-    logger.info('Fetched %d elements' % len(coll_items))
-
-    with open(args.ifile) as infile:
-        reader = csv.DictReader(infile, delimiter='\t')
-        to_be_deleted = [row['collection_item'] for row in reader]
-    logger.info('Found %d items to be deleted' % len(to_be_deleted))
-
-    for tbd in to_be_deleted:
-        try:
-            kb.delete(coll_items[tbd])
-            logger.info('%s with ID %s deleted' % (COLLECTION_TYPES[args.collection_type],
-                                                   tbd))
-        except KeyError, ke:
-            logger.warning('No %s related to ID %s' % (COLLECTION_TYPES[args.collection_type],
-                                                       ke))
-    logger.info('Job completed')
-
-
-if __name__ == '__main__':
-    main(sys.argv[1:])
--- a/galaxy-tools/biobank/updater/discard_from_collection.xml	Mon Sep 26 09:27:16 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-<tool id="vl_update_discard_from_collection" name="VLU.discard_from_collection">
-  <description>
-    Discard input elements from the selected collection
-  </description>
-  <command interpreter="python">
-    discard_from_collection.py
-    #if $advanced_configuration.configuration_level == 'advanced'
-      --host=$advanced_configuration.vl_host
-      --user=$advanced_configuration.vl_user
-      --passwd=$advanced_configuration.vl_passwd
-    #end if
-    --loglevel=$__app__.config.vl_loglevel
-    --logfile=${logfile}
-    --ifile=${ifile}
-    #if str($collection_selector.collection_type) != 'no_coll_selected'
-      --collection_type=${collection_selector.collection_type}
-      #if str($collection_selector.collection_type) == 'DataCollection'
-        #if str($collection_selector.dcoll_label) != 'no_label_selected'
-          --collection_label=${collection_selector.dcoll_label}
-	#end if
-      #elif str($collection_selector.collection_type) == 'VesselsCollection'
-        #if str($collection_selector.vcoll_label) != 'no_label_selected'
-          --collection_label=${collection_selector.vcoll_label}
-	#end if
-      #end if
-    #end if
-  </command>
-
-  <inputs>
-    <param format="tabular" name="ifile" type="data"
-	   label="A tabular dataset with the following columns..."/>
-
-    <conditional name="collection_selector">
-      <param name="collection_type" type="select"
-	     label="Collection Type">
-	<option value="no_coll_selected">Select a Collection type...</option>
-	<option value="DataCollection">Data Collection</option>
-	<option value="VesselsCollection">Vessels Collection</option>
-      </param>
-      <when value="DataCollection">
-	<param name="dcoll_label" type="select" label="Data Collection label"
-	       help="Choose one of the already defined Data Collections.">
-	  <options from_parameter="tool.app.known_data_collections"
-		   transform_lines="[ &quot;%s%s%s&quot;
-	                              % (l[1], self.separator, l[1])
-				      for l in obj ]">
-	    <column name="value" index="1"/>
-	    <column name="name" index="0"/>
-	    <filter type="sort_by" column="0"/>
-	    <filter type="add_value" name="Select a Data Collection..."
-		    value="no_label_selected" index="0"/>
-	  </options>
-	</param>
-      </when>
-      <when value="VesselsCollection">
-	<param name="vcoll_label" type="select" label="Vessels Collection label"
-	       help="Choose one of the already defined Vessels Collections.">
-	  <options from_parameter="tool.app.known_vessels_collections"
-		   transform_lines="[ &quot;%s%s%s&quot;
-	                              % (l[1], self.separator, l[1])
-				      for l in obj ]">
-	    <column name="value" index="1"/>
-	    <column name="name" index="0"/>
-	    <filter type="sort_by" column="0"/>
-	    <filter type="add_value" name="Select a Vessels Collection..."
-		    value="no_label_selected" index="0"/>
-	  </options>
-	</param>
-      </when>
-    </conditional>
-
-    <!-- ************************************************** -->
-    <conditional name="advanced_configuration">
-      <param name="configuration_level" type="select" 
-	     label="Configuration level">
-	<option value="default" selected="true">Default configuration</option>	
-	<option value="advanced">Advanced configuration</option>
-      </param>
-      <when value="default"/>
-      <when value="advanced">
-	<param name="vl_host" size="40" type="text" value="biobank05.crs4.it" 
-	       label="Omero/VL host"/>
-	<param name="vl_user" size="20" type="text" value="galaxy" 
-	       label="Omero/VL user"/>
-	<param name="vl_passwd" size="20" type="text" value="What?Me worry?" 
-	       label="Omero/VL passwd"/>
-      </when>
-    </conditional>
-  </inputs>
-
-  <outputs>
-    <data format="txt" name="logfile" label="${tool.name}.logfile"/>
-  </outputs>
-
-  <help>
-This tool discard from a DataCollection or a VesselCollection one or
-more items.
-
-The expected input file must be like
-
-+---------------+
-|collection_item|
-+---------------+
-|V013AFF22311   |
-+---------------+
-|V0ABB3451516   |
-+---------------+
-|V012441AAEEC   |
-+---------------+
-
-Input file rows must be VIDs obtained using the **map_vid** tool.
-
-Collection must be selected using the specific selection lists that
-show only the ones imported into the system.
-  </help>
-</tool>
\ No newline at end of file