diff --git a/Dockerfile b/Dockerfile index 3a624445..f9ebc45b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/viewer/cset_upload.py b/viewer/cset_upload.py index 5faf6468..f9dd0f9e 100644 --- a/viewer/cset_upload.py +++ b/viewer/cset_upload.py @@ -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] @@ -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( @@ -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 diff --git a/viewer/migrations/0026_add_lhs_pdb_to_computedmolecule.py b/viewer/migrations/0026_add_lhs_pdb_to_computedmolecule.py new file mode 100644 index 00000000..bc4ed06b --- /dev/null +++ b/viewer/migrations/0026_add_lhs_pdb_to_computedmolecule.py @@ -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, + ), + ), + ] diff --git a/viewer/models.py b/viewer/models.py index 75dcac39..6ebccca4 100644 --- a/viewer/models.py +++ b/viewer/models.py @@ -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" @@ -911,11 +917,12 @@ def __str__(self) -> str: return f"{self.smiles}" def __repr__(self) -> str: - return "" % ( + return "" % ( self.id, self.smiles, self.name, self.compound, + self.lhs_pdb, )