Example #1
0
 def test_wuss_to_vienna(self):
     """wuss_to_vienna() should transform Wuss into Vienna"""
     empty = WussStructure('.....')
     normal = WussStructure('[.{[<...}}}}')
     pseudo = WussStructure('[..AA..]..aa')
     self.assertEqual(wuss_to_vienna(normal), '(.(((...))))')
     self.assertEqual(wuss_to_vienna(empty), '.....')
     self.assertEqual(wuss_to_vienna(pseudo), '(......)....')
Example #2
0
 def setUp(self):
     """Define three standard structures: note differences in whitespace
     and number formatting"""
     self.Struct = WussStructure
     super(WussStructureTests, self).setUp()
     self.WussNoPairs = WussStructure('.-_,~:')
     self.WussOneHelix = WussStructure('[-{<(__)-->}]', -0.01)
     self.WussTwoHelix = WussStructure('{[.]}(<>).', 1.11)
     self.WussThreeHelix = WussStructure('::(<<({__}),,([(__)])-->>)')
     self.WussPseudo = WussStructure('<<__AA>>_aa::')
Example #3
0
 def setUp(self):
     """Define three standard structures: note differences in whitespace
     and number formatting"""
     self.Struct = WussStructure
     super(WussStructureTests,self).setUp()
     self.WussNoPairs = WussStructure('.-_,~:')
     self.WussOneHelix = WussStructure('[-{<(__)-->}]',-0.01)
     self.WussTwoHelix = WussStructure('{[.]}(<>).',1.11)
     self.WussThreeHelix = WussStructure('::(<<({__}),,([(__)])-->>)')
     self.WussPseudo = WussStructure('<<__AA>>_aa::')
Example #4
0
class WussStructureTests(StructureStringTests):
    """Test that WussStructure methods and properties work"""
    def setUp(self):
        """Define three standard structures: note differences in whitespace
        and number formatting"""
        self.Struct = WussStructure
        super(WussStructureTests, self).setUp()
        self.WussNoPairs = WussStructure('.-_,~:')
        self.WussOneHelix = WussStructure('[-{<(__)-->}]', -0.01)
        self.WussTwoHelix = WussStructure('{[.]}(<>).', 1.11)
        self.WussThreeHelix = WussStructure('::(<<({__}),,([(__)])-->>)')
        self.WussPseudo = WussStructure('<<__AA>>_aa::')

    def test_wuss_toPairs(self):
        """WussStructure toPairs() should return a valid Pairs object"""
        self.assertEqual(self.WussNoPairs.toPairs(), [])
        self.assertEqualItems(self.WussOneHelix.toPairs(),\
        [(0,12),(2,11),(3,10),(4,7)])
        self.assertEqualItems(self.WussTwoHelix.toPairs(),\
        [(0,4),(1,3),(5,8),(6,7)])
        self.assertEqualItems(self.WussThreeHelix.toPairs(),\
        [(2,25),(3,24),(4,23),(5,10),(6,9),(13,20),(14,19),(15,18)])
        self.assertEqualItems(self.WussPseudo.toPairs(),\
        [(0,7),(1,6)])

    def test_wuss_toPartners(self):
        """WussStructure toPartners() should return valid Partners object"""
        self.assertEqual(self.WussNoPairs.toPartners(), [None] * 6)
        self.assertEqualItems(self.WussThreeHelix.toPartners(),\
        [None,None,25,24,23,10,9,None,None,6,5,None,None,20,19,\
        18,None,None,15,14,13,None,None,4,3,2])
        self.assertEqualItems(self.WussPseudo.toPartners(),\
        [7,6,None,None,None,None,1,0,None,None,None,None,None])
Example #5
0
class WussStructureTests(StructureStringTests):
    """Test that WussStructure methods and properties work"""
    def setUp(self):
        """Define three standard structures: note differences in whitespace
        and number formatting"""
        self.Struct = WussStructure
        super(WussStructureTests,self).setUp()
        self.WussNoPairs = WussStructure('.-_,~:')
        self.WussOneHelix = WussStructure('[-{<(__)-->}]',-0.01)
        self.WussTwoHelix = WussStructure('{[.]}(<>).',1.11)
        self.WussThreeHelix = WussStructure('::(<<({__}),,([(__)])-->>)')
        self.WussPseudo = WussStructure('<<__AA>>_aa::')
        
    def test_wuss_toPairs(self):
        """WussStructure toPairs() should return a valid Pairs object"""
        self.assertEqual(self.WussNoPairs.toPairs(),[])
        self.assertEqualItems(self.WussOneHelix.toPairs(),\
        [(0,12),(2,11),(3,10),(4,7)])
        self.assertEqualItems(self.WussTwoHelix.toPairs(),\
        [(0,4),(1,3),(5,8),(6,7)])
        self.assertEqualItems(self.WussThreeHelix.toPairs(),\
        [(2,25),(3,24),(4,23),(5,10),(6,9),(13,20),(14,19),(15,18)])
        self.assertEqualItems(self.WussPseudo.toPairs(),\
        [(0,7),(1,6)])
    
    def test_wuss_toPartners(self):
        """WussStructure toPartners() should return valid Partners object"""
        self.assertEqual(self.WussNoPairs.toPartners(),[None]*6)
        self.assertEqualItems(self.WussThreeHelix.toPartners(),\
        [None,None,25,24,23,10,9,None,None,6,5,None,None,20,19,\
        18,None,None,15,14,13,None,None,4,3,2])
        self.assertEqualItems(self.WussPseudo.toPartners(),\
        [7,6,None,None,None,None,1,0,None,None,None,None,None])
Example #6
0
    def test_MinimalStockholmParser_w_valid_data(self):
        """MinimalStockholmParser: integrity of output """

        # Some ugly constructions here, but this is what the output of
        # parsing fake_two_records should be
        headers = ['#=GF AC   RF00014', '#=GF AU   Mifsud W']
        sequences =\
        {'U17136.1/898-984':\
        ''.join(['AACACAUCAGAUUUCCUGGUGUAACGAAUUUUUUAAGUGCUUCUUGCUUA',\
            'AGCAAGUUUCAUCCCGACCCCCUCAGGGUCGGGAUUU']),\
        'M15749.1/155-239':\
        ''.join(['AACGCAUCGGAUUUCCCGGUGUAACGAA-UUUUCAAGUGCUUCUUGCAUU',\
            'AGCAAGUUUGAUCCCGACUCCUG-CGAGUCGGGAUUU']),\
        'AF090431.1/222-139':\
        ''.join(['CUCACAUCAGAUUUCCUGGUGUAACGAA-UUUUCAAGUGCUUCUUGCAUA',\
            'AGCAAGUUUGAUCCCGACCCGU--AGGGCCGGGAUUU'])}

        structure = WussStructure(''.join(\
        ['...<<<<<<<.....>>>>>>>....................<<<<<...',\
        '.>>>>>....<<<<<<<<<<.....>>>>>>>>>>..']))

        data = []
        for r in MinimalStockholmParser(self._fake_two_records, strict=False):
            data.append(r)
        self.assertEqual(\
            (data[0][0]['GF'],data[0][1].todict(),\
                str(data[0][2])),(headers,sequences,structure))
        assert isinstance(data[0][1], Alignment)

        # This line tests that invalid entries are ignored when strict=False
        # Note, there are two records in self._fake_two_records, but 2nd is
        # invalid
        self.assertEqual(len(data), 1)