Ejemplo n.º 1
0
def generate_sequence(N=0, spin_ids=None, spin_nums=None, spin_names=None, res_nums=None, res_names=None, mol_names=None, isotopes=None, elements=None):
    """Generate the sequence data from the BRMB information.

    @keyword N:             The number of spins.
    @type N:                int
    @keyword spin_ids:      The list of spin IDs.
    @type spin_ids:         list of str
    @keyword spin_nums:     The list of spin numbers.
    @type spin_nums:        list of int or None
    @keyword spin_names:    The list of spin names.
    @type spin_names:       list of str or None
    @keyword res_nums:      The list of residue numbers.
    @type res_nums:         list of int or None
    @keyword res_names:     The list of residue names.
    @type res_names:        list of str or None
    @keyword mol_names:     The list of molecule names.
    @type mol_names:        list of str or None
    @keyword isotopes:      The optional list of isotope types.
    @type isotopes:         list of str or None
    @keyword elements:      The optional list of element types.
    @type elements:         list of str or None
    """

    # The blank data.
    if not spin_nums:
        spin_nums = [None] * N
    if not spin_names:
        spin_names = [None] * N
    if not res_nums:
        res_nums = [None] * N
    if not res_names:
        res_names = [None] * N
    if not mol_names:
        mol_names = [None] * N

    # Generate the spin IDs.
    spin_ids = []
    for i in range(N):
        spin_ids.append(generate_spin_id(mol_name=mol_names[i], res_num=res_nums[i], spin_name=spin_names[i]))

    # Loop over the spin data.
    for i in range(N):
        # The spin already exists.
        spin = return_spin(spin_ids[i])
        if spin:
            continue

        # Create the spin.
        spin = create_spin(spin_num=spin_nums[i], spin_name=spin_names[i], res_num=res_nums[i], res_name=res_names[i], mol_name=mol_names[i])

        # Set the spin isotope and element.
        spin_id = spin._spin_ids[0]
        if elements:
            set_spin_element(spin_id=spin_id, element=elements[i], force=True)
        if isotopes and elements:
            isotope = "%s%s" % (isotopes[i], elements[i])
            set_spin_isotope(spin_id=spin_id, isotope=isotope, force=True)

    # Clean up the spin metadata.
    metadata_cleanup()
Ejemplo n.º 2
0
def attach_protons():
    """Attach a single proton to all heteronuclei."""

    # Loop over all spins.
    mol_names = []
    res_nums = []
    res_names = []
    for spin, mol_name, res_num, res_name, spin_id in spin_loop(full_info=True, return_id=True):
        # The spin is already a proton.
        if hasattr(spin, 'element') and spin.element == 'H':
            continue

        # Get the interatomic data container.
        interatoms = return_interatom_list(spin_id)
        proton_found = False
        if len(interatoms):
            for i in range(len(interatoms)):
                # Get the attached spin.
                spin_attached = return_spin(interatoms[i].spin_id1)
                if id(spin_attached) == id(spin):
                    spin_attached = return_spin(interatoms[i].spin_id2)

                # Is it a proton?
                if hasattr(spin_attached, 'element') and spin_attached.element == 'H' or spin.name == 'H':
                    proton_found = True
                    break

        # Attached proton found.
        if proton_found:
            continue

        # Store the sequence info.
        mol_names.append(mol_name)
        res_nums.append(res_num)
        res_names.append(res_name)

    # Create all protons (this must be done out of the spin loop, as it affects the looping!).
    ids = []
    for i in range(len(mol_names)):
        # Create the spin container.
        spin = create_spin(spin_name='H', res_name=res_names[i], res_num=res_nums[i], mol_name=mol_names[i])
        ids.append(generate_spin_id(mol_name=mol_names[i], res_num=res_nums[i], res_name=res_names[i], spin_name='H'))
    print("Creating the spins %s." % ids)

    # Set the element and spin type.
    set_spin_element(spin_id='@H', element='H')
    set_spin_isotope(spin_id='@H', isotope='1H')
