예제 #1
0
	def OnLeftUp(self, event):
		'''When left mouse button is lifted up, determine the DNA selection from angles generated at down an up events.'''
		amino_acid = self.HitTest()
		if amino_acid is not False:
			amino_acid = amino_acid.replace('2','')

			if amino_acid == 'reset': #special case to catch reset button
				self.codon = False
				self.target = []
				self.offtarget = []
				self.possible = []
				self.text_edit_active = False #exit text editing mode
			elif amino_acid == 'text': #special case to catch the codon edit region
				self.text_edit_active = True #switch to text editing mode
			elif amino_acid not in self.target:
				self.target.append(amino_acid)
				self.text_edit_active = False #exit text editing mode
			elif amino_acid in self.target:
				self.target.remove(amino_acid)
				self.text_edit_active = False #exit text editing mode
		else:
			self.text_edit_active = False #exit text editing mode
			
		if len(self.target)>0:
			self.codon, self.target, self.offtarget, self.possible = mbc.run(self.target)
		else:
			self.codon = False
			self.offtarget = []
			self.possible = []
		self.update_ownUI()
예제 #2
0
파일: codon_GUI.py 프로젝트: msGenDev/DNApy
	def OnLeftUp(self, event):
		'''When left mouse button is lifted up, determine the DNA selection from angles generated at down an up events.'''
		amino_acid = self.HitTest()
		if amino_acid is not False:
			amino_acid = amino_acid.replace('2','')

			if amino_acid not in self.target:
				self.target.append(amino_acid)
			elif amino_acid in self.target:
				self.target.remove(amino_acid)
			elif amino_acid == 'reset':
				self.codon = False
				self.target = []
				self.offtarget = []
				self.possible = []
			
		if len(self.target)>0:
			self.codon, self.target, self.offtarget, self.possible = mbc.run(self.target)
		else:
			self.codon = False
			self.offtarget = []
			self.possible = []
		self.update_ownUI()
