示例#1
0
	def AnnotateSingleAb(self,inSeqID, inProteinSeq,inDNAseq):
                if not inProteinSeq and  not inDNAseq:
        	        return ""

               #initiate the FR1,CDR1,FR2,CDR2,FR3,CDR3,FR4 to emtry, just in case any can't be found
                self._dict[inSeqID].update({'FR1-PRO':"",'CDR1-PRO':'','FR2-PRO':'','CDR2-PRO':'',"FR3-PRO":'','CDR3-PRO':'','FR4-PRO':'','FV-PRO':''})
                self._dict[inSeqID].update({'FR1-DNA':"",'CDR1-DNA':'','FR2-DNA':'','CDR2-DNA':'',"FR3-DNA":'','CDR3-DNA':'','FR4-DNA':'','FV-DNA':''})

		count_missing_fragment =0
		for x in ("FR1","CDR1","FR2",'CDR2','FR3','CDR3'):
			try: 
				#pdb.set_trace()
				dna_frag= inDNAseq[self._dict[inSeqID][x+"head_pos"]-1:self._dict[inSeqID][x+'tail_pos']]
				#print "DNA_frag : "  + dna_frag
				#print "PRO_Frag : " + translator.translate_dna_single(dna_frag)
				self._dict[inSeqID].update({x+'-DNA': dna_frag})
				self._dict[inSeqID].update({x+'-PRO':translator.translate_dna_single(dna_frag)})	
			except: 
				print "IgBlastn couldn't find: "+ inSeqID + ':' + x
				count_missing_fragment += 1
				if count_missing_fragment > 2:
					print "Warining! missing the some fragmentation from IgBlastn in this sequence:"
					print inDNAseq
					return 

							
		FR1head=self.find_high_PMW_score(self._pwmFR1head,inProteinSeq)
		FR1head_pos=inProteinSeq.find(FR1head)

		#print "start to find FR2"
		try :
			FR1tail_pos=self._dict[inSeqID]["FR1tail_pos"]/3 -1
		except: 
			FR1tail=self.find_high_PMW_score(self._pwmFR1tail,inProteinSeq[FR1head_pos:])
			FR1tail_pos=inProteinSeq.find(FR1tail)+len(FR1tail)-1

		new_FR1protein=inProteinSeq[FR1head_pos:FR1tail_pos+1]
		new_FR1dna= translator.convertPROtoDNA(inDNAseq,FR1head_pos,FR1tail_pos+1)
		if len(new_FR1dna)>=len(self._dict[inSeqID]['FR1-DNA']):
			self._dict[inSeqID].update({'FR1-PRO':new_FR1protein})	
			self._dict[inSeqID].update({'FR1-DNA':new_FR1dna})
		'''
		try:
			FR2head=self.find_high_PMW_score(self._pwmFR2head,inProteinSeq[FR1tail_pos:])
			FR2head_pos=inProteinSeq.find(FR2head)
			self._dict[inSeqID].update({'CDR1-PRO':inProteinSeq[FR1tail_pos+1:FR2head_pos]})
			self._dict[inSeqID].update({'CDR1-DNA':translator.convertPROtoDNA(inDNAseq,FR1tail_pos+1,FR2head_pos)})
		except:
			return
		'''

		try :
                        FR2head_pos=(self._dict[inSeqID]["FR2head_pos"]-1)/3
		except:
			FR2head=self.find_high_PMW_score(self._pwmFR2head,inProteinSeq[FR1tail_pos:])
			FR2head_pos=inProteinSeq.find(FR2head)
		if self._dict[inSeqID]["FR2-DNA"] !='':
			pass	
                elif FR1tail_pos and FR2head_pos :
			self._dict[inSeqID].update({'CDR1-PRO':inProteinSeq[FR1tail_pos+1:FR2head_pos]})
                	self._dict[inSeqID].update({'CDR1-DNA':translator.convertPROtoDNA(inDNAseq,FR1tail_pos+1,FR2head_pos)})

		try : 
			FR2tail_pos= (self._dict[inSeqID]["CDR2head_pos"]-1)/3 -1
		except:
			FR2tail=self.find_high_PMW_score(self._pwmFR2tail,inProteinSeq[FR2head_pos:])
			FR2tail_pos=inProteinSeq.find(FR2tail)+len(FR2tail)-1
		if self._dict[inSeqID]["FR2-DNA"] != '' :
                        pass
		elif FR2head_pos and FR2tail_pos:
			self._dict[inSeqID].update({'FR2-PRO':inProteinSeq[FR2head_pos:FR2tail_pos+1]})
			self._dict[inSeqID].update({'FR2-DNA':translator.convertPROtoDNA(inDNAseq,FR2head_pos,FR2tail_pos+1)})
		#print "FR2 tail:" + FR2tail
		#print FR2tail_pos

		try :
			FR3head_pos= (self._dict[inSeqID]["FR3head_pos"]-1)/3 -1
		except:
			FR3head=self.find_high_PMW_score(self._pwmFR3head,inProteinSeq[FR2tail_pos:])
			FR3head_pos=inProteinSeq.find(FR3head)
		if self._dict[inSeqID]["CDR2-DNA"] !='' :
			pass
		elif FR2tail_pos and FR3head :
			self._dict[inSeqID].update({'CDR2-PRO':inProteinSeq[FR2tail_pos+1:FR3head_pos]})
			self._dict[inSeqID].update({'CDR2-DNA':translator.convertPROtoDNA(inDNAseq,FR2tail_pos+1,FR3head_pos)})
		#print "FR3head :" + FR3head
		#print FR3head_pos

		try:
			FR3tail_pos= (self._dict[inSeqID]["CDR3head_pos"]-1)/3 -1
		except: 
			FR3tail=self.find_high_PMW_score(self._pwmFR3tail,inProteinSeq[FR3head_pos:])
			FR3tail_pos=inProteinSeq.find(FR3tail)+len(FR3tail)-1
		if self._dict[inSeqID]["FR3-DNA"] !='' !='':
			pass
		elif FR3head_pos and FR3tail_pos :
			#new_FR3protein= inProteinSeq[FR3head_pos:FR3tail_pos]
			#new_FR3dna = translator.convertPROtoDNA(inDNAseq,,FR3head_pos, FR3tail_pos])
			self._dict[inSeqID].update({'FR3-PRO':inProteinSeq[FR3head_pos:FR3tail_pos+1]})
			self._dict[inSeqID].update({'FR3-DNA':translator.convertPROtoDNA(inDNAseq,FR3head_pos,FR3tail_pos+1)})

		try:
			FR4head_pos = self._dict[inSeqID]["CD3tail_pos"]/3
		except:
			FR4head=self.find_high_PMW_score(self._pwmFR4head,inProteinSeq[FR3tail_pos:])
			FR4head_pos=inProteinSeq.find(FR4head)
		new_CDR3protein= inProteinSeq[FR3tail_pos+1:FR4head_pos]
		new_FR3dna= translator.convertPROtoDNA(inDNAseq,FR3tail_pos+1,FR4head_pos)
		if FR3tail_pos and FR4head_pos and len(new_FR3dna)> len(self._dict[inSeqID]["CDR3-DNA"]):	
			self._dict[inSeqID].update({'CDR3-PRO':inProteinSeq[FR3tail_pos+1:FR4head_pos]})
			self._dict[inSeqID].update({'CDR3-DNA':translator.convertPROtoDNA(inDNAseq,FR3tail_pos+1,FR4head_pos)})
		#pdb.set_trace()
		FR4tail=self.find_high_PMW_score(self._pwmFR4head,inProteinSeq[FR3tail_pos:])
		FR4tail_pos=inProteinSeq.find(FR4tail)+len(FR4tail)-1
		if FR4head and FR4tail:
			self._dict[inSeqID].update({'FR4-PRO':inProteinSeq[FR4head_pos:FR4tail_pos+1]})
			self._dict[inSeqID].update({'FR4-DNA':translator.convertPROtoDNA(inDNAseq,FR4head_pos,FR4tail_pos+1)})
		elif FR4head:
			self._dict[inSeqID].update({'FR4-PRO':FR4head})
			self._dict[inSeqID].update({'FR4-DNA':translator.convertPROtoDNA(inDNAseq,FR4head_pos,len(inProteinSeq))})
		else:
			self._dict[inSeqID].update({'FR4-PRO':''})
			self._dict[inSeqID].update({'FR4-DNA':''})

		FVpro =self._dict[inSeqID]["FR1-PRO"]+self._dict[inSeqID]["CDR1-PRO"]+self._dict[inSeqID]["FR2-PRO"]+self._dict[inSeqID]["CDR2-PRO"]+self._dict[inSeqID]["FR3-PRO"]+self._dict[inSeqID]["CDR3-PRO"]+self._dict[inSeqID]["FR4-PRO"]
		self._dict[inSeqID].update({'FV-PRO': FVpro })
		FVdna=self._dict[inSeqID]["FR1-DNA"]+self._dict[inSeqID]["CDR1-DNA"]+self._dict[inSeqID]["FR2-DNA"]+self._dict[inSeqID]["CDR2-DNA"]+self._dict[inSeqID]["FR3-DNA"]+self._dict[inSeqID]["CDR3-DNA"]+self._dict[inSeqID]["FR4-DNA"]
                self._dict[inSeqID].update({'FV-DNA':FVdna})
