def print_splitted_fp_in_csv(res_or_tri, which=0):
    """
    split 360 bits into parts
    """
    data_dir = os.path.join(data480_root, "fp_aaindex_if_padded" if res_or_tri == "res" else "fp_aaindex_if_padded_tri")

    delimiter = ","
    cids = complex_ids(data_dir)

    name = ("%s 3 bits" % (res_or_tri), "atb 4 bits", "15 bits")

    from ve.fp.complex_util.padding import PaddedComplexFingerPrint, OverallSpatialDistribution

    atg_dist, atb_dist, tri_dist = OverallSpatialDistribution.from_cache()

    first_3_count = sum(atg_dist.values() if res_or_tri == "res" else tri_dist.values()) * 3
    second_3_count = sum(atb_dist.values()) * 3
    last_15_count = sum(atg_dist.values()) * 15

    first_3_dataloader = make_dataloader(data_dir, make_single_line_converter(slice(0, first_3_count)))
    second_3_dataloader = make_dataloader(
        data_dir, make_single_line_converter(slice(first_3_count, first_3_count + second_3_count))
    )
    last_15_dataloader = make_dataloader(
        data_dir,
        make_single_line_converter(
            slice(first_3_count + second_3_count, first_3_count + second_3_count + last_15_count)
        ),
    )

    dls = [first_3_dataloader, second_3_dataloader, last_15_dataloader]

    print ("cid, %s" % name[which])
    for cid in sorted(cids):
        print ("%s,%s" % (cid, delimiter.join(map(lambda d: "%.2f" % d, dls[which](cid)))))
    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()) * 80 + sum(overall_atb_dist.values()) * (80 + 15)

        self.assertEqual(actual, expected)
        self.assertEqual(actual_using_cache, expected)
 def setUp(self):
     self.atg_dist, self.atb_dist = OverallSpatialDistribution.from_cache("/home/rxzhu/QiuTianyi/code/ve/data/data237/fp/.cache/overall_residue_distribution_test")
    def test_atg_side(self):
        actual = dict(self.atg_dist)
        expected = {1: 1, 4: 1, 6: 2, 7: 2, 8: 1, 9: 1, 11: 1, 12: 1, 13: 2, 14: 2, 16: 2, 17: 3, 18: 3, 19: 1, 20: 1, 21: 2, 22: 1, 23: 2, 24: 3, 26: 1, 27: 2, 28: 2, 29: 1, 30: 1, 31: 2, 32: 3, 33: 3, 34: 2, 35: 1, 36: 2, 37: 2, 38: 2, 39: 3, 40: 1, 41: 2, 42: 2, 43: 2, 44: 3, 45: 1, 46: 1, 47: 4, 48: 2, 49: 4}
        
        self.assertEqual(actual, expected)

    def test_atb_side(self):
        actual = dict(self.atb_dist)
        expected = {1: 1, 2: 1, 3: 2, 4: 1, 5: 1, 6: 1, 7: 1, 8: 3, 9: 2, 10: 1, 11: 2, 12: 2, 13: 3, 14: 2, 16: 2, 17: 2, 18: 2, 19: 2, 20: 1, 21: 2, 22: 1, 23: 2, 24: 3, 25: 1, 26: 2, 27: 2, 28: 5, 29: 3, 31: 1, 32: 3, 33: 3, 34: 4, 35: 1, 36: 1, 37: 3, 38: 2, 39: 3, 40: 1, 41: 1, 42: 2, 43: 2, 44: 2, 46: 1, 47: 2, 48: 2, 49: 4}
        
        self.assertEqual(actual, expected)


from ve.fp.complex_util.res_spat_dist import ResiduePositionDistribution

atg_dist, atb_dist = OverallSpatialDistribution.from_cache()
        
from ve.fp.complex_util.split_cylinder import SplitCylinderViaComplexPlaneTrait
from ve.fp.complex_util.triangle import ResidueTriangleTrait

from ve.fp.fp_80 import Residue as ResidueClass

TempClass = make_complex_class(SplitCylinderViaComplexPlaneTrait, residue_class = ResidueClass)

from ve.fp.complex_util.res_spat_dist import ResidueSpatialDistributionTrait
class ComplexClass(TempClass, ResidueTriangleTrait, ResidueSpatialDistributionTrait):
    pass

class PaddingTestCase(unittest.TestCase):
    def setUp(self):
        self.atg_dist = atg_dist