def testNoQuality(self):
     """
     A FASTA file read must not have any quality information.
     """
     data = '\n'.join(['>id1', 'ACGT'])
     mockOpener = mockOpen(read_data=data)
     with patch('__builtin__.open', mockOpener, create=True):
         reads = list(FastaReads('filename.fasta'))
         self.assertEqual(None, reads[0].quality)
 def testOneRead(self):
     """
     A FASTA file with one read must be read properly.
     """
     data = '\n'.join(['>id1', 'ACGT'])
     mockOpener = mockOpen(read_data=data)
     with patch('__builtin__.open', mockOpener, create=True):
         reads = list(FastaReads('filename.fasta'))
         self.assertEqual([Read('id1', 'ACGT')], reads)
 def testTwoReads(self):
     """
     A FASTA file with two reads must be read properly and its
     sequences must be returned in the correct order.
     """
     data = '\n'.join(['>id1', 'ACGT', '>id2', 'TGCA'])
     mockOpener = mockOpen(read_data=data)
     with patch('__builtin__.open', mockOpener, create=True):
         reads = list(FastaReads('filename.fasta'))
         self.assertEqual(2, len(reads))
         self.assertEqual([Read('id1', 'ACGT'), Read('id2', 'TGCA')], reads)
 def testSaveAsFASTA(self):
     """
     A Reads instance must be able to save in FASTA format.
     """
     reads = Reads()
     read1 = Read('id1', 'AT')
     read2 = Read('id2', 'AC')
     reads.add(read1)
     reads.add(read2)
     mockOpener = mockOpen()
     with patch('__builtin__.open', mockOpener, create=True):
         reads.save('filename', 'fasta')
     handle = mockOpener()
     self.assertEqual([call('>id1\nAT\n'), call('>id2\nAC\n')],
                      handle.write.call_args_list)
 def testSaveWithUppercaseFormat(self):
     """
     A Reads instance must save correctly when the format string is
     given in upper case.
     """
     reads = Reads()
     read1 = Read('id1', 'AT')
     read2 = Read('id2', 'AC')
     reads.add(read1)
     reads.add(read2)
     mockOpener = mockOpen()
     with patch('__builtin__.open', mockOpener, create=True):
         reads.save('filename', 'FASTA')
     handle = mockOpener()
     self.assertEqual([call('>id1\nAT\n'), call('>id2\nAC\n')],
                      handle.write.call_args_list)
 def testEmpty(self):
     """An empty FASTA file results in an empty iterator."""
     mockOpener = mockOpen()
     with patch('__builtin__.open', mockOpener, create=True):
         reads = FastaReads('filename.fasta')
         self.assertEqual([], list(reads))