def test19():
    """Test with differnt column width"""
    colwidth = random.randint(60, 100)
    L = [
        dnaSeq_sol.dnaSeq(randomSeq(random.randint(300, 600)))
        for i in range(5)
    ]
    for d in L:
        d.info = ">" + "".join([random.choice("ABCDEFH ") for i in range(30)])
    dnaSeq_sol.writeFA(L, "test1.fa", col_width=colwidth)

    L2 = []
    for l in L:
        d = dnaSeq.dnaSeq(str(l))
        d.info = l.info
        L2.append(d)

    dnaSeq.writeFA(L2, "test2.fa", col_width=colwidth)

    ## compare files
    for l1, l2 in zip(open("test1.fa"), open("test2.fa")):
        if l1[0] == '>':
            if l1.lstrip('>').strip() != l2.lstrip('>').strip():
                return False
        else:
            if l1 != l2:
                return False

    return True
def test19():
    """Test with differnt column width"""
    colwidth = random.randint(60,100)
    L = [dnaSeq_sol.dnaSeq(randomSeq(random.randint(300,600))) for i in range(5)]
    for d in L:
        d.info = ">" + "".join([random.choice("ABCDEFH ") for i in range(30)])
    dnaSeq_sol.writeFA(L, "test1.fa", col_width = colwidth)

    L2 = []
    for l in L:
        d = dnaSeq.dnaSeq(str(l))
        d.info = l.info
        L2.append(d)

    dnaSeq.writeFA(L2, "test2.fa", col_width = colwidth)

    ## compare files
    for l1,l2 in zip(open("test1.fa"), open("test2.fa")):
        if l1[0] == '>':
            if l1.lstrip('>').strip() != l2.lstrip('>').strip():
                return False
        else:
            if l1 != l2:
                return False

    return True
def test18():
    """Test to make sure it creates a file that is readable"""
    L = [dnaSeq.dnaSeq(randomSeq(random.randint(300,600))) for i in range(5)]
    for d in L:
        d.info = ">" + "".join([random.choice("ABCDEFH ") for i in range(30)])
    dnaSeq.writeFA(L, "test1.fa")
    L2 = dnaSeq.readFA("test1.fa")
    return all([o1.info.lstrip('>').strip()==o2.info.lstrip('>').strip() and str(o1)==str(o2) for o1,o2 in zip(L,L2)])
Exemplo n.º 4
0
 def writeTest(self):
     dnaSeq.writeFA(self.seqs, "generated.fa", 80)
     with open("tester.fa") as fp1, open("generated.fa") as fp2:
         lines1 = fp1.readlines()
         lines2 = fp2.readlines()
         self.assertTrue(len(lines1)==len(lines2), "The generated file appears to have the wrong number of lines")
         
         for line1,line2 in zip(lines1,lines2):
             self.assertTrue(line1.rstrip() == line2.rstrip(), "The generated file appears to have incorrect lines")
def test18():
    """Test to make sure it creates a file that is readable"""
    L = [dnaSeq.dnaSeq(randomSeq(random.randint(300, 600))) for i in range(5)]
    for d in L:
        d.info = ">" + "".join([random.choice("ABCDEFH ") for i in range(30)])
    dnaSeq.writeFA(L, "test1.fa")
    L2 = dnaSeq.readFA("test1.fa")
    return all([
        o1.info.lstrip('>').strip() == o2.info.lstrip('>').strip()
        and str(o1) == str(o2) for o1, o2 in zip(L, L2)
    ])