Module molgroups.components

Functions

def AddMolecules(component_list, length=None)

Classes

class Component (length=9.575, xray_wavelength=None, **kwargs)

Specify a biomolecule by name, chemical formula, cell volume and charge.

Labile hydrogen positions should be coded using H[1] rather than H. H[1] will be substituded with H for solutions with natural water or D for solutions with heavy water. Any deuterated non-labile hydrogen can be marked with D, and they will stay as D regardless of the solvent.

name is the molecule name.

formula is the chemical formula as string or atom dictionary, with H[1] for labile hydrogen.

cell_volume is the volume of the molecule. If None, cell volume will be inferred from the natural density of the molecule. Cell volume is assumed to be independent of isotope.

density is the natural density of the molecule. If None, density will be inferred from cell volume.

charge is the overall charge on the molecule.

Attributes

labile_formula is the original formula, with H[1] for the labile H. You can retrieve the deuterated from using::

molecule.labile_formula.replace(elements.H[1], elements.D)

natural_formula has H substituted for H[1] in labile_formula.

D2Omatch is percentage of D2O by volume in H2O required to match the SLD of the molecule, including substitution of labile hydrogen in proportion to the D/H ratio in the solvent. Values will be outside the range [0, 100] if the contrast match is impossible.

sld/Dsld are the the SLDs of the molecule with H[1] replaced by naturally occurring H/D ratios and pure D respectively.

mass/Dmass are the masses for natural H/D and pure D respectively.

charge is the charge on the molecule

cell_volume is the estimated cell volume for the molecule

density is the estimated molecule density

Change 1.5.3: drop Hmass and Hsld. Move formula to labile_formula. Move Hnatural to formula.

Expand source code
class Component(Molecule):
    # Subclasses Molecule to automatically store a component length for use later
    # and calculate total neutron scattering lengths
    def __init__(self, length=9.575, xray_wavelength=None, **kwargs):
        super().__init__(**kwargs)
        self.length = length
        self.nSLs = self.fnGetnSL(xray_wavelength)

    def fnGetnSL(self, xray_wavelength=None):
        if xray_wavelength is None:
            return numpy.array([self.sld * self.cell_volume * 1e-6, self.Dsld * self.cell_volume * 1e-6])
        else:
            return numpy.array([xray_sld(self.formula, wavelength=xray_wavelength)[0] * self.cell_volume * 1e-6])

Ancestors

  • periodictable.fasta.Molecule

Methods

def fnGetnSL(self, xray_wavelength=None)
class Lipid (headgroup, tails, methyls, name=None)
Expand source code
class Lipid(object):
    def __init__(self, headgroup, tails, methyls, name=None):
        # hg = Component object with headgroup information or PC molgroups object
        # tails = List of component objects containing lipid tail information
        # methyls = List of methyl groups, one for each lipid tail; OR, a single group
        #           that is copied to each tail; OR, None, which uses a null group with
        #           no volume (use with cholesterol). Use methyl=Dmethyl for CD3.

        # tails section
        n_tails = len(tails)
        if not isinstance(tails, list):
            tails = [tails]

        tail_volume = sum([t.cell_volume for t in tails])
        tail_formula = ' '.join([str(t.formula) for t in tails])
        tail_length = sum([t.length for t in tails]) / n_tails
        self.tails = Component(name='tails', formula=tail_formula, cell_volume=tail_volume, length=tail_length)

        # headgroup
        self.headgroup = headgroup if headgroup is not None else null_component

        # Create methyl groups
        if not isinstance(methyls, list):
            methyls = [methyls]
        if len(methyls) == 1:
            methyls = n_tails * methyls
        assert n_tails == len(methyls), 'Lipid tails and lipid methyl lists must have equal length, not %i and %i' \
                                            % (len(tails), len(methyls))

        # Replace None with null molecule
        methyls = [m if m is not None else null_component for m in methyls]
        m_volume = sum([m.cell_volume for m in methyls])
        m_formula = ' '.join([str(m.formula) for m in methyls])
        m_length = sum([m.length for m in methyls]) / n_tails
        self.methyls = Component(name='methyls', formula=m_formula, cell_volume=m_volume, length=m_length)

        if name is not None:
            self.name = name
        else:
            self.name = ' + '.join([c.name for c in (tails + [self.headgroup]) if c.name is not None])

Subclasses

class Tether (tether, tetherg, tails, methyls, name=None)

Subclass of Lipid for use with tether molecules. Uses hg field for tether glycerol. Tether includes both volume from the surface-attachment group (e.g. thiol) and the length of the separating polymer

Expand source code
class Tether(Lipid):
    """Subclass of Lipid for use with tether molecules.
        Uses hg field for tether glycerol.
        Tether includes both volume from the surface-attachment group (e.g. thiol)
            and the length of the separating polymer"""

    def __init__(self, tether, tetherg, tails, methyls, name=None):

        super().__init__(name=name, headgroup=tetherg, tails=tails, methyls=methyls)
        self.tether = tether
        self.tetherg = self.headgroup

        if name is not None:
            self.name = name
        else:
            self.name = ' + '.join([c.name for c in ([self.tether] + tails) if c.name is not None])

Ancestors