コード例 #1
0
 def test_structured_chains_joined_with_unstructured_are_joined(self):
     chains = [
         IfeChain(internal=10, pdb='1S72', model=1, chain='A', length=50),
         IfeChain(internal=10, pdb='1S72', model=1, chain='B', length=50),
         IfeChain(internal=0, pdb='1S72', model=1, chain='C', length=10)
     ]
     interactions = {
         'A': {
             'B': 30,
             'C': 5
         },
         'B': {
             'A': 30,
             'C': 5
         },
         'C': {
             'A': 5,
             'B': 5
         }
     }
     ans = {
         '1S72|1|A': ['1S72|1|A+1S72|1|B'],
         '1S72|1|B': ['1S72|1|A+1S72|1|B'],
         '1S72|1|C': ['1S72|1|A+1S72|1|B'],
     }
     val = self.grouping(chains, interactions)
     self.assertEquals(ans, val)
コード例 #2
0
 def test_structured_chains_joined_only_by_unstructureds_arent_joined(self):
     chains = [
         IfeChain(internal=10, pdb='1S72', model=1, chain='A', length=50),
         IfeChain(internal=10, pdb='1S72', model=1, chain='B', length=50),
         IfeChain(internal=0, pdb='1S72', model=1, chain='C', length=10),
         IfeChain(internal=0, pdb='1S72', model=1, chain='D', length=10)
     ]
     interactions = {
         'A': {
             'B': 1,
             'C': 5
         },
         'B': {
             'A': 1,
             'C': 5
         },
         'C': {
             'A': 5,
             'B': 5,
             'D': 10
         },
         'D': {
             'A': 0,
             'B': 0,
             'C': 10
         }
     }
     val = self.grouping(chains, interactions)
     ans = {
         '1S72|1|A': ['1S72|1|A'],
         '1S72|1|B': ['1S72|1|B'],
         '1S72|1|C': ['1S72|1|A', '1S72|1|B'],
         '1S72|1|D': ['1S72|1|A', '1S72|1|B'],
     }
     self.assertEquals(ans, val)
コード例 #3
0
 def test_structured_chains_joined_only_by_unstructured_arent_joined(self):
     chains = [
         IfeChain(internal=10, pdb='1S72', model=1, chain='A', length=50),
         IfeChain(internal=10, pdb='1S72', model=1, chain='B', length=50),
         IfeChain(internal=0, pdb='1S72', model=1, chain='C', length=10)
     ]
     interactions = {
         'A': {
             'B': 1,
             'C': 5
         },
         'B': {
             'A': 1,
             'C': 5
         },
         'C': {
             'A': 5,
             'B': 5
         }
     }
     assert self.grouping(chains, interactions) == {
         '1S72|1|A': ['1S72|1|A'],
         '1S72|1|B': ['1S72|1|B'],
         '1S72|1|C': ['1S72|1|A', '1S72|1|B']
     }
コード例 #4
0
 def test_compares_using_length(self):
     ife1 = IfeChain(pdb='0111', chain='A', length=10, internal=50)
     ife2 = IfeChain(pdb='0111', chain='C', length=50, internal=50)
     self.assertTrue(ife1 < ife2)
     self.assertTrue(ife1 <= ife2)
     self.assertFalse(ife1 == ife2)
     self.assertTrue(ife2 > ife1)
コード例 #5
0
 def test_sorts_by_full_length(self):
     val1 = IfeChain(pdb='01GG', chain='A', internal=0, length=10,
                     full_length=10, db_id=1)
     val2 = IfeChain(pdb='01GG', chain='A', internal=0, length=10,
                     full_length=12, db_id=1)
     self.assertTrue(val1 < val2)
     self.assertTrue(val2 > val1)
コード例 #6
0
 def test_puts_non_interactions_unstructured_chains_seperately(self):
     chains = [
         IfeChain(internal=0, pdb='1S72', model=1, chain='A', length=10),
         IfeChain(internal=0, pdb='1S72', model=1, chain='B', length=10)
     ]
     ans = {'1S72|1|A': ['1S72|1|A'], '1S72|1|B': ['1S72|1|B']}
     self.assertEquals(ans, self.grouping(chains, {}))
