[Avida-cvs] [avida-svn] r871 - branches/developers/avida-edward/source/python/AvidaGui2
baerb at myxo.css.msu.edu
baerb at myxo.css.msu.edu
Wed Aug 16 13:04:15 PDT 2006
Author: baerb
Date: 2006-08-16 16:04:15 -0400 (Wed, 16 Aug 2006)
New Revision: 871
Modified:
branches/developers/avida-edward/source/python/AvidaGui2/pyInstructionDescriptionCtrl.py
branches/developers/avida-edward/source/python/AvidaGui2/pyNewIconView.py
branches/developers/avida-edward/source/python/AvidaGui2/pyPetriConfigureCtrl.py
branches/developers/avida-edward/source/python/AvidaGui2/pyWriteGenesisEvent.py
branches/developers/avida-edward/source/python/AvidaGui2/to-do_list
Log:
Finished with making ancestors independent of the current workspce
-- genomes of ancesstors stored in petri dish file or in
ancestor_name_genome_dict in pyNewIconView
-- if ancestor name already exists in ancestor view add (i) to the
end of the name (where i is the number of the copy)
Corrected a few spelling errors in instruction discriptions.
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyInstructionDescriptionCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyInstructionDescriptionCtrl.py 2006-08-14 17:42:11 UTC (rev 870)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyInstructionDescriptionCtrl.py 2006-08-16 20:04:15 UTC (rev 871)
@@ -5,11 +5,11 @@
from AvidaCore import *
descriptions_dict = {
- 'a':"""The instructions nop-A (a), nop-B (b), and nop-C (c) are no-operation instructions, and will not do anything when executed. They will, however, modifiy the behavior of the instruction preceeding it (by changing the CPU component that it affects; see also nop-register notation and nop-head notation) or act as part of a template to denote positions in the genome.""",
+ 'a':"""The instructions nop-A (a), nop-B (b), and nop-C (c) are no-operation instructions, and will not do anything when executed. They will, however, modify the behavior of the instruction preceding it (by changing the CPU component that it affects; see also nop-register notation and nop-head notation) or act as part of a template to denote positions in the genome.""",
- 'b':"""The instructions nop-A (a), nop-B (b), and nop-C (c) are no-operation instructions, and will not do anything when executed. They will, however, modifiy the behavior of the instruction preceeding it (by changing the CPU component that it affects; see also nop-register notation and nop-head notation) or act as part of a template to denote positions in the genome.""",
+ 'b':"""The instructions nop-A (a), nop-B (b), and nop-C (c) are no-operation instructions, and will not do anything when executed. They will, however, modify the behavior of the instruction preceding it (by changing the CPU component that it affects; see also nop-register notation and nop-head notation) or act as part of a template to denote positions in the genome.""",
- 'c':"""The instructions nop-A (a), nop-B (b), and nop-C (c) are no-operation instructions, and will not do anything when executed. They will, however, modifiy the behavior of the instruction preceeding it (by changing the CPU component that it affects; see also nop-register notation and nop-head notation) or act as part of a template to denote positions in the genome.""",
+ 'c':"""The instructions nop-A (a), nop-B (b), and nop-C (c) are no-operation instructions, and will not do anything when executed. They will, however, modify the behavior of the instruction preceding it (by changing the CPU component that it affects; see also nop-register notation and nop-head notation) or act as part of a template to denote positions in the genome.""",
'd':"""This instruction compares the BX register to its complement. If they are not equal, the next instruction (after a modifying no-operation instruction, if one is present) is executed. If they are equal, that next instruction is skipped.""",
@@ -41,11 +41,11 @@
'r':"""This instruction allocates additional memory for the organism up to the maximum it is allowed to use for its offspring.""",
- 's':"""This instruction is used for an organism to divide off an finnished offspring. The original organism keeps the state of its memory up until the read-head. The offspring's memory is initialized to everything between the read-head and the write-head. All memory past the write-head is removed entirely.""",
+ 's':"""This instruction is used for an organism to divide off an finished offspring. The original organism keeps the state of its memory up until the read-head. The offspring's memory is initialized to everything between the read-head and the write-head. All memory past the write-head is removed entirely.""",
't':"""This instruction reads the contents of the organism's memory at the position of the read-head, and copy that to the position of the write-head. If a non-zero copy mutation rate is set, a test will be made based on this probability to determine if a mutation occurs. If so, a random instruction (chosen from the full set with equal probability) will be placed at the write-head instead.""",
- 'u':"""This instruction will read in the template the follows it, and find the location of a complement template in the code. The BX register will be set to the distance to the complement from the current position of the instruction-pointer, and the CX register will be set to the size of the template. The flow-head will also be placed at the beginning of the complement template. If no template follows, both BX and CX will be set to zero, and the flow-head will be placed on the instruction immediatly following the h-search.""",
+ 'u':"""This instruction will read in the template the follows it, and find the location of a complement template in the code. The BX register will be set to the distance to the complement from the current position of the instruction-pointer, and the CX register will be set to the size of the template. The flow-head will also be placed at the beginning of the complement template. If no template follows, both BX and CX will be set to zero, and the flow-head will be placed on the instruction immediately following the h-search.""",
'v':"""This instruction will cause the IP to jump to the position in memory of the flow-head.""",
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyNewIconView.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyNewIconView.py 2006-08-14 17:42:11 UTC (rev 870)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyNewIconView.py 2006-08-16 20:04:15 UTC (rev 871)
@@ -4,7 +4,53 @@
from qt import *
from descr import *
+import re
+imageAncestor_data = [
+"24 16 23 1",
+"t c #3c553e",
+"n c #42a985",
+"l c #782424",
+"f c #7e9a3e",
+"i c #8c7c75",
+"d c #914c54",
+"q c #a1ca5d",
+"o c #a6a8a3",
+"r c #b3b5b2",
+"s c #b5868b",
+"c c #bba4a6",
+"m c #c02a30",
+"p c #c0bebe",
+"a c #cbcccb",
+"j c #d7d7d6",
+"# c #e64d4a",
+"e c #e7c9cc",
+"u c #eb3c88",
+"b c #efefef",
+"k c #f2ddde",
+"g c #f4756e",
+"h c #f7a798",
+". c #ffffff",
+"....................#a..",
+"..................bcde..",
+"................bcdcfb..",
+"...........becghcdijca..",
+"..........kclliml#dejn..",
+"........jeddefoolooi###c",
+".......kpdjqaooipjaooole",
+".bbgbb.pdiaariosb.barr..",
+"biddstm#gdsens#s........",
+"jcatoisdsdmgggsk........",
+".renaatdooosdsb.........",
+".ba.qrl....b............",
+".jarsdg.................",
+"..roupb.................",
+".baae...................",
+"..bj...................."
+]
+
+imageAncestor = QPixmap(imageAncestor_data)
+
def canDecode( e ):
# use the same mime as standard IconView
@@ -29,7 +75,12 @@
def __init__(self, parent, widget_name):
QIconView.__init__(self, parent, widget_name)
# self.setAcceptDrops(1)
+ self.ancestor_name_genome_dict = {}
+ self.setVScrollBarMode(QIconView.Auto)
+ self.setHScrollBarMode(QIconView.Auto)
+ self.setArrangement(QIconView.TopToBottom)
+
# def canDecode(self, e):
# descr("BDB")
#
@@ -57,3 +108,35 @@
if e.source() is self:
return
self.emit(PYSIGNAL("DroppedOnNewIconViewSig"),(e,))
+
+ def addGenomeToDict(self, in_key, in_value):
+ final_key = str(in_key)
+
+ # check if ancestor name already exist in the list. If it does append
+ # a (#) to the end of it.
+
+ while (self.ancestor_name_genome_dict.has_key(final_key)):
+ pattern = re.compile(r"(\()([0-9]+)(\)$)")
+ search_result = pattern.search(final_key)
+ if (search_result):
+ i = int(search_result.group(2)) + 1
+ final_key = in_key + "(" + str(i) + ")"
+ else:
+ final_key = in_key + "(1)"
+ self.ancestor_name_genome_dict[final_key] = str(in_value)
+ return(final_key)
+
+ def getGenomeFromDict(self, in_key):
+ return(self.ancestor_name_genome_dict[str(in_key)])
+
+ def clearGenomeDict(self):
+ self.ancestor_name_genome_dict = {}
+
+ def removeGenomeFromDict(self, in_key):
+ del self.ancestor_name_genome_dict[in_key]
+
+class pyNewIconViewItem(QIconViewItem):
+
+ def __init__(self, parent_view, organism):
+ QIconViewItem.__init__(self, parent_view, organism, imageAncestor)
+
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyPetriConfigureCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyPetriConfigureCtrl.py 2006-08-14 17:42:11 UTC (rev 870)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyPetriConfigureCtrl.py 2006-08-16 20:04:15 UTC (rev 871)
@@ -7,54 +7,12 @@
from pyPetriConfigureView import pyPetriConfigureView
from pyWriteGenesisEvent import pyWriteGenesisEvent
from pyWriteToFreezer import pyWriteToFreezer
+from pyNewIconView import pyNewIconViewItem
from AvidaCore import cGenesis, cString
from qt import *
-imageAncestor_data = [
-"24 16 23 1",
-"t c #3c553e",
-"n c #42a985",
-"l c #782424",
-"f c #7e9a3e",
-"i c #8c7c75",
-"d c #914c54",
-"q c #a1ca5d",
-"o c #a6a8a3",
-"r c #b3b5b2",
-"s c #b5868b",
-"c c #bba4a6",
-"m c #c02a30",
-"p c #c0bebe",
-"a c #cbcccb",
-"j c #d7d7d6",
-"# c #e64d4a",
-"e c #e7c9cc",
-"u c #eb3c88",
-"b c #efefef",
-"k c #f2ddde",
-"g c #f4756e",
-"h c #f7a798",
-". c #ffffff",
-"....................#a..",
-"..................bcde..",
-"................bcdcfb..",
-"...........becghcdijca..",
-"..........kclliml#dejn..",
-"........jeddefoolooi###c",
-".......kpdjqaooipjaooole",
-".bbgbb.pdiaariosb.barr..",
-"biddstm#gdsens#s........",
-"jcatoisdsdmgggsk........",
-".renaatdooosdsb.........",
-".ba.qrl....b............",
-".jarsdg.................",
-"..roupb.................",
-".baae...................",
-"..bj...................."
-]
-
import os, os.path, shutil
import math
@@ -62,8 +20,8 @@
def __init__(self,parent = None,name = None,fl = 0):
pyPetriConfigureView.__init__(self,parent,name,fl)
- self.imageAncestor = QPixmap(imageAncestor_data)
self.setAcceptDrops(1)
+ self.AncestorIconView.setVScrollBarMode(QIconView.AlwaysOff)
def setAvidaSlot(self, avida):
old_avida = self.m_avida
@@ -74,7 +32,6 @@
pass
def construct(self, session_mdl):
- descr()
self.m_session_mdl = session_mdl
self.m_session_petri_view = pyPetriConfigureView()
self.m_avida = None
@@ -143,7 +100,6 @@
self.populated = False
def destruct(self):
- descr()
self.m_session_petri_view = None
self.m_avida = None
self.full_petri_dict = {}
@@ -273,13 +229,13 @@
self.m_session_mdl.m_update_to_pause = self.StopAtSpinBox.value()
def FillDishSlot(self, dish_name, petri_dict):
- descr()
self.full_petri_dict = petri_dict.dictionary
settings_dict = petri_dict.dictionary["SETTINGS"]
- # Erase all items for the ancestor list (largest to smallest index)
+ # Erase all items for the ancestor list
+ self.AncestorIconView.clearGenomeDict()
self.AncestorIconView.clear()
# Find all ancestors with the name of the form START_CREATUREi
@@ -287,8 +243,12 @@
i = 0
while(settings_dict.has_key("START_CREATURE" + str(i))):
start_creature = settings_dict["START_CREATURE" + str(i)]
- tmp_item = QIconViewItem(self.AncestorIconView, start_creature,
- self.imageAncestor)
+
+ # Read the genome from the petri dish file
+
+ org_string = settings_dict["START_GENOME" + str(i)]
+ tmp_name=self.AncestorIconView.addGenomeToDict(start_creature, org_string)
+ tmp_item = pyNewIconViewItem(self.AncestorIconView, tmp_name )
i = i + 1
if settings_dict.has_key("MAX_UPDATES") == True:
max_updates = int(settings_dict["MAX_UPDATES"])
@@ -388,7 +348,6 @@
PYSIGNAL("finishedPetriDishSig"), ())
def DisablePetriConfigureSlot(self):
- descr()
self.ConfigTitleTextLabel.setText("Environmental Settings Disabled During Run")
# Turn off the controls
@@ -440,7 +399,6 @@
PYSIGNAL("doDisablePetriDishSig"), ())
def EnablePetriConfigureSlot(self):
- descr()
self.ConfigTitleTextLabel.setText("Environmental Settings")
# Turn on the controls
@@ -487,7 +445,6 @@
def CreateFilesFromPetriSlot(self, out_dir = None):
- descr()
# The input files will be placed in a python generated temporary directory
# ouput files will be stored in tmp_dir/output until the data is frozen
@@ -504,7 +461,6 @@
(os.path.join(self.m_session_mdl.m_tempdir, "genesis.avida"),))
def Form2Dictionary(self):
- descr()
settings_dict = {}
# Write START_CREATUREi for all the organisms in the Ancestor Icon View
@@ -513,6 +469,8 @@
i = 0
while (curr_item):
settings_dict["START_CREATURE" + str(i)] = str(curr_item.text())
+
+ settings_dict["START_GENOME" + str(i)] = self.AncestorIconView.getGenomeFromDict(str(curr_item.text()))
i = i + 1
curr_item = curr_item.nextItem()
if (self.StopAtRadioButton.isChecked() == True):
@@ -575,7 +533,6 @@
return settings_dict
def FreezePetriSlot(self, population_dict = None, ancestor_dict = None, send_reset_signal = False, send_quit_signal = False):
- descr()
if len(population_dict) == 0:
freeze_empty_only_flag = True;
else:
@@ -632,7 +589,6 @@
def doLoadPetriDishConfigFileSlot(self, genesisFileName = None):
- descr()
genesis = cGenesis()
genesis.Open(cString(genesisFileName))
if 0 == genesis.IsOpen():
@@ -655,9 +611,6 @@
self.setAvidaSlot)
def dragEnterEvent( self, e ):
- descr("BDB")
- descr(e)
- descr("BDB")
freezer_item_name = QString()
@@ -673,10 +626,6 @@
def dropEvent( self, e ):
- descr()
- descr("BDB -- e.pos()")
- tmp_pos = self.mapToGlobal(e.pos())
- descr("x = " + str(tmp_pos.x()) + " y = " + str(tmp_pos.y()))
freezer_item_name = QString()
if ( QTextDrag.decode( e, freezer_item_name ) ) :
freezer_item_name = str(e.encodedData("text/plain"))
@@ -687,10 +636,9 @@
# The function petriDroppedSlot and petriAncestorDroppedSlot are identical
# at some point petriDroppedSlot should not allow creatures dropped outside
- # the AncestorIconView to be added to the Ancestort List
+ # the AncestorIconView to be added to the Ancestor List
def petriDroppedSlot(self, e):
- descr()
# Try to decode to the data you understand...
freezer_item_name = QString()
if ( QTextDrag.decode( e, freezer_item_name ) and not self.DishDisabled) :
@@ -698,14 +646,27 @@
if freezer_item_name[-8:] == 'organism':
core_name = freezer_item_name[:-9]
core_name = os.path.basename(str(freezer_item_name[:-9]))
- tmp_item = QIconViewItem(self.AncestorIconView, core_name, self.imageAncestor)
- #initialize Avida (which repaints the dish)
+
+ # Read the genome from the organism file
+
+ org_file = open(os.path.join(self.m_session_mdl.m_current_freezer,
+ core_name+".organism"))
+ org_string = org_file.readline()
+ org_string = org_string.rstrip()
+ org_string = org_string.lstrip()
+ org_file.close
+
+ tmp_name = self.AncestorIconView.addGenomeToDict(core_name, org_string)
+ tmp_item = pyNewIconViewItem(self.AncestorIconView, tmp_name)
+
+
+ # initialize Avida (which repaints the dish)
+
self.m_session_mdl.m_session_mdtr.emit(
PYSIGNAL("doInitializeAvidaPhaseISig"),
(self.m_session_mdl.m_tempdir,))
def petriAncestorDroppedSlot(self, e):
- descr()
# Try to decode to the data you understand...
freezer_item_name = QString()
if ( QTextDrag.decode( e, freezer_item_name ) and not self.DishDisabled) :
@@ -713,7 +674,18 @@
if freezer_item_name[-8:] == 'organism':
core_name = freezer_item_name[:-9]
core_name = os.path.basename(str(freezer_item_name[:-9]))
- tmp_item = QIconViewItem(self.AncestorIconView, core_name, self.imageAncestor)
+
+ # Read the genome from the organism file
+
+ org_file = open(os.path.join(self.m_session_mdl.m_current_freezer,
+ core_name+".organism"))
+ org_string = org_file.readline()
+ org_string = org_string.rstrip()
+ org_string = org_string.lstrip()
+ org_file.close
+
+ tmp_name = self.AncestorIconView.addGenomeToDict(core_name, org_string)
+ tmp_item = pyNewIconViewItem(self.AncestorIconView, tmp_name)
return
# Find the first item in the AncestorView with the name ancestor_item_name
@@ -721,15 +693,13 @@
# correct item should be deleted.
def deleteAncestorSlot(self, ancestor_item_name):
- descr()
curr_item = self.AncestorIconView.firstItem()
while (curr_item):
curr_item_name = str(curr_item.text())
- descr("BDB -- curr_item_name = " + curr_item_name + " ancestor_item_name = " + ancestor_item_name)
if (str(curr_item_name) == ancestor_item_name):
- descr("BDB -- in if curr_item_name = " + curr_item_name + " ancestor_item_name = " + ancestor_item_name)
self.AncestorIconView.takeItem(curr_item)
# curr_item.~QIconViewItem()
+ self.AncestorIconView.removeGenomeFromDict(curr_item_name)
break
curr_item = curr_item.nextItem()
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyWriteGenesisEvent.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyWriteGenesisEvent.py 2006-08-14 17:42:11 UTC (rev 870)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyWriteGenesisEvent.py 2006-08-16 20:04:15 UTC (rev 871)
@@ -73,14 +73,9 @@
self.m_session_mdl.m_founding_cells_dict = None
self.m_session_mdl.m_founding_cells_dict = cells_dict
- # Read the genome from the organism file
+ # Read the genome from the dictionary
- org_file = open(os.path.join(freeze_dir, start_creature+".organism"))
- org_string = org_file.readline()
- org_string = org_string.rstrip()
- org_string = org_string.lstrip()
- org_file.close
- organisms_dict[str(i)] = org_string
+ organisms_dict[str(i)] = settings_dict["START_GENOME" + str(i)]
shutil.copyfile(os.path.join(workspace_dir, "inst_set.default"), os.path.join(tmp_in_dir, "inst_set.default"))
Modified: branches/developers/avida-edward/source/python/AvidaGui2/to-do_list
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/to-do_list 2006-08-14 17:42:11 UTC (rev 870)
+++ branches/developers/avida-edward/source/python/AvidaGui2/to-do_list 2006-08-16 20:04:15 UTC (rev 871)
@@ -5,8 +5,6 @@
Priority High
-15-Jun-06 Finish work on AncestorIconView
-
16-Jan-06 Get file system finished -- Make one big database file?
11-Jul-06 Fix problem where user drags in in a new population, clicks on freeze and then clicks cancel the program loads the new population without saving.
@@ -15,10 +13,8 @@
29-Apr-06 Change configuration on fly -- work with Kaben on the underlieing problem
-15-Jun-06 Drop on viewer icon
+15-Jun-06 Drop organism/full population directly on organism/analysis viewer icon
-15-Jun-06 Add Viewers to view choice on menu
-
15-Jun-06 Add text "environmental settings" on main screen
07-Jul-06 Save lineage of creature as well as genotype
@@ -37,21 +33,19 @@
29-Apr-06 Add "Environment Setting"/"Petri Dish" at top left of frame
-15-May-06 Prevent program from deleting files with names beginning with "*"
+15-May-06 Prevent program from deleting files with names beginning with "@"
15-Jun-06 Change wording on can't freeze message
15-Jun-06 Create CGI script to allow users to enter information when they check out avida executable.
-29-Jun-06 set petri dish flag to open
+29-Jun-06 set petri dish flag to open -- what does this mean?????
-29-Jun-06 change name of restart petri dish
-
29-Jun-06 Same control on front and back of petri dish.
30-Jun-06 Make cell location relative to center of screen (use +/- X and Y) instead of using Avida cell location
-03-Jul-06 Default, Replication Only, All Nine, Funky Org, zoo
+03-Jul-06 Add some more data sets -- Default, Replication Only, All Nine, Funky Org, zoo
03-Jul-06 Delete item by clicking and delete
@@ -59,7 +53,7 @@
13-Jul-06 Change the patterns of dots for multiple ancestors
-09-Aug-06 Deactivate Ancestor Icon Drag
+09-Aug-06 Deactivate Ancestor Icon Drag when there is a full population
09-Aug-06 Rename duplicate Ancestors names when they are droppeed into Ancestor View
@@ -207,6 +201,16 @@
07-Jul-06 Save organism box is not modal -- fix it. -- Finished 11-Jul-06
+15-Jun-06 Finish work on AncestorIconView -- Finished 10-Aug-06
+
+15-Jun-06 Add Viewers to view choice on menu
+
+29-Jun-06 change name of restart petri dish
+
+August - 06
+
+ - Fixed problems with IconView to get trash can to work
+
************Kaben******************
* 23-Jan-06 Get program to run on all Macs -- Finished 27-Jan-06
More information about the Avida-cvs
mailing list