ribolands/syswraps.py
def sys_subopt_range(seq,
                     RNAsubopt = 'RNAsubopt',
                     params = None,
                     nos = 5100000,
                     maxe = 30.0,
                     temp = 37.0,
                     noLP = False,
                     circ = False):
    """ Compute an energy range that computes a given number of structures.

    .. note:: If your RAM is big enough, ``barriers`` can be compiled to read \
      billions of structures, however computations with more than 10.000.000 \
      structures may take a very long time.

    Args:
      seq (str): nucleic acid sequence.
      RNAsubopt (str, optional): path to executable.
      nos (int, optional): number of structures.
      maxe (float, optional): an upper bound of the energy range.
      temp (float, optional): temperature in Celsius.
      noLP (bool): exclude lonely-base-pairs in suboptimal structures. Defaults to False.
      circ (bool): compute density of states. Defaults to False.

    Returns:
      [tuple]: (energy-range, number-of-structures)
    """

    if which(RNAsubopt) is None:
        raise ExecError(RNAsubopt, "RNAsubopt", 'http://www.tbi.univie.ac.at/RNA')

    num, nump = 0, 0
    e = maxe if nos == 0 else 5.  # Decreasing this value may introduce bugs ...
    ep = e - 1
    while num <= nos:
        rlog.info("Energy: {:.2f}".format(float(e)))
        sptcall = [RNAsubopt, "-D -e {:.2f} -T {:.2f}".format(float(e), temp)]
        if params:
            sptcall.extend(["--paramFile", params])
        if circ:
            sptcall.append("--circ")
        if noLP:
            sptcall.append("--noLP")

        process = sub.Popen([' '.join(sptcall)],
                            stdin = sub.PIPE, 
                            stdout = sub.PIPE, 
                            stderr = sub.PIPE, 
                            shell = True)
        output, err = process.communicate(seq.encode())
        if err:
            # this one might be not so bad ...
            raise Exception(err)

        structures = 0
        for l in output.split(b'\n')[1:-1]:
            [interval, value] = l.split()
            structures += int(value)
            # Make sure that nump fits to the preset ep value
            if nump == 0:
                if ep * 10 == int(interval):
                    nump = structures
            # Break the loop if you reach the number of structures in the output
            if (nos and structures >= nos - (nos * 0.01)) or float(interval) / 10 >= maxe:
                e = float(interval) / 10
                num = structures
                break  # return to while
        else: # the last loop didn't break ...
            num = structures
            if num > nos or num == nump:
                e = float(interval) / 10
                break
            new = e + (e - ep) / (math.log(float(num) / nump)) * \
                (math.log(float(nos) / num))
            ep, nump = e, num
            e = new if new < maxe else maxe
            if abs(e - ep) < 0.1:
                e = ep
                break
            continue
        break  # end while after for loop exit
    return e, num
 Compute an energy range that computes a given number of structures.

    .. note:: If your RAM is big enough, ``barriers`` can be compiled to read \
      billions of structures, however computations with more than 10.000.000 \
      structures may take a very long time.

    Args:
      seq (str): nucleic acid sequence.
      RNAsubopt (str, optional): path to executable.
      nos (int, optional): number of structures.
      maxe (float, optional): an upper bound of the energy range.
      temp (float, optional): temperature in Celsius.
      noLP (bool): exclude lonely-base-pairs in suboptimal structures. Defaults to False.
      circ (bool): compute density of states. Defaults to False.

    Returns:
      [tuple]: (energy-range, number-of-structures)
    
