Saturday, May 2, 2009

A Note about casting in TinkerCell

The qgraphicsitem_cast is used to cast at the "top level" graphical items, i.e. PartGraphicsItem, ConnectionGraphicsItem, TextGraphicsItem, PartGraphicsItem::ControlPoint, ConnectionGraphicsItem::ControlPoint, and GraphicalTool. Note, ControlPoint::getControlPoint() can be used to get either one of the ControlPoint classes.

For example:
PartGraphicsItem * part =  qgraphicsitem_cast(item)
ConnectionGraphicsItem * connection = qgraphicsitem_cast(item)

However, this type casting is NOT used for subclasses, such as ArrowHeadItem or ModuleLinkerItem, both of which inherit from PartGraphicsItem. Casting for these subclasses is done using the class_name static field.

For example:
PartGraphicsItem * part =  qgraphicsitem_cast(item)
if (part->className == ArrowHeadItem::class_name)
      ArroHeadItem * arrow = static_cast(part); 

Reason for this way of casting:
The top level classes are used by various tools, so the qgraphicsitem_cast is reseved for tools to identify which of the top level class an item belong to. The subclasses are usually only relevant for one or two tools, e.g. the ModuleLinkerItem. Other tools do not need to differentiate between PartGraphicsItem and ModuleLinkerItem. 

Friday, May 1, 2009

BioBricks in TinkerCell

A first attempt at storing a composite BioBrick

The BBa_I0462 is composed of 4 other sub-parts. Each part, including the composite part, has author, date, and other annotations. The sequence, however, is a property of each of the sub-parts, not the composite parts.

All this information is stored in this model object drawn in TinkerCell. Here is the Python code for accessing all the information (they can also be viewed through the visual interface).

>>part = tc_find("BBa_I0462")
>>print fromStrings( tc_annotation(part) )
('Caitlin Conboy and Jennifer Braff', '12/04/2003', 'luxR Protein Generator', 'uri', 'reference')

>>print tc_getTextAttribute(part,"format")

>>print tc_getTextAttribute(part,"type")

>>subparts = fromItems( tc_getChildren(part) )
>>for i in subparts: print tc_getName(i) + " is a " + tc_getFamily(i);
BBa_I0462_B0012 is a Terminator
BBa_I0462_B0010 is a Terminator
BBa_I0462_C0062 is a Coding
BBa_I0462_B0034 is a RBS

>>for i in subparts: print tc_getName(i) + " : "; print fromStrings( tc_annotation(i) );
BBa_I0462_B0012 :
('Reshma Shetty', 'NA', 'Transcription terminator for the E.coli RNA polymerase.', 'uri', 'reference')

BBa_I0462_B0010 :
('Randy Rettberg', '11/19/2003', 'Transcriptional terminator consisting of a 64 bp stem-loop', 'uri', 'reference')

BBa_I0462_C0062 :
('Vinay S Mahajan, Voichita D. Marinescu, Brian Chow, Alexander D Wissner-Gross and Peter Carr', '2003', 'luxR repressor/activator', 'uri', 'reference')

BBa_I0462_B0034 :
('Vinay S Mahajan, Voichita D. Marinescu, Brian Chow, Alexander D Wissner-Gross and Peter Carr', '2003', 'RBS based on Elowitz repressilator', 'uri', 'reference')

>>for i in subparts: print getName(i) + " : "; print getTextAttribute(i,"sequence");
BBa_I0462_B0012 :

BBa_I0462_B0010 :

BBa_I0462_C0062 :
aaagaggag ... ttctgcgtttata

BBa_I0462_B0034 :

>>print getParameter(subparts[3],"strength")