| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
import os |
| 4 |
import unittest |
| 5 |
from pyfastaq import caf, utils, sequences |
| 6 |
|
| 7 |
modules_dir = os.path.dirname(os.path.abspath(caf.__file__)) |
| 8 |
data_dir = os.path.join(modules_dir, 'tests', 'data') |
| 9 |
|
| 10 |
class TestCaf(unittest.TestCase): |
| 11 |
def test_get_next_from_file(self): |
| 12 |
'''Test get_next_from_file()''' |
| 13 |
|
| 14 |
f_in = utils.open_file_read(os.path.join(data_dir, 'caf_test.caf')) |
| 15 |
|
| 16 |
c = caf.Caf() |
| 17 |
c.get_next_from_file(f_in) |
| 18 |
read = caf.Caf() |
| 19 |
read.id = 'read1.p1k' |
| 20 |
read.seq = sequences.Fasta(read.id, 'NACGTAN') |
| 21 |
read.seq = read.seq.to_Fastq([4, 24, 42, 43, 40, 30, 8]) |
| 22 |
read.insert_min = 2000 |
| 23 |
read.insert_max = 4000 |
| 24 |
read.ligation = '12345' |
| 25 |
read.clone = 'clone1' |
| 26 |
read.clip_start = 1 |
| 27 |
read.clip_end = 5 |
| 28 |
self.assertEqual(c, read) |
| 29 |
|
| 30 |
c.get_next_from_file(f_in) |
| 31 |
read = caf.Caf() |
| 32 |
read.id = 'read2.p1k' |
| 33 |
read.seq = sequences.Fasta(read.id, 'CGACGTT') |
| 34 |
read.seq = read.seq.to_Fastq([9, 9, 40, 41, 42, 42, 4]) |
| 35 |
read.insert_min = 2000 |
| 36 |
read.insert_max = 4000 |
| 37 |
read.ligation = '23456' |
| 38 |
read.clone = 'clone2' |
| 39 |
read.clip_start = None |
| 40 |
read.clip_end = None |
| 41 |
self.assertEqual(c, read) |
| 42 |
|
| 43 |
utils.close(f_in) |
| 44 |
|
| 45 |
|
| 46 |
if __name__ == '__main__': |
| 47 |
unittest.main() |