class TestBoundaryCalling: expected_values = { True: ("chr11:77633337-77643336", 6), False: ("chr11:77640001-77650000", 6) } def setup_method(self, method): self.dir = os.path.dirname(os.path.realpath(__file__)) self.hic = Hic(os.path.join( self.dir, "../data/test_network/rao2014.chr11_77400000_78600000.hic"), mode="r") self.ins = InsulationIndex(self.hic, window_sizes=(50000, )) self.ii = self.ins.insulation_index(50000) def teardown_method(self, method): self.hic.close() self.ins.close() @pytest.mark.parametrize("sub_bin_precision", [True, False]) def test_boundaries(self, sub_bin_precision): boundaries = self.ins.boundaries(50000, delta_window=3, sub_bin_precision=sub_bin_precision) assert self.expected_values[sub_bin_precision][0] == str(boundaries[0]) assert self.expected_values[sub_bin_precision][1] == len(boundaries)
def setup_method(self, method): self.dir = os.path.dirname(os.path.realpath(__file__)) self.hic = Hic(os.path.join( self.dir, "../data/test_network/rao2014.chr11_77400000_78600000.hic"), mode="r") self.ins = InsulationIndex(self.hic, window_sizes=(50000, )) self.ii = self.ins.insulation_index(50000)
def setup_method(self, method): # make TAD-like structures for testing hic = Hic() nodes = [] for i in range(1, 12000, 1000): node = Node(chromosome="chr1", start=i, end=i + 1000 - 1) nodes.append(node) for i in range(1, 4000, 500): node = Node(chromosome="chr2", start=i, end=i + 500 - 1) nodes.append(node) hic.add_nodes(nodes) edges = [] for i in range(0, 5): for j in range(i, 5): edges.append(Edge(source=i, sink=j, weight=50)) for i in range(6, 12): for j in range(i, 12): edges.append(Edge(source=i, sink=j, weight=75)) for i in range(13, 18): for j in range(i, 18): edges.append(Edge(source=i, sink=j, weight=30)) for i in range(18, 20): for j in range(i, 20): edges.append(Edge(source=i, sink=j, weight=50)) hic.add_edges(edges) self.hic = hic
def get_hic(max_random_offset=2.0, amplify=False): hic = Hic() # add some nodes (120 to be exact) nodes = [] for i in range(1, 5000, 1000): nodes.append(Node(chromosome="chr1", start=i, end=i + 1000 - 1)) for i in range(1, 3000, 1000): nodes.append(Node(chromosome="chr2", start=i, end=i + 1000 - 1)) for i in range(1, 2000, 500): nodes.append(Node(chromosome="chr3", start=i, end=i + 1000 - 1)) hic.add_nodes(nodes) # add some edges with increasing weight for testing edges = [] weight = 1.0 for i in range(0, len(nodes)): for j in range(i, len(nodes)): if amplify and i > 7: a = 10.0 else: a = 1.0 edges.append( Edge(source=i, sink=j, weight=a + weight * max_random_offset * random.random())) weight += 1.0 hic.add_edges(edges) return hic
def setup_method(self, method): hic = Hic() # add some nodes (120 to be exact) nodes = [] for i in range(1, 5000, 1000): nodes.append(Node(chromosome="chr1", start=i, end=i + 1000 - 1)) for i in range(1, 3000, 1000): nodes.append(Node(chromosome="chr2", start=i, end=i + 1000 - 1)) for i in range(1, 2000, 500): nodes.append(Node(chromosome="chr3", start=i, end=i + 1000 - 1)) hic.add_nodes(nodes) # add some edges with increasing weight for testing edges = [] weight = 1 for i in range(0, len(nodes)): for j in range(i, len(nodes)): edges.append(Edge(source=i, sink=j, weight=weight)) weight += 1 hic.add_edges(edges) self.hic = hic