ribolands/barmap.py
def barmap_treekin(bname, seq, bfiles, plist, args):
    """ write treekin files from bfiles and plist information """
    tmpdir = args.tmpdir
    start = args.start
    stop = args.stop
    verb = args.verbose
    tX = args.tX
    t8 = args.t8
    cutoff = args.occupancy_cutoff

    p0 = args.p0
    tt = 0
    tfiles = []
    reg_flt = re.compile(b'[-+]?[0-9]*.?[0-9]+([eE][-+]?[0-9]+)?.')
    # http://www.regular-expressions.info/floatingpoint.html

    for e, l in enumerate(range(start, stop + 1)):
        t8 = tX if l == stop else t8

        cseq = seq[0:l]
        cname = "{}-t8_{}-len_{}".format(bname, t8, l)
        [bfile, efile, rfile, psfile, bmfile] = bfiles[e]

        with open(bfile) as bf:
            for i, _ in enumerate(bf):
                pass
        if i >= 2:
            try:
                ctfile, _ = ril.sys_treekin_051(cname, rfile,
                        treekin = args.treekin,
                        bofile = bfile,
                        p0 = p0,
                        t0 = args.t0,
                        ti = args.ti,
                        t8 = t8,
                        binrates = True,
                        useplusI = False,
                        exponent = False,
                        mpack_method = None,
                        force = args.force,
                        verbose = verb)

            except SubprocessError:
                print("# repeating treekin calculations with --exponent")
                ctfile, _ = ril.sys_treekin_051(cname, rfile,
                        treekin = args.treekin,
                        bofile = bfile,
                        p0 = p0,
                        t0 = args.t0,
                        ti = args.ti,
                        t8 = t8,
                        binrates = True,
                        useplusI = False,
                        exponent = True,
                        mpack_method = None,
                        force = args.force,
                        verbose = verb)

            lastlines = s.check_output(
                ['tail', '-2', ctfile]).strip().split(b'\n')
            if reg_flt.match(lastlines[0]):
                tt += float(lastlines[0].split()[0])
                if l < stop:
                    curlmin = np.array(plist)[:, e]
                    newlmin = np.array(plist)[:, e + 1]
                    p0 = set_p0(bfile, l, lastlines, curlmin, newlmin,
                                cutoff, verb)
                else:
                    for (i, pop) in enumerate(lastlines[0].split()):
                        if i != 0 and float(pop) > cutoff:
                            ss, en = get_structure(bfile, i, energy=True)
                            print("{:3d} {:3d} {:f} {:s} {:6.2f}".format(l, i,
                                float(pop), ss, float(en)))
            else:
                raise SubprocessError(
                    'found crashed treekin trajectory.', ctfile)
        else:
            # Create an empty file
            ctfile = cname + '.tkn'
            open(ctfile, 'a').close()
            tt += t8
            print("{:3d} {:3d} {:f} {:s} {:6.2f}".format(l, 1, 1.0, get_structure(bfile, 1), 0.00))
        tfiles.append(ctfile)
    return tfiles
 write treekin files from bfiles and plist information 