예제 #3
0
	def OnToggle(self, evt):
		'''When any togglebutton is pressed'''
		AA = []
		clicked_color = '#A2CD5A'
		unclicked_color = '#EEEEEE'
		if self.Ala.GetValue(): 
			AA.append('A')
			self.Ala.SetBackgroundColour(clicked_color)
		else:
			self.Ala.SetBackgroundColour(unclicked_color)

		if self.Val.GetValue(): 
			AA.append('V')
			self.Val.SetBackgroundColour(clicked_color)
		else:
			self.Val.SetBackgroundColour(unclicked_color)

		if self.Ile.GetValue(): 
			AA.append('I')
			self.Ile.SetBackgroundColour(clicked_color)
		else:
			self.Ile.SetBackgroundColour(unclicked_color)

		if self.Leu.GetValue(): 
			AA.append('L')
			self.Leu.SetBackgroundColour(clicked_color)
		else:
			self.Leu.SetBackgroundColour(unclicked_color)

		if self.Met.GetValue(): 
			AA.append('M')
			self.Met.SetBackgroundColour(clicked_color)
		else:
			self.Met.SetBackgroundColour(unclicked_color)

		if self.Phe.GetValue(): 
			AA.append('F')
			self.Phe.SetBackgroundColour(clicked_color)
		else:
			self.Phe.SetBackgroundColour(unclicked_color)

		if self.Tyr.GetValue(): 
			AA.append('Y')
			self.Tyr.SetBackgroundColour(clicked_color)
		else:
			self.Tyr.SetBackgroundColour(unclicked_color)

		if self.Trp.GetValue(): 
			AA.append('W')
			self.Trp.SetBackgroundColour(clicked_color)
		else:
			self.Trp.SetBackgroundColour(unclicked_color)

		if self.Asp.GetValue(): 
			AA.append('D')
			self.Asp.SetBackgroundColour(clicked_color)
		else:
			self.Asp.SetBackgroundColour(unclicked_color)

		if self.Glu.GetValue(): 
			AA.append('E')
			self.Glu.SetBackgroundColour(clicked_color)
		else:
			self.Glu.SetBackgroundColour(unclicked_color)

		if self.Asn.GetValue(): 
			AA.append('N')
			self.Asn.SetBackgroundColour(clicked_color)
		else:
			self.Asn.SetBackgroundColour(unclicked_color)

		if self.Gln.GetValue(): 
			AA.append('Q')
			self.Gln.SetBackgroundColour(clicked_color)
		else:
			self.Gln.SetBackgroundColour(unclicked_color)

		if self.Ser.GetValue(): 
			AA.append('S')
			self.Ser.SetBackgroundColour(clicked_color)
		else:
			self.Ser.SetBackgroundColour(unclicked_color)

		if self.Thr.GetValue(): 
			AA.append('T')
			self.Thr.SetBackgroundColour(clicked_color)
		else:
			self.Thr.SetBackgroundColour(unclicked_color)

		if self.Arg.GetValue(): 
			AA.append('R')
			self.Arg.SetBackgroundColour(clicked_color)
		else:
			self.Arg.SetBackgroundColour(unclicked_color)

		if self.His.GetValue(): 
			AA.append('H')
			self.His.SetBackgroundColour(clicked_color)
		else:
			self.His.SetBackgroundColour(unclicked_color)

		if self.Lys.GetValue(): 
			AA.append('K')
			self.Lys.SetBackgroundColour(clicked_color)
		else:
			self.Lys.SetBackgroundColour(unclicked_color)

		if self.Cys.GetValue(): 
			AA.append('C')
			self.Cys.SetBackgroundColour(clicked_color)
		else:
			self.Cys.SetBackgroundColour(unclicked_color)

		if self.Gly.GetValue(): 
			AA.append('G')
			self.Gly.SetBackgroundColour(clicked_color)
		else:
			self.Gly.SetBackgroundColour(unclicked_color)

		if self.Pro.GetValue(): 
			AA.append('P')
			self.Pro.SetBackgroundColour(clicked_color)
		else:
			self.Pro.SetBackgroundColour(unclicked_color)

		if len(AA) > 0:
			codon, target, offtarget, possibleAA = mbc.run(AA)
			self.mixed_base_codon.SetReadOnly(False)
			self.mixed_base_codon.SetText(codon)
			self.mixed_base_codon.SetReadOnly(True)
			targetstring = ''
			for entry in target: #make string with the target AA
				if targetstring == '':
					targetstring += entry
				else:
					targetstring += ', '+entry
			offtargetstring = ''
			for entry in offtarget: #make string with the offtarget AA
				if offtargetstring == '':
					offtargetstring += entry
				else:
					offtargetstring += ', '+entry
			self.target_hits.SetLabel('Target amino acids: '+targetstring)
			self.offtarget_hits.SetLabel('Off-target amino acids: '+offtargetstring)	
	
	
			#set the yellow buttons to indicate which AA are possible without further off-target hits	
			possible_color = '#FFFF99'	
			if 'A' in possibleAA and self.Ala.GetValue() == False: 
				self.Ala.SetBackgroundColour(possible_color)

			if  'V' in possibleAA and self.Val.GetValue() == False: 
				self.Val.SetBackgroundColour(possible_color)

			if  'I' in possibleAA and self.Ile.GetValue() == False: 
				self.Ile.SetBackgroundColour(possible_color)

			if  'L' in possibleAA and self.Leu.GetValue() == False: 
				self.Leu.SetBackgroundColour(possible_color)

			if  'M' in possibleAA and self.Met.GetValue() == False: 
				self.Met.SetBackgroundColour(possible_color)

			if  'F' in possibleAA and self.Phe.GetValue() == False: 
				self.Phe.SetBackgroundColour(possible_color)

			if  'Y' in possibleAA and self.Tyr.GetValue() == False: 
				self.Tyr.SetBackgroundColour(possible_color)

			if  'W' in possibleAA and self.Trp.GetValue() == False: 
				self.Trp.SetBackgroundColour(possible_color)

			if  'D' in possibleAA and self.Asp.GetValue() == False: 
				self.Asp.SetBackgroundColour(possible_color)

			if  'E' in possibleAA and self.Glu.GetValue() == False: 
				self.Glu.SetBackgroundColour(possible_color)

			if  'N' in possibleAA and self.Asn.GetValue() == False: 
				self.Asn.SetBackgroundColour(possible_color)

			if  'Q' in possibleAA and self.Gln.GetValue() == False: 
				self.Gln.SetBackgroundColour(possible_color)

			if  'S' in possibleAA and self.Ser.GetValue() == False: 
				self.Ser.SetBackgroundColour(possible_color)

			if  'T' in possibleAA and self.Thr.GetValue() == False: 
				self.Thr.SetBackgroundColour(possible_color)

			if  'R' in possibleAA and self.Arg.GetValue() == False: 
				self.Arg.SetBackgroundColour(possible_color)

			if  'H' in possibleAA and self.His.GetValue() == False: 
				self.His.SetBackgroundColour(possible_color)

			if  'K' in possibleAA and self.Lys.GetValue() == False: 
				self.Lys.SetBackgroundColour(possible_color)

			if  'C' in possibleAA and self.Cys.GetValue() == False: 
				self.Cys.SetBackgroundColour(possible_color)

			if  'G' in possibleAA and self.Gly.GetValue() == False: 
				self.Gly.SetBackgroundColour(possible_color)

			if  'P' in possibleAA and self.Pro.GetValue() == False: 
				self.Pro.SetBackgroundColour(possible_color)

			#make list of all codons in degenerate triplet
			codonlist = dna.UnAmb(codon)
		
			#count how many times each AA is coded for by these codons
			self.AA_count = mbc.count_codon_list(codonlist)
		
			#plot graph
			self.update_plot()

		else:
			self.mixed_base_codon.SetReadOnly(False)
			self.mixed_base_codon.SetText('None')
			self.mixed_base_codon.SetReadOnly(True)
			self.target_hits.SetLabel('Target amino acids: ')
			self.offtarget_hits.SetLabel('Off-target amino acids: ')
			self.AA_count = {'A':0, 'C':0, 'E':0, 'D':0, 'G':0, 'F':0, 'I':0, 'H':0, 'K':0, 'M':0, 'L':0, 'N':0, 'Q':0, 'P':0, 'S':0, 'R':0, 'T':0, 'W':0, 'V':0, 'Y':0, 'stop':0}
			self.update_plot()	
