Back to index

python-biopython  1.60
test_SeqIO_AbiIO.py
Go to the documentation of this file.
00001 # Copyright 2011 by Wibowo Arindrarto (w.arindrarto@gmail.com)
00002 # This code is part of the Biopython distribution and governed by its
00003 # license.  Please see the LICENSE file that should have been included
00004 # as part of this package.
00005 
00006 import unittest
00007 
00008 from os.path import join, basename
00009 
00010 from Bio import SeqIO
00011 from Bio.Seq import Seq
00012 from Bio.SeqRecord import SeqRecord
00013 from Bio._py3k import _bytes_to_string, _as_bytes
00014 
00015 test_data = {
00016 'data_empty': { 
00017               'path': ['Abi', 'empty.ab1'],
00018               'seq': 'NNNNN',
00019               'qual': [0, 0, 0, 0, 0],
00020               'sample': '226041_C-ME-19_pCAGseqF',
00021               'sample_well': 'C10',
00022               'machine_model': '3730',
00023               'run_start': '2009-12-12 09:56:53',
00024               'run_finish': '2009-12-12 11:44:49',
00025               },       
00026 'data_3730': { 
00027              'path': ['Abi', '3730.ab1'],
00028              'seq': 
00029 'GGGCGAGCKYYAYATTTTGGCAAGAATTGAGCTCTATGGCCACAACCATGGTGAGCAAGGGCGAGGAGGATAACATGGCCATCATCAAGGAGTTCATGCGCTTCAAGGTGCACATGGAGGGCTCCGTGAACGGCCACGAGTTCGAGATCGAGGGCGAGGGCGAGGGCCGCCCCTACGAGGGCACCCAGACCGCCAAGCTGAAGGTGACCAAGGGTGGCCCCCTGCCCTTCGCCTGGGACATCCTGTCCCCTCAGTTCATGTACGGCTCCAAGGCCTACGTGAAGCACCCCGCCGACATCCCCGACTACTTGAAGCTGTCCTTCCCCGAGGGCTTCAAGTGGGAGCGCGTGATGAACTTCGAGGACGGCGGCGTGGTGACCGTGACCCAGGACTCCTCCCTGCAGGACGGCGAGTTCATCTACAAGGTGAAGCTGCGCGGCACCAACTTCCCCTCCGACGGCCCCGTAATGCAGAAGAAGACCATGGGCTGGGAGGCCTCCTCCGAGCGGATGTACCCCGAGGACGGCGCCCTGAAGGGCGAGATCAAGCAGAGGCTGAAGCTGAAGGACGGCGGCCACTACGACGCTGAGGTCAAGACCACCTACAAGGCCAAGAAGCCCGTGCAGCTGCCCGGCGCCTACAACGTCAACATCAAGTTGGACATCACCTCCCACAACGAGGACTACACCATCGTGGAACAGTACGAACGCGCCGAGGGCCGCCACTCCACCGGCGGCATGGACGAGCTGTACAAGGGCGGCAGCGGCATGGTGAGCAAGGGCGAGGAGCTGTTCACCGGGGTGGTGCCCATCCTGGTCGAGCTGGACGGCGACGTAAACGGCCACAAGTTCAGCGTGTCCGGCGAGGGCGAGGGCGATGCCACCTACGGCAAGCTGACCCTGAAGTTCATCTGCACCACCGGCAAGCTGCCCGTGCCCTGGCCCACCCTCGTGACCACCCTGACCTACGGCGTGCAGTGCTTCAGCCGCTACCCCGACCACATGAAGCAGCACGACTTCTTCAAGTCCGCCATGCCCGAAGGCTACGTCCAGGAGCGCACCATCTTCTTCAAGGACGACGGCAACTACAARACCCGCGCCGAGGTGAARTTCGAGGGCGACACCCTGGTGAACCGCATCGAGCTGAAAGGGGCAYCGCACCTTTC',
00030              'qual': 
00031 [20, 3, 4, 4, 4, 6, 4, 4, 0, 0, 0, 6, 0, 10, 20, 26, 22, 17, 21, 31, 29, 32, 28, 18, 23, 17, 19, 35, 36, 50, 39, 50, 50, 50, 50, 50, 25, 35, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 35, 39, 33, 20, 35, 31, 50, 50, 50, 50, 50, 50, 50, 50, 50, 31, 50, 35, 31, 23, 28, 31, 21, 43, 39, 35, 24, 30, 26, 35, 31, 50, 50, 50, 50, 50, 50, 50, 50, 50, 39, 31, 24, 39, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 31, 31, 43, 43, 50, 50, 50, 50, 50, 31, 31, 31, 31, 50, 50, 50, 50, 50, 50, 50, 50, 31, 31, 35, 50, 50, 50, 50, 31, 36, 55, 55, 55, 55, 36, 55, 55, 55, 55, 55, 36, 55, 55, 55, 55, 55, 36, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 40, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 36, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 40, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 43, 43, 50, 43, 43, 50, 43, 43, 50, 43, 43, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 43, 43, 50, 43, 43, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 28, 28, 35, 28, 28, 35, 28, 28, 35, 28, 28, 35, 28, 28, 35, 28, 21, 28, 35, 28, 28, 35, 35, 35, 35, 35, 37, 38, 21, 28, 35, 28, 28, 35, 35, 35, 35, 35, 35, 35, 36, 36, 21, 39, 35, 35, 35, 39, 35, 37, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 28, 28, 35, 35, 28, 28, 35, 35, 35, 36, 36, 22, 39, 35, 35, 35, 35, 35, 35, 37, 38, 28, 35, 21, 36, 36, 37, 35, 35, 20, 39, 39, 35, 35, 35, 35, 37, 38, 28, 35, 37, 34, 35, 24, 24, 27, 25, 20, 24, 37, 35, 27, 21, 20, 21, 27, 17, 20, 24, 32, 26, 20, 12, 20, 10, 20, 24, 25, 23, 20, 32, 24, 24, 23, 20, 24, 23, 18, 34, 34, 34, 22, 26, 24, 24, 18, 22, 22, 23, 25, 20, 12, 20, 24, 23, 24, 23, 22, 20, 20, 0, 20, 24, 23, 20, 8, 10, 4, 20, 20, 3, 7, 19, 20, 4, 4, 7, 7, 0, 7, 11, 18, 8, 3, 23, 23, 20, 11, 4, 20, 18, 12, 20, 20, 20, 4, 20, 4, 2, 3, 21, 21, 21, 21, 10, 15, 14, 15, 19, 2, 4, 3, 6, 11, 3, 4, 6, 21, 16, 20, 11, 1, 4, 12, 0, 15, 8, 1, 3, 3, 12, 1, 11, 20, 4],
00032              'sample': '226032_C-ME-18_pCAGseqF',
00033              'sample_well': 'B9',
00034              'dye': 'Z-BigDyeV3',
00035              'polymer': 'POP7                            ',
00036              'machine_model': '3730',
00037              'run_start': '2009-12-12 09:56:53',
00038              'run_finish': '2009-12-12 11:44:49',
00039             },
00040 'data_3100': { 
00041              'path': ['Abi', '3100.ab1'],
00042              'seq': 
00043 'CAAGATTGCATTCATGATCTACGATTACTAGCGATTCCAGCTTCATATAGTCGAGTTGCAGACTACAATCCGAACTGAGAACAACTTTATGGGATTTGCTTGACCTCGCGGTTTCGCTGCCCTTTGTATTGTCCATTGTAGCACGTGTGTAGCCCAAATCATAAGGGGCATGATGATTTGACGTCATCCCCACCTTCCTCCGGTTTGTCACCGGCAGTCAACTTAGAGTGCCCAACTTAATGATGGCAACTAAGCTTAAGGGTTGCGCTCGTTGCGGGACTTAACCCAACATCTCACGACACGAGCTGACGACAACCATGCACCACCTGTCACTCTGTCCCCCGAAGGGGAAAACTCTATCTCTAGAGGAGTCAGAGGATGTCAAGATTTGGTAAGGTTCTTCGCGTTGCTTCGAATTAAACCACATGCTCCACCGCTTGTGCGGGTCCCCGTCAATTCCTTTGAGTTTCAACCTTGCGGTCGTACTCCCCAGGCGGAGTGCTTAATGCGTTAGCTGCAGCACTAAGGGGCGGAAACCCCCTAACACTTAGCACTCATCGTTTACGGCGTGGACTACCAGGGTATCTAATCCTGTTTGATCCCCACGCTTTCGCACATCAGCGTCAGTTACAGACCAGAAAGTCGCCTTCGCCACTGGTGTTCCTCCATATCTCTGCGCATTTCACCGCTACACATGGAAATTCCACTTTCCTCTTCTGCACTCAAGTTTTCCAGATTTCGATGAACCTTCAACGATGGAGGCCCGTGGCTTTTCACCATTCAAGGAACCTTTTA',
00044              'qual': 
00045 [5, 3, 4, 4, 4, 5, 9, 4, 4, 4, 5, 4, 4, 4, 4, 4, 6, 13, 23, 20, 15, 17, 10, 9, 13, 23, 18, 14, 19, 34, 15, 24, 34, 18, 30, 35, 41, 34, 22, 39, 53, 58, 35, 46, 24, 42, 46, 46, 54, 42, 53, 58, 52, 41, 22, 62, 52, 62, 52, 62, 41, 38, 16, 42, 62, 56, 62, 62, 62, 62, 62, 62, 54, 56, 39, 62, 49, 35, 19, 44, 44, 42, 62, 62, 62, 62, 54, 62, 62, 62, 62, 49, 49, 43, 39, 62, 62, 62, 62, 62, 62, 62, 59, 43, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 49, 59, 62, 62, 59, 59, 62, 62, 62, 62, 62, 59, 62, 62, 62, 62, 62, 62, 59, 59, 62, 62, 62, 62, 62, 59, 62, 62, 59, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 59, 59, 62, 59, 59, 62, 62, 62, 59, 59, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 50, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 59, 59, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 54, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 59, 59, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 59, 59, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 49, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 42, 31, 31, 26, 18, 24, 33, 56, 56, 62, 56, 62, 47, 39, 62, 62, 62, 62, 62, 62, 49, 47, 62, 62, 62, 49, 62, 62, 62, 62, 49, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 58, 58, 58, 58, 58, 58, 58, 58, 58, 54, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 54, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 53, 58, 58, 58, 51, 49, 58, 58, 58, 58, 50, 58, 58, 58, 58, 58, 58, 51, 32, 58, 58, 42, 58, 51, 58, 49, 39, 58, 58, 51, 58, 53, 58, 50, 58, 58, 58, 53, 54, 53, 58, 54, 53, 58, 53, 58, 32, 58, 44, 46, 50, 58, 54, 58, 58, 49, 41, 58, 58, 58, 54, 54, 54, 51, 52, 53, 51, 54, 54, 54, 38, 52, 53, 47, 54, 54, 53, 54, 54, 54, 52, 54, 42, 47, 35, 42, 54, 45, 54, 53, 54, 23, 34, 24, 51, 52, 33, 46, 44, 33, 49, 51, 45, 53, 32, 52, 53, 52, 51, 36, 52, 53, 52, 52, 37, 53, 52, 40, 27, 24, 46, 16, 33, 45, 51, 43, 51, 51, 46, 46, 45, 42, 31, 43, 41, 43, 35, 43, 43, 42, 31, 46, 46, 32, 46, 35, 42, 46, 42, 31, 31, 43, 42, 35, 21, 42, 35, 28, 46, 47, 37, 41, 29, 39, 31, 32, 39, 31, 41, 43, 34, 43, 36, 27, 31, 27, 35, 36, 24, 44, 33, 31, 32, 38, 35, 31, 32, 29, 31, 31, 31, 38, 38, 36, 31, 34, 30, 21, 28, 32, 32, 47, 31, 33, 30, 23, 22, 25, 25, 26, 30, 30, 21, 28, 31, 21, 14, 5, 3, 16, 9, 18, 27, 8, 19, 4, 5, 13, 47, 27, 14, 21, 9, 17, 21, 17, 27, 14, 23, 23, 14, 15, 28, 15, 12, 8, 5, 3, 17, 28, 16, 13, 17, 11, 2, 2, 3, 29, 7, 3, 1, 3, 3, 8, 7, 7, 24, 12, 3, 4, 15, 3, 4, 7, 5, 1, 2, 2, 8, 24, 6, 4, 11, 23, 9, 6, 4, 3, 5, 3, 5, 17, 17, 22, 11, 4, 5, 8, 16, 10, 6, 11, 6, 11, 5, 5, 27, 18, 7, 15, 16, 30, 21, 14, 7],
00046              'sample': '16S_S2_1387R',
00047              'sample_well': 'H3',
00048              'dye': 'Z-BigDyeV3',
00049              'polymer': 'POP7                            ',
00050              'machine_model': '3100',
00051              'run_start': '2010-01-27 09:52:45',
00052              'run_finish': '2010-01-27 10:41:07',
00053             },
00054 'data_310': { 
00055             'path': ['Abi', '310.ab1'],
00056             'seq': 
00057 'TGATNTTNACNNTTTTGAANCANTGAGTTAATAGCAATNCTTTACNAATAAGAATATACACTTTCTGCTTAGGGATGATAATTGGCAGGCAAGTGAATCCCTGAGCGTGNATTTGATAATGACCTAAATAATGGATGGGGTTTTAATTCCCAGACCTTCCCCTTTTTAANNGGNGGATTANTGGGGGNNNAACNNGGGGGGCCCTTNCCNAAGGGGGAAAAAATTTNAAACCCCCCNAGGNNGGGNAAAAAAAAATTTCCAAATTNCCGGGGTNNCCCCCAANTTTTTNCCGCNGGGAAAANNNNCCCCCCCNGGGNCCCCCCCCNNAAAAAAAAAAAAAAAAACCCCCCCCCCNTTGGGGNGGTNTNCNCCCCCNNANAANNGGGGGNNAAAAAAAAAGGCCCCCCCCAAAAAAAACCCNCNTTCTNNCNNNNNGNNCNGNNCCCCCNNCCNTNTNGGGGGGGGGGGNGGAAAAAAAACCCCTTTNTGNNNANANNAACCCNCTCNTNTTTTTTTTTTTANGNNNNCNNNNCAAAAAAAAANCNCCCCCNNCNNNCNNNCNCCCCNNNNTNAAAANANNAANNNNTTTTTTTNGGGGGGGTGNGCGNCCCNNANCNNNNNNNNGCGNGGNCNCCNNCCCNCNANAAANNNTNTTTTTTTTTTTTTTTNTNNTCNNCCCNNNCCCCNNCCCCCCCCCCCCCNCCNCNNNNNGGGGNNNCGGNNCNNNNNNNCCNTNCTNNAN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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
00060             'sample': 'D11F',
00061             'sample_well': 'C5',
00062             'dye': None,
00063             'polymer': None,
00064             'machine_model': '310 ',
00065             'run_start': '2009-02-19 01:19:30',
00066             'run_finish': '2009-02-19 04:04:15',
00067            },
00068 }
00069 
00070 test_data_fake = {
00071 'fake': {
00072               'path': ['Abi', 'fake.ab1'],
00073              }
00074 }
00075 
00076 def open_files(test_array):
00077     for trace in test_array:
00078         test_array[trace]['handle'] = open(join(*test_array[trace]['path']), 'rb')
00079 
00080 def open_files_wrong_mode(test_array):
00081     for trace in test_array:
00082         test_array[trace]['handle'] = open(join(*test_array[trace]['path']))
00083 
00084 def close_files(test_array):
00085     for trace in test_array:
00086         test_array[trace]['handle'].close()
00087 
00088 class TestAbi(unittest.TestCase):
00089     
00090     def setUp(self):
00091         open_files(test_data)
00092 
00093     def tearDown(self):
00094         close_files(test_data)
00095 
00096     def test_file_type(self):
00097         """Test if filetype is ABIF."""
00098         for trace in test_data:
00099             self.assertEqual(test_data[trace]['handle'].read(4), _as_bytes('ABIF'))
00100 
00101     def test_seqrecord(self):
00102         """Test if the extracted seqrecords data are equal to expected values."""
00103         for trace in test_data:
00104             record = SeqIO.read(test_data[trace]['handle'], 'abi')
00105             self.assertEqual(basename(test_data[trace]["path"][-1]).replace('.ab1',''), record.name)
00106             self.assertEqual(test_data[trace]['seq'], str(record.seq))
00107             self.assertEqual(test_data[trace]['qual'], record.letter_annotations['phred_quality'])
00108             self.assertEqual(test_data[trace]['sample'], record.id)
00109             self.assertEqual(test_data[trace]['sample_well'], record.annotations['sample_well'])
00110             self.assertEqual(test_data[trace]['machine_model'], record.annotations['machine_model'])
00111             self.assertEqual(test_data[trace]['run_start'], record.annotations['run_start'])
00112             self.assertEqual(test_data[trace]['run_finish'], record.annotations['run_finish'])
00113 
00114     def test_trim(self):
00115         """Test if trim works."""
00116         for trace in test_data:
00117             record = SeqIO.read(test_data[trace]['handle'], 'abi-trim')
00118             if trace != 'data_empty':
00119                 self.assertNotEqual(str(record.seq), test_data[trace]['seq'])
00120                 self.assertTrue(str(record.seq) in test_data[trace]['seq'])
00121             else:
00122                 self.assertEqual(str(record.seq), test_data[trace]['seq'])
00123 
00124 
00125 class TestAbiWrongMode(unittest.TestCase):
00126     
00127     def test_file_mode(self):
00128         """Test if exception is raised if file is not opened in 'rb' mode."""
00129         open_files_wrong_mode(test_data)
00130         for trace in test_data:
00131             self.assertRaises(ValueError, SeqIO.read, test_data[trace]['handle'], 'abi')
00132         close_files(test_data)
00133 
00134 
00135 class TestAbiFake(unittest.TestCase):
00136 
00137     def test_file_type(self):
00138         """Test if error is raised if filetype is not ABIF."""
00139         open_files(test_data_fake)
00140         for trace in test_data_fake:
00141             self.assertRaises(IOError, SeqIO.read, test_data_fake[trace]['handle'], 'abi')
00142         close_files(test_data_fake)
00143 
00144 
00145 if __name__ == "__main__":
00146     runner = unittest.TextTestRunner(verbosity = 2)
00147     unittest.main(testRunner=runner)