Example #1
0
    def annotate(self, biobrickName):
        biobrickName = biobrickName.encode('utf-8')
        currentName = tc_getName(self.currentPart)

        def replace():  # rename the part
            currentName = biobrickName
            tc_rename(self.currentPart, currentName)

        def label():  # just add an overlay showing the biobrick name
            tc_displayText(self.currentPart, biobrickName)
            tc_setDisplayLabelColor(ANNOTATOR_HIGHLIGHTCOLOR, "#000000")

        if currentName.rstrip(
                "1234567890") in TC_DEFAULT_NAMES:  # set by tinkercell
            replace()
        elif registry.isBiobrickName(currentName):  # probably set by wikidust
            if biobrickName.find(
                    currentName) != -1:  # nevermind, short name by user
                label()
            else:
                replace()
        else:  # custom name by user
            label()
        #tc_setTextAttribute(self.currentPart, "biobrickname", biobrickName) #redundant?
        partInfo = registry.PartInfo(biobrickName)
        # read annotation from a list
        annotationList = fromTC(tc_getTextData(self.currentPart, "annotation"))
        annotationDict = {}
        keys = annotationList[0]  #row names
        values = annotationList[2][0]  #first column
        for index in range(len(keys)):
            annotationDict[keys[index]] = values[index]
        # add info to annotation
        for attribute in partInfo:
            #TODO add other stuff as text attributes?
            if not attribute in REGISTRY_2_TC or not REGISTRY_2_TC[
                    attribute] in annotationDict:
                pass  #print "skipping %s because it's not implemented" % attribute
            #elif annotationDict[ REGISTRY_2_TC[attribute] ] != "":
            #    pass #print "skipping %s because it's already set" % attribute
            else:  # ready to add attribute
                annotationDict[REGISTRY_2_TC[attribute]] = partInfo[attribute]
                #print "%s.%s = %s" % (currentName, REGISTRY_2_TC[attribute], partInfo[attribute])
        # flatten back into a list and save
        annotationList = []
        rownames = []
        for key in annotationDict.keys():
            rownames.append(key)
            annotationList.append(annotationDict[key])
        #print annotationList
        tc_setTextData(self.currentPart, "annotation",
                       toTC([annotationList], rows=rownames))
        try:
            sequence = partInfo["seq_data"]
            sequence = sequence.replace(" ", "")
            #print sequence
            #tc_setSequence(self.currentPart, sequence)
        except KeyError:  # no sequence
            pass
Example #2
0
 def annotate(self, biobrickName):
     biobrickName = biobrickName.encode('utf-8')
     currentName  = tc_getName(self.currentPart)
     def replace(): # rename the part
         currentName = biobrickName
         tc_rename(self.currentPart, currentName)
     def label(): # just add an overlay showing the biobrick name
         tc_displayText(self.currentPart, biobrickName)
         tc_setDisplayLabelColor(ANNOTATOR_HIGHLIGHTCOLOR, "#000000")
     if currentName.rstrip("1234567890") in TC_DEFAULT_NAMES: # set by tinkercell
         replace()
     elif registry.isBiobrickName(currentName): # probably set by wikidust
         if biobrickName.find(currentName) != -1: # nevermind, short name by user
             label()
         else:
             replace()
     else: # custom name by user
         label()
     #tc_setTextAttribute(self.currentPart, "biobrickname", biobrickName) #redundant?
     partInfo = registry.PartInfo(biobrickName)
     # read annotation from a list
     annotationList = fromTC( tc_getTextData(self.currentPart,"annotation") )
     annotationDict = {}
     keys   = annotationList[0] #row names
     values = annotationList[2][0] #first column
     for index in range( len(keys) ):
         annotationDict[ keys[index] ] = values[index]
     # add info to annotation
     for attribute in partInfo:
         #TODO add other stuff as text attributes?
         if not attribute in REGISTRY_2_TC or not REGISTRY_2_TC[attribute] in annotationDict:
             pass #print "skipping %s because it's not implemented" % attribute
         #elif annotationDict[ REGISTRY_2_TC[attribute] ] != "":
         #    pass #print "skipping %s because it's already set" % attribute
         else: # ready to add attribute
             annotationDict[ REGISTRY_2_TC[attribute] ] = partInfo[attribute]
             #print "%s.%s = %s" % (currentName, REGISTRY_2_TC[attribute], partInfo[attribute]) 
     # flatten back into a list and save
     annotationList = []
     rownames = []
     for key in annotationDict.keys():
         rownames.append(key)
         annotationList.append( annotationDict[key] )
     #print annotationList
     tc_setTextData(self.currentPart, "annotation", toTC([annotationList], rows=rownames))
     try:
         sequence = partInfo["seq_data"]
         sequence = sequence.replace(" ", "")
         #print sequence
         #tc_setSequence(self.currentPart, sequence)
     except KeyError: # no sequence
         pass
Example #3
0
def runTests():
    testNames = ("BBa_F2620", "f2620", "jerry", "ffg34", "g435", "g3454",
                 "bba_f2620", "bBa f4354")
    for name in testNames:
        print "%s is a biobrick name: %s" % (name,
                                             registry.isBiobrickName(name))
Example #4
0
def runTests():
    testNames = ("BBa_F2620", "f2620", "jerry", "ffg34",
                 "g435", "g3454", "bba_f2620", "bBa f4354")
    for name in testNames:
        print "%s is a biobrick name: %s" % (name, registry.isBiobrickName(name))