Skip to content

Commit

Permalink
adjusting filters for the BindingConcatenated, etc addition
Browse files Browse the repository at this point in the history
  • Loading branch information
cmatKhan committed Jul 6, 2024
1 parent 05a27e8 commit be1c421
Show file tree
Hide file tree
Showing 11 changed files with 341 additions and 144 deletions.
Original file line number Diff line number Diff line change
@@ -1,52 +1,20 @@
import django_filters
from django.db.models import Q

from ...models import Binding, BindingConcatenated, BindingManualQC
from yeastregulatorydb.regulatory_data.models import BindingConcatenated


class BindingConcatenatedFilter(django_filters.rest_framework.FilterSet):
id = django_filters.NumberFilter()
genomic_inserts = django_filters.NumberFilter()
mito_inserts = django_filters.NumberFilter()
plasmid_inserts = django_filters.NumberFilter()
notes = django_filters.CharFilter(lookup_expr="iexact")

# Filter fields for related bindings
regulator = django_filters.NumberFilter(field_name="bindings__regulator")
regulator = django_filters.NumberFilter(field_name="regulator")
regulator_locus_tag = django_filters.CharFilter(
field_name="bindings__regulator__genomicfeature__locus_tag", lookup_expr="iexact"
field_name="regulator__genomicfeature__locus_tag", lookup_expr="iexact"
)
regulator_symbol = django_filters.CharFilter(
field_name="bindings__regulator__genomicfeature__symbol", lookup_expr="iexact"
)
batch = django_filters.CharFilter(field_name="bindings__batch", lookup_expr="iexact")
replicate = django_filters.NumberFilter(field_name="bindings__replicate")
source = django_filters.NumberFilter(field_name="bindings__source")
source_orig_id = django_filters.CharFilter(field_name="bindings__source_orig_id", lookup_expr="iexact")
strain = django_filters.CharFilter(field_name="bindings__strain", lookup_expr="iexact")
condition = django_filters.ChoiceFilter(field_name="bindings__condition", choices=Binding.CONDITION_CHOICES)
lab = django_filters.CharFilter(field_name="bindings__source__lab", lookup_expr="iexact")
assay = django_filters.CharFilter(field_name="bindings__source__assay", lookup_expr="iexact")
workflow = django_filters.CharFilter(field_name="bindings__source__workflow", lookup_expr="iexact")
regulator_symbol = django_filters.CharFilter(field_name="regulator__genomicfeature__symbol", lookup_expr="iexact")
source = django_filters.NumberFilter(field_name="source")
source_name = django_filters.CharFilter(field_name="source__name", lookup_expr="iexact")

class Meta:
model = BindingConcatenated
fields = [
"id",
"genomic_inserts",
"mito_inserts",
"plasmid_inserts",
"notes",
"regulator",
"regulator_locus_tag",
"regulator_symbol",
"batch",
"replicate",
"source",
"condition",
"source_orig_id",
"strain",
"lab",
"assay",
"workflow",
]
fields = ["id", "regulator", "regulator_locus_tag", "regulator_symbol", "source", "source_name"]
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BindingFilter(django_filters.rest_framework.FilterSet):
assay = django_filters.CharFilter(field_name="source__assay", lookup_expr="iexact")
workflow = django_filters.CharFilter(field_name="source__workflow", lookup_expr="iexact")
data_usable = django_filters.ChoiceFilter(
field_name="bindingmanualqc__data_usable", choices=BindingManualQC.MANUAL_QC_CHOICES
field_name="bindingmanualqc__data_usable", choices=BindingManualQC.MANUAL_QC_CHOICES, label="Data Usable"
)

# pylint: disable=R0801
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,48 @@
import django_filters
from django.db.models import Q

from ...models.BindingManualQC import BindingManualQC


