Skip to content

Commit

Permalink
🎨 Clean up (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnyosun authored Nov 21, 2024
1 parent f7d75cf commit fdeacb7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class Migration(migrations.Migration):

dependencies = [
("bionty", "0041_alter_artifactcellline_artifact_and_more"),
("clinicore", "0006_artifactbiosample_artifactclinicaltrial_and_more"),
Expand Down
46 changes: 19 additions & 27 deletions clinicore/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ class Meta(Record.Meta, TracksRun.Meta, TracksUpdates.Meta):
"""Internal id, valid only in one DB instance."""
uid: str = CharField(unique=True, max_length=8, default=ids.base62_8)
"""Universal id, valid across DB instances."""
name: str | None = CharField(max_length=255, default=None, db_index=True)
name: str | None = CharField(max_length=255, db_index=True)
"""ClinicalTrials.gov ID, the format is "NCT" followed by an 8-digit number."""
title: str | None = TextField(null=True, default=None)
title: str | None = TextField(null=True)
"""Official title of the clinical trial."""
objective: str | None = TextField(null=True, default=None)
objective: str | None = TextField(null=True)
"""Objective of the clinical trial."""
description: str | None = TextField(null=True, default=None)
description: str | None = TextField(null=True)
"""Description of the clinical trial."""
collections: Collection = models.ManyToManyField(
Collection, related_name="clinical_trials"
Expand Down Expand Up @@ -99,11 +99,11 @@ class Biosample(Record, CanCurate, TracksRun, TracksUpdates):
"""Internal id, valid only in one DB instance."""
uid: str = CharField(unique=True, max_length=12, default=ids.base62_12)
"""Universal id, valid across DB instances."""
name: str | None = CharField(max_length=255, default=None, db_index=True, null=True)
name: str | None = CharField(db_index=True, null=True)
"""Name of the biosample."""
batch: str | None = CharField(max_length=60, default=None, null=True, db_index=True)
batch: str | None = CharField(max_length=60, null=True, db_index=True)
"""Batch label of the biosample."""
description: str | None = TextField(null=True, default=None)
description: str | None = TextField(null=True)
"""Description of the biosample."""
patient: Patient = ForeignKey(
"Patient", PROTECT, related_name="biosamples", null=True, default=None
Expand Down Expand Up @@ -167,12 +167,12 @@ class Patient(Record, CanCurate, TracksRun, TracksUpdates):
"""Internal id, valid only in one DB instance."""
uid: str = CharField(unique=True, max_length=12, default=ids.base62_12)
"""Universal id, valid across DB instances. Use this field to model internal patient IDs."""
name: str | None = CharField(max_length=255, default=None, db_index=True)
name: str | None = CharField(db_index=True)
"""Name of the patient."""
age: int | None = IntegerField(null=True, default=None, db_index=True)
"""Age of the patient."""
gender: str | None = CharField(
max_length=10, choices=GENDER_CHOICES, null=True, default=None, db_index=True
max_length=10, choices=GENDER_CHOICES, null=True, db_index=True
)
"""Gender of the patient."""
ethnicity: Ethnicity = ForeignKey(Ethnicity, PROTECT, null=True, default=None)
Expand Down Expand Up @@ -220,21 +220,15 @@ class Meta(BioRecord.Meta, TracksRun.Meta, TracksUpdates.Meta):
"""A universal id (hash of selected field)."""
name: str = CharField(max_length=256, db_index=True)
"""Name of the medication."""
ontology_id: str | None = CharField(
max_length=32, db_index=True, null=True, default=None
)
ontology_id: str | None = CharField(max_length=32, db_index=True, null=True)
"""Ontology ID of the medication."""
chembl_id: str | None = CharField(
max_length=32, db_index=True, null=True, default=None
)
chembl_id: str | None = CharField(max_length=32, db_index=True, null=True)
"""ChEMBL ID of the medication."""
abbr: str | None = CharField(
max_length=32, db_index=True, unique=True, null=True, default=None
)
abbr: str | None = CharField(max_length=32, db_index=True, unique=True, null=True)
"""A unique abbreviation of medication."""
synonyms: str | None = TextField(null=True, default=None)
synonyms: str | None = TextField(null=True)
"""Bar-separated (|) synonyms that correspond to this medication."""
description: str | None = TextField(null=True, default=None)
description: str | None = TextField(null=True)
"""Description of the medication."""
parents: Medication = models.ManyToManyField(
"self", symmetrical=False, related_name="children"
Expand Down Expand Up @@ -311,27 +305,25 @@ class Treatment(Record, CanCurate, TracksRun, TracksUpdates):
"""Internal id, valid only in one DB instance."""
uid: str = CharField(unique=True, max_length=12, default=ids.base62_12)
"""Universal id, valid across DB instances."""
name: str | None = CharField(max_length=255, default=None, db_index=True)
name: str | None = CharField(db_index=True)
"""Name of the treatment."""
status: str | None = CharField(
max_length=16, choices=STATUS_CHOICES, null=True, default=None
)
status: str | None = CharField(max_length=16, choices=STATUS_CHOICES, null=True)
"""Status of the treatment."""
medication: Medication | None = ForeignKey(
Medication, PROTECT, null=True, default=None
)
"""Medications linked to the treatment."""
dosage: float | None = FloatField(null=True, default=None)
"""Dosage of the treatment."""
dosage_unit: str | None = CharField(max_length=32, null=True, default=None)
dosage_unit: str | None = CharField(max_length=32, null=True)
"""Unit of the dosage."""
administered_datetime: datetime | None = DateTimeField(null=True, default=None)
"""Date and time the treatment was administered."""
duration: DurationField = DurationField(null=True, default=None)
"""Duration of the treatment."""
route: str | None = CharField(max_length=32, null=True, default=None)
route: str | None = CharField(max_length=32, null=True)
"""Route of administration of the treatment."""
site: str | None = CharField(max_length=32, null=True, default=None)
site: str | None = CharField(max_length=32, null=True)
"""Body site of administration of the treatment."""
artifacts: Artifact = models.ManyToManyField(
Artifact, through="ArtifactTreatment", related_name="treatments"
Expand Down
22 changes: 12 additions & 10 deletions docs/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "7f26a335-cf1c-4e69-be3b-0c26b154606a",
"id": "0",
"metadata": {},
"source": [
"# Quickstart"
Expand All @@ -11,7 +11,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f37ebcaa",
"id": "1",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -21,7 +21,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a51faaf3-ee27-43c6-b48d-13be1adb5c46",
"id": "2",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -31,7 +31,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a1e61ead",
"id": "3",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -41,17 +41,19 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c71693bf",
"id": "4",
"metadata": {},
"outputs": [],
"source": [
"clinical_trail = cl.ClinicalTrial(name=\"NCT00000000\", title=\"This is a test clinical trial\").save()"
"clinical_trail = cl.ClinicalTrial(\n",
" name=\"NCT00000000\", title=\"This is a test clinical trial\"\n",
").save()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5d3f489d",
"id": "5",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -61,7 +63,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7f19edc5",
"id": "6",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -74,7 +76,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "47078824",
"id": "7",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -84,7 +86,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "81d079b6",
"id": "8",
"metadata": {},
"outputs": [],
"source": [
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = [{name = "Lamin Labs", email = "[email protected]"}]
readme = "README.md"
dynamic = ["version", "description"]
dependencies = [
"lamindb[bionty,aws]",
"lamindb[bionty]>=0.77.0",
]

[project.urls]
Expand All @@ -31,7 +31,7 @@ testpaths = [
[tool.ruff]
src = ["src"]
line-length = 88
select = [
lint.select = [
"F", # Errors detected by Pyflakes
"E", # Error detected by Pycodestyle
"W", # Warning detected by Pycodestyle
Expand All @@ -48,7 +48,7 @@ select = [
"PTH", # Use pathlib
"S" # Security
]
ignore = [
lint.ignore = [
# Do not catch blind exception: `Exception`
"BLE001",
# Errors from function calls in argument defaults. These are fine when the result is immutable.
Expand Down Expand Up @@ -119,10 +119,10 @@ ignore = [
"S607",
]

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"docs/*" = ["I"]
"tests/**/*.py" = [
"D", # docstrings are allowed to look a bit off
Expand Down

0 comments on commit fdeacb7

Please sign in to comment.