Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/ep_layer_filledspline.py
diff options
context:
space:
mode:
authorThomas Jourdan <b.vehikel@googlemail.com>2009-12-06 12:40:41 (GMT)
committer Thomas Jourdan <b.vehikel@googlemail.com>2009-12-06 12:40:41 (GMT)
commit7ce7155dead3893e572006588fc342fb3af7ec60 (patch)
tree2bb234d6d159aa797767bf1ceccea53117dc773a /ep_layer_filledspline.py
parentbcde11455168a07de8a3b17f2a4d77ce8931e75d (diff)
Layers are now arranged as a tree data structure.
Diffstat (limited to 'ep_layer_filledspline.py')
-rw-r--r--ep_layer_filledspline.py68
1 files changed, 25 insertions, 43 deletions
diff --git a/ep_layer_filledspline.py b/ep_layer_filledspline.py
index 1a7a6ae..a180ff9 100644
--- a/ep_layer_filledspline.py
+++ b/ep_layer_filledspline.py
@@ -15,15 +15,14 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#import math
-#import random
-import model_layer
-import ka_random
+import model_random
+import ka_debug
import ka_factory
+import model_locus
+import model_layer
import model_constraintpool
import exon_color
import exon_position
-#import exon_direction
SAMPLERTYPE_CONSTRAINT = 'samplertype_constraint'
@@ -58,11 +57,17 @@ class FilledSpline(model_layer.Layer):
self.line_width = cpool.get(self, 'line_width')[0]
self.roundness = cpool.get(self, 'roundness')[0]
self.center = exon_position.Position(self.path, 0.0, 0.0)
-# self.direction_steps = [exon_direction.Direction(self.path, 0.0, 0.0)]
sampler_factory = ka_factory.get_factory('sampler')
sampler_key = sampler_factory.keys()[0]
self.sampler = sampler_factory.create(sampler_key, self.path)
+ def dot(self):
+ result = ""
+ anchor = ka_debug.dot_id(self) + ' -> '
+ for ref in [self.linecolor, self.fillcolor, self.center, self.sampler]:
+ result += ka_debug.dot_ref(anchor, ref)
+ return result
+
def __eq__(self, other):
"""Equality based on the objects components."""
equal = isinstance(other, FilledSpline) \
@@ -73,30 +78,19 @@ class FilledSpline(model_layer.Layer):
and self.roundness == other.roundness \
and self.center == other.center \
and self.sampler == other.sampler
-# and len(self.direction_steps) == len(other.direction_steps)
-# if equal:
-# for index, direction in enumerate(self.direction_steps):
-# equal = equal and direction == other.direction_steps[index]
return equal
def randomize(self):
"""Randomize the layers components."""
super(FilledSpline, self).randomize()
cpool = model_constraintpool.ConstraintPool.get_pool()
- length_constraint = cpool.get(self, 'length')
line_width_constraint = cpool.get(self, 'line_width')
roundness_constraint = cpool.get(self, 'roundness')
self.linecolor.randomize()
self.fillcolor.randomize()
- self.line_width = ka_random.uniform_constrained(line_width_constraint)
- self.roundness = ka_random.uniform_constrained(roundness_constraint)
+ self.line_width = model_random.uniform_constrained(line_width_constraint)
+ self.roundness = model_random.uniform_constrained(roundness_constraint)
self.center.randomize()
-# self.direction_steps = []
-# length = random.randint(length_constraint[0], length_constraint[1])
-# for i in range(length):
-# direction = exon_direction.Direction(self.path, 0.0, 0.0)
-# direction.randomize()
-# self.direction_steps.append(direction)
sampler_factory = ka_factory.get_factory('sampler')
samplertype_constraint = cpool.get(self, SAMPLERTYPE_CONSTRAINT)
self.sampler = sampler_factory.create_random(samplertype_constraint,
@@ -107,29 +101,19 @@ class FilledSpline(model_layer.Layer):
"""Make small random changes to the layers components."""
super(FilledSpline, self).mutate()
cpool = model_constraintpool.ConstraintPool.get_pool()
- length_constraint = cpool.get(self, 'length')
line_width_constraint = cpool.get(self, 'line_width')
roundness_constraint = cpool.get(self, 'roundness')
self.linecolor.mutate()
self.fillcolor.mutate()
-# ka_random.mutate_list(self.direction_steps,
-# length_constraint,
-# exon_direction.Direction(self.path, 0.0, 0.0))
- if ka_random.is_mutating():
- self.line_width += ka_random.jitter_constrained(line_width_constraint)
- if ka_random.is_mutating():
- self.roundness += ka_random.jitter_constrained(roundness_constraint)
+ self.line_width = model_random.jitter_constrained(self.line_width, line_width_constraint)
+ self.roundness = model_random.jitter_constrained(self.roundness, roundness_constraint)
self.center.mutate()
self.sampler.mutate()
-# for direction in self.direction_steps:
-# direction.mutate()
- def shuffle(self):
+ def swap_places(self):
"""Shuffle similar components."""
- super(FilledSpline, self).shuffle()
- if ka_random.is_shuffling():
- self.sampler.shuffle()
-# self.direction_steps.shuffle()
+ self.center.swap_places()
+ self.sampler.swap_places()
def crossingover(self, other):
"""
@@ -138,17 +122,17 @@ class FilledSpline(model_layer.Layer):
# check for distinct references, needs to copy content, not references
post: __return__ is not self
post: __return__ is not other
+ post: model_locus.unique_check(__return__, self, other) == ''
"""
new_one = FilledSpline(self.get_trunk())
- crossing = self.crossingover_base(new_one, other, 3)
+ crossing = self.crossingover_base(new_one, other, 2)
new_one.linecolor = self.linecolor.crossingover(other.linecolor)
new_one.fillcolor = self.fillcolor.crossingover(other.fillcolor)
new_one.line_width = self.line_width if crossing[0] else other.line_width
new_one.roundness = self.roundness if crossing[1] else other.roundness
- new_one.center = self.center if crossing[2] else other.center
-# new_one.direction_steps = ka_random.crossingover(self.direction_steps, \
-# other.direction_steps)
- new_one.sampler = self.sampler if crossing[1] else other.sampler
+ new_one.center = self.center.crossingover(other.center)
+ new_one.sampler = model_random.crossingover_elem(self.sampler,
+ other.sampler)
return new_one
def render(self, ctx, width, height):
@@ -198,7 +182,7 @@ class FilledSpline(model_layer.Layer):
ctx.stroke()
def explain(self, formater):
-# super(FilledSpline, self).explain(formater)
+ super(FilledSpline, self).explain(formater)
formater.color_item(self.linecolor, 'line color:')
formater.text_item('line width: ' + str(self.line_width))
formater.text_item('roundness: ' + str(self.roundness))
@@ -206,10 +190,9 @@ class FilledSpline(model_layer.Layer):
formater.position_item(self.center, 'center:')
text, surface, descr = self.sampler.explain()
if surface is not None:
- formater.surface_item(surface, 'sampling points:' + text, descr)
+ formater.surface_item(surface, 'sampling points: ' + text, descr)
else:
formater.text_item(text)
-# formater.direction_array(self.direction_steps, 'direction:')
def copy(self):
"""The FilledSpline diagram layers copy constructor.
@@ -223,6 +206,5 @@ class FilledSpline(model_layer.Layer):
new_one.line_width = self.line_width
new_one.roundness = self.roundness
new_one.center = self.center.copy()
-# new_one.direction_steps = ka_random.copy_list(self.direction_steps)
new_one.sampler = self.sampler.copy()
return new_one