class BindingManualQCFilter(django_filters.rest_framework.FilterSet):
id = django_filters.NumberFilter()
single_binding = django_filters.NumberFilter()
composite_binding = django_filters.NumberFilter()
best_datatype = django_filters.ChoiceFilter(choices=BindingManualQC.MANUAL_QC_CHOICES)
data_usable = django_filters.ChoiceFilter(choices=BindingManualQC.MANUAL_QC_CHOICES)
passing_replicate = django_filters.ChoiceFilter(choices=BindingManualQC.MANUAL_QC_CHOICES)
rank_recall = django_filters.ChoiceFilter(choices=BindingManualQC.MANUAL_QC_CHOICES)
regulator = django_filters.NumberFilter(field_name="binding__regulator")
single_binding = django_filters.NumberFilter(label="Single Binding ID", help_text="ID of the single binding")
composite_binding = django_filters.NumberFilter(
label="Composite Binding ID", help_text="ID of the composite binding"
)
best_datatype = django_filters.ChoiceFilter(
choices=BindingManualQC.MANUAL_QC_CHOICES, label="Best Datatype", help_text="Best datatype for the binding"
)
data_usable = django_filters.ChoiceFilter(
choices=BindingManualQC.MANUAL_QC_CHOICES, label="Data Usable", help_text="Data usable for the binding"
)
passing_replicate = django_filters.ChoiceFilter(
choices=BindingManualQC.MANUAL_QC_CHOICES,
label="Passing Replicate",
help_text="Passing replicate for the binding",
)
rank_recall = django_filters.ChoiceFilter(
choices=BindingManualQC.MANUAL_QC_CHOICES, label="Rank Recall", help_text="Rank recall for the binding"
)
regulator = django_filters.NumberFilter(method="filter_regulator", label="Regulator ID", help_text="Regulator ID")
regulator_locus_tag = django_filters.CharFilter(
field_name="binding__regulator__genomicfeature__locus_tag", lookup_expr="iexact"
method="filter_regulator_locus_tag",
lookup_expr="iexact",
label="Regulator locus tag",
help_text="Regulator locus tag",
)
regulator_symbol = django_filters.CharFilter(
field_name="binding__regulator__genomicfeature__symbol", lookup_expr="iexact"
method="filter_regulator_symbol", lookup_expr="iexact", label="Regulator symbol", help_text="Regulator symbol"
)
batch = django_filters.CharFilter(
method="filter_batch", lookup_expr="iexact", label="Binding Batch", help_text="Binding batch"
)
source = django_filters.CharFilter(
method="filter_source", lookup_expr="iexact", label="Data Source ID", help_text="Data Source ID"
)
source_name = django_filters.CharFilter(
method="filter_source", lookup_expr="iexact", label="Data Source name", help_text="Data Source name"
)
batch = django_filters.CharFilter(field_name="binding__batch", lookup_expr="iexact")
source = django_filters.CharFilter(field_name="binding__source", lookup_expr="iexact")

class Meta:
model = BindingManualQC
Expand All @@ -30,9 +53,35 @@ class Meta:
"best_datatype",
"data_usable",
"passing_replicate",
"rank_recall",
"regulator",
"regulator_locus_tag",
"regulator_symbol",
"batch",
"source",
"source_name",
]

def filter_binding(self, queryset, name, value):
return queryset.filter(
Q(single_binding__isnull=False, **{f"single_binding__{name}": value})
| Q(composite_binding__isnull=False, **{f"composite_binding__{name}": value})
)

def filter_regulator(self, queryset, name, value):
return self.filter_binding(queryset, "regulator", value)

def filter_regulator_locus_tag(self, queryset, name, value):
return self.filter_binding(queryset, "regulator__genomicfeature__locus_tag", value)

def filter_regulator_symbol(self, queryset, name, value):
return self.filter_binding(queryset, "regulator__genomicfeature__symbol", value)

def filter_batch(self, queryset, name, value):
return self.filter_binding(queryset, "batch", value)

def filter_source(self, queryset, name, value):
return self.filter_binding(queryset, "source", value)

def filter_source(self, queryset, name, value):
return self.filter_binding(queryset, "source_name", value)
18 changes: 13 additions & 5 deletions yeastregulatorydb/regulatory_data/api/filters/DataSourceFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@

class DataSourceFilter(django_filters.rest_framework.FilterSet):
id = django_filters.NumberFilter()
fileformat_id = django_filters.NumberFilter()
fileformat = django_filters.CharFilter(field_name="fileformat__fileformat", lookup_expr="iexact")
lab = django_filters.CharFilter(lookup_expr="iexact")
assay = django_filters.CharFilter(lookup_expr="iexact")
workflow = django_filters.CharFilter(lookup_expr="iexact")
fileformat_id = django_filters.NumberFilter(label="File Format ID", help_text="ID of the file format")
fileformat = django_filters.CharFilter(
field_name="fileformat__fileformat", lookup_expr="iexact", label="File Format", help_text="File format"
)
lab = django_filters.CharFilter(lookup_expr="iexact", label="Lab", help_text="Lab which generated the data")
assay = django_filters.CharFilter(
lookup_expr="iexact",
label="Assay",
help_text="Assay used to generate the data, eg 'callingcards' or 'chipexo'",
)
workflow = django_filters.CharFilter(
lookup_expr="iexact", label="Workflow", help_text="Workflow used to generate data"
)

