Ejemplo n.º 1
0
    def test_circuitWithGenes(self):
        circuit = makeFullTestCircuit()
        self.assertEqual(circuit.printAllPartsWithGeneNames()['TOP'],
                         ['P', 'i', 'T'])
        self.assertEqual(circuit.printAllPartsWithGeneNames()['BOTTOM'],
                         ['t', 'P', 'G.3.1', 'i', 't'])

        circuit1 = enz.induceCircuit(enzyme1, circuit)
        self.assertEqual(circuit1.printAllPartsWithGeneNames()['TOP'],
                         ['P', 't', 'P', 'G.3.1', 'i'])
        self.assertEqual(circuit1.printAllPartsWithGeneNames()['BOTTOM'],
                         ['i', 'T', 't'])

        circuit2 = enz.induceCircuit(enzyme2, circuit1)
        self.assertEqual(circuit2.printAllPartsWithGeneNames()['TOP'],
                         ['P', 'T', 'G.3.1', 'i'])
        self.assertEqual(circuit2.printAllPartsWithGeneNames()['BOTTOM'],
                         ['i', 't', 'P', 't'])

        circuit3 = enz.induceCircuit(enzyme2, circuit)
        self.assertEqual(circuit3.printAllPartsWithGeneNames()['TOP'],
                         ['P', 'i'])
        self.assertEqual(circuit3.printAllPartsWithGeneNames()['BOTTOM'],
                         ['G.3.1', 'i', 't'])

        circuit4 = enz.induceCircuit(enzyme1, circuit3)
        self.assertEqual(circuit4.printAllPartsWithGeneNames()['TOP'],
                         ['P', 'G.3.1', 'i'])
        self.assertEqual(circuit4.printAllPartsWithGeneNames()['BOTTOM'],
                         ['i', 't'])
Ejemplo n.º 2
0
 def test_circuit_path2(self):
     circuit2 = makeCircuit3State()
     
     ##The original circuit
     self.assertEqual(circuit2.printCircuit(), [1,'D',2,'[',3,'(',4,'-[',5,'(',6,'-D',7])
             
     ##Circuit when exposed to Ara
     circuitC = enz.induceCircuit(enzyme1, circuit2)
     self.assertEqual(circuitC.printCircuit(), [1,'D',-6,'-(',-5,'[',3,'(',4,'-[',-2,'-D',7])
     
     ##Circuit when exposed to ATc after Ara
     circuitD = enz.induceCircuit(enzyme2, circuitC)
     self.assertEqual(circuitD.printCircuit(), [1,'D',-6,'-(',-3,'-[',5,'(',4,'-[',-2,'-D',7])
Ejemplo n.º 3
0
    def test_circuit_path1(self):
        circuit1 = makeCircuit3State()
        
        ##The original circuit
        self.assertEqual(circuit1.printCircuit(), [1,'D',2,'[',3,'(',4,'-[',5,'(',6,'-D',7])

        ##Circuit when exposed to ATc
        circuitA = enz.induceCircuit(enzyme2, circuit1)
        self.assertEqual(circuitA.printCircuit(), [1,'D',2,'[',3,'(',6,'-D',7])
        
        ##Curcuit when exposed to Ara after ATc
        circuitB = enz.induceCircuit(enzyme1, circuitA)
        self.assertEqual(circuitB.printCircuit(), [1,'D',-6,'-(',-3,'-[',-2,'-D',7])
Ejemplo n.º 4
0
    def test_circuitWith3Genes(self):
        circuit = make3GeneTestCircuit()
        self.assertEqual(circuit.printOnlyExpressed(), ['G.5.1', 'G.7.1'])

        circuit1 = enz.induceCircuit(enzyme1, circuit)
        self.assertEqual(circuit1.printOnlyExpressed(), ['G.7.1'])

        circuit2 = enz.induceCircuit(enzyme2, circuit1)
        self.assertEqual(circuit2.printOnlyExpressed(), ['G.7.1', 'G.1.1'])

        circuit3 = enz.induceCircuit(enzyme2, circuit)
        self.assertEqual(circuit3.printOnlyExpressed(), ['G.5.1'])

        circuit4 = enz.induceCircuit(enzyme1, circuit3)
        self.assertEqual(circuit4.printOnlyExpressed(), ['G.5.1', 'G.1.1'])
