Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/ep_sampler_randomwalk.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_sampler_randomwalk.py
parentbcde11455168a07de8a3b17f2a4d77ce8931e75d (diff)
Layers are now arranged as a tree data structure.
Diffstat (limited to 'ep_sampler_randomwalk.py')
-rw-r--r--ep_sampler_randomwalk.py31
1 files changed, 20 insertions, 11 deletions
diff --git a/ep_sampler_randomwalk.py b/ep_sampler_randomwalk.py
index 5c5e747..ae419f0 100644
--- a/ep_sampler_randomwalk.py
+++ b/ep_sampler_randomwalk.py
@@ -16,7 +16,9 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import math
-import ka_random
+import ka_debug
+import model_random
+import model_locus
import model_allele
import model_constraintpool
import exon_direction
@@ -39,6 +41,13 @@ class RandomWalkSampler(model_allele.Allele):
super(RandomWalkSampler, self).__init__(trunk)
self.direction_steps = [exon_direction.Direction(self.path, 0.0, 0.0)]
+ def dot(self):
+ result = ""
+ anchor = ka_debug.dot_id(self) + ' -> '
+ for ref in self.direction_steps:
+ result += ka_debug.dot_ref(anchor, ref)
+ return result
+
def __eq__(self, other):
"""Equality based on on number of sections."""
equal = isinstance(other, RandomWalkSampler) \
@@ -52,7 +61,7 @@ class RandomWalkSampler(model_allele.Allele):
"""Randomizes the walk."""
cpool = model_constraintpool.ConstraintPool.get_pool()
sections_constraint = cpool.get(self, SECTIONS_CONSTRAINT)
- for i in range(ka_random.randint_constrained(sections_constraint)):
+ for dummy in range(model_random.randint_constrained(sections_constraint)):
direction = exon_direction.Direction(self.path, 0.0, 0.0)
direction.randomize()
self.direction_steps.append(direction)
@@ -61,14 +70,13 @@ class RandomWalkSampler(model_allele.Allele):
"""Mutates the random walk."""
cpool = model_constraintpool.ConstraintPool.get_pool()
sections_constraint = cpool.get(self, SECTIONS_CONSTRAINT)
- if ka_random.is_mutating():
- ka_random.mutate_list(self.direction_steps, sections_constraint,
+ if model_random.is_mutating():
+ model_random.mutate_list(self.direction_steps, sections_constraint,
exon_direction.Direction(self.path, 0.0, 0.0))
- def shuffle(self):
- """Reorder"""
- ##!!self.direction_steps.shuffle()
- pass
+ def swap_places(self):
+ """Reorder steps."""
+ model_random.swap_places(self.direction_steps)
def crossingover(self, other):
"""
@@ -77,10 +85,11 @@ class RandomWalkSampler(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) == ''
"""
new_one = RandomWalkSampler(self.get_trunk())
- new_one.direction_steps = ka_random.crossingover(self.direction_steps,
- other.direction_steps)
+ new_one.direction_steps = model_random.crossingover_list(self.direction_steps,
+ other.direction_steps)
return new_one
def get_sample_points(self):
@@ -111,5 +120,5 @@ class RandomWalkSampler(model_allele.Allele):
post: __return__ is not self
"""
new_one = RandomWalkSampler(self.get_trunk())
- new_one.direction_steps = ka_random.copy_list(self.direction_steps)
+ new_one.direction_steps = model_random.copy_list(self.direction_steps)
return new_one