from primer3 import calcHairpin, calcHomodimer, calc_heterodimer

# divisions are done to convert from cals to kcals
# issue: the inputted sequences need to be <= 60bp

def heterodimer_dg(fwd, rev):
    dg = calc_heterodimer(fwd,rev).dg / 1000
    return dg

# checks to make sure primers do not interact with each other
# not currently used
def heterodimer_created(fwd, rev): 
    dg = heterodimer_dg(fwd, rev) # delta G
    min_dg = -10000 # set these to realistic values
    max_dg = 10000
    if min_dg <= dg <= max_dg:
        return 0
    else:
        return True


def self_interaction(primer_seq):
    # checks to see if primer hairpins or forms a homodimer

    hairpin_dg = calcHairpin(primer_seq).dg / 1000
    homodimer_dg = calcHomodimer(primer_seq).dg / 1000

    min_dg, max_dg = -10000, 10000 # set to realistic values. can make different min/max for hairpin vs. homodimer
    if min_dg <= hairpin_dg <= max_dg:
        return True
    if min_dg <= homodimer_dg <= max_dg:
        return True
    return 0