def copy_file(orig_uuid): """Helper function that copies a file if given the original file's UUID :param orig_uuid: UUID of file to copy. :type orig_uuid: str. :returns: UUID of newly copied file. """ orig_fsi = read(orig_uuid) newfile_uuid = None try: newfile_uuid = create(orig_fsi.source, orig_fsi.sharename, orig_fsi.filetype, permanent=is_permanent(orig_uuid)) import_file(newfile_uuid, refresh=True) except AttributeError: pass return newfile_uuid
def copy_file(orig_uuid): """Helper function that copies a file if given the original file's UUID :param orig_uuid: UUID of file to copy. :type orig_uuid: str. :returns: UUID of newly copied file. """ orig_fsi = read(orig_uuid) newfile_uuid = None try: newfile_uuid = create( orig_fsi.source, orig_fsi.sharename, orig_fsi.filetype, permanent=is_permanent(orig_uuid) ) import_file(newfile_uuid, refresh=True) except AttributeError: pass return newfile_uuid
def prepare(self, object): data = super(NodeIndex, self).prepare(object) annotations = AnnotatedNode.objects.filter(node=object) uuid = str(object.study.id) if object.assay is not None: uuid += "_" + str(object.assay.id) # create dynamic fields for each attribute for annotation in annotations: if annotation.attribute_subtype is None: name = annotation.attribute_type else: name = annotation.attribute_subtype + "_" + annotation.attribute_type if annotation.attribute_value_unit is None: value = annotation.attribute_value else: value = annotation.attribute_value + " " + annotation.attribute_value_unit # replace problematic characters in field names name = string.replace(name, "/", settings.REFINERY_SOLR_SPACE_DYNAMIC_FIELDS) name = string.replace(name, "(", settings.REFINERY_SOLR_SPACE_DYNAMIC_FIELDS) name = string.replace(name, ")", settings.REFINERY_SOLR_SPACE_DYNAMIC_FIELDS) name = string.replace(name, "#", settings.REFINERY_SOLR_SPACE_DYNAMIC_FIELDS) name = string.replace(name, ",", settings.REFINERY_SOLR_SPACE_DYNAMIC_FIELDS) name = string.replace(name, " ", settings.REFINERY_SOLR_SPACE_DYNAMIC_FIELDS) name = string.replace(name, "'", settings.REFINERY_SOLR_SPACE_DYNAMIC_FIELDS) key = name + "_" + uuid + "_s" # a node might have multiple parents with different attribute values for a given attribute # e.g. parentA Characteristic[cell type] = K562 and parentB Characteristic[cell type] = HeLa # child nodes should inherit all attributes of their parents as a concatenation of the # unique list # # old version (only one attribute kept): # data[key] = value if not key in data: data[key] = set() if value != "": data[key].add(value) else: data[key].add("N/A") # iterate over all keys in data and join sets into strings for key, value in data.iteritems(): if type(value) is set: data[key] = " + ".join(value) # add type as dynamic field to get proper facet values data[NodeIndex.TYPE_PREFIX + "_" + uuid + "_s"] = object.type # add name as dynamic field to get proper facet values data[NodeIndex.NAME_PREFIX + "_" + uuid + "_s"] = object.name # add analysis_uuid as dynamic field to get proper facet values if object.analysis_uuid is not None: data[NodeIndex.ANALYSIS_UUID_PREFIX + "_" + uuid + "_s"] = object.analysis_uuid else: data[NodeIndex.ANALYSIS_UUID_PREFIX + "_" + uuid + "_s"] = "N/A" # add subanalysis as dynamic field to get proper facet values if object.subanalysis is not None: data[NodeIndex.SUBANALYSIS_PREFIX + "_" + uuid + "_s"] = object.subanalysis else: data[NodeIndex.SUBANALYSIS_PREFIX + "_" + uuid + "_s"] = -1 # add workflow_output as dynamic field to get proper facet values if object.workflow_output is not None: data[NodeIndex.WORKFLOW_OUTPUT_PREFIX + "_" + uuid + "_s"] = object.workflow_output else: data[NodeIndex.WORKFLOW_OUTPUT_PREFIX + "_" + uuid + "_s"] = "N/A" # add file type as facet value file_store_item = file_store_tasks.read(object.file_uuid) if file_store_item: data[NodeIndex.FILETYPE_PREFIX + "_" + uuid + "_s"] = file_store_item.get_filetype() else: logger.warning("Unable to get file store item " + str(object.file_uuid) + ". No file type available.") data[NodeIndex.FILETYPE_PREFIX + "_" + uuid + "_s"] = "" return data
def prepare(self, object): data = super(NodeIndex, self).prepare(object) annotations = AnnotatedNode.objects.filter( node=object ) uuid = str( object.study.id ) if object.assay is not None: uuid += "_" + str( object.assay.id ) # create dynamic fields for each attribute for annotation in annotations: if annotation.attribute_subtype is None: name = annotation.attribute_type else: name = annotation.attribute_subtype + "_" + annotation.attribute_type if annotation.attribute_value_unit is None: value = annotation.attribute_value else: value = annotation.attribute_value + " " + annotation.attribute_value_unit # replace problematic characters in field names name = string.replace( name, "/", settings.REFINERY_SOLR_SPACE_DYNAMIC_FIELDS ) name = string.replace( name, "(", settings.REFINERY_SOLR_SPACE_DYNAMIC_FIELDS ) name = string.replace( name, ")", settings.REFINERY_SOLR_SPACE_DYNAMIC_FIELDS ) name = string.replace( name, "#", settings.REFINERY_SOLR_SPACE_DYNAMIC_FIELDS ) name = string.replace( name, ",", settings.REFINERY_SOLR_SPACE_DYNAMIC_FIELDS ) name = string.replace( name, " ", settings.REFINERY_SOLR_SPACE_DYNAMIC_FIELDS ) name = string.replace( name, "'", settings.REFINERY_SOLR_SPACE_DYNAMIC_FIELDS ) key = name + "_" + uuid + "_s" # a node might have multiple parents with different attribute values for a given attribute # e.g. parentA Characteristic[cell type] = K562 and parentB Characteristic[cell type] = HeLa # child nodes should inherit all attributes of their parents as a concatenation of the # unique list # # old version (only one attribute kept): # data[key] = value if not key in data: data[key] = set(); if value != "": data[key].add( value ) else: data[key].add( "N/A" ) # iterate over all keys in data and join sets into strings for key, value in data.iteritems(): if type(value) is set: data[key] = " + ".join(value) # add type as dynamic field to get proper facet values data[NodeIndex.TYPE_PREFIX + "_" + uuid + "_s"] = object.type # add name as dynamic field to get proper facet values data[NodeIndex.NAME_PREFIX + "_" + uuid + "_s"] = object.name # add analysis_uuid as dynamic field to get proper facet values if object.analysis_uuid is not None: data[NodeIndex.ANALYSIS_UUID_PREFIX + "_" + uuid + "_s"] = object.analysis_uuid else: data[NodeIndex.ANALYSIS_UUID_PREFIX + "_" + uuid + "_s"] = "N/A" # add subanalysis as dynamic field to get proper facet values if object.subanalysis is not None: data[NodeIndex.SUBANALYSIS_PREFIX + "_" + uuid + "_s"] = object.subanalysis else: data[NodeIndex.SUBANALYSIS_PREFIX + "_" + uuid + "_s"] = -1 # add workflow_output as dynamic field to get proper facet values if object.workflow_output is not None: data[NodeIndex.WORKFLOW_OUTPUT_PREFIX + "_" + uuid + "_s"] = object.workflow_output else: data[NodeIndex.WORKFLOW_OUTPUT_PREFIX + "_" + uuid + "_s"] = "N/A" # add file type as facet value file_store_item = file_store_tasks.read( object.file_uuid ); if file_store_item: data[NodeIndex.FILETYPE_PREFIX + "_" + uuid + "_s"] = file_store_item.get_filetype() else: logger.warning( "Unable to get file store item " + str( object.file_uuid ) + ". No file type available." ) data[NodeIndex.FILETYPE_PREFIX + "_" + uuid + "_s"] = "" return data