Exemplo n.º 1
0
def test_primer_Design_saving_to_text_file():

    files_ = [dedent(x) for x in
    ('''\
    >fw64 t-sequence
    atgactgctaacccttc
    >rv64 t-sequence
    catcgtaagtttcgaac''',

    '''\
    >fw64 t-sequence
    atgactgctaacccttcN
    >rv64 t-sequence
    catcgtaagtttcgaacN''',

    '''\
    >fw64 t-sequence
    atgactgctaacccttcN''',

    '''\
    >fw64 t-sequence
    atgactgctaacccttcN
    >rv64 t-sequence
    catcgtaagtttcgaac''',

    '''\
    >rv64 t-sequence
    catcgtaagtttcgaacN''',

    '''\
    >rv64 t-sequence
    catcgtaagtttcgaacN
    >fw64 t-sequence
    atgactgctaacccttc''',

    '''\
    >fw64 t-sequenceZ
    atgactgctaacccttc
    >rv64 t-sequenceZ
    catcgtaagtttcgaac''',

    '''\
    >fw64 t-sequenceZ
    atgactgctaacccttc
    >rv64 t-sequenceZ
    catcgtaagtttcgaac
    >fw64 t-sequence
    atgactgctaacccttc
    >rv64 t-sequence
    catcgtaagtttcgaac''',

    '''\
    >fw64x t-sequence
    atgactgctaacccttc
    >rv64x t-sequence
    catcgtaagtttcgaac''',

    '''\
    >fw64x t-sequence
    atgactgctaacccttc
    >rv64x t-sequence
    catcgtaagtttcgaac
    >fw64 t-sequence
    atgactgctaacccttc
    >rv64 t-sequence
    catcgtaagtttcgaac''',
    )]

    templ=Dseqrecord("atgactgctaacccttccttggtgttgaacaagatcgacgacatttcgttcgaaacttacgatg")

    templ.accession = "t-sequence"

    try:
        os.remove("PRIMERS.TXT")
    except OSError:
        pass

    pf, pr = cloning_primers(templ, path="PRIMERS.TXT")

    assert os.path.isfile("PRIMERS.TXT")

    with open("PRIMERS.TXT", "r") as f: text=f.read().strip()

    assert text == files_[0]

    with open("PRIMERS.TXT", "w") as f: text=f.write(files_[1])

    pf, pr = cloning_primers(templ, path="PRIMERS.TXT")

    with open("PRIMERS.TXT", "r") as f: text=f.read().strip()

    assert text == files_[1]

    with open("PRIMERS.TXT", "w") as f: text=f.write(files_[2])

    pf, pr = cloning_primers(templ, path="PRIMERS.TXT")

    with open("PRIMERS.TXT", "r") as f: text=f.read().strip()

    assert text == files_[3]

    with open("PRIMERS.TXT", "w") as f: text=f.write(files_[4])

    pf, pr = cloning_primers(templ, path="PRIMERS.TXT")

    with open("PRIMERS.TXT", "r") as f: text=f.read().strip()

    assert text == files_[5]

    with open("PRIMERS.TXT", "w") as f: text=f.write(files_[6])

    pf, pr = cloning_primers(templ, path="PRIMERS.TXT")

    with open("PRIMERS.TXT", "r") as f: text=f.read().strip()

    assert text == files_[7]

    with open("PRIMERS.TXT", "w") as f: text=f.write(files_[8])

    pf, pr = cloning_primers(templ, path="PRIMERS.TXT")

    with open("PRIMERS.TXT", "r") as f: text=f.read().strip()

    assert text == files_[9]

    with open("PRIMERS.TXT", "w") as f: text=f.write('')

    pf, pr = cloning_primers(templ, path="PRIMERS.TXT")

    f, r = parse("PRIMERS.TXT", ds=False)

    assert f.description == "fw64 t-sequence"
    assert r.description == "rv64 t-sequence"