Ejemplo n.º 5
0
    def test_simpleCircuit(self):
        ##Create the circuit
        circuit = makeSimpleCicuit()

        self.assertEqual(circuit.printCircuit(), [1,'D',2,'-D',3])
        newCircuit = enz.induceCircuit(enzyme1,circuit)
        self.assertEqual(newCircuit.printCircuit(), [1,'D',-2,'-D',3])
Ejemplo n.º 6
0
    def test_3StateCircuit(self):
        circuit = makeCircuit3State()

        self.assertEqual(
            circuit.printCircuit(),
            [5, 'D', 5, '[', 1, '(', -7, '-[', 5, '(', -10, '-D', -10])
        self.assertEqual(circuit.printAllParts()['TOP'], ['G', 'i'])
        self.assertEqual(circuit.printAllParts()['BOTTOM'],
                         ['P', 'P', 'T', 'i'])

        ##Induce the circuit with enzyme1 and validate
        circuit1 = enz.induceCircuit(enzyme1, circuit)
        self.assertEqual(
            circuit1.printCircuit(),
            [5, 'D', 10, '-(', -5, '[', 1, '(', -7, '-[', -5, '-D', -10])
        self.assertEqual(circuit1.printAllParts()['TOP'], ['P', 'G', 'i'])
        self.assertEqual(circuit1.printAllParts()['BOTTOM'], ['P', 'T', 'i'])

        ##Induce the circuit with enzyme2 and validate
        circuit2 = enz.induceCircuit(enzyme2, circuit1)
        self.assertEqual(
            circuit2.printCircuit(),
            [5, 'D', 10, '-(', -1, '-[', 5, '(', -7, '-[', -5, '-D', -10])
        self.assertEqual(circuit2.printAllParts()['TOP'], ['P', 'i'])
        self.assertEqual(circuit2.printAllParts()['BOTTOM'],
                         ['P', 'T', 'G', 'i'])

        ##Induce the circuit with enzyme2 and validate that it is correct
        circuit3 = enz.induceCircuit(enzyme2, circuit)
        self.assertEqual(circuit3.printCircuit(),
                         [5, 'D', 5, '[', 1, '(', -10, '-D', -10])
        self.assertEqual(circuit3.printAllParts()['TOP'], ['G', 'i'])
        self.assertEqual(circuit3.printAllParts()['BOTTOM'], ['P', 'P', 'i'])

        ##Inducde the circuit with enzyme1 and validate it
        circuit4 = enz.induceCircuit(enzyme1, circuit3)
        self.assertEqual(circuit4.printCircuit(),
                         [5, 'D', 10, '-(', -1, '-[', -5, '-D', -10])
        self.assertEqual(circuit4.printAllParts()['TOP'], ['P', 'i'])
        self.assertEqual(circuit4.printAllParts()['BOTTOM'], ['P', 'G', 'i'])
Ejemplo n.º 7
0
def build5StateCircuit(parts):
    ##Create the recombination sites
    site1 = rs.RecognitionSite('D', 1)
    site2 = rs.RecognitionSite('[', 1)
    site3 = rs.RecognitionSite('(', 1)
    site4 = rs.RecognitionSite('[', -1)
    site5 = rs.RecognitionSite('(', 1)
    site6 = rs.RecognitionSite('D', -1)

    sites = [site1, site2, site3, site4, site5, site6]

    ##Instantiate the circuit
    circuit = gc.GeneticCircuit([])
    numberOfParts = len(parts)

    for pI in range(numberOfParts):
        ##p is a number
        if parts[pI] < 0:
            circuit.addComponent(part.Part(abs(parts[pI]), -1))
        else:
            circuit.addComponent(part.Part(parts[pI], 1))

        ##Add the site as long as its not the last part
        if (pI + 1 < numberOfParts):
            circuit.addComponent(sites[pI])

    ##Want to return all the induced circuits as well
    enzyme1 = enz.Enzyme('ATc')
    enzyme1.addSiteToRecognize('(')
    enzyme2 = enz.Enzyme('Ara')
    enzyme2.addSiteToRecognize('[')
    enzyme2.addSiteToRecognize('D')

    c1 = circuit
    c2 = enz.induceCircuit(enzyme1, c1)
    c3 = enz.induceCircuit(enzyme2, c1)
    c4 = enz.induceCircuit(enzyme2, c2)
    c5 = enz.induceCircuit(enzyme1, c3)

    return [c1, c2, c3, c4, c5]
