class Molecule(models.Model):
    """A Django model to hold the information for a molecule -> a 3D set of
    co-ordinates"""
    # Character attributes
    smiles = models.CharField(max_length=255, db_index=True, null=True)
    lig_id = models.CharField(max_length=5, null=True)
    chain_id = models.CharField(max_length=1, null=True)
    # The type of map
    # Set the groups types
    mol_choices, default_mol = get_mol_choices()
    mol_type = models.CharField(choices=mol_choices,
                                default=default_mol,
                                max_length=2)
    # Textfield
    sdf_info = models.TextField(null=True)
    # Float attributes
    rscc = models.FloatField(null=True)
    occupancy = models.FloatField(null=True)
    x_com = models.FloatField(null=True)
    y_com = models.FloatField(null=True)
    z_com = models.FloatField(null=True)
    rmsd = models.FloatField(null=True)
    # Foreign key relations
    prot_id = models.ForeignKey(Protein)
    cmpd_id = models.ForeignKey(Compound)

    # Unique constraints
    class Meta:
        unique_together = ("prot_id", "cmpd_id", "mol_type")
        permissions = (("view_molecule", "View molecule"), )
Esempio n. 2
0
class Molecule(models.Model):
    """Django model for holding information about a Molecule. A molecule is linked to a compound, and represents the
    unique 3D coordinates for that molecule. Note a compound can be linked to multiple molecules, each with a different
    3D structure, but the same 2D structure

    Parameters
    ----------
    smiles: CharField
        The smiles string of the molecule. (optional) TODO: Check if this is needed...
    lig_id: CharField
        The ligand ID from the pdb file it originated from (e.g. LIG 1 A) (optional)
    chain_id: CharField
        The chain from the protein structure pdb file that this ligand is from (e.g. A) (optional)
    mol_type: CharField
        molecule type - from a pre-defined list and determined by file extension on upload (defined in
        loader.config.get_mol_choices):
        mol_choices = (
        (PROASIS, "Proasis molecule", ".mol", "MOL"),
        (SDF, "Sdf molecule", ".sdf", "SDF"),
        (HYDROGEN, "Hydrogens added ", "_h.mol", "H_MOL"),
        (
            HYDROGEN_AM1_CHARGES,
            "Mol2 format with Hydrogens and AM1 BCC",
            ".mol2",
            "MOL2",
        ),
        )
    sdf_info: TextField
        The 3D coordinates for the molecule in MDL (mol file) format. Taken directly from the uploaded file
    rscc: FloatField
        The RSCC score of the molecule 3D coordinates vs. PANDDA event map (optional)
    occupancy: FloatField
        The occupancy (electron density) of the molecule (optional)
    x_com: FloatField
        x-coordinate for centre of mass (optional)
    y_com: FloatField
        y-coordinate for centre of mass (optional)
    z_com: FloatField
        z-coordinate for centre of mass (optional)
    rmsd: FloatField
        RMSD of this molecule compared to ? (optional - unused)
    prot_id: ForeignKey
        Foreign key link to the associated protein (apo) that this ligand was pulled from
    cmpd_id: ForeignKey
        Foreign key link to the associated 2D compound
    history: HistoricalRecords
        Tracks the changes made to an instance of this model over time

    """
    # Character attributes
    smiles = models.CharField(max_length=255, db_index=True, null=True)
    lig_id = models.CharField(max_length=5, null=True)
    chain_id = models.CharField(max_length=1, null=True)
    # The type of map
    # Set the groups types
    mol_choices, default_mol = get_mol_choices()
    mol_type = models.CharField(choices=mol_choices, default=default_mol, max_length=2)
    # Textfield
    sdf_info = models.TextField(null=True)
    # Float attributes
    rscc = models.FloatField(null=True)
    occupancy = models.FloatField(null=True)
    x_com = models.FloatField(null=True)
    y_com = models.FloatField(null=True)
    z_com = models.FloatField(null=True)
    rmsd = models.FloatField(null=True)
    # Foreign key relations
    prot_id = models.ForeignKey(Protein, on_delete=models.CASCADE)
    cmpd_id = models.ForeignKey(Compound, on_delete=models.CASCADE)
    history = HistoricalRecords()

    # Unique constraints
    class Meta:
        unique_together = ("prot_id", "cmpd_id", "mol_type")