Beispiel #1
0
def CalculateHydrophobicMoment3(
        sequence,
        angle=100. / 180. * math.pi,
        hydrophobicity_dict=hydrophobicity_dict_eisenberg):
    if type(sequence) == type(seq.SequenceHandle()):
        sequence = sequence.GetGaplessString()
    elif type(sequence) != type(str()):
        sequence = entity_alg.CreateSequenceFromView(
            sequence, 'temp').GetGaplessString()
    v = geom.Rotate(geom.Vec2(1.0, 0.0), -angle)
    moment = geom.Vec2()
    for r in sequence:
        v = geom.Rotate(v, angle)
        moment += hydrophobicity_dict[r] * v
    vm = moment / geom.Length(moment)
    m_max = moment
    for i in range(-3, 4):
        v = geom.Rotate(geom.Vec2(1.0, 0.0), -angle)
        moment = geom.Vec2()
        for r in sequence:
            v = geom.Rotate(v, angle)
            v2 = v - 0.2 * i * vm
            v2 = geom.Dot(v2, vm) / geom.Length(v2) * vm
            moment += hydrophobicity_dict[r] * v2
        if geom.Length(moment) > geom.Length(m_max): m_max = moment
    return geom.Length(m_max)
Beispiel #2
0
def CalculateCharge(sequence):
    if type(sequence) == type(seq.SequenceHandle()):
        sequence = sequence.GetGaplessString()
    elif type(sequence) != type(str()):
        sequence = entity_alg.CreateSequenceFromView(
            sequence, 'temp').GetGaplessString()
    c = 0
    for s in sequence:
        c += residue_charge_dict[s]
    return c
Beispiel #3
0
def CalculateHydrophobicity(sequence,
                            hydrophobicity_dict=hydrophobicity_dict_eisenberg):
    if type(sequence) == type(seq.SequenceHandle()):
        sequence = sequence.GetGaplessString()
    elif type(sequence) != type(str()):
        sequence = entity_alg.CreateSequenceFromView(
            sequence, 'temp').GetGaplessString()
    hydrophobicity = 0.0
    for r in sequence:
        hydrophobicity += hydrophobicity_dict[r]
    return hydrophobicity
Beispiel #4
0
def CalculateHydrophobicMoment(
        sequence,
        angle=100. / 180. * math.pi,
        hydrophobicity_dict=hydrophobicity_dict_eisenberg):
    if type(sequence) == type(seq.SequenceHandle()):
        sequence = sequence.GetGaplessString()
    elif type(sequence) != type(str()):
        sequence = entity_alg.CreateSequenceFromView(
            sequence, 'temp').GetGaplessString()
    v = geom.Rotate(geom.Vec2(1.0, 0.0), -angle)
    moment = geom.Vec2()
    for r in sequence:
        v = geom.Rotate(v, angle)
        moment += hydrophobicity_dict[r] * v
    return geom.Length(moment)
Beispiel #5
0
def CalculateChargeWithSlidingWindow(sequence, w=11):
    if type(sequence) == type(seq.SequenceHandle()):
        sequence = sequence.GetGaplessString()
    elif type(sequence) != type(str()):
        sequence = entity_alg.CreateSequenceFromView(
            sequence, 'temp').GetGaplessString()
    charge_list = []
    before = int(w / 2.)
    after = w - before
    n = len(sequence)
    for i in range(n):
        b = max(0, i - before)
        e = min(n, i + after)
        l = float(e - b)
        charge_list.append(CalculateCharge(sequence[b:e]) / l)
    return charge_list
Beispiel #6
0
def CalculateHydrophobicityWithSlidingWindow(
        sequence, w=11, hydrophobicity_dict=hydrophobicity_dict_eisenberg):
    if type(sequence) == type(seq.SequenceHandle()):
        sequence = sequence.GetGaplessString()
    elif type(sequence) != type(str()):
        sequence = entity_alg.CreateSequenceFromView(
            sequence, 'temp').GetGaplessString()
    hydrophobicity_list = []
    before = int(w / 2.)
    after = w - before
    n = len(sequence)
    for i in range(n):
        b = max(0, i - before)
        e = min(n, i + after)
        l = float(e - b)
        hydrophobicity_list.append(
            CalculateHydrophobicity(sequence[b:e],
                                    hydrophobicity_dict_eisenberg) / l)
    return hydrophobicity_list