Back to index

python-biopython  1.60
Public Member Functions
test_GenomeDiagram.GraphTest Class Reference

List of all members.

Public Member Functions

def test_limits
def test_slicing

Detailed Description

Definition at line 211 of file test_GenomeDiagram.py.


Member Function Documentation

Check line graphs.

Definition at line 212 of file test_GenomeDiagram.py.

00212 
00213     def test_limits(self):
00214         """Check line graphs."""
00215         #TODO - Fix GD so that the same min/max is used for all three lines?
00216         points = 1000
00217         scale = math.pi * 2.0 / points
00218         data1 = [math.sin(x*scale) for x in range(points)]
00219         data2 = [math.cos(x*scale) for x in range(points)]
00220         data3 = [2*math.sin(2*x*scale) for x in range(points)]
00221         
00222         gdd = Diagram('Test Diagram', circular=False,
00223                       y=0.01, yt=0.01, yb=0.01,
00224                       x=0.01, xl=0.01, xr=0.01)
00225         gdt_data = gdd.new_track(1, greytrack=False)
00226         gds_data = gdt_data.new_set("graph")
00227         for data_values, name, color in zip([data1,data2,data3],
00228                                             ["sin", "cos", "2sin2"],
00229                                             ["red","green","blue"]):
00230             data = zip(range(points), data_values)
00231             gds_data.new_graph(data, "", style="line",
00232                                color = color, altcolor = color,
00233                                center = 0)
00234 
00235         gdd.draw(format='linear',
00236                  tracklines=False,
00237                  pagesize=(15*cm,15*cm),
00238                  fragments=1,
00239                  start=0, end=points)
00240         gdd.write(os.path.join('Graphics', "line_graph.pdf"), "pdf")
00241         #Circular diagram
00242         gdd.draw(tracklines=False,
00243                  pagesize=(15*cm,15*cm),
00244                  circular=True, #Data designed to be periodic
00245                  start=0, end=points, circle_core=0.5)
00246         gdd.write(os.path.join('Graphics', "line_graph_c.pdf"), "pdf")
        
Check GraphData slicing.

Definition at line 247 of file test_GenomeDiagram.py.

00247 
00248     def test_slicing(self):
00249         """Check GraphData slicing."""
00250         gd = GraphData()
00251         gd.set_data([(1, 10), (5, 15), (20, 40)])
00252         gd.add_point((10, 20))
00253         
00254         assert gd[4:16] == [(5, 15), (10, 20)], \
00255                 "Unable to insert and retrieve points correctly"
00256 


The documentation for this class was generated from the following file: