コード例 #1
0
def mismatch_center(off, effect='x'):
    i = len(off) // 2
    context = off[i - 1:i + 2]

    if len(off) < 3:
        raise RnaDesignError

    if au_au_pattern.match(context):
        mut_table = au_au_mismatches
    elif au_gc_pattern.match(context):
        mut_table = au_gc_mismatches
    elif gc_gc_pattern.match(context):
        mut_table = gc_gc_mismatches
    else:
        raise AssertionError

    if effect == 'x':
        effector = rc(mutate(off, i, c(mut_table[off[i]])))
        on = rc(effector)

    elif effect == 'o':
        on = mutate(off, i, mut_table[c(off[i])])
        effector = rc(off)

    return Mutant(effector, on, off)
コード例 #2
0
def wobble_all(off, effect='x'):
    # Find all the positions where a wobble base pair could be made, i.e. all
    # the positions in the "off" sequence that are either G or U.

    if effect == 'x':
        effector = c(off)

        for i, bp in enumerate(off):
            if bp == 'G':
                effector = mutate(effector, i, 'U')
            if bp == 'U':
                effector = mutate(effector, i, 'G')

        on = rc(effector)

    elif effect == 'o':
        on = off

        for i, bp in enumerate(off):
            if bp == 'A':
                on = mutate(on, i, 'G')
            if bp == 'C':
                on = mutate(on, i, 'U')

        effector = rc(off)

    else:
        raise ValueError("Unknown effect: '{}'".format(effect))

    return Mutant(effector, on, off)
コード例 #3
0
def bulge(off, effect='x', nuc='A'):
    if effect == 'x':
        effector = insert(rc(off), len(off) // 2, nuc)
        on = rc(effector)

    if effect == 'o':
        on = insert(off, len(off) // 2, nuc)
        effector = rc(off)

    return Mutant(effector, on, off)
コード例 #4
0
def wobble(off, effect='x', location='center'):

    # Find all the positions where a wobble base pair could be made, i.e. all
    # the positions in the "off" sequence that are either G or U.

    if effect == 'x':
        gu_iter = re.finditer('[GU]', off)

    elif effect == 'o':
        gu_iter = re.finditer('[AC]', off)

    else:
        raise ValueError("Unknown effect: '{}'".format(effect))

    gus = [x.start() for x in gu_iter]

    if not gus:
        raise RnaDesignError("No G or U nucleotides in input sequence.")

    # Decide where to insert the wobble base pair based on the location
    # argument.  The default is to mutate the center-most position, but the
    # user can choose to mutate the inner- or outer-most positions as well.

    if location == 'center':
        N = D = len(off)
        for i in gus:
            d = abs(i - N / 2)
            if d < D: gu, D = i, d

    elif location == 'edge':
        # We'll assume that the edge is on the left, here.
        gu = gus[0]

    elif location == 'non-edge':
        gu = gus[-1]

    else:
        raise ValueError("Unknown location: '{}'".format(location))

    # Create "on" and "effector" sequences that will have the desired effect.
    # The effect "x" means more cutting is desired, so the interaction between
    # the "effector" and "off" sequences has to be weakened.  The effect "o"
    # means that less cutting is desired, so the interaction between the
    # "effector" and "on" sequences has to be weakened.

    if effect == 'x':
        effector = r(mutate(c(off), gu, {'G': 'U', 'U': 'G'}[off[gu]]))
        on = rc(effector)

    elif effect == 'o':
        on = mutate(off, gu, {'C': 'U', 'A': 'G'}[off[gu]])
        effector = rc(off)

    return Mutant(effector, on, off)
コード例 #5
0
def mismatch(off, pattern, mutations, effect='x', location='center'):
    import re

    matches = pattern.finditer(off)
    indices = [x.start() + 1 for x in matches]
    if not indices: raise RnaDesignError
    i = pick_location(location, indices, len(off))

    if effect == 'x':
        effector = rc(mutate(off, i, c(mutations[off[i]])))
        on = rc(effector)

    elif effect == 'o':
        on = mutate(off, i, mutations[c(off[i])])
        effector = rc(off)

    return Mutant(effector, on, off)