diff options
author | Thomas 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) |
commit | 7ce7155dead3893e572006588fc342fb3af7ec60 (patch) | |
tree | 2bb234d6d159aa797767bf1ceccea53117dc773a /exon_position.py | |
parent | bcde11455168a07de8a3b17f2a4d77ce8931e75d (diff) |
Layers are now arranged as a tree data structure.
Diffstat (limited to 'exon_position.py')
-rw-r--r-- | exon_position.py | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/exon_position.py b/exon_position.py index efe560a..2fd7bed 100644 --- a/exon_position.py +++ b/exon_position.py @@ -18,8 +18,9 @@ import random import cairo import ka_extensionpoint -import ka_random +import model_random import model_constraintpool +import model_locus import model_allele EPSILON = 0.00001 @@ -55,22 +56,25 @@ class Position(model_allele.Allele): """Set x_pos, y_pos to random values.""" cpool = model_constraintpool.ConstraintPool.get_pool() constraints = cpool.get(self, POSITION_CONSTRAINT) - self.constraint = ka_extensionpoint.create(random.choice(constraints), self.path) + self.constraint = ka_extensionpoint.create(random.choice(constraints), + self.path) self.x_pos, self.y_pos = self.constraint.randomize() def mutate(self): """Make small random changes in position.""" - if ka_random.is_mutating(): - if ka_random.is_mutating(): + if model_random.is_mutating(): + if model_random.is_mutating(): cpool = model_constraintpool.ConstraintPool.get_pool() constraints = cpool.get(self, POSITION_CONSTRAINT) - self.constraint = ka_extensionpoint.create(random.choice(constraints), self.path) - self.x_pos, self.y_pos = self.constraint.mutate(self.x_pos, self.y_pos) + self.constraint = ka_extensionpoint.create( + random.choice(constraints), self.path) + self.x_pos, self.y_pos = self.constraint.mutate(self.x_pos, + self.y_pos) - def shuffle(self): - """Exchange x- and y-coordinate.""" - temp0, temp1 = self.x_pos, self.y_pos - self.x_pos, self.y_pos = temp1, temp0 + def swap_places(self): + """Exchange x- and y-tiles.""" + self.x_pos, self.y_pos = model_random.swap_parameters(self.x_pos, + self.y_pos) def crossingover(self, other): """Returns either a copy of self or a copy of other. @@ -78,8 +82,9 @@ class Position(model_allele.Allele): # 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) == '' """ - randseq = ka_random.crossing_sequence(1) + randseq = model_random.crossing_sequence(1) return self.copy() if randseq[0] else other.copy() def copy(self): @@ -94,6 +99,7 @@ class Position(model_allele.Allele): return new_one def explain(self): + """Returns a string describing details.""" return u'%4.3f, %4.3f' % (self.x_pos, self.y_pos) @staticmethod |