Esempio n. 1
0
else:
    cascade = args.cascade

if not args.experimental:
    # Independent simulation for each chromosome
    from repli1d.fast_sim import get_fast_MRT_RFDs

    for (start, end, ch, ndiff), [x, d3p, stallp] in zip(list_task, d3pl):

        # simulate
        lres.append(
            get_fast_MRT_RFDs(
                nsim,
                d3p + np.ones_like(d3p) * np.sum(d3p) * noise / len(d3p),
                ndiff,
                kon=kon,
                fork_speed=fork_speed,
                dori=args.dori * 5 / resolution,
                single_mol_exp=args.single,
                continuous=args.continuous,
                cascade=cascade))
        #print("check", np.sum(d3p), np.sum(np.ones_like(d3p)*np.sum(d3p)*0.1/len(d3p)))

        print("End Simeeeeuuuuuuuuuuuuuuuuuuuu")
else:
    from repli1d.fast_sim_break import get_fast_MRT_RFDs

    #print(d3p)
    if args.cutholes is None:

        bigch = np.concatenate([d3p for x, d3p, stallp in d3pl])
def run(profile, tndiff, tstart, tend, actualProfile=None):

    res = args.resolution
    if actualProfile is not None:

        tmpProfile = actualProfile.copy()
        #print(tmpProfile.shape,np.array(profile).shape,start,tstart,tend,tmpProfile[tstart-start:tend-start].shape,tstart-start,tend-start)
        weight_t = np.sum(tmpProfile[tstart - start:tend - start])
        tmpProfile[tstart - start:tend -
                   start] = weight_t * np.array(profile) / np.sum(profile)
    else:
        tmpProfile = profile
    MRTp, MRTs, RFDs, Rept_time, single_mol_exp, pos_time_activated_ori, It, wRFD = get_fast_MRT_RFDs(
        nsim,
        tmpProfile,
        tndiff,
        kon=kon,
        fork_speed=fork_speed,
        dori=20 * 5 / resolution,
        single_mol_exp=False,
        continuous=args.continuous,
        wholeRFD=True)
    #print("check", np.sum(d3p), np.sum(np.ones_like(d3p)*np.sum(d3p)*0.1/len(d3p)))

    #print("Start, end",tstart,tend,tndiff)
    # Compare to exp data
    """
        MRTpearson, MRTstd, MRT = compare(
            MRTp[::10//resolution], "MRT", cell, res=10, ch=ch, start=start, end=end, return_exp=True)
        RFDpearson, RFDstd, RFD = compare(RFDs, "OKSeq", cell, res=resolution, ch=ch,
                                          start=start, end=end, return_exp=True, rescale=1/resolution)

        """

    if cell != "Cerevisae":
        if actualProfile is not None:
            MRTpearsonl, MRTstdl, MRTl = compare(
                MRTp[int((tstart - start) / res):int((tend - start) /
                                                     res)][::10 // resolution],
                "MRT",
                cell,
                res=10,
                ch=ch,
                start=tstart,
                end=tend,
                return_exp=True)
            RFDpearsonl, RFDstdl, RFDl = compare(
                RFDs[int((tstart - start) / res):int((tend - start) / res)],
                "OKSeq",
                cell,
                res=resolution,
                ch=ch,
                start=tstart,
                end=tend,
                return_exp=True,
                rescale=1 / resolution)
        else:
            RFDstdl = 0

        MRTpearson, MRTstd, MRT = compare(MRTp[::10 // resolution],
                                          "MRT",
                                          cell,
                                          res=10,
                                          ch=ch,
                                          start=start,
                                          end=end,
                                          return_exp=True)
        RFDpearson, RFDstd, RFD = compare(RFDs,
                                          "OKSeq",
                                          cell,
                                          res=resolution,
                                          ch=ch,
                                          start=start,
                                          end=end,
                                          return_exp=True,
                                          rescale=1 / resolution)
    else:
        if actualProfile is not None:
            MRTpearsonl, MRTstdl, MRTl = compare(
                MRTp[int((tstart - start) / res):int((tend - start) / res)],
                "MRT",
                cell,
                res=1,
                ch=ch,
                start=tstart,
                end=tend,
                return_exp=True)
            RFDpearsonl, RFDstdl, RFDl = compare(
                RFDs[int((tstart - start) / res):int((tend - start) / res)],
                "OKSeq",
                cell,
                res=1,
                ch=ch,
                start=tstart,
                end=tend,
                return_exp=True,
                rescale=1,
                nanpolate=True,
                smoothf=2)
        else:
            RFDstdl = 0

        MRTpearson, MRTstd, MRT = compare(MRTp,
                                          "MRT",
                                          cell,
                                          res=1,
                                          ch=ch,
                                          start=start,
                                          end=end,
                                          return_exp=True)
        RFDpearson, RFDstd, RFD = compare(RFDs,
                                          "OKSeq",
                                          cell,
                                          res=1,
                                          ch=ch,
                                          start=start,
                                          end=end,
                                          return_exp=True,
                                          rescale=1,
                                          nanpolate=True,
                                          smoothf=2)

        RFDs = smooth(RFDs, 2)

    if args.RFDo:
        print(RFDstd, RFDstdl)
        return RFDstd + RFDstdl, MRTp, MRT, RFD, RFDs, wRFD
    else:
        return MRTstd + RFDstd, MRTp, MRT, RFD, RFDs, wRFD
def run(profile):
    MRTp, MRTs, RFDs, Rept_time, single_mol_exp, pos_time_activated_ori, It = get_fast_MRT_RFDs(
        nsim,
        profile,
        ndiff,
        kon=kon,
        fork_speed=fork_speed,
        dori=20 * 5 / resolution,
        single_mol_exp=False,
        continuous=args.continuous)
    #print("check", np.sum(d3p), np.sum(np.ones_like(d3p)*np.sum(d3p)*0.1/len(d3p)))

    # Compare to exp data
    """
        MRTpearson, MRTstd, MRT = compare(
            MRTp[::10//resolution], "MRT", cell, res=10, ch=ch, start=start, end=end, return_exp=True)
        RFDpearson, RFDstd, RFD = compare(RFDs, "OKSeq", cell, res=resolution, ch=ch,
                                          start=start, end=end, return_exp=True, rescale=1/resolution)

        """
    if cell != "Cerevisae":
        MRTpearson, MRTstd, MRT = compare(MRTp[::10 // resolution],
                                          "MRT",
                                          cell,
                                          res=10,
                                          ch=ch,
                                          start=start,
                                          end=end,
                                          return_exp=True)
        RFDpearson, RFDstd, RFD = compare(RFDs,
                                          "OKSeq",
                                          cell,
                                          res=resolution,
                                          ch=ch,
                                          start=start,
                                          end=end,
                                          return_exp=True,
                                          rescale=1 / resolution)
    else:
        MRTpearson, MRTstd, MRT = compare(MRTp,
                                          "MRT",
                                          cell,
                                          res=1,
                                          ch=ch,
                                          start=start,
                                          end=end,
                                          return_exp=True)
        RFDpearson, RFDstd, RFD = compare(RFDs,
                                          "OKSeq",
                                          cell,
                                          res=1,
                                          ch=ch,
                                          start=start,
                                          end=end,
                                          return_exp=True,
                                          rescale=1,
                                          nanpolate=True,
                                          smoothf=2)

    if args.RFDo:
        #print(RFDstd)
        return RFDstd, MRTp, MRT, RFD, RFDs
    else:
        return MRTstd + RFDstd, MRTp, MRT, RFD, RFDs
                                          start=start, end=end,
                                          resolution=5, raw=False, oData=False,
                                          bp=True, bpc=False)

                if args.correct:

                    x, CNV = replication_data(cell, "CNV", chromosome=ch,
                                              start=start, end=end,
                                              resolution=5, raw=False)
                    CNV[CNV == 0] = 2
                    d3p /= CNV
                d3p[np.isnan(d3p)] = 0

                print("Simu")
                sim = get_fast_MRT_RFDs(
                    nsim, d3p+np.ones_like(d3p)*np.sum(d3p)*random_activation/len(d3p), ndiff, kon=kon,
                    fork_speed=fork_speed, dori=dori)
                with open(filename, "wb") as f:
                    pickle.dump(sim, f)

            MRTp, MRTs, RFDs, Rep_Time, single_mol_exp, pos_time_activated_ori, It = sim
            # Compare to exp data
            MRTpearson, MRTstd, MRT = compare(
                MRTp[::2], "MRT", compMRT, res=10, ch=ch, start=start, end=end, return_exp=True)
            RFDpearson, RFDstd, RFD = compare(RFDs, "OKSeq", compRFD, res=5, ch=ch,
                                              start=start, end=end, return_exp=True, rescale=1/5)

            print(MRTpearson, MRTstd, RFDpearson, RFDstd)

            M.append(mark)
            D.append(ndiff)