示例#1
0
 def test_isaligned(self):
     seqs = fasta_io.read(StringIO())
     assert seqs.isaligned()
     seqs = fasta_io.read(StringIO(fasta_io.example))
     assert seqs.isaligned()
     seqs = fasta_io.read(StringIO(example4))
     assert not seqs.isaligned()
示例#2
0
    def test_write_comments(self):
        f = StringIO(example_with_optional_comments)
        seqs = fasta_io.read(f)
        fout = StringIO()
        fasta_io.write(fout, seqs)
        fout.seek(0)
        seqs2 = fasta_io.read(fout)
        self.assertEqual(seqs, seqs2)

        self.assertEqual(seqs[1].description, seqs2[1].description)
示例#3
0
    def test_write_seq(self):
        f = StringIO(fasta_io.example)
        seqs = fasta_io.read(f)
        fout = StringIO()
        fasta_io.write(fout, seqs)

        fout.seek(0)
        seqs2 = fasta_io.read(fout)

        self.assertEqual(seqs, seqs2)
示例#4
0
 def test_read_comments(self):
     f = StringIO(example_with_optional_comments)
     seqs = fasta_io.read(f)
     self.assertEqual(len(seqs), 2)
     self.assertEqual(seqs[1].startswith("SATVSEI"), True)
     self.assertEqual(seqs[1].description.splitlines()[1],
                      ("comment line 1 (optional)"))
示例#5
0
 def test_read(self):
     f = StringIO(fasta_io.example)
     seqs = fasta_io.read(f)
     # print seqs
     self.assertEqual(len(seqs), 3)
     self.assertEqual(seqs[0].description, "Lamprey GLOBIN V - SEA LAMPREY")
     self.assertEqual(seqs[0].name, "Lamprey")
     self.assertEqual(len(seqs[1]), 231)
示例#6
0
    def test_read_headerless(self):
        # This example has blank headers.
        f = StringIO(example3)
        seqs = fasta_io.read(f)
        self.assertEqual(len(seqs), 4)
        # print seqs

        fout = StringIO()
        fasta_io.write(fout, seqs)
示例#7
0
 def test_read_with_blank_line(self):
     f = StringIO(example4)
     seqs = fasta_io.read(f)
     assert not seqs.isaligned()
     self.assertEqual(len(seqs), 3)
示例#8
0
 def test_read_empty(self):
     f = StringIO()
     seqs = fasta_io.read(f)
     assert len(seqs) == 0
示例#9
0
 def test_write_with_header(self):
     f = StringIO(fasta_io.example)
     seqs = fasta_io.read(f)
     seqs.description = "A description\nMore description"
     fout = StringIO()
     fasta_io.write(fout, seqs)
示例#10
0
 def test_parse_globin(self):
     # f = open_resource(__file__, "test_data", "globin.fa")
     f = data_stream("globin.fa")
     seqs = fasta_io.read(f, protein_alphabet)
     self.assertEqual(len(seqs), 56)
     f.close()