-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement paired_or_unpaired collections...
- Loading branch information
Showing
25 changed files
with
860 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
client/src/components/Collections/PairedOrUnpairedListCollectionCreator.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<script setup lang="ts"> | ||
import { type ColDef } from "ag-grid-community"; | ||
import { BCol, BContainer, BRow } from "bootstrap-vue"; | ||
import { computed, ref } from "vue"; | ||
import type { HistoryItemSummary } from "@/api"; | ||
import { useAgGrid } from "@/composables/useAgGrid"; | ||
import type { DatasetPair } from "../History/adapters/buildCollectionModal"; | ||
interface Props { | ||
historyId: string; | ||
initialElements: HistoryItemSummary[]; | ||
defaultHideSourceItems?: boolean; | ||
fromSelection?: boolean; | ||
extensions?: string[]; | ||
height?: string; | ||
width?: string; | ||
} | ||
const { gridApi, AgGridVue, onGridReady, theme } = useAgGrid(resize); | ||
const generatedPairs = ref<DatasetPair[]>([]); | ||
function resize() { | ||
if (gridApi.value) { | ||
gridApi.value.sizeColumnsToFit(); | ||
} | ||
} | ||
const props = defineProps<Props>(); | ||
const style = computed(() => { | ||
return { width: props.width || "100%", height: props.height || "500px" }; | ||
}); | ||
// Default Column Properties | ||
const defaultColDef = ref<ColDef>({ | ||
editable: false, | ||
sortable: false, | ||
filter: false, | ||
resizable: true, | ||
}); | ||
const rowData = ref<Record<string, unknown>[]>([]); | ||
const columnDefs = computed(() => { | ||
const datasets: ColDef = { | ||
headerName: "Dataset(s)", | ||
field: "datasets", | ||
editable: false, | ||
}; | ||
return [datasets]; | ||
}); | ||
const summaryText = computed(() => { | ||
const numMatchedText = `Auto-matched ${generatedPairs.value.length} pair(s) of datasets from target datasets.`; | ||
const numUnmatched = props.initialElements.length; | ||
let numUnmatchedText = ""; | ||
if (numUnmatched > 0) { | ||
numUnmatchedText = `${numUnmatched} dataset(s) were not paired and will not be included in the resulting list of pairs.`; | ||
} | ||
return `${numMatchedText} ${numUnmatchedText}`; | ||
}); | ||
function initialize() { | ||
for (const dataset of props.initialElements) { | ||
console.log(dataset); | ||
rowData.value.push({ datasets: dataset.name }); | ||
} | ||
} | ||
initialize(); | ||
</script> | ||
|
||
<template> | ||
<BContainer style="max-width: 100%"> | ||
<BRow> | ||
<BCol> | ||
<p>{{ summaryText }}</p> | ||
</BCol> | ||
</BRow> | ||
<BRow> | ||
<div :style="style" :class="theme"> | ||
<AgGridVue | ||
:row-data="rowData" | ||
:column-defs="columnDefs" | ||
:default-col-def="defaultColDef" | ||
:style="style" | ||
@gridReady="onGridReady" /> | ||
</div> | ||
</BRow> | ||
</BContainer> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
lib/galaxy/model/dataset_collections/types/paired_or_unpaired.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from galaxy.exceptions import RequestParameterInvalidException | ||
from galaxy.model import ( | ||
DatasetCollectionElement, | ||
HistoryDatasetAssociation, | ||
) | ||
from . import BaseDatasetCollectionType | ||
from .paired import ( | ||
FORWARD_IDENTIFIER, | ||
REVERSE_IDENTIFIER, | ||
) | ||
|
||
SINGLETON_IDENTIFIER = "unpaired" | ||
|
||
|
||
class PairedOrUnpairedDatasetCollectionType(BaseDatasetCollectionType): | ||
""" """ | ||
|
||
collection_type = "paired_or_unpaired" | ||
|
||
def generate_elements(self, dataset_instances, **kwds): | ||
num_datasets = len(dataset_instances) | ||
if num_datasets > 2 or num_datasets < 1: | ||
raise RequestParameterInvalidException( | ||
f"Incorrect number of datasets - 1 or 2 datasets is required to create a paired_or_unpaired collection" | ||
) | ||
|
||
if num_datasets == 2: | ||
if forward_dataset := self._ensure_dataset_with_identifier(dataset_instances, FORWARD_IDENTIFIER): | ||
left_association = DatasetCollectionElement( | ||
element=forward_dataset, | ||
element_identifier=FORWARD_IDENTIFIER, | ||
) | ||
yield left_association | ||
if reverse_dataset := self._ensure_dataset_with_identifier(dataset_instances, REVERSE_IDENTIFIER): | ||
right_association = DatasetCollectionElement( | ||
element=reverse_dataset, | ||
element_identifier=REVERSE_IDENTIFIER, | ||
) | ||
yield right_association | ||
else: | ||
if single_datasets := self._ensure_dataset_with_identifier(dataset_instances, SINGLETON_IDENTIFIER): | ||
single_association = DatasetCollectionElement( | ||
element=single_datasets, | ||
element_identifier=SINGLETON_IDENTIFIER, | ||
) | ||
yield single_association |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.