コード例 #7
0
 def test_it_sorts_by_chain_and_internal(self):
     ife1 = IfeChain(pdb='0111', chain='A', internal=5)
     ife2 = IfeChain(pdb='0111', chain='D', internal=6)
     self.assertTrue(ife1 < ife2)
     self.assertTrue(ife1 <= ife2)
     self.assertTrue(ife2 > ife1)
     self.assertTrue(ife2 >= ife1)
     self.assertTrue(ife2 != ife1)
コード例 #8
0
 def test_will_put_structured_but_interacting_chains_seperatly(self):
     chains = [
         IfeChain(internal=10, pdb='1S72', model=1, chain='A', length=50),
         IfeChain(internal=10, pdb='1S72', model=1, chain='B', length=50)
     ]
     interactions = {'A': {'B': 3}, 'B': {'A': 3}}
     val = self.grouping(chains, interactions)
     ans = {'1S72|1|A': ['1S72|1|A'], '1S72|1|B': ['1S72|1|B']}
     self.assertEquals(ans, val)
コード例 #9
0
 def test_will_join_unstructured_chains_on_interactions(self):
     chains = [
         IfeChain(internal=0, pdb='1S72', model=1, chain='A', length=10),
         IfeChain(internal=0, pdb='1S72', model=1, chain='B', length=10)
     ]
     interactions = {'A': {'B': 10}, 'B': {'A': 10}}
     val = self.grouping(chains, interactions)
     ans = {
         '1S72|1|A': ['1S72|1|A+1S72|1|B'],
         '1S72|1|B': ['1S72|1|A+1S72|1|B']
     }
     self.assertEquals(ans, val)
コード例 #10
0
    def setUp(self):
        super(PartitingInteractionsTest, self).setUp()
        inters = {
            'A': {
                'A': 0,
                'B': 3,
                'C': 2,
                'D': 0
            },
            'B': {
                'A': 3,
                'B': 0,
                'C': 0,
                'D': 4
            },
            'C': {
                'A': 2,
                'B': 0,
                'C': 0,
                'D': 0
            },
            'D': {
                'A': 0,
                'B': 4,
                'C': 0,
                'D': 0
            }
        }

        ifes = [
            IfeChain(chain='A', internal=10),
            IfeChain(chain='B', internal=0),
            IfeChain(chain='C', internal=10),
            IfeChain(chain='D', internal=0),
        ]
        self.same, self.rest = self.loader.parition_interactions(ifes, inters)
コード例 #11
0
 def test_sorts_by_chain(self):
     val1 = IfeChain(chain='A')
     val2 = IfeChain(chain='B')
     self.assertTrue(val1 > val2)
     self.assertTrue(val2 < val1)
コード例 #12
0
 def test_can_load_correct_with_sym_ops(self):
     ifes = [IfeChain(pdb='1A34', chain='B'),
             IfeChain('1A34', chain='C')]
     val = self.loader.cross_chain_interactions(ifes, sym_op='P_1')
     ans = {'B': {'B': 0, 'C': 9}, 'C': {'B': 9, 'C': 0}}
     self.assertEquals(ans, val)
コード例 #13
0
 def test_can_load_yeast_ribo_interactions(self):
     ifes = [IfeChain(pdb='4V7R', chain='D1'),
             IfeChain(pdb='4V7R', chain='D3')]
     val = self.loader.cross_chain_interactions(ifes)
     ans = {'D1': {'D1': 0, 'D3': 16}, 'D3': {'D1': 16, 'D3': 0}}
     self.assertEquals(ans, val)
コード例 #14
0
 def test_loads_interactions_symmetrically(self):
     ifes = [IfeChain(pdb='2MKN', chain='C'),
             IfeChain(pdb='2MKN', chain='B')]
     val = self.loader.cross_chain_interactions(ifes)
     ans = {'C': {'C': 0, 'B': 19}, 'B': {'B': 0, 'C': 19}}
     self.assertEquals(ans, val)
コード例 #15
0
 def test_knows_if_two_chains_are_not_equal(self):
     val1 = IfeChain(internal=4)
     val2 = IfeChain(chain='G', internal=4)
     self.assertNotEquals(val1, val2)
コード例 #16
0
 def test_duplicate_additions_do_nothing(self):
     val = IfeGroup(IfeChain(pdb='0111', chain='A', internal=4, model=4),
                    IfeChain(pdb='0111', chain='C', internal=0, model=4))
     val.add(IfeChain(pdb='0111', chain='A', internal=4, model=4))
     self.assertEquals('0111|4|A+0111|4|C', val.id)
