class ResiduePlanePaddedComplexFingerPrintCacheTest(unittest.TestCase):
    """ Test case for padded complex fp cache"""
    
    def setUp(self):
        #cache init
        from ve.fp.complex_util.cache import ComplexFingerPrintCache as C
        self.C = C

        from ve.fp.fp_175_padded import ResiduePlaneBasedComplex
        from ve.fp.fp_80 import Residue
        atg = load_pdb_struct(os.path.join(test_data_dir, "antigen.pdb"), Residue)
        atb = load_pdb_struct(os.path.join(test_data_dir, "antibody.pdb"), Residue)
        
        c_id = "1SLG_D" 
        self.c = ResiduePlaneBasedComplex(complex_id = c_id, antigen = atg, antibody = atb)
        
    def test_load_atg_tri(self):
        """
        test if cached fingerprint can be loaded as padded fp
        in this case, the atg side iterating through triangles based on complex plane
        and whether the loaded one equals to the computed one
        """
        self.C.set_signature("atg_tri_residue_plane")

        expected_fp = self.c.gen_fp_by_splitting_cylinder(bases=self.c.atg.residues,
                                                  targets=[(0,self.c.get_triangles())],
                                                  fps = PaddedComplexFingerPrint())

                                                  
        actual_fp = self.C.load(self.c.c_id, self.c, complex_fp_cls =  PaddedComplexFingerPrint)
        self.assertEqual(expected_fp, actual_fp)

    def test_load_atg_res(self):
        """
        the atg side iterating through residues based on complex plane
        """
        self.C.set_signature("atg_res_residue_plane")

        expected_fp = self.c.gen_fp_by_splitting_cylinder(bases=self.c.atg.residues,
                                                          targets=[(0,self.c.atg.residues)],
                                                          fps = PaddedComplexFingerPrint())
                                                  
        actual_fp = self.C.load(self.c.c_id, self.c, complex_fp_cls =  PaddedComplexFingerPrint)
        self.assertEqual(expected_fp, actual_fp)

    def test_load_atb_res(self):
        """
        the atb side iterating through residues based on complex plane
        """
        self.C.set_signature("atb_res_residue_plane")

        expected_fp = self.c.gen_fp_by_splitting_cylinder(bases=self.c.atb.residues,
                                                          targets=[(0,self.c.atb.residues)],
                                                          fps = PaddedComplexFingerPrint())
        
        actual_fp = self.C.load(self.c.c_id, self.c, complex_fp_cls =  PaddedComplexFingerPrint)
        self.assertEqual(expected_fp, actual_fp)
예제 #2
0
 def setUp(self):
     c_id = "2NLJ_C"
     #c_id = "1SLG_D"
     
     from ve.fp.fp_80 import Residue
     atg = load_pdb_struct(os.path.join(data237_complex_root, c_id, "antigen.pdb"), Residue)
     atb = load_pdb_struct(os.path.join(data237_complex_root, c_id, "antibody.pdb"), Residue)
     
     self.c = ResiduePlaneBasedComplex(complex_id = c_id, antigen = atg, antibody = atb)
    def setUp(self):
        #cache init
        from ve.fp.complex_util.cache import ComplexFingerPrintCache as C
        self.C = C

        from ve.fp.fp_175_padded import ResiduePlaneBasedComplex
        from ve.fp.fp_80 import Residue
        atg = load_pdb_struct(os.path.join(test_data_dir, "antigen.pdb"), Residue)
        atb = load_pdb_struct(os.path.join(test_data_dir, "antibody.pdb"), Residue)
        
        c_id = "1SLG_D" 
        self.c = ResiduePlaneBasedComplex(complex_id = c_id, antigen = atg, antibody = atb)
예제 #4
0
class ResiduePlaneBasedComplexTestCase(unittest.TestCase):
    
    def setUp(self):
        c_id = "2NLJ_C"
        #c_id = "1SLG_D"
        
        from ve.fp.fp_80 import Residue
        atg = load_pdb_struct(os.path.join(data237_complex_root, c_id, "antigen.pdb"), Residue)
        atb = load_pdb_struct(os.path.join(data237_complex_root, c_id, "antibody.pdb"), Residue)
        
        self.c = ResiduePlaneBasedComplex(complex_id = c_id, antigen = atg, antibody = atb)

    def test_fp_length_use_tri_atg_as_rec(self):
        """
        test the fp length
        in case:
        1, antigen is set as the receptor
        2, iterate through antigen residue triangles
        """
        overall_atg_dist,overall_atb_dist =  OverallSpatialDistribution.from_cache()
        fp_str = self.c.gen_fp_str(use_tri = True, atg_as_receptor = True, use_cache = False)
        actual = len(fp_str.split(","))

        fp_str_using_cache = self.c.gen_fp_str(use_tri = True, atg_as_receptor = True, use_cache = True)
        actual_using_cache = len(fp_str.split(","))

        expected = sum(overall_atg_dist.values()) * (50+15) + sum(overall_atb_dist.values()) * 50
        
        self.assertEqual(actual, expected)
        self.assertEqual(actual_using_cache, expected)

    def test_fp_length_use_res_atg_as_rec(self):
        """
        test the fp length
        in case:
        1, antigen is set as the receptor
        2, iterate through antigen residues
        """
        overall_atg_dist,overall_atb_dist =  OverallSpatialDistribution.from_cache()
        fp_str = self.c.gen_fp_str(use_tri = False, atg_as_receptor = True, use_cache = False)
        actual = len(fp_str.split(","))

        fp_str_using_cache = self.c.gen_fp_str(use_tri = False, atg_as_receptor = True, use_cache = True)
        actual_using_cache = len(fp_str.split(","))
        
        expected = sum(overall_atg_dist.values()) * (50+15) + sum(overall_atb_dist.values()) * 50
        
        self.assertEqual(actual, expected)
        self.assertEqual(actual_using_cache, expected)
        
    def test_fp_length_use_res_atb_as_rec(self):
        """
        test the fp length
        in case:
        1, antibody is set as the receptor
        2, iterate through antigen residues
        """
        overall_atg_dist,overall_atb_dist =  OverallSpatialDistribution.from_cache()
        fp_str = self.c.gen_fp_str(use_tri = False, atg_as_receptor = False, use_cache = False)
        actual = len(fp_str.split(","))
        
        fp_str_using_cache = self.c.gen_fp_str(use_tri = False, atg_as_receptor = False, use_cache = True)
        actual_using_cache = len(fp_str.split(","))

        expected = sum(overall_atg_dist.values()) * 50 + sum(overall_atb_dist.values()) * (50 + 15)

        self.assertEqual(actual, expected)
        self.assertEqual(actual_using_cache, expected)

    def test_fp_length_use_tri_atb_as_rec(self):
        """
        test the fp length
        in case:
        1, antibody is set as the receptor
        2, iterate through antigen residue triangles
        """

        overall_atg_dist,overall_atb_dist =  OverallSpatialDistribution.from_cache()
        fp_str = self.c.gen_fp_str(use_tri = True, atg_as_receptor = False, use_cache = False)
        actual = len(fp_str.split(","))

        fp_str_using_cache = self.c.gen_fp_str(use_tri = True, atg_as_receptor = False, use_cache = True)
        actual_using_cache = len(fp_str.split(","))

        expected = sum(overall_atg_dist.values()) * 50 + sum(overall_atb_dist.values()) * (50 + 15)

        self.assertEqual(actual, expected)
        self.assertEqual(actual_using_cache, expected)