Ejemplo n.º 8
0
    def test_simpleCircuit(self):
        ##Create the circuit
        circuit = makeSimpleCircuit()

        self.assertEqual(circuit.printCircuit(), [1, 'D', 2, '-D', 3])
        ##Check the the expression profile is as expected
        self.assertEqual(circuit.printAllParts()['TOP'],
                         ['G', 'i', 'G', 'P', 't', 'P'])
        self.assertEqual(circuit.printAllParts()['BOTTOM'], ['T', 'i', 'i'])
        self.assertEqual(circuit.printOnlyExpressed(), [])

        circuit1 = enz.induceCircuit(enzyme1, circuit)
        self.assertEqual(circuit1.printAllParts()['TOP'],
                         ['G', 'i', 'i', 't', 'P'])
        self.assertEqual(circuit1.printAllParts()['BOTTOM'],
                         ['T', 'G', 'P', 'i'])
Ejemplo n.º 9
0
circuit.addComponent(part1_1)
circuit.addComponent(site1)
circuit.addComponent(part2_1)
circuit.addComponent(site2)
circuit.addComponent(part3_1)
circuit.addComponent(site3)
circuit.addComponent(part4_1)
circuit.addComponent(site4)
circuit.addComponent(part5_1)
circuit.addComponent(site5)
circuit.addComponent(part6_1)
circuit.addComponent(site6)
circuit.addComponent(part7_1)

c2 = enz.induceCircuit(enzyme1, circuit)
c3 = enz.induceCircuit(enzyme2, circuit)
c4 = enz.induceCircuit(enzyme2, c2)
c5 = enz.induceCircuit(enzyme1, c3)

# print circuit.printAllPartsWithGeneNames()
# print c2.printAllPartsWithGeneNames()
# print c3.printAllPartsWithGeneNames()
# print c4.printAllPartsWithGeneNames()
# print c5.printAllPartsWithGeneNames()