示例#2
0
			uniqList.append(tmpList)
	return uniqList

elemName=''
elemDNA=''
elemList=[]
for line in Infile1:
        line = line.strip('\n')
        if line.strip():
		if (line.startswith(">") ):
			line=line.lstrip('>')
			sense_DNA=truncate(elemDNA)
			if len(sense_DNA)<1:
				sense_DNA=truncate(translator.reverse_complement(elemDNA))
			if elemName:
				output=[elemName,sense_DNA,translator.translate_dna_single(sense_DNA)]
				elemList.append(output)
			#add function to search for patten
			elemName=line
			elemDNA=""
		else:
			elemDNA=elemDNA+line
                 
else:  
	sense_DNA=truncate(elemDNA)
	if len(sense_DNA)<1:
		sense_DNA=truncate(translator.reverse_complement(elemDNA))
	output=[elemName,sense_DNA,translator.translate_dna_single(sense_DNA)]
	elemList.append(output)

示例#3
0
文件: ParseFastA.py 项目: zhaiqt/vpcr
		
	pos5=elemDNA.find(prime5)
	pos3=elemDNA.find(prime3)+len(prime3) 
	return elemDNA[pos5:pos3]


elemName=""
elemDNA=""
for line in Infile1:
        line = line.strip('\n')
        if line.strip():
		if (line.startswith(">") ):
			line=line.lstrip('>')
			elemDNA=truncate(elemDNA)
			if elemName:
				output=elemName+","+elemDNA+","+translator.translate_dna_single(elemDNA)+"\n"
				Outfile1.write(output)
			#add function to search for patten
			elemName=line
			elemDNA=""
		else:
			elemDNA=elemDNA+line
                 
else:  
	elemDNA=truncate(elemDNA)
	output=elemName+","+elemDNA+","+translator.translate_dna_single(elemDNA)+"\n"
	Outfile1.write(output)               

Infile1.close()
Outfile1.close()