Ejemplo n.º 3
0
def attach_protons():
    """Attach a single proton to all heteronuclei."""

    # Loop over all spins.
    mol_names = []
    res_nums = []
    res_names = []
    for spin, mol_name, res_num, res_name, spin_id in spin_loop(full_info=True, return_id=True):
        # The spin is already a proton.
        if hasattr(spin, 'element') and spin.element == 'H':
            continue

        # Get the interatomic data container.
        interatoms = return_interatom_list(spin_hash=spin._hash)
        proton_found = False
        if len(interatoms):
            for i in range(len(interatoms)):
                # Get the attached spin.
                spin_attached = return_spin(spin_hash=interatoms[i]._spin_hash1)
                if id(spin_attached) == id(spin):
                    spin_attached = return_spin(spin_hash=interatoms[i]._spin_hash2)

                # Is it a proton?
                if hasattr(spin_attached, 'element') and spin_attached.element == 'H' or spin.name == 'H':
                    proton_found = True
                    break

        # Attached proton found.
        if proton_found:
            continue

        # Store the sequence info.
        mol_names.append(mol_name)
        res_nums.append(res_num)
        res_names.append(res_name)

    # Create all protons (this must be done out of the spin loop, as it affects the looping!).
    ids = []
    for i in range(len(mol_names)):
        # Create the spin container.
        spin = create_spin(spin_name='H', res_name=res_names[i], res_num=res_nums[i], mol_name=mol_names[i])[0]
        ids.append(generate_spin_id(mol_name=mol_names[i], res_num=res_nums[i], res_name=res_names[i], spin_name='H'))
    print("Creating the spins %s." % ids)

    # Set the element and spin type.
    set_spin_element(spin_id='@H', element='H')
    set_spin_isotope(spin_id='@H', isotope='1H')
Ejemplo n.º 4
0
def generate_sequence(N=0,
                      spin_ids=None,
                      spin_nums=None,
                      spin_names=None,
                      res_nums=None,
                      res_names=None,
                      mol_names=None,
                      isotopes=None,
                      elements=None):
    """Generate the sequence data from the BRMB information.

    @keyword N:             The number of spins.
    @type N:                int
    @keyword spin_ids:      The list of spin IDs.
    @type spin_ids:         list of str
    @keyword spin_nums:     The list of spin numbers.
    @type spin_nums:        list of int or None
    @keyword spin_names:    The list of spin names.
    @type spin_names:       list of str or None
    @keyword res_nums:      The list of residue numbers.
    @type res_nums:         list of int or None
    @keyword res_names:     The list of residue names.
    @type res_names:        list of str or None
    @keyword mol_names:     The list of molecule names.
    @type mol_names:        list of str or None
    @keyword isotopes:      The optional list of isotope types.
    @type isotopes:         list of str or None
    @keyword elements:      The optional list of element types.
    @type elements:         list of str or None
    """

    # The blank data.
    if not spin_nums:
        spin_nums = [None] * N
    if not spin_names:
        spin_names = [None] * N
    if not res_nums:
        res_nums = [None] * N
    if not res_names:
        res_names = [None] * N
    if not mol_names:
        mol_names = [None] * N

    # Generate the spin IDs.
    spin_ids = []
    for i in range(N):
        spin_ids.append(
            generate_spin_id(mol_name=mol_names[i],
                             res_num=res_nums[i],
                             spin_name=spin_names[i]))

    # Loop over the spin data.
    for i in range(N):
        # The spin already exists.
        spin = return_spin(spin_id=spin_ids[i])
        if spin:
            continue

        # Create the spin.
        spin = create_spin(spin_num=spin_nums[i],
                           spin_name=spin_names[i],
                           res_num=res_nums[i],
                           res_name=res_names[i],
                           mol_name=mol_names[i])[0]

        # Set the spin isotope and element.
        spin_id = spin._spin_ids[0]
        if elements:
            set_spin_element(spin_id=spin_id, element=elements[i], force=True)
        if isotopes and elements:
            isotope = "%s%s" % (isotopes[i], elements[i])
            set_spin_isotope(spin_id=spin_id, isotope=isotope, force=True)

    # Clean up the spin metadata.
    metadata_cleanup()