Compute an energy range that computes a given number of structures.
note:: If your RAM is big enough, ``barriers`` can be compiled to read \
billions of structures, however computations with more than 10.000.000 \
structures may take a very long time.
Compute an energy range that computes a given number of structures . note :: If your RAM is big enough ` ` barriers ` ` can be compiled to read \ billions of structures however computations with more than 10 . 000 . 000 \ structures may take a very long time .
def sys_subopt_range(seq,
                     RNAsubopt = 'RNAsubopt',
                     params = None,
                     nos = 5100000,
                     maxe = 30.0,
                     temp = 37.0,
                     noLP = False,
                     circ = False):
    if which(RNAsubopt) is None:
        raise ExecError(RNAsubopt, "RNAsubopt", 'http://www.tbi.univie.ac.at/RNA')
    num, nump = 0, 0
    e = maxe if nos == 0 else 5.  
    ep = e - 1
    while num <= nos:
        rlog.info("Energy: {:.2f}".format(float(e)))
        sptcall = [RNAsubopt, "-D -e {:.2f} -T {:.2f}".format(float(e), temp)]
        if params:
            sptcall.extend(["--paramFile", params])
        if circ:
            sptcall.append("--circ")
        if noLP:
            sptcall.append("--noLP")
        process = sub.Popen([' '.join(sptcall)],
                            stdin = sub.PIPE, 
                            stdout = sub.PIPE, 
                            stderr = sub.PIPE, 
                            shell = True)
        output, err = process.communicate(seq.encode())
        if err:
            raise Exception(err)
        structures = 0
        for l in output.split(b'\n')[1:-1]:
            [interval, value] = l.split()
            structures += int(value)
            if nump == 0:
                if ep * 10 == int(interval):
                    nump = structures
            if (nos and structures >= nos - (nos * 0.01)) or float(interval) / 10 >= maxe:
                e = float(interval) / 10
                num = structures
                break  
        else: 
            num = structures
            if num > nos or num == nump:
                e = float(interval) / 10
                break
            new = e + (e - ep) / (math.log(float(num) / nump)) * \
                (math.log(float(nos) / num))
            ep, nump = e, num
            e = new if new < maxe else maxe
            if abs(e - ep) < 0.1:
                e = ep
                break
            continue
        break  
    return e, num
def sys_subopt_range ( seq , RNAsubopt = 'RNAsubopt' , params = None , nos = 5100000 , maxe = 30.0 , temp = 37.0 , noLP = False , circ = False ) : if which ( RNAsubopt ) is None : raise ExecError ( RNAsubopt , "RNAsubopt" , 'http://www.tbi.univie.ac.at/RNA' ) num , nump = 0 , 0 e = maxe if nos == 0 else 5. ep = e - 1 while num <= nos : rlog . info ( "Energy: {:.2f}" . format ( float ( e ) ) ) sptcall = [ RNAsubopt , "-D -e {:.2f} -T {:.2f}" . format ( float ( e ) , temp ) ] if params : sptcall . extend ( [ "--paramFile" , params ] ) if circ : sptcall . append ( "--circ" ) if noLP : sptcall . append ( "--noLP" ) process = sub . Popen ( [ ' ' . join ( sptcall ) ] , stdin = sub . PIPE , stdout = sub . PIPE , stderr = sub . PIPE , shell = True ) output , err = process . communicate ( seq . encode ( ) ) if err : raise Exception ( err ) structures = 0 for l in output . split ( b'\n' ) [ 1 : - 1 ] : [ interval , value ] = l . split ( ) structures += int ( value ) if nump == 0 : if ep * 10 == int ( interval ) : nump = structures if ( nos and structures >= nos - ( nos * 0.01 ) ) or float ( interval ) / 10 >= maxe : e = float ( interval ) / 10 num = structures break else : num = structures if num > nos or num == nump : e = float ( interval ) / 10 break new = e + ( e - ep ) / ( math . log ( float ( num ) / nump ) ) * ( math . log ( float ( nos ) / num ) ) ep , nump = e , num e = new if new < maxe else maxe if abs ( e - ep ) < 0.1 : e = ep break continue break return e , num
Compute an energy range that computes a given number of structures.
Compute an energy range that computes a given number of structures .
""" Compute an energy range that computes a given number of structures.

    .. note:: If your RAM is big enough, ``barriers`` can be compiled to read \
      billions of structures, however computations with more than 10.000.000 \
      structures may take a very long time.

    Args:
      seq (str): nucleic acid sequence.
      RNAsubopt (str, optional): path to executable.
      nos (int, optional): number of structures.
      maxe (float, optional): an upper bound of the energy range.
      temp (float, optional): temperature in Celsius.
      noLP (bool): exclude lonely-base-pairs in suboptimal structures. Defaults to False.
      circ (bool): compute density of states. Defaults to False.

    Returns:
      [tuple]: (energy-range, number-of-structures)
    """ # Decreasing this value may introduce bugs ... # this one might be not so bad ... # Make sure that nump fits to the preset ep value # Break the loop if you reach the number of structures in the output # return to while # the last loop didn't break ... # end while after for loop exit
None
[tuple]
seq
nucleic acid sequence.
nucleic acid sequence .
RNAsubopt
path to executable.
path to executable .
params
nos
number of structures.
number of structures .
maxe
an upper bound of the energy range.
an upper bound of the energy range .
temp
temperature in Celsius.
temperature in Celsius .
noLP
exclude lonely-base-pairs in suboptimal structures. Defaults to False.
exclude lonely - base - pairs in suboptimal structures . Defaults to False .
False
circ
compute density of states. Defaults to False.
compute density of states . Defaults to False .
False