Skip to content

Commit

Permalink
fix: Adds lhs_pdb to ComputedMolecule (also move to Python 3.11.7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Christie authored and alanbchristie committed Dec 21, 2023
1 parent d56957b commit 8977bca
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11.6-slim-bullseye
FROM python:3.11.7-slim-bullseye

# We rely on the presence of a requirements.txt file in project root.
# This is achieved prior to a container build using poetry
Expand Down
17 changes: 10 additions & 7 deletions viewer/cset_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,10 @@ def set_mol(
long_inchi = inchi
inchi = inchi[:254]

ref_cpd: Compound = self.create_mol(
compound: Compound = self.create_mol(
inchi, name=molecule_name, long_inchi=long_inchi
)

mol_block = Chem.MolToMolBlock(mol)

insp = mol.GetProp('ref_mols')
insp = insp.split(',')
insp = [i.strip() for i in insp]
Expand Down Expand Up @@ -345,8 +343,6 @@ def set_mol(

insp_frags.append(ref)

_ = mol.GetProp('original SMILES')

# Try to get the SiteObservation.
# This may fail.
prot = self.get_site_observation(
Expand Down Expand Up @@ -377,10 +373,17 @@ def set_mol(
logger.info('Creating new ComputedMolecule')
computed_molecule = ComputedMolecule()

lhs_pdb = None
if mol.HasProp('lhs_pdb'):
lhs_pdb = mol.GetProp('lhs_pdb')
elif mol.HasProp('ref_pdb'):
lhs_pdb = mol.GetProp('ref_pdb')

assert computed_molecule
computed_molecule.compound = ref_cpd
computed_molecule.compound = compound
computed_molecule.computed_set = compound_set
computed_molecule.sdf_info = mol_block
computed_molecule.sdf_info = Chem.MolToMolBlock(mol)
computed_molecule.lhs_pdb = lhs_pdb
computed_molecule.molecule_name = molecule_name
computed_molecule.name = f"{target}-{computed_molecule.identifier}"
computed_molecule.smiles = smiles
Expand Down
22 changes: 22 additions & 0 deletions viewer/migrations/0026_add_lhs_pdb_to_computedmolecule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 3.2.23 on 2023-12-21 14:46

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('viewer', '0025_increase_length_of_computedset_method'),
]

operations = [
migrations.AddField(
model_name='computedmolecule',
name='lhs_pdb',
field=models.TextField(
blank=True,
help_text='Set from the lhs_pdb or ref_pdb property of the underlying Molecule',
max_length=50,
null=True,
),
),
]
9 changes: 8 additions & 1 deletion viewer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,12 @@ class ComputedMolecule(models.Model):

compound = models.ForeignKey(Compound, on_delete=models.CASCADE)
sdf_info = models.TextField(help_text="The 3D coordinates for the molecule")
lhs_pdb = models.TextField(
max_length=MOLECULE_NAME_LENGTH,
help_text="Set from the lhs_pdb or ref_pdb property of the underlying Molecule",
null=True,
blank=True,
)
computed_set = models.ForeignKey(ComputedSet, on_delete=models.CASCADE)
name = models.CharField(
max_length=50, help_text="A combination of Target and Identifier"
Expand Down Expand Up @@ -911,11 +917,12 @@ def __str__(self) -> str:
return f"{self.smiles}"

def __repr__(self) -> str:
return "<ComputedMolecule %r %r %r %r>" % (
return "<ComputedMolecule %r %r %r %r %r>" % (
self.id,
self.smiles,
self.name,
self.compound,
self.lhs_pdb,
)


Expand Down

0 comments on commit 8977bca

Please sign in to comment.