mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 00:12:08 +08:00
Merge pull request #9874 from assuntad23/feature/9669-sort-collection-for-paired-collections
Feature/9669 sort collection for paired collections
This commit is contained in:
@@ -1852,7 +1852,7 @@ class History(HasTags, Dictifiable, UsesAnnotations, HasName, RepresentById):
|
||||
hdas = self.active_datasets
|
||||
for hda in hdas:
|
||||
# Copy HDA.
|
||||
new_hda = hda.copy(force_flush=False)
|
||||
new_hda = hda.copy(flush=False)
|
||||
new_history.add_dataset(new_hda, set_hid=False, quota=applies_to_quota)
|
||||
|
||||
if target_user:
|
||||
@@ -3110,7 +3110,7 @@ class HistoryDatasetAssociation(DatasetInstance, HasTags, Dictifiable, UsesAnnot
|
||||
self.version = self.version + 1 if self.version else 1
|
||||
session.add(past_hda)
|
||||
|
||||
def copy(self, parent_id=None, copy_tags=None, force_flush=True, copy_hid=True, new_name=None):
|
||||
def copy(self, parent_id=None, copy_tags=None, flush=True, copy_hid=True, new_name=None):
|
||||
"""
|
||||
Create a copy of this HDA.
|
||||
"""
|
||||
@@ -3147,7 +3147,7 @@ class HistoryDatasetAssociation(DatasetInstance, HasTags, Dictifiable, UsesAnnot
|
||||
object_session(self).flush([self])
|
||||
|
||||
hda.set_peek()
|
||||
if force_flush:
|
||||
if flush:
|
||||
object_session(self).flush()
|
||||
return hda
|
||||
|
||||
@@ -4120,7 +4120,7 @@ class DatasetCollection(Dictifiable, UsesAnnotations, RepresentById):
|
||||
error_message = "Dataset collection has no %s with key %s." % (get_by_attribute, key)
|
||||
raise KeyError(error_message)
|
||||
|
||||
def copy(self, destination=None, element_destination=None):
|
||||
def copy(self, destination=None, element_destination=None, flush=True):
|
||||
new_collection = DatasetCollection(
|
||||
collection_type=self.collection_type,
|
||||
element_count=self.element_count
|
||||
@@ -4130,6 +4130,7 @@ class DatasetCollection(Dictifiable, UsesAnnotations, RepresentById):
|
||||
new_collection,
|
||||
destination=destination,
|
||||
element_destination=element_destination,
|
||||
flush=flush
|
||||
)
|
||||
object_session(self).add(new_collection)
|
||||
object_session(self).flush()
|
||||
@@ -4537,16 +4538,17 @@ class DatasetCollectionElement(Dictifiable, RepresentById):
|
||||
else:
|
||||
return [element_object]
|
||||
|
||||
def copy_to_collection(self, collection, destination=None, element_destination=None):
|
||||
def copy_to_collection(self, collection, destination=None, element_destination=None, flush=True):
|
||||
element_object = self.element_object
|
||||
if element_destination:
|
||||
if self.is_collection:
|
||||
element_object = element_object.copy(
|
||||
destination=destination,
|
||||
element_destination=element_destination
|
||||
element_destination=element_destination,
|
||||
flush=flush
|
||||
)
|
||||
else:
|
||||
new_element_object = element_object.copy()
|
||||
new_element_object = element_object.copy(flush=flush)
|
||||
if destination is not None and element_object.hidden_beneath_collection_instance:
|
||||
new_element_object.hidden_beneath_collection_instance = destination
|
||||
# Ideally we would not need to give the following
|
||||
|
||||
@@ -2902,7 +2902,7 @@ class MergeCollectionTool(DatabaseOperationTool):
|
||||
new_elements = OrderedDict()
|
||||
for key, value in new_element_structure.items():
|
||||
if getattr(value, "history_content_type", None) == "dataset":
|
||||
copied_value = value.copy(force_flush=False)
|
||||
copied_value = value.copy(flush=False)
|
||||
else:
|
||||
copied_value = value.copy()
|
||||
new_elements[key] = copied_value
|
||||
@@ -2920,7 +2920,7 @@ class FilterDatasetsTool(DatabaseOperationTool):
|
||||
for dce in elements_to_copy:
|
||||
element_identifier = dce.element_identifier
|
||||
if getattr(dce.element_object, "history_content_type", None) == "dataset":
|
||||
copied_value = dce.element_object.copy(force_flush=False)
|
||||
copied_value = dce.element_object.copy(flush=False)
|
||||
else:
|
||||
copied_value = dce.element_object.copy()
|
||||
new_elements[element_identifier] = copied_value
|
||||
@@ -2995,7 +2995,7 @@ class FlattenTool(DatabaseOperationTool):
|
||||
if dce.is_collection:
|
||||
add_elements(dce_object, prefix=identifier)
|
||||
else:
|
||||
copied_dataset = dce_object.copy(force_flush=False)
|
||||
copied_dataset = dce_object.copy(flush=False)
|
||||
new_elements[identifier] = copied_dataset
|
||||
copied_datasets.append(copied_dataset)
|
||||
|
||||
@@ -3041,7 +3041,7 @@ class SortTool(DatabaseOperationTool):
|
||||
|
||||
for dce in sorted_elements:
|
||||
dce_object = dce.element_object
|
||||
copied_dataset = dce_object.copy(force_flush=False)
|
||||
copied_dataset = dce_object.copy(flush=False)
|
||||
new_elements[dce.element_identifier] = copied_dataset
|
||||
|
||||
self._add_datasets_to_history(history, itervalues(new_elements))
|
||||
@@ -3065,7 +3065,7 @@ class RelabelFromFileTool(DatabaseOperationTool):
|
||||
if new_label in new_elements:
|
||||
raise Exception("New identifier [%s] appears twice in resulting collection, these values must be unique." % new_label)
|
||||
if getattr(dce_object, "history_content_type", None) == "dataset":
|
||||
copied_value = dce_object.copy(force_flush=False)
|
||||
copied_value = dce_object.copy(flush=False)
|
||||
else:
|
||||
copied_value = dce_object.copy()
|
||||
new_elements[new_label] = copied_value
|
||||
@@ -3111,7 +3111,7 @@ class ApplyRulesTool(DatabaseOperationTool):
|
||||
copied_datasets = []
|
||||
|
||||
def copy_dataset(dataset):
|
||||
copied_dataset = dataset.copy(force_flush=False)
|
||||
copied_dataset = dataset.copy(flush=False)
|
||||
copied_datasets.append(copied_dataset)
|
||||
return copied_dataset
|
||||
|
||||
@@ -3137,7 +3137,7 @@ class TagFromFileTool(DatabaseOperationTool):
|
||||
|
||||
def add_copied_value_to_new_elements(new_tags_dict, dce):
|
||||
if getattr(dce.element_object, "history_content_type", None) == "dataset":
|
||||
copied_value = dce.element_object.copy(force_flush=False)
|
||||
copied_value = dce.element_object.copy(flush=False)
|
||||
# copy should never be visible, since part of a collection
|
||||
copied_value.visble = False
|
||||
new_datasets.append(copied_value)
|
||||
@@ -3208,7 +3208,7 @@ class FilterFromFileTool(DatabaseOperationTool):
|
||||
passes_filter = in_filter_file if how_filter == "remove_if_absent" else not in_filter_file
|
||||
|
||||
if getattr(dce_object, "history_content_type", None) == "dataset":
|
||||
copied_value = dce_object.copy(force_flush=False)
|
||||
copied_value = dce_object.copy(flush=False)
|
||||
else:
|
||||
copied_value = dce_object.copy()
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<action module="galaxy.tools.actions.model_operations"
|
||||
class="ModelOperationToolAction"/>
|
||||
<inputs>
|
||||
<param type="data_collection" collection_type="list" name="input" label="Input Collection" />
|
||||
<param type="data_collection" collection_type="list,list:paired" name="input" label="Input Collection" />
|
||||
<conditional name="sort_type">
|
||||
<param type="select" name="sort_type" label="Sort collection identifiers" help="All element identifiers must be present once.">
|
||||
<option value="alpha">alphabetically</option>
|
||||
@@ -22,7 +22,7 @@
|
||||
</conditional>
|
||||
</inputs>
|
||||
<outputs>
|
||||
<collection name="output" format_source="input" type="list" label="${on_string} (sorted)" >
|
||||
<collection name="output" format_source="input" type_source="input" label="${on_string} (sorted)" >
|
||||
</collection>
|
||||
</outputs>
|
||||
<tests>
|
||||
@@ -91,6 +91,51 @@
|
||||
</element>
|
||||
</output_collection>
|
||||
</test>
|
||||
<test>
|
||||
<param name="input">
|
||||
<collection type="list:paired">
|
||||
<element name="def456">
|
||||
<collection type="paired">
|
||||
<element name="forward" value="simple_line.txt" />
|
||||
<element name="reverse" value="simple_line_alternative.txt" />
|
||||
</collection>
|
||||
</element>
|
||||
<element name="abc789">
|
||||
<collection type="paired">
|
||||
<element name="forward" value="simple_line.txt" />
|
||||
<element name="reverse" value="simple_line_alternative.txt" />
|
||||
</collection>
|
||||
</element>
|
||||
</collection>
|
||||
</param>
|
||||
<param name="sort_type" value="alpha" />
|
||||
<output_collection name="output" type="list:paired">
|
||||
<element name="abc789">
|
||||
<element name="forward">
|
||||
<assert_contents>
|
||||
<has_text_matching expression="^This is a line of text.\n$" />
|
||||
</assert_contents>
|
||||
</element>
|
||||
<element name="reverse">
|
||||
<assert_contents>
|
||||
<has_text_matching expression="^This is a different line of text.\n$" />
|
||||
</assert_contents>
|
||||
</element>
|
||||
</element>
|
||||
<element name="def456">
|
||||
<element name="forward">
|
||||
<assert_contents>
|
||||
<has_text_matching expression="^This is a line of text.\n$" />
|
||||
</assert_contents>
|
||||
</element>
|
||||
<element name="reverse">
|
||||
<assert_contents>
|
||||
<has_text_matching expression="^This is a different line of text.\n$" />
|
||||
</assert_contents>
|
||||
</element>
|
||||
</element>
|
||||
</output_collection>
|
||||
</test>
|
||||
</tests>
|
||||
<help><![CDATA[
|
||||
|
||||
|
||||
Reference in New Issue
Block a user