Ejemplo n.º 1
0
def test_random_value():
    r = RandomDict()
    for i in range(10000):
        r[i] = i

    values = set(range(10000))
    for i in range(100000):
        assert r.random_value() in values
print('Writing sim data to file.')
count = 1
with open(args.Outputname + "_R1.fastq",
          "w") as handleR1, open(args.Outputname + "_R2.fastq",
                                 "w") as handleR2:
    for myfile in args.T:
        record_dict = SeqIO.index(myfile.name, "fasta")
        record_rand = RandomDict(record_dict)
        for cell in range(0, nrCells):
            cellSeq = random.sample(cell_pool, 1)[0]
            cell_pool.discard(cellSeq)
            umi_set = generate_umi_set(args.umi_bc_length, 100, 0.2)
            for record in range(0, nrSeqs):
                UMIseq = random.sample(umi_set, 1)[0]
                myItem = record_rand.random_value()
                if random.random() < 0.01:
                    myItem.seq = Seq(
                        mutate(sequence=myItem.seq, mutation_rate=0.001))
                myItem += "A" * 150
                start = 0
                #print(myItem.id + " length: " + str(limit))
                end = start + myLength
                mySub = myItem[start:end]
                seqid = myItem.id + ":" + cellSeq + ":" + UMIseq + ":" + str(
                    count)
                mySub.id = seqid + "/2"
                mySub.letter_annotations["phred_quality"] = [24] * len(mySub)
                tmp = SeqIO.write(mySub, handleR2, "fastq")

                mySub2 = SeqRecord(Seq(cellSeq + UMIseq),
Ejemplo n.º 3
0
def test_empty_random_value():
    r = RandomDict()
    r.random_value()