コード例 #17
0
 def test_has_an_id(self):
     val = IfeGroup(IfeChain(pdb='0111', chain='A', internal=5, model=10),
                    IfeChain(pdb='0111', chain='C', internal=0, model=10))
     self.assertEquals('0111|10|A', val.id)
コード例 #18
0
 def test_knows_if_structured_if_has_no_structured_chain(self):
     val = IfeGroup(IfeChain(chain='A', internal=4),
                    IfeChain(chain='B', internal=0))
     self.assertFalse(val.is_structured)
コード例 #19
0
 def test_knows_if_chain_is_not_structured(self):
     val = IfeChain(internal=4)
     self.assertFalse(val.is_structured)
コード例 #20
0
 def test_dispatches_model_to_integral(self):
     val = IfeGroup(IfeChain(pdb='0111', chain='A', internal=100,
                             full_length=5, model=2),
                    IfeChain(pdb='0111', chain='B', internal=10,
                             full_length=5, model=10))
     self.assertEquals(2, val.model)
コード例 #21
0
 def test_dispatches_bps_to_integral(self):
     val = IfeGroup(IfeChain(pdb='0111', chain='A', internal=100,
                             full_length=5, bps=120),
                    IfeChain(pdb='0111', chain='B', internal=10,
                             full_length=5, bps=12))
     self.assertEquals(120, val.bps)
コード例 #22
0
 def test_dispatches_pdb_to_integral(self):
     val = IfeGroup(IfeChain(pdb='0111', chain='A', internal=4,
                             full_length=5))
     self.assertEquals('0111', val.pdb)
コード例 #23
0
 def test_it_is_bigger_than_none(self):
     val = IfeChain(pdb='01GG', chain='A', internal=0, length=10,
                    full_length=10, db_id=1)
     self.assertTrue(val > None)
     self.assertTrue(None < val)
コード例 #24
0
 def test_uses_name_to_tiebreak_integral_chain(self):
     val = IfeGroup(IfeChain(pdb='0111', chain='C', length=10, internal=0,
                             model=3),
                    IfeChain(pdb='0111', chain='A', length=10, internal=0,
                             model=3))
     self.assertEquals('0111|3|A', val.integral.id)
コード例 #25
0
 def test_getattr_complains_if_missing_key(self):
     val = IfeGroup(IfeChain(pdb='0111', chain='A', internal=4,
                             full_length=5))
     self.assertRaises(AttributeError, lambda: val.bob)
コード例 #26
0
 def test_if_no_structured_in_id_uses_all(self):
     val = IfeGroup(IfeChain(pdb='0111', chain='A', internal=2, model=1),
                    IfeChain(pdb='0111', chain='C', internal=0, model=2),
                    IfeChain(pdb='0111', chain='D', internal=2, model=3))
     self.assertEquals('0111|1|A+0111|3|D+0111|2|C', val.id)
コード例 #27
0
 def test_knows_how_many_chains_in_it(self):
     val = IfeGroup(IfeChain(chain='A', internal=4),
                    IfeChain(chain='B', internal=0))
     self.assertEquals(2, len(val))
コード例 #28
0
 def test_uses_most_bp_chain_as_integral(self):
     val = IfeGroup(IfeChain(pdb='0111', chain='A', internal=4, model=1),
                    IfeChain(pdb='0111', chain='C', internal=0, model=1))
     self.assertEquals('0111|1|A', val.integral.id)
コード例 #29
0
 def test_uses_structured_only_in_id(self):
     val = IfeGroup(IfeChain(pdb='0111', chain='A', internal=5, model=10),
                    IfeChain(pdb='0111', chain='C', internal=0, model=0),
                    IfeChain(pdb='0111', chain='D', internal=6, model=10))
     self.assertEquals('0111|10|D+0111|10|A', val.id)
コード例 #30
0
 def test_uses_length_as_tiebreak(self):
     val = IfeGroup(IfeChain(pdb='0111', chain='A', length=10, internal=50,
                             model=10),
                    IfeChain(pdb='0111', chain='C', length=50, internal=50,
                             model=10))
     self.assertEquals('0111|10|C', val.integral.id)