Skip to content

Commit

Permalink
regulatory_data parts seem to be functioning. all untested. no test d…
Browse files Browse the repository at this point in the history
…ata yet
  • Loading branch information
cmatKhan committed Dec 11, 2023
1 parent 1fac6d9 commit 97e5afe
Show file tree
Hide file tree
Showing 76 changed files with 1,466 additions and 326 deletions.
32 changes: 25 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,45 @@ Moved to [settings](http://cookiecutter-django.readthedocs.io/en/latest/settings

- To create a **superuser account**, use this command:

$ python manage.py createsuperuser
```bash
python manage.py createsuperuser
```

For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users.

### Type checks

Running type checks with mypy:

$ mypy yeastregulatorydb
```bash
mypy yeastregulatorydb
```

#### mypy caveats

- there is an issue accessing `Models.objects` that is unresolved. See
[issue 1684](https://github.com/typeddjango/django-stubs/issues/1684). I
choose to resolve this by ignoring the attr-defined error when accessing
`Model.objects` (see any viewset for an example). Note that in cases where
a custom manager is defined, I use _default_manager
([see django docs](https://docs.djangoproject.com/en/4.2/topics/db/managers/#django.db.models.Model._default_manager)). This raises a "accessing private method" warning in pylint,
which is also ignored.

### Test coverage

To run the tests, check your test coverage, and generate an HTML coverage report:

$ coverage run -m pytest
$ coverage html
$ open htmlcov/index.html
```bash
coverage run -m pytest
coverage html
open htmlcov/index.html
```

#### Running tests with pytest

$ pytest
```bash
pytest
```

### Live reloading and Sass CSS compilation

Expand Down Expand Up @@ -161,4 +179,4 @@ it okay to delete and re-download it? [y/n] (y): y
Choose from [1/2/3/4/5] (1): 4
[26/27] keep_local_envs_in_vcs (y): n
[27/27] debug (n): n
```
```
6 changes: 5 additions & 1 deletion compose/local/django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
# dependencies for building Python packages
build-essential \
# psycopg2 dependencies
libpq-dev
libpq-dev \
# HTSlib dependencies
zlib1g-dev \
libbz2-dev \
liblzma-dev

# Requirements are installed here to ensure they will be cached.
COPY ./requirements .
Expand Down
4 changes: 4 additions & 0 deletions compose/local/docs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
build-essential \
# psycopg2 dependencies
libpq-dev \
# HTSlib dependencies
zlib1g-dev \
libbz2-dev \
liblzma-dev \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
Expand Down
6 changes: 5 additions & 1 deletion compose/production/django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
# dependencies for building Python packages
build-essential \
# psycopg2 dependencies
libpq-dev
libpq-dev \
# HTSlib dependencies
zlib1g-dev \
libbz2-dev \
liblzma-dev

# Requirements are installed here to ensure they will be cached.
COPY ./requirements .
Expand Down
26 changes: 26 additions & 0 deletions config/api_router.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
from django.conf import settings
from rest_framework.routers import DefaultRouter, SimpleRouter

from yeastregulatorydb.regulatory_data.api.views import (
BindingSourceViewSet,
BindingViewSet,
CallingCardsBackgroundViewSet,
ChrMapViewSet,
ExpressionManualQCViewSet,
ExpressionSourceViewSet,
ExpressionViewSet,
FileFormatViewSet,
GenomicFeatureViewSet,
PromoterSetSigViewSet,
PromoterSetViewSet,
RegulatorViewSet,
)
from yeastregulatorydb.users.api.views import UserViewSet

if settings.DEBUG:
Expand All @@ -9,6 +23,18 @@
router = SimpleRouter()

router.register("users", UserViewSet)
router.register("bindingsource", BindingSourceViewSet)
router.register("binding", BindingViewSet)
router.register("callingcardsbackground", CallingCardsBackgroundViewSet)
router.register("chrmap", ChrMapViewSet)
router.register("expressionmanualqc", ExpressionManualQCViewSet)
router.register("expressionsource", ExpressionSourceViewSet)
router.register("expression", ExpressionViewSet)
router.register("fileformat", FileFormatViewSet)
router.register("genomicfeature", GenomicFeatureViewSet)
router.register("promotersetsig", PromoterSetSigViewSet)
router.register("promoterset", PromoterSetViewSet)
router.register("regulator", RegulatorViewSet)


app_name = "api"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ yeastregulatorydb.regulatory\_data.api.serializers.PromoterSetSigSerializer modu
:undoc-members:
:show-inheritance:

yeastregulatorydb.regulatory\_data.api.serializers.RegulatorSerializerSerializer module
yeastregulatorydb.regulatory\_data.api.serializers.RegulatorSerializer module
---------------------------------------------------------------------------------------

.. automodule:: yeastregulatorydb.regulatory_data.api.serializers.RegulatorSerializerSerializer
.. automodule:: yeastregulatorydb.regulatory_data.api.serializers.RegulatorSerializer
:members:
:undoc-members:
:show-inheritance:
Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Welcome to YeastRegulatoryDB's documentation!

howto
users
api



Expand Down
Empty file added docs/readthedocs.db
Empty file.
4 changes: 4 additions & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ django-cors-headers==4.3.1 # https://github.com/adamchainz/django-cors-headers
# DRF-spectacular for api documentation
drf-spectacular==0.26.5 # https://github.com/tfranzel/drf-spectacular
django-filter==23.5 # https://github.com/carltongibson/django-filter

# Third Party Software
# ------------------------------------------------------------------------------
callingcardstools==1.3.0 # https://github.com/cmatkhan/callingcardstools
1 change: 0 additions & 1 deletion yeastregulatorydb/contrib/sites/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = []

operations = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class Migration(migrations.Migration):

dependencies = [("sites", "0001_initial")]

operations = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _update_or_create_site_with_sequence(site_model, connection, domain, name):
# site is created.
# To avoid this, we need to manually update DB sequence and make sure it's
# greater than the maximum value.
max_id = site_model.objects.order_by('-id').first().id
max_id = site_model.objects.order_by("-id").first().id
with connection.cursor() as cursor:
cursor.execute("SELECT last_value from django_site_id_seq")
(current_id,) = cursor.fetchone()
Expand Down Expand Up @@ -57,7 +57,6 @@ def update_site_backward(apps, schema_editor):


class Migration(migrations.Migration):

dependencies = [("sites", "0002_alter_domain_unique")]

operations = [migrations.RunPython(update_site_forward, update_site_backward)]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("sites", "0003_set_site_domain_and_name"),
]
Expand Down
2 changes: 2 additions & 0 deletions yeastregulatorydb/regulatory_data/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# pylint: disable=unused-import
from django.contrib import admin

# Register your models here.
from .models import *
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@


class BindingFilter(django_filters.FilterSet):
# pylint: disable=R0801
id = django_filters.NumberFilter()
pk = django_filters.NumberFilter()
regulator_id = django_filters.NumberFilter()
regulator_locus_tag = django_filters.CharFilter(field_name="regulator__locus_tag", lookup_expr="iexact")
regulator_symbol = django_filters.CharFilter(field_name="regulator__symbol", lookup_expr="iexact")
batch = django_filters.CharFilter(lookup_expr="iexact")
# pylint: enable=R0801
replicate = django_filters.NumberFilter()
source_id = django_filters.NumberFilter()
source_orig_id = django_filters.CharFilter(lookup_expr="iexact")
lab = django_filters.CharFilter(field_name="source_id__lab", lookup_expr="iexact")
assay = django_filters.CharFilter(field_name="source_id__assay", lookup_expr="iexact")
workflow = django_filters.CharFilter(field_name="source_id__workflow", lookup_expr="iexact")

# pylint: disable=R0801
class Meta:
model = Binding
fields = [
Expand All @@ -33,3 +36,5 @@ class Meta:
"assay",
"workflow",
]

# pylint: enable=R0801
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ...models.CallingCardsBackground import CallingCardsBackground


class CallingCardsBackgroundFilter(django_filters.filters.FilterSet):
class CallingCardsBackgroundFilter(django_filters.FilterSet):
class Meta:
model = CallingCardsBackground
fields = {"name": ["exact"]}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@


class ExpressionFilter(django_filters.FilterSet):
# pylint: disable=R0801
id = django_filters.NumberFilter()
pk = django_filters.NumberFilter()
regulator_id = django_filters.NumberFilter()
regulator_locus_tag = django_filters.CharFilter(field_name="regulator__locus_tag", lookup_expr="iexact")
regulator_symbol = django_filters.CharFilter(field_name="regulator__symbol", lookup_expr="iexact")
batch = django_filters.CharFilter(field_name="batch", lookup_expr="iexact")
# pylint: enable=R0801
replicate = django_filters.NumberFilter()
control = django_filters.CharFilter(lookup_expr="iexact")
mechanism = django_filters.CharFilter(lookup_expr="iexact")
Expand Down Expand Up @@ -39,3 +41,5 @@ class Meta:
"assay",
"workflow",
]

# pylint: enable=R0801
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ExpressionManualQCFilter(django_filters.FilterSet):
assay = django_filters.CharFilter(field_name="expression_id__source_id__assay", lookup_expr="iexact")
workflow = django_filters.CharFilter(field_name="expression_id__source_id__workflow", lookup_expr="iexact")

# pylint: disable=R0801
class Meta:
model = ExpressionManualQC
fields = [
Expand All @@ -43,3 +44,5 @@ class Meta:
"assay",
"workflow",
]

# pylint: enable=R0801
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ...models.FileFormat import FileFormat


class ExpressionManualQCFilter(django_filters.FilterSet):
class FileFormatFilter(django_filters.FilterSet):
class Meta:
model = FileFormat
fields = {"fileformat": ["exact"]}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class GenomicFeatureFilter(django_filters.FilterSet):
chr = django_filters.CharFilter(field_name="chr__ucsc")
start = django_filters.NumberFilter()
end = django_filters.NumberFilter()
strand = django_filters.ChoiceFilter(choices=GenomicFeature.STRAND_CHOICES)
strand = django_filters.CharFilter(lookup_expr='exact')
type = django_filters.CharFilter(lookup_expr="iexact")
gene_biotype = django_filters.CharFilter(lookup_expr="iexact")
locus_tag = django_filters.CharFilter(lookup_expr="iexact")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class PromoterSetSigFilter(django_filters.FilterSet):
assay = django_filters.CharFilter(field_name="binding_id__source_id__assay", lookup_expr="iexact")
workflow = django_filters.CharFilter(field_name="binding_id__source_id__workflow", lookup_expr="iexact")

# pylint: disable=R0801
class Meta:
model = PromoterSetSig
fields = [
Expand All @@ -39,3 +40,5 @@ class Meta:
"assay",
"workflow",
]

# pylint: enable=R0801
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from rest_framework import serializers

from ...models.BindingManualQC import BindingManualQC
from .mixins.CustomValidateMixin import CustomValidateMixin


class BindingManualQCSerializer(serializers.ModelSerializer):
class BindingManualQCSerializer(CustomValidateMixin, serializers.ModelSerializer):
uploader = serializers.ReadOnlyField(source="uploader.username")
modifiedBy = serializers.CharField(source="uploader.username", required=False)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from rest_framework import serializers

from ...models.Binding import Binding
from .mixins.CustomValidateMixin import CustomValidateMixin


class BindingSerializer(serializers.ModelSerializer):
class BindingSerializer(CustomValidateMixin, serializers.ModelSerializer):
uploader = serializers.ReadOnlyField(source="uploader.username")
modifiedBy = serializers.CharField(source="uploader.username", required=False)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from rest_framework import serializers

from ...models.BindingSource import BindingSource
from .mixins.CustomValidateMixin import CustomValidateMixin


class BindingSourceSerializer(serializers.ModelSerializer):
class BindingSourceSerializer(CustomValidateMixin, serializers.ModelSerializer):
uploader = serializers.ReadOnlyField(source="uploader.username")
modifiedBy = serializers.CharField(source="uploader.username", required=False)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from rest_framework import serializers

from ...models.CallingCardsBackground import CallingCardsBackground
from .mixins.CustomValidateMixin import CustomValidateMixin


class CallingCardsBackgroundSerializer(serializers.ModelSerializer):
class CallingCardsBackgroundSerializer(CustomValidateMixin, serializers.ModelSerializer):
uploader = serializers.ReadOnlyField(source="uploader.username")
modifiedBy = serializers.CharField(source="uploader.username", required=False)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from rest_framework import serializers

from ...models.ChrMap import ChrMap
from .mixins.CustomValidateMixin import CustomValidateMixin


class ChrMapSerializer(serializers.ModelSerializer):
class ChrMapSerializer(CustomValidateMixin, serializers.ModelSerializer):
uploader = serializers.ReadOnlyField(source="uploader.username")
modifiedBy = serializers.CharField(source="uploader.username", required=False)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from rest_framework import serializers

from ...models.ExpressionManualQC import ExpressionManualQC
from .mixins.CustomValidateMixin import CustomValidateMixin


class ExpressionManualQCSerializer(serializers.ModelSerializer):
class ExpressionManualQCSerializer(CustomValidateMixin, serializers.ModelSerializer):
uploader = serializers.ReadOnlyField(source="uploader.username")
modifiedBy = serializers.CharField(source="uploader.username", required=False)

Expand Down
Loading

0 comments on commit 97e5afe

Please sign in to comment.