Skip to content

Commit

Permalink
Merge pull request #290 from MetaCell/feature/CSCKAN-293_3
Browse files Browse the repository at this point in the history
restoring projections along new projection phenotype
  • Loading branch information
ddelpiano authored Jul 18, 2024
2 parents fdac91a + bbf86d0 commit 4b3e745
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 8 deletions.
1 change: 0 additions & 1 deletion backend/composer/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ class ConnectivityStatementAdmin(
"sentence__pmcid",
"knowledge_statement",
)
exclude = ("projection",)

fieldsets = ()

Expand Down
3 changes: 3 additions & 0 deletions backend/composer/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ def create_statement_preview(self, instance, journey):
origins = ""

circuit_type = instance.get_circuit_type_display() if instance.circuit_type else None
projection = instance.get_projection_display() if instance.projection else None
projection_phenotype = str(instance.projection_phenotype) if instance.projection_phenotype else ''

laterality_description = instance.get_laterality_description()
Expand All @@ -586,6 +587,8 @@ def create_statement_preview(self, instance, journey):
statement = f"A {phenotype.lower()} connection goes {journey_sentence}.\n"

statement += f"This "
if projection:
statement += f"{projection.lower()} "
if projection_phenotype:
statement += f"{projection_phenotype.lower()} "
if circuit_type:
Expand Down
8 changes: 4 additions & 4 deletions backend/composer/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class Laterality(models.TextChoices):


class Projection(models.TextChoices):
IPSI = "IPSI", "Ipsilateral"
CONTRAT = "CONTRAT", "Contralateral"
BI = "BI", "Bilateral"
IPSI = "IPSI", "ipsilateral"
CONTRAT = "CONTRAT", "contralateral"
BI = "BI", "bilateral"


# todo: motor and sensory should move to phenotype options per csv
Expand Down Expand Up @@ -78,7 +78,7 @@ class ExportRelationships(models.TextChoices):
hasSomaPhenotype = "hasSomaPhenotype", "SomaPhenotype"
hasAlert = "hasAlert", "Alert"
hasSomaLocatedIn = "hasSomaLocatedIn", "Soma"
hasProjectionPhenotype = "hasProjectionPhenotype", "ProjectionPhenotype"
hasProjectionPhenotype = "hasProjection", "ProjectionPhenotype"
hasAxonPresynapticElementIn = "hasAxonPresynapticElementIn", "Axon terminal"
hasAxonSensorySubcellularElementIn = "hasAxonSensorySubcellularElementIn", "Afferent terminal",
hasAxonLocatedIn = "hasAxonLocatedIn", "Axon"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 4.1.4 on 2024-07-18 09:08

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("composer", "0051_alter_anatomicalentity_region_layer"),
]

operations = [
migrations.AlterModelOptions(
name="anatomicalentity",
options={
"verbose_name": "Anatomical Entity",
"verbose_name_plural": "Anatomical Entities",
},
),
migrations.AlterField(
model_name="connectivitystatement",
name="projection",
field=models.CharField(
blank=True,
choices=[
("IPSI", "ipsilateral"),
("CONTRAT", "contralateral"),
("BI", "bilateral"),
],
max_length=20,
null=True,
),
),
]
4 changes: 4 additions & 0 deletions backend/composer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,10 @@ class Meta:
check=Q(circuit_type__in=[c[0] for c in CircuitType.choices]),
name="circuit_type_valid",
),
models.CheckConstraint(
check=Q(projection__in=[p[0] for p in Projection.choices]),
name="projection_valid",
)
]


Expand Down
2 changes: 1 addition & 1 deletion backend/composer/services/export_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
HAS_NERVE_BRANCHES_TAG = "Has nerve branches"
TEMP_CIRCUIT_MAP = {
CircuitType.INTRINSIC: "http://uri.interlex.org/tgbugs/uris/readable/IntrinsicPhenotype",
CircuitType.PROJECTION: "http://uri.interlex.org/tgbugs/uris/readable/ProjectionPhenotype",
CircuitType.PROJECTION: "http://uri.interlex.org/tgbugs/uris/readable/HasProjection",
CircuitType.MOTOR: "http://uri.interlex.org/tgbugs/uris/readable/MotorPhenotype",
CircuitType.SENSORY: "http://uri.interlex.org/tgbugs/uris/readable/SensoryPhenotype",
}
Expand Down
16 changes: 14 additions & 2 deletions frontend/src/components/Forms/StatementForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,24 @@ const StatementForm = (props: any) => {
};


copiedUISchema.projection = {
"ui:widget": "CustomSingleSelect",
"ui:options": {
isDisabled,
label: "Projection laterality",
classNames: "col-xs-12 col-md-6",
placeholder: "Enter Projection Laterality",
},
};


copiedUISchema.projection_phenotype_id = {
"ui:widget": "CustomSingleSelect",
"ui:options": {
isDisabled,
label: "Projection",
label: "Projection phenotype",
classNames: "col-xs-12 col-md-6",
placeholder: "Enter Projection",
placeholder: "Enter Projection Phenotype",
data: projections.getProjections().map((row: any) => ({
label: row.name,
value: row.id,
Expand Down Expand Up @@ -712,6 +723,7 @@ const StatementForm = (props: any) => {
"sex_id",
"laterality",
"circuit_type",
"projection",
"projection_phenotype_id",
]}
{...props}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const StatementDetailsAccordion = (props: any) => {
"apinatomy_model",
"circuit_type",
"laterality",
"projection",
"projection_phenotype_id",
"phenotype_id",
"additional_information"
Expand Down

0 comments on commit 4b3e745

Please sign in to comment.