class Meta:
model = DataSource
Expand Down
54 changes: 40 additions & 14 deletions yeastregulatorydb/regulatory_data/api/filters/ExpressionFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,47 @@
class ExpressionFilter(django_filters.rest_framework.FilterSet):
# pylint: disable=R0801
id = django_filters.NumberFilter()
regulator = django_filters.NumberFilter()
regulator_locus_tag = ListCharFilter(field_name="regulator__genomicfeature__locus_tag", lookup_expr="iexact")
regulator_symbol = ListCharFilter(field_name="regulator__genomicfeature__symbol", lookup_expr="iexact")
batch = django_filters.CharFilter(field_name="batch", lookup_expr="iexact")
regulator = django_filters.NumberFilter(help_text="Regulator Record ID")
regulator_locus_tag = ListCharFilter(
field_name="regulator__genomicfeature__locus_tag",
lookup_expr="iexact",
label="Regulator Locus Tag",
help_text="Comma separated list of locus tags",
)
regulator_symbol = ListCharFilter(
field_name="regulator__genomicfeature__symbol",
lookup_expr="iexact",
label="Regulator Symbol",
help_text="Comma separated list of symbols",
)
batch = django_filters.CharFilter(field_name="batch", lookup_expr="iexact", help_text="Expression Batch string")
# pylint: enable=R0801
replicate = django_filters.NumberFilter()
control = django_filters.CharFilter(lookup_expr="iexact")
mechanism = django_filters.CharFilter(lookup_expr="iexact")
restriction = django_filters.CharFilter(lookup_expr="iexact")
time = django_filters.NumberFilter(field_name="time")
source = django_filters.NumberFilter()
source_time = django_filters.CharFilter(method="filter_source_time")
lab = django_filters.CharFilter(field_name="source__lab", lookup_expr="iexact")
assay = django_filters.CharFilter(field_name="source__assay", lookup_expr="iexact")
workflow = django_filters.CharFilter(field_name="source__workflow", lookup_expr="iexact")
replicate = django_filters.NumberFilter(label="Replicate Number", help_text="Replicate number")
control = django_filters.CharFilter(
lookup_expr="iexact", label="Experiment control condition", help_text="Control condition"
)
mechanism = django_filters.CharFilter(
lookup_expr="iexact", label="Regulatory Mechanism", help_text="Regulatory Mechanism (McIsaac only)"
)
restriction = django_filters.CharFilter(
lookup_expr="iexact", label="Restriction enzyme", help_text="Regulatory enzyme (McIsaac only)"
)
time = django_filters.NumberFilter(field_name="time", label="Time Point", help_text="Time point (McIsaac only)")
source = django_filters.NumberFilter(label="Source Record ID", help_text="Source Record ID")
source_time = django_filters.CharFilter(
method="filter_source_time",
label="Source/Time",
help_text="Comma separated tuples of source/time pairs separated by semi-colons",
)
lab = django_filters.CharFilter(
field_name="source__lab", lookup_expr="iexact", label="Lab Name", help_text="Lab Name"
)
assay = django_filters.CharFilter(
field_name="source__assay", lookup_expr="iexact", label="Assay Name", help_text="Assay Name"
)
workflow = django_filters.CharFilter(
field_name="source__workflow", lookup_expr="iexact", label="Workflow Name", help_text="Workflow Name"
)

class Meta:
model = Expression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,44 @@

