GUI: attempt to make filters in the tell sample panel dependent on the other active filters
This commit is contained in:
1 parent
90a8f3f9b8
commit
337b59af39
1 file changed
+28
-4
@@ -230,9 +230,17 @@ class UserSampleSpreadsheet(QAbstractTableModel):
|
||||
self.layoutChanged.emit()
|
||||
|
||||
def unique_values_for_column(self, column: int, limit: int = 200) -> list[str]:
|
||||
"""Get unique values for a column from currently filtered samples (excluding this column's filter)."""
|
||||
# Get currently filtered samples, but exclude the filter for this column
|
||||
temp_filter = self.__filters.pop(column, None)
|
||||
filtered_samples = self._apply_filter(self.samples)
|
||||
# Restore the filter
|
||||
if temp_filter is not None:
|
||||
self.__filters[column] = temp_filter
|
||||
|
||||
seen: set[str] = set()
|
||||
out: list[str] = []
|
||||
for s in self.samples:
|
||||
for s in filtered_samples:
|
||||
v = get_entry(s, column)
|
||||
if v is None:
|
||||
continue
|
||||
@@ -244,7 +252,9 @@ class UserSampleSpreadsheet(QAbstractTableModel):
|
||||
out.append(txt)
|
||||
if len(out) >= limit:
|
||||
break
|
||||
if column == 5:
|
||||
|
||||
# Sort appropriately
|
||||
if column == 5: # User/pgroup column
|
||||
try:
|
||||
out.sort(key=lambda x: int(x[1:]) if x and x[0].lower() == "p" and x[1:].isdigit() else float("inf"))
|
||||
except Exception:
|
||||
@@ -254,9 +264,16 @@ class UserSampleSpreadsheet(QAbstractTableModel):
|
||||
return out
|
||||
|
||||
def suggested_prefixes_for_sample_name(self, limit: int = 200) -> list[str]:
|
||||
"""Get sample name prefixes from currently filtered samples (excluding column 0 filter)."""
|
||||
# Get currently filtered samples, excluding the sample name filter
|
||||
temp_filter = self.__filters.pop(0, None)
|
||||
filtered_samples = self._apply_filter(self.samples)
|
||||
if temp_filter is not None:
|
||||
self.__filters[0] = temp_filter
|
||||
|
||||
rx = re.compile(r"^([A-Za-z]+)")
|
||||
counts: dict[str, int] = {}
|
||||
for s in self.samples:
|
||||
for s in filtered_samples:
|
||||
name = (s.sample_name or "").strip()
|
||||
if not name:
|
||||
continue
|
||||
@@ -271,9 +288,16 @@ class UserSampleSpreadsheet(QAbstractTableModel):
|
||||
return [k for k, _ in items[:limit]]
|
||||
|
||||
def suggested_prefixes_for_location(self, limit: int = 200) -> tuple[list[str], list[str]]:
|
||||
"""Get location prefixes from currently filtered samples (excluding column 3 filter)."""
|
||||
# Get currently filtered samples, excluding the location filter
|
||||
temp_filter = self.__filters.pop(3, None)
|
||||
filtered_samples = self._apply_filter(self.samples)
|
||||
if temp_filter is not None:
|
||||
self.__filters[3] = temp_filter
|
||||
|
||||
seg_seen: set[str] = set()
|
||||
segpos_seen: set[str] = set()
|
||||
for s in self.samples:
|
||||
for s in filtered_samples:
|
||||
loc = s.loc_str() # "-" or like "B3-10"
|
||||
if loc and loc != "-" and isinstance(loc, str) and "-" in loc:
|
||||
left = loc.split("-", 1)[0] # e.g., "B3"
|
||||
|
||||
Reference in new issue
Block a user