def render(self, graphics, ypos, rng, style, error):
     from random import random
     data = []
     for i in range(0, 120):
         data.append(random())
     graphics.draw_curve_data(graphics.get_xmargins(), ypos,
                              Color(0, 0, 1, .6), data, 120, Range(0, 1),
                              40)
     return 0
Esempio n. 2
0
 def get_range_for_seqid(self, seqid):
     from ctypes import byref
     err = Error()
     if self.has_seqid(seqid) == 0:
         gterror("feature_index does not contain seqid")
     range = Range()
     rval = gtlib.gt_feature_index_get_range_for_seqid(
         self.fi, byref(range), seqid.encode('UTF-8'), err)
     if rval != 0:
         gterror(err)
     return range
Esempio n. 3
0
 def get_features_for_range(self, start, end, seqid):
     from ctypes import byref
     a = Array.create()
     err = Error()
     rng = Range(start, end)
     rval = gtlib.gt_feature_index_get_features_for_range(
         self.fi, a, seqid, byref(rng), err)
     if rval != 0:
         gterror(err)
     result = []
     for i in range(a.size()):
         fptr = gtlib.gt_genome_node_ref(a.get(i))
         result.append(FeatureNode.create_from_ptr(fptr))
     return result
Esempio n. 4
0
    # construct a gene on the forward strand with two exons

    gene = FeatureNode.create_new(seqid, "gene", 100, 900, "+")
    exon = FeatureNode.create_new(seqid, "exon", 100, 200, "+")
    gene.add_child(exon)
    intron = FeatureNode.create_new(seqid, "intron", 201, 799, "+")
    gene.add_child(intron)
    exon = FeatureNode.create_new(seqid, "exon", 800, 900, "+")
    gene.add_child(exon)

    # construct a single-exon gene on the reverse strand
    # (within the intron of the forward strand gene)

    reverse_gene = FeatureNode.create_new(seqid, "gene", 400, 600, "-")
    reverse_exon = FeatureNode.create_new(seqid, "exon", 400, 600, "-")
    reverse_gene.add_child(reverse_exon)

    pngfile = (sys.argv)[2]

    style = Style()
    style.load_file((sys.argv)[1])

    diagram = Diagram.from_array([gene, reverse_gene], Range(1, 1000), style)

    layout = Layout(diagram, 600, style)
    height = layout.get_height()
    canvas = CanvasCairoFile(style, 600, height)
    layout.sketch(canvas)

    canvas.to_file(pngfile)
Esempio n. 5
0
    exon = FeatureNode.create_new(seqid, "exon", 100, 200, "+")
    gene.add_child(exon)
    intron = FeatureNode.create_new(seqid, "intron", 201, 799, "+")
    gene.add_child(intron)
    exon = FeatureNode.create_new(seqid, "exon", 800, 900, "+")
    gene.add_child(exon)

    # construct a single-exon gene on the reverse strand
    # (within the intron of the forward strand gene)

    reverse_gene = FeatureNode.create_new(seqid, "gene", 400, 600, "-")
    reverse_exon = FeatureNode.create_new(seqid, "exon", 400, 600, "-")
    reverse_gene.add_child(reverse_exon)

    nodes.append(reverse_gene)

    pngfile = (sys.argv)[2]

    style = Style()
    style.load_file((sys.argv)[1])

    diagram = Diagram.from_array(nodes, Range(G.start, G.end), style)

    layout = Layout(diagram, 600, style)
    height = layout.get_height()
    canvas = CanvasCairoFile(style, 600, height)
    layout.sketch(canvas)

    canvas.to_file(pngfile)