예제 #4
0
    def OnToggle(self, evt):
        '''When any togglebutton is pressed'''
        AA = []
        clicked_color = '#A2CD5A'
        unclicked_color = '#EEEEEE'
        if self.Ala.GetValue():
            AA.append('A')
            self.Ala.SetBackgroundColour(clicked_color)
        else:
            self.Ala.SetBackgroundColour(unclicked_color)

        if self.Val.GetValue():
            AA.append('V')
            self.Val.SetBackgroundColour(clicked_color)
        else:
            self.Val.SetBackgroundColour(unclicked_color)

        if self.Ile.GetValue():
            AA.append('I')
            self.Ile.SetBackgroundColour(clicked_color)
        else:
            self.Ile.SetBackgroundColour(unclicked_color)

        if self.Leu.GetValue():
            AA.append('L')
            self.Leu.SetBackgroundColour(clicked_color)
        else:
            self.Leu.SetBackgroundColour(unclicked_color)

        if self.Met.GetValue():
            AA.append('M')
            self.Met.SetBackgroundColour(clicked_color)
        else:
            self.Met.SetBackgroundColour(unclicked_color)

        if self.Phe.GetValue():
            AA.append('F')
            self.Phe.SetBackgroundColour(clicked_color)
        else:
            self.Phe.SetBackgroundColour(unclicked_color)

        if self.Tyr.GetValue():
            AA.append('Y')
            self.Tyr.SetBackgroundColour(clicked_color)
        else:
            self.Tyr.SetBackgroundColour(unclicked_color)

        if self.Trp.GetValue():
            AA.append('W')
            self.Trp.SetBackgroundColour(clicked_color)
        else:
            self.Trp.SetBackgroundColour(unclicked_color)

        if self.Asp.GetValue():
            AA.append('D')
            self.Asp.SetBackgroundColour(clicked_color)
        else:
            self.Asp.SetBackgroundColour(unclicked_color)

        if self.Glu.GetValue():
            AA.append('E')
            self.Glu.SetBackgroundColour(clicked_color)
        else:
            self.Glu.SetBackgroundColour(unclicked_color)

        if self.Asn.GetValue():
            AA.append('N')
            self.Asn.SetBackgroundColour(clicked_color)
        else:
            self.Asn.SetBackgroundColour(unclicked_color)

        if self.Gln.GetValue():
            AA.append('Q')
            self.Gln.SetBackgroundColour(clicked_color)
        else:
            self.Gln.SetBackgroundColour(unclicked_color)

        if self.Ser.GetValue():
            AA.append('S')
            self.Ser.SetBackgroundColour(clicked_color)
        else:
            self.Ser.SetBackgroundColour(unclicked_color)

        if self.Thr.GetValue():
            AA.append('T')
            self.Thr.SetBackgroundColour(clicked_color)
        else:
            self.Thr.SetBackgroundColour(unclicked_color)

        if self.Arg.GetValue():
            AA.append('R')
            self.Arg.SetBackgroundColour(clicked_color)
        else:
            self.Arg.SetBackgroundColour(unclicked_color)

        if self.His.GetValue():
            AA.append('H')
            self.His.SetBackgroundColour(clicked_color)
        else:
            self.His.SetBackgroundColour(unclicked_color)

        if self.Lys.GetValue():
            AA.append('K')
            self.Lys.SetBackgroundColour(clicked_color)
        else:
            self.Lys.SetBackgroundColour(unclicked_color)

        if self.Cys.GetValue():
            AA.append('C')
            self.Cys.SetBackgroundColour(clicked_color)
        else:
            self.Cys.SetBackgroundColour(unclicked_color)

        if self.Gly.GetValue():
            AA.append('G')
            self.Gly.SetBackgroundColour(clicked_color)
        else:
            self.Gly.SetBackgroundColour(unclicked_color)

        if self.Pro.GetValue():
            AA.append('P')
            self.Pro.SetBackgroundColour(clicked_color)
        else:
            self.Pro.SetBackgroundColour(unclicked_color)

        if len(AA) > 0:
            codon, target, offtarget, possibleAA = mbc.run(AA)
            self.mixed_base_codon.SetReadOnly(False)
            self.mixed_base_codon.SetText(codon)
            self.mixed_base_codon.SetReadOnly(True)
            targetstring = ''
            for entry in target:  #make string with the target AA
                if targetstring == '':
                    targetstring += entry
                else:
                    targetstring += ', ' + entry
            offtargetstring = ''
            for entry in offtarget:  #make string with the offtarget AA
                if offtargetstring == '':
                    offtargetstring += entry
                else:
                    offtargetstring += ', ' + entry
            self.target_hits.SetLabel('Target amino acids: ' + targetstring)
            self.offtarget_hits.SetLabel('Off-target amino acids: ' +
                                         offtargetstring)

            #set the yellow buttons to indicate which AA are possible without further off-target hits
            possible_color = '#FFFF99'
            if 'A' in possibleAA and self.Ala.GetValue() == False:
                self.Ala.SetBackgroundColour(possible_color)

            if 'V' in possibleAA and self.Val.GetValue() == False:
                self.Val.SetBackgroundColour(possible_color)

            if 'I' in possibleAA and self.Ile.GetValue() == False:
                self.Ile.SetBackgroundColour(possible_color)

            if 'L' in possibleAA and self.Leu.GetValue() == False:
                self.Leu.SetBackgroundColour(possible_color)

            if 'M' in possibleAA and self.Met.GetValue() == False:
                self.Met.SetBackgroundColour(possible_color)

            if 'F' in possibleAA and self.Phe.GetValue() == False:
                self.Phe.SetBackgroundColour(possible_color)

            if 'Y' in possibleAA and self.Tyr.GetValue() == False:
                self.Tyr.SetBackgroundColour(possible_color)

            if 'W' in possibleAA and self.Trp.GetValue() == False:
                self.Trp.SetBackgroundColour(possible_color)

            if 'D' in possibleAA and self.Asp.GetValue() == False:
                self.Asp.SetBackgroundColour(possible_color)

            if 'E' in possibleAA and self.Glu.GetValue() == False:
                self.Glu.SetBackgroundColour(possible_color)

            if 'N' in possibleAA and self.Asn.GetValue() == False:
                self.Asn.SetBackgroundColour(possible_color)

            if 'Q' in possibleAA and self.Gln.GetValue() == False:
                self.Gln.SetBackgroundColour(possible_color)

            if 'S' in possibleAA and self.Ser.GetValue() == False:
                self.Ser.SetBackgroundColour(possible_color)

            if 'T' in possibleAA and self.Thr.GetValue() == False:
                self.Thr.SetBackgroundColour(possible_color)

            if 'R' in possibleAA and self.Arg.GetValue() == False:
                self.Arg.SetBackgroundColour(possible_color)

            if 'H' in possibleAA and self.His.GetValue() == False:
                self.His.SetBackgroundColour(possible_color)

            if 'K' in possibleAA and self.Lys.GetValue() == False:
                self.Lys.SetBackgroundColour(possible_color)

            if 'C' in possibleAA and self.Cys.GetValue() == False:
                self.Cys.SetBackgroundColour(possible_color)

            if 'G' in possibleAA and self.Gly.GetValue() == False:
                self.Gly.SetBackgroundColour(possible_color)

            if 'P' in possibleAA and self.Pro.GetValue() == False:
                self.Pro.SetBackgroundColour(possible_color)

            #make list of all codons in degenerate triplet
            codonlist = dna.UnAmb(codon)

            #count how many times each AA is coded for by these codons
            self.AA_count = mbc.count_codon_list(codonlist)

            #plot graph
            self.update_plot()

        else:
            self.mixed_base_codon.SetReadOnly(False)
            self.mixed_base_codon.SetText('None')
            self.mixed_base_codon.SetReadOnly(True)
            self.target_hits.SetLabel('Target amino acids: ')
            self.offtarget_hits.SetLabel('Off-target amino acids: ')
            self.AA_count = {
                'A': 0,
                'C': 0,
                'E': 0,
                'D': 0,
                'G': 0,
                'F': 0,
                'I': 0,
                'H': 0,
                'K': 0,
                'M': 0,
                'L': 0,
                'N': 0,
                'Q': 0,
                'P': 0,
                'S': 0,
                'R': 0,
                'T': 0,
                'W': 0,
                'V': 0,
                'Y': 0,
                'stop': 0
            }
            self.update_plot()