Пример #1
0
    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
Пример #2
0
        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
Пример #3
0
    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
Пример #4
0
    def _calculate(self, *args, **kwargs):
        for i in range(10):
            if i < 5:
                chromosome = 'chr1'
                start = i*1000
                end = (i+1)*1000
            elif i < 8:
                chromosome = 'chr2'
                start = (i-5)*1000
                end = (i+1-5)*1000
            else:
                chromosome = 'chr3'
                start = (i-8)*1000
                end = (i+1-8)*1000
            node = Node(chromosome=chromosome, start=start, end=end)
            self.add_region(node, flush=False)
        self.flush()

        for i in range(10):
            for j in range(i, 10):
                edge = Edge(source=i, sink=j, weight=i*j, foo=i, bar=j, baz='x' + str(i*j))
                self.add_edge(edge, flush=False)
        self.flush()