class ExpressionManualQCFilter(django_filters.rest_framework.FilterSet):
id = django_filters.NumberFilter()
expression = django_filters.NumberFilter()
strain_verified = django_filters.ChoiceFilter(choices=[("yes", "yes"), ("no", "no"), ("unverified", "unverified")])
expression = django_filters.NumberFilter(label="Expression ID", help_text="ID of the expression")
strain_verified = django_filters.ChoiceFilter(
choices=[("yes", "yes"), ("no", "no"), ("unverified", "unverified")],
label="Strain Verified",
help_text="Strain verified status",
)
regulator_locus_tag = django_filters.CharFilter(
field_name="expression__regulator__genomicfeature__locus_tag", lookup_expr="iexact"
field_name="expression__regulator__genomicfeature__locus_tag",
lookup_expr="iexact",
label="Regulator locus tag",
help_text="Regulator locus tag",
)
regulator_symbol = django_filters.CharFilter(
field_name="expression__regulator__genomicfeature__symbol", lookup_expr="iexact"
field_name="expression__regulator__genomicfeature__symbol",
lookup_expr="iexact",
label="Regulator symbol",
help_text="Regulator symbol",
)
time = django_filters.NumberFilter(field_name="expression__time", label="Time", help_text="Time (McIsaac only)")
source = django_filters.NumberFilter(field_name="expression__source__id", label="Source ID", help_text="Source ID")
lab = django_filters.CharFilter(
field_name="expression__source__lab",
lookup_expr="iexact",
label="Lab Name",
help_text="Lab which generated the data",
)
assay = django_filters.CharFilter(
field_name="expression__source__assay",
lookup_expr="iexact",
label="Assay Name",
help_text="Assay used to generate the data, eg 'callingcards'",
)
workflow = django_filters.CharFilter(
field_name="expression__source__workflow",
lookup_expr="iexact",
label="Workflow Name",
help_text="Workflow used to generate data",
)
batch = django_filters.CharFilter(field_name="expression__batch", lookup_expr="iexact")
replicate = django_filters.NumberFilter(field_name="expression__replicate")
control = django_filters.CharFilter(field_name="expression__control", lookup_expr="iexact")
mechanism = django_filters.CharFilter(field_name="expression__mechanism", lookup_expr="iexact")
restriction = django_filters.CharFilter(field_name="expression__restriction", lookup_expr="iexact")
time = django_filters.NumberFilter(field_name="expression__time")
source = django_filters.NumberFilter(field_name="expression__source__id")
lab = django_filters.CharFilter(field_name="expression__source__lab", lookup_expr="iexact")
assay = django_filters.CharFilter(field_name="expression__source__assay", lookup_expr="iexact")
workflow = django_filters.CharFilter(field_name="expression__source__workflow", lookup_expr="iexact")

# pylint: disable=R0801
class Meta:
Expand All @@ -33,11 +53,6 @@ class Meta:
"strain_verified",
"regulator_locus_tag",
"regulator_symbol",
"batch",
"replicate",
"control",
"mechanism",
"restriction",
"time",
"source",
"lab",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,35 @@

class GenomicFeatureFilter(django_filters.rest_framework.FilterSet):
id = django_filters.NumberFilter()
chr = django_filters.CharFilter(field_name="chr__ucsc")
start = django_filters.NumberFilter()
end = django_filters.NumberFilter()
strand = django_filters.CharFilter(lookup_expr="exact")
type = django_filters.CharFilter(lookup_expr="iexact")
locus_tag = django_filters.CharFilter(lookup_expr="iexact")
symbol = django_filters.CharFilter(lookup_expr="iexact")
source = django_filters.CharFilter(lookup_expr="iexact")
alias = django_filters.CharFilter(lookup_expr="iexact")
chr = django_filters.CharFilter(
field_name="chr__ucsc", lookup_expr="exact", label="Chromosome", help_text="Chromosome"
)
start = django_filters.RangeFilter(
field_name="start",
label="Start coordinate",
help_text="A range describing the start position(s) of the feature",
)
end = django_filters.RangeFilter(
field_name="end", label="End coordinate", help_text="A range describing the end position(s) of the feature"
)
strand = django_filters.CharFilter(lookup_expr="exact", label="Feature strand", help_text="Feature strand")
type = django_filters.CharFilter(
lookup_expr="iexact", label="Feature type", help_text="Feature type, eg `gene', `CDS', `tRNA', etc"
)
locus_tag = django_filters.CharFilter(
lookup_expr="iexact", label="Locus tag", help_text="The systematic ID from SGD"
)
symbol = django_filters.CharFilter(
lookup_expr="iexact", label="Feature symbol", help_text="The common name of the feature from SGD"
)
source = django_filters.CharFilter(
lookup_expr="iexact", label="Feature source", help_text="Source of the annotation"
)
alias = django_filters.CharFilter(
lookup_expr="iexact",
label="Feature alias",
help_text="If there are aliases for the common name of the feature, they are listed in this field",
)
note = django_filters.CharFilter(lookup_expr="iexact")

class Meta:
Expand Down
Loading

0 comments on commit be1c421

Please sign in to comment.