comparison SMART/Java/Python/structure/test/Test_Sequence.py @ 6:769e306b7933

Change the repository level.
author yufei-luo
date Fri, 18 Jan 2013 04:54:14 -0500
parents
children
comparison
equal deleted inserted replaced
5:ea3082881bf8 6:769e306b7933
1 # Copyright INRA (Institut National de la Recherche Agronomique)
2 # http://www.inra.fr
3 # http://urgi.versailles.inra.fr
4 #
5 # This software is governed by the CeCILL license under French law and
6 # abiding by the rules of distribution of free software. You can use,
7 # modify and/ or redistribute the software under the terms of the CeCILL
8 # license as circulated by CEA, CNRS and INRIA at the following URL
9 # "http://www.cecill.info".
10 #
11 # As a counterpart to the access to the source code and rights to copy,
12 # modify and redistribute granted by the license, users are provided only
13 # with a limited warranty and the software's author, the holder of the
14 # economic rights, and the successive licensors have only limited
15 # liability.
16 #
17 # In this respect, the user's attention is drawn to the risks associated
18 # with loading, using, modifying and/or developing or reproducing the
19 # software by the user in light of its specific status of free software,
20 # that may mean that it is complicated to manipulate, and that also
21 # therefore means that it is reserved for developers and experienced
22 # professionals having in-depth computer knowledge. Users are therefore
23 # encouraged to load and test the software's suitability as regards their
24 # requirements in conditions enabling the security of their systems and/or
25 # data to be ensured and, more generally, to use and operate it in the
26 # same conditions as regards security.
27 #
28 # The fact that you are presently reading this means that you have had
29 # knowledge of the CeCILL license and that you accept its terms.
30
31
32 import unittest
33 from SMART.Java.Python.structure.Sequence import Sequence
34
35
36 class Test_Sequence(unittest.TestCase):
37
38 def setUp(self):
39 self._bs = Sequence()
40 self._bs1 = Sequence()
41
42 def test_getSize(self):
43 self._bs.setName("sequence1")
44 self._bs.setSequence("AGCGGACGATGCAGCATGCGAATGACGATA")
45 obsSize = self._bs.getSize()
46 expSize = 30
47 self.assertEquals( expSize, obsSize )
48
49 def test_concatenate(self):
50 self._bs.setName("sequence")
51 self._bs.setSequence("GATGTGCAGACTTTTCACGCAGGACTACATCACTGT")
52 self._bs.setQuality("WWWVVVWPWWWVWWWWVVVVKVPWWVVWVWUUQUTQ")
53 self._bs1.setName("sequence1")
54 self._bs1.setSequence("GGAAACATATGCACATAAACGTTGAAATCATGCTTA")
55 self._bs1.setQuality("WWWWWWWWWWWWWWWWWVWWVWWVWWWWWWUUUUUU")
56 self._bs.concatenate(self._bs1)
57 expSeq = "GATGTGCAGACTTTTCACGCAGGACTACATCACTGTGGAAACATATGCACATAAACGTTGAAATCATGCTTA"
58 expQal = "WWWVVVWPWWWVWWWWVVVVKVPWWVVWVWUUQUTQWWWWWWWWWWWWWWWWWVWWVWWVWWWWWWUUUUUU"
59 self.assertEquals(expSeq, self._bs.getSequence())
60 self.assertEquals(expQal, self._bs.getQuality())
61
62 def test_reverseComplement(self):
63 self._bs.setName("seq1")
64 self._bs.setSequence("TACGGC")
65 exp = "GCCGTA"
66 self._bs.reverseComplement()
67 obs = self._bs.getSequence()
68 self.assertEquals(exp, obs)
69
70 def test_containsAmbiguousNucleotides(self):
71 self._bs.setName("seq1")
72 self._bs.setSequence("WCGTUacgtu")
73 self.assertTrue (self._bs.containsAmbiguousNucleotides())
74
75 def test_shrinkToFirstNucleotides(self):
76 self._bs.setName("seq1")
77 self._bs.setSequence("WCGTUacgtu")
78 self._bs.shrinkToFirstNucleotides(3)
79 expSeq = "WCG"
80 self.assertEquals(expSeq, self._bs.getSequence())
81
82 def test_shrinkToLastNucleotides(self):
83 self._bs.setName("seq1")
84 self._bs.setSequence("WCGTUacgtu")
85 self._bs.shrinkToLastNucleotides(5)
86 expSeq = "acgtu"
87 self.assertEquals(expSeq, self._bs.getSequence())
88
89 if __name__ == "__main__":
90 unittest.main()