def test_convert_to_mRNA_position_placement_split(self): """ Makes sure that lists of regions works for both positive and negative strands """ return tool = pybedtools.create_interval_from_list("ENSMUSG1 125 127 ENSMUSG1_1_83;ENSMUSG1_6_83 0 + 125 125".split()) location_dict = {"ENSMUSG1" : {"strand" : "+", "regions" : [(0, 50), (100, 150), ] } } correct_tool = pybedtools.create_interval_from_list("ENSMUSG1 75 77 ENSMUSG1_1_83;ENSMUSG1_6_83 0 + 125 125".split()) self.assertEqual(convert_to_mRNA_position(tool, location_dict), correct_tool ) tool = pybedtools.create_interval_from_list("ENSMUSG1 25 27 ENSMUSG1_1_83;ENSMUSG1_6_83 0 - 25 25".split()) location_dict = {"ENSMUSG1" : {"strand" : "-", "regions" : [(100, 150), (0, 50), ] } } correct_tool = pybedtools.create_interval_from_list("ENSMUSG1 73 75 ENSMUSG1_1_83;ENSMUSG1_6_83 0 - 25 25".split()) self.assertEqual(convert_to_mRNA_position(tool, location_dict), correct_tool)
def test_convert_to_mRNA_position_placement(self): """ Makes sure that the placement within a region or list of regions is correct """ return interval = pybedtools.create_interval_from_list("ENSMUSG1 50 60 ENSMUSG1_1_83;ENSMUSG1_6_83 0 + 60 60".split()) location_dict = {"ENSMUSG1" : {"strand" : "+", "regions" : [(0,100), ] } } correct_tool = pybedtools.create_interval_from_list("ENSMUSG1 50 60 ENSMUSG1_1_83;ENSMUSG1_6_83 0 + 60 60".split()) self.assertEqual(convert_to_mRNA_position(interval, location_dict), correct_tool) interval = pybedtools.create_interval_from_list("ENSMUSG1 50 60 ENSMUSG1_1_83;ENSMUSG1_6_83 0 -".split()) location_dict = {"ENSMUSG1" : {"strand" : "-", "regions" : [(0,100), ] } } #individual_fraction, total_fraction correct_tool = pybedtools.create_interval_from_list("ENSMUSG1 40 50 ENSMUSG1_1_83;ENSMUSG1_6_83 0 -".split()) x = convert_to_mRNA_position(interval, location_dict) print x self.assertEqual(x, correct_tool)
def test_convert_to_mRNA_position_fail(self): """ Various attempts to break RNA position and make sure that error are caught """ return tool = pybedtools.create_interval_from_list("ENSMUSG1 51 60 ENSMUSG1_1_83;ENSMUSG1_6_83 0 - 10 10".split()) location_dict = {"ENSMUSG1" : {"strand" : "-", "regions" : [(100, 150), (25,50), ] } } self.assertEqual(convert_to_mRNA_position(tool, location_dict).chrom, "none") tool = pybedtools.create_interval_from_list("ENSMUSG1 51 60 ENSMUSG1_1_83;ENSMUSG1_6_83 0 - 175 175".split()) self.assertEqual(convert_to_mRNA_position(tool, location_dict).chrom, "none") pybedtools.BedTool("chr1 x y ")