# print circuit.printCircuit(excludeRecombinationSites=True)
# print c2.printCircuit(excludeRecombinationSites=True)
# print c3.printCircuit(excludeRecombinationSites=True)
# print c4.printCircuit(excludeRecombinationSites=True)
# print c5.printCircuit(excludeRecombinationSites=True)
Ejemplo n.º 10
0
def build16StateCircuit(parts,
                        includeAllCircuits=True,
                        includeTheseCircuits={},
                        compareTo=[],
                        getPromsAndTerms=False):
    ##Create the recombination sites
    ##TP901 sites: F,O
    ##BxbI sites: X, I
    ##A118 sites: A, B
    comparingToLength = len(compareTo)

    site1 = rs.RecognitionSite('X', 1)
    site2 = rs.RecognitionSite('O', 1)
    site3 = rs.RecognitionSite('X', -1)
    site4 = rs.RecognitionSite('O', 1)
    site5 = rs.RecognitionSite('A', 1)
    site6 = rs.RecognitionSite('I', 1)
    site7 = rs.RecognitionSite('A', -1)
    site8 = rs.RecognitionSite('I', 1)
    site9 = rs.RecognitionSite('F', 1)
    site10 = rs.RecognitionSite('B', 1)
    site11 = rs.RecognitionSite('F', -1)
    site12 = rs.RecognitionSite('B', 1)

    sites = [
        site1, site2, site3, site4, site5, site6, site7, site8, site9, site10,
        site11, site12
    ]

    ##Instantiate the circuit
    circuit = gc.GeneticCircuit([])
    numberOfParts = len(parts)
    partsWithPromotersInThem = {}
    partsWithTerminatorsInThem = {}
    allCircuits = [None for i in xrange(16)]

    for pI in range(numberOfParts):
        ##p is a number
        addedComp = None
        if parts[pI] < 0:
            posPartId = abs(parts[pI])
            addedComp = circuit.addComponent(part.Part(posPartId, -1))
        else:
            addedComp = circuit.addComponent(part.Part(parts[pI], 1))

        ##Attempting to remove redundant circuits
        if addedComp.getId() not in part.PARTSWITHOUTPROMOTERS:
            partsWithPromotersInThem[addedComp.getPartLocation()] = True

        ##Using the incomplete array because we are only considering part 4 for
        ##now as a potential redundant terminator part
        if addedComp.getId() in part.PARTSWITHTERMINTAORS_INCOMPLETE:
            #if addedComp.getId() in part.PARTSWITHTERMINTAORS:
            partsWithTerminatorsInThem[addedComp.getPartLocation()] = True

        ##Add the site as long as its not the last part
        if (pI + 1 < numberOfParts):
            circuit.addComponent(sites[pI])

    if includeAllCircuits:
        ##Want to return all the induced circuits as well
        enzyme1 = enz.Enzyme('BxbI')
        enzyme1.addSiteToRecognize('X')
        enzyme1.addSiteToRecognize('I')
        enzyme2 = enz.Enzyme('TP901')
        enzyme2.addSiteToRecognize('F')
        enzyme2.addSiteToRecognize('O')
        enzyme3 = enz.Enzyme('A118')
        enzyme3.addSiteToRecognize('A')
        enzyme3.addSiteToRecognize('B')
        c1 = circuit
        c2 = enz.induceCircuit(enzyme1, c1)
        c3 = enz.induceCircuit(enzyme2, c1)
        c4 = enz.induceCircuit(enzyme3, c1)

        c5 = enz.induceCircuit(enzyme2, c2)
        c6 = enz.induceCircuit(enzyme3, c2)

        c7 = enz.induceCircuit(enzyme1, c3)
        c8 = enz.induceCircuit(enzyme3, c3)

        c9 = enz.induceCircuit(enzyme1, c4)
        c10 = enz.induceCircuit(enzyme2, c4)

        c11 = enz.induceCircuit(enzyme3, c5)
        c12 = enz.induceCircuit(enzyme2, c6)

        c13 = enz.induceCircuit(enzyme3, c7)
        c14 = enz.induceCircuit(enzyme1, c8)

        c15 = enz.induceCircuit(enzyme2, c9)
        c16 = enz.induceCircuit(enzyme1, c10)

        allCircuits = [
            c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15,
            c16
        ]
        if getPromsAndTerms:
            return {
                'allCircuits': allCircuits,
                'partsWithPromotersInThem': partsWithPromotersInThem,
                'partsWithTerminatorsInThem': partsWithTerminatorsInThem
            }
        else:
            return allCircuits

    elif len(includeTheseCircuits) > 0:
        ##Want to return only a subset of the circuits
        enzyme1 = enz.Enzyme('BxbI')
        enzyme1.addSiteToRecognize('X')
        enzyme1.addSiteToRecognize('I')
        enzyme2 = enz.Enzyme('TP901')
        enzyme2.addSiteToRecognize('F')
        enzyme2.addSiteToRecognize('O')
        enzyme3 = enz.Enzyme('A118')
        enzyme3.addSiteToRecognize('A')
        enzyme3.addSiteToRecognize('B')

        enzymes = [enzyme1, enzyme2, enzyme3]
        parentCircuit = [None, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9]
        inducingEnzyme = [None, 0, 1, 2, 1, 2, 0, 2, 0, 1, 2, 1, 2, 0, 1, 0]

        for i in xrange(len(allCircuits)):
            if len(includeTheseCircuits) > 0:
                if (i + 1) not in includeTheseCircuits:
                    continue
            if i == 0:
                if comparingToLength > 0:
                    if getNumberOfGenesExpressedForCircuit([circuit
                                                            ]) != compareTo[i]:
                        return False
                allCircuits[0] = circuit
            else:
                allCircuits[i] = enz.induceCircuit(
                    enzymes[inducingEnzyme[i]], allCircuits[parentCircuit[i]])
                if comparingToLength > 0:
                    if getNumberOfGenesExpressedForCircuit([allCircuits[i]
                                                            ]) != compareTo[i]:
                        return False
        return allCircuits
    else:
        return [circuit]