write treekin files from bfiles and plist information
write treekin files from bfiles and plist information
def barmap_treekin(bname, seq, bfiles, plist, args):
    tmpdir = args.tmpdir
    start = args.start
    stop = args.stop
    verb = args.verbose
    tX = args.tX
    t8 = args.t8
    cutoff = args.occupancy_cutoff
    p0 = args.p0
    tt = 0
    tfiles = []
    reg_flt = re.compile(b'[-+]?[0-9]*.?[0-9]+([eE][-+]?[0-9]+)?.')
    for e, l in enumerate(range(start, stop + 1)):
        t8 = tX if l == stop else t8
        cseq = seq[0:l]
        cname = "{}-t8_{}-len_{}".format(bname, t8, l)
        [bfile, efile, rfile, psfile, bmfile] = bfiles[e]
        with open(bfile) as bf:
            for i, _ in enumerate(bf):
                pass
        if i >= 2:
            try:
                ctfile, _ = ril.sys_treekin_051(cname, rfile,
                        treekin = args.treekin,
                        bofile = bfile,
                        p0 = p0,
                        t0 = args.t0,
                        ti = args.ti,
                        t8 = t8,
                        binrates = True,
                        useplusI = False,
                        exponent = False,
                        mpack_method = None,
                        force = args.force,
                        verbose = verb)
            except SubprocessError:
                print("# repeating treekin calculations with --exponent")
                ctfile, _ = ril.sys_treekin_051(cname, rfile,
                        treekin = args.treekin,
                        bofile = bfile,
                        p0 = p0,
                        t0 = args.t0,
                        ti = args.ti,
                        t8 = t8,
                        binrates = True,
                        useplusI = False,
                        exponent = True,
                        mpack_method = None,
                        force = args.force,
                        verbose = verb)
            lastlines = s.check_output(
                ['tail', '-2', ctfile]).strip().split(b'\n')
            if reg_flt.match(lastlines[0]):
                tt += float(lastlines[0].split()[0])
                if l < stop:
                    curlmin = np.array(plist)[:, e]
                    newlmin = np.array(plist)[:, e + 1]
                    p0 = set_p0(bfile, l, lastlines, curlmin, newlmin,
                                cutoff, verb)
                else:
                    for (i, pop) in enumerate(lastlines[0].split()):
                        if i != 0 and float(pop) > cutoff:
                            ss, en = get_structure(bfile, i, energy=True)
                            print("{:3d} {:3d} {:f} {:s} {:6.2f}".format(l, i,
                                float(pop), ss, float(en)))
            else:
                raise SubprocessError(
                    'found crashed treekin trajectory.', ctfile)
        else:
            ctfile = cname + '.tkn'
            open(ctfile, 'a').close()
            tt += t8
            print("{:3d} {:3d} {:f} {:s} {:6.2f}".format(l, 1, 1.0, get_structure(bfile, 1), 0.00))
        tfiles.append(ctfile)
    return tfiles
def barmap_treekin ( bname , seq , bfiles , plist , args ) : tmpdir = args . tmpdir start = args . start stop = args . stop verb = args . verbose tX = args . tX t8 = args . t8 cutoff = args . occupancy_cutoff p0 = args . p0 tt = 0 tfiles = [ ] reg_flt = re . compile ( b'[-+]?[0-9]*.?[0-9]+([eE][-+]?[0-9]+)?.' ) for e , l in enumerate ( range ( start , stop + 1 ) ) : t8 = tX if l == stop else t8 cseq = seq [ 0 : l ] cname = "{}-t8_{}-len_{}" . format ( bname , t8 , l ) [ bfile , efile , rfile , psfile , bmfile ] = bfiles [ e ] with open ( bfile ) as bf : for i , _ in enumerate ( bf ) : pass if i >= 2 : try : ctfile , _ = ril . sys_treekin_051 ( cname , rfile , treekin = args . treekin , bofile = bfile , p0 = p0 , t0 = args . t0 , ti = args . ti , t8 = t8 , binrates = True , useplusI = False , exponent = False , mpack_method = None , force = args . force , verbose = verb ) except SubprocessError : print ( "# repeating treekin calculations with --exponent" ) ctfile , _ = ril . sys_treekin_051 ( cname , rfile , treekin = args . treekin , bofile = bfile , p0 = p0 , t0 = args . t0 , ti = args . ti , t8 = t8 , binrates = True , useplusI = False , exponent = True , mpack_method = None , force = args . force , verbose = verb ) lastlines = s . check_output ( [ 'tail' , '-2' , ctfile ] ) . strip ( ) . split ( b'\n' ) if reg_flt . match ( lastlines [ 0 ] ) : tt += float ( lastlines [ 0 ] . split ( ) [ 0 ] ) if l < stop : curlmin = np . array ( plist ) [ : , e ] newlmin = np . array ( plist ) [ : , e + 1 ] p0 = set_p0 ( bfile , l , lastlines , curlmin , newlmin , cutoff , verb ) else : for ( i , pop ) in enumerate ( lastlines [ 0 ] . split ( ) ) : if i != 0 and float ( pop ) > cutoff : ss , en = get_structure ( bfile , i , energy = True ) print ( "{:3d} {:3d} {:f} {:s} {:6.2f}" . format ( l , i , float ( pop ) , ss , float ( en ) ) ) else : raise SubprocessError ( 'found crashed treekin trajectory.' , ctfile ) else : ctfile = cname + '.tkn' open ( ctfile , 'a' ) . close ( ) tt += t8 print ( "{:3d} {:3d} {:f} {:s} {:6.2f}" . format ( l , 1 , 1.0 , get_structure ( bfile , 1 ) , 0.00 ) ) tfiles . append ( ctfile ) return tfiles
write treekin files from bfiles and plist information
write treekin files from bfiles and plist information
""" write treekin files from bfiles and plist information """ # http://www.regular-expressions.info/floatingpoint.html # Create an empty file
bname
seq
bfiles
plist
args