Skip to content

Commit

Permalink
fix: ComputedSet method now 50 characters (and better ComputedMolecul…
Browse files Browse the repository at this point in the history
…e identifier)
  • Loading branch information
Alan Christie committed Dec 19, 2023
1 parent 108398c commit a8d359f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
4 changes: 2 additions & 2 deletions viewer/cset_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def task(self) -> ComputedSet:
truncated_submitter_method: str = 'unspecified'
if self.submitter_method:
truncated_submitter_method = self.submitter_method[
: ComputedSet.LENGTH_METHOD_NAME
: ComputedSet.LENGTH_METHOD_IN_NAME
]
if len(self.submitter_method) > len(truncated_submitter_method):
logger.warning(
Expand Down Expand Up @@ -522,7 +522,7 @@ def task(self) -> ComputedSet:
computed_set.name = cs_name
computed_set.md_ordinal = new_ordinal
computed_set.upload_date = today
computed_set.method = truncated_submitter_method
computed_set.method = self.submitter_method[: ComputedSet.LENGTH_METHOD]
computed_set.target = Target.objects.get(title=self.target)
computed_set.spec_version = float(self.version.strip('ver_'))
if self.user_id:
Expand Down
36 changes: 36 additions & 0 deletions viewer/migrations/0025_increase_length_of_computedset_method.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 3.2.23 on 2023-12-19 14:31

import shortuuid.django_fields
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('viewer', '0024_modified_computedset'),
]

operations = [
migrations.AlterField(
model_name='computedset',
name='method',
field=models.CharField(
blank=True,
help_text='The name of the algorithmic method used to generate the compounds (e.g. Fragmenstein)',
max_length=50,
null=True,
),
),
migrations.AlterField(
model_name='computedmolecule',
name='identifier',
field=shortuuid.django_fields.ShortUUIDField(
alphabet='ACDEFGHJKLMNPRSTUVWXYZ345679',
blank=True,
help_text="A four character string of non-confusing uppercase letters and digits for easy reference. This is combined with the Target to form the ComputedMolecule's name",
length=4,
max_length=4,
null=True,
prefix='',
),
),
]
8 changes: 5 additions & 3 deletions viewer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,10 +791,12 @@ class ComputedSet(models.Model):
)

LENGTH_SUBMITTER_NAME: int = 50
LENGTH_METHOD_NAME: int = 20
LENGTH_METHOD: int = 50
LENGTH_METHOD_URL: int = 1000
LENGTH_SUBMITTED_SDF: int = 255

LENGTH_METHOD_IN_NAME: int = 20

name = models.CharField(max_length=50, unique=True, primary_key=True)
target = models.ForeignKey(Target, null=True, on_delete=models.CASCADE)
submitted_sdf = models.FileField(
Expand All @@ -820,7 +822,7 @@ class ComputedSet(models.Model):
ComputedSetSubmitter, null=True, on_delete=models.CASCADE
)
method = models.CharField(
max_length=LENGTH_METHOD_NAME,
max_length=LENGTH_METHOD,
null=True,
blank=True,
help_text="The name of the algorithmic method used to generate the compounds (e.g. Fragmenstein)",
Expand Down Expand Up @@ -887,7 +889,7 @@ class ComputedMolecule(models.Model):
smiles = models.CharField(max_length=255)
identifier = ShortUUIDField(
length=SHORT_UUID_LENGTH,
alphabet="ACDEFGHJKLMNPRSTUVWXYZ23456789",
alphabet="ACDEFGHJKLMNPRSTUVWXYZ345679",
null=True,
blank=True,
help_text="A four character string of non-confusing uppercase letters and digits for easy reference."
Expand Down

0 comments on commit a8d359f

Please sign in to comment.