Пример #1
0
 def CCF(self):
     infile = str(self.pfile.get())
     targetPath = airsIO.getPath(infile)
     ccffile = str(self.tfile.get())
     ccfPath = airsIO.getPath(ccffile)
     cmd0 = "ccf2.py %s %s" % (targetPath, ccfPath)
     os.system(cmd0)
Пример #2
0
    def Generate(self):
        target1 = str(self.infile1.get())
        target1PATH = airsIO.getPath(target1)
        target2 = str(self.infile2.get())
        target2PATH = airsIO.getPath(target2)

        cmd1 = "cmm-morph.py %s %s %d" % (target1PATH, target2PATH, int(self.steps.get()))
        print cmd1
        os.system(cmd1)
        counter = 0
        while counter < int(self.steps.get()):
            openfile = "morph-%s-%s-%d.cmm" % (target1PATH, target2PATH, counter)
            chimera.openModels.open(openfile)
            counter = counter + 1
Пример #3
0
	def Apply(self):
		target=airsIO.cleanFileName(str(self.target.get()))
		targetPath=airsIO.getPath(target)
		t=os.path.splitext(target)
		targetPRE=str(t[0])

		pseudoatoms=str(self.atoms.get())
		apix=float(self.apix.get())
		thresh=float(self.thresh.get())
		res=float(self.res.get())
		
		sseFLAG=self.sse.get()
		skeFLAG=self.skeleton.get()

		print "Generating skeletons on %s where pseudoatoms are %s. apix: %f threshold: %f resolution: %f skeletons: %d sse: %d"%(targetPath,pseudoatoms,apix,thresh,res,skeFLAG,sseFLAG)
		
		if pseudoatoms=="None":
			pseudoatoms="%s-atoms.pdb"%(targetPRE)
			cmd0="pseudoatom.py %s %s %f %f %f"%(targetPath, pseudoatoms, apix, res, thresh)
			print cmd0
			os.system(cmd0)
		else:
			pseudoatomsPath=airsIO.getPath(pseudoatoms)
			
		helixsize=float(self.helixsize.get())
		sheetsize=float(self.sheetsize.get())	

		mode=6		
		if skeFLAG==1 and sseFLAG==0:
			mode=4
		elif skeFLAG==0 and sseFLAG==1:
			mode=5
		outfile="%s-score.pdb"%(targetPRE)
		cmd1="skeleton %d %s %s %f  %f %f %f %s"%(mode,targetPath, pseudoatoms, apix, thresh, helixsize, sheetsize, outfile)
		print cmd1
		os.system(cmd1)
		
		if mode==4 or mode==6:
			helixout="%s_helix.mrc"%(targetPRE)
			chimera.openModels.open(helixout)
			sheetout="%s_sheet.mrc"%(targetPRE)
			chimera.openModels.open(sheetout)
			skeletonout="%s_skeleton.mrc"%(targetPRE)
			chimera.openModels.open(skeletonout)
		if mode==5 or mode==6:
			chimera.openModels.open(outfile)
Пример #4
0
	def Apply(self):
		target=str(self.target.get())
		targetPath=airsIO.getPath(target)
		t=os.path.splitext(target)
		targetNAME=str(t[0])
		
		hhint=str(self.intfile.get())
		if hhint != "None":
			hhinfile=airsIO.getPath(hhint)	
		auto=int(self.autoassign.get())
		percen=int(self.percen.get())
		
		apix=float(self.apix.get())
		res=float(self.res.get())
		Hvalue=float(self.Hvalue.get())
		Bvalue=float(self.Bvalue.get())
		thr=float(self.thr.get())

		logfile="log_%s_%f_%f.txt"%(targetNAME,Hvalue,Bvalue)

		if hhint=="None":
			if percen==1:
				cmd0="ssehunter2.py %s %f %f thr=%f helixcutoff=%f sheetcutoff=%f percen > %s"%(targetPath,apix,res,thr,Hvalue,Bvalue,logfile)
			else:
				cmd0="ssehunter2.py %s %f %f thr=%f helixcutoff=%f sheetcutoff=%f > %s"%(targetPath,apix,res,thr,Hvalue,Bvalue,logfile)
		else:
			if  percen==1:
				cmd0="ssehunter2.py %s %f %f thr=%f helixcutoff=%f sheetcutoff=%f hh=%s percen >%s"%(targetPath,apix,res,thr,Hvalue,Bvalue,hhinfile,logfile)
			else:
				cmd0="ssehunter2.py %s %f %f thr=%f helixcutoff=%f sheetcutoff=%f hh=%s >%s"%(targetPath,apix,res,thr,Hvalue,Bvalue,hhinfile,logfile)
				
		print cmd0
		os.system(cmd0)

		hfile="helix.pdb"
		bfile="sheet.pdb"
		scorefile="score-%s.pdb"%(targetNAME)
		chimera.openModels.open(scorefile)
		
		if auto==1 or percen==1:
			chimera.openModels.open(hfile)
			chimera.openModels.open(bfile)
Пример #5
0
    def median(self):
        filename = airsIO.cleanFileName(str(self.infile.get()))
        filepath = airsIO.getPath(filename)
        width = str(self.Mwid.get())

        outfile = "median-%s" % (filename.strip())
        cmd0 = "proc3d %s %s rfilt=20,%s" % (filepath, outfile, width)
        print cmd0
        os.system(cmd0)

        chimera.openModels.open(outfile)
Пример #6
0
    def hp(self):
        filename = airsIO.cleanFileName(str(self.infile.get()))
        filepath = airsIO.getPath(filename)
        apix = str(self.apix.get())
        filterRadius = str(self.filterRadius.get())

        outfile = "hp-%s" % (filename.strip())
        cmd0 = "proc3d %s %s hp=%s,%s" % (filepath, outfile, apix, filterRadius)
        print cmd0
        os.system(cmd0)

        chimera.openModels.open(outfile)
Пример #7
0
    def bf(self):
        filename = airsIO.cleanFileName(str(self.infile.get()))
        filepath = airsIO.getPath(filename)
        sigma1 = str(self.sigma1.get())
        sigma2 = str(self.sigma2.get())
        iteration = int(self.iteration.get())
        width = str(self.wid.get())

        outfile = "bf-%s" % (filename.strip())
        cmd0 = "proc3d %s %s blfilt=%s,%s,%d,%s" % (filepath, outfile, sigma1, sigma2, iteration, width)
        print cmd0
        os.system(cmd0)

        chimera.openModels.open(outfile)
Пример #8
0
	def Generate(self):
		target=airsIO.cleanFileName(str(self.infile.get()))
		targetPath=airsIO.getPath(target)
		t=os.path.splitext(target)
		targetPRE=str(t[0])
		
		self.selectionlist=[]
		atoms=""
		selected=chimera.selection.currentAtoms()
		for i in selected:
			atoms=atoms+str(i.serialNumber)+","
		print atoms
		outfile="%s.cmm"%(targetPRE)
		cmd1="pdb2cmm.py %s %s cmm %s"%(targetPath,outfile,atoms[0:-1].strip())
		print cmd1
		os.system(cmd1)
		chimera.openModels.open(outfile)
Пример #9
0
	def calculatemodes(self):
		# Construct system
		inputfile=str(self.infile.get())
		inputPath=airsIO.getPath(inputfile)

		self.universe = InfiniteUniverse(DeformationForceField())
		self.universe.protein = Protein(inputPath, model='calpha')
		self.modelist()
		nbasis = max(8, self.universe.numberOfAtoms()/30)
		cutoff, nbasis = estimateCutoff(self.universe, nbasis)
		print "Calculating %d low-frequency modes for %s." %(nbasis,self.infile.get())
		if cutoff is None:
			#Do full normal mode calculation
			self.modes = NormalModes(self.universe)
		else:
			# Do subspace mode calculation with Fourier basis
			subspace = FourierBasis(self.universe, cutoff)
			self.modes = SubspaceNormalModes(self.universe, subspace)
		self.modeSelector()
Пример #10
0
 def Apply(self):
     infile = airsIO.cleanFileName(str(self.target.get()))
     targetPath = airsIO.getPath(infile)
     alt = float(self.alt.get())
     az = float(self.az.get())
     phi = float(self.phi.get())
     dx = float(self.dx.get())
     dy = float(self.dy.get())
     dz = float(self.dz.get())
     outfile = "rt-%s" % (infile.strip())
     print outfile
     if str(infile.split(".")[-1].strip()) == ("mrc" or "map" or "ccp4"):
         cmd0 = "chimerart.py %s %s %f,%f,%f,%f,%f,%f" % (targetPath, outfile, alt, az, phi, dx, dy, dz)
     elif str(infile.split(".")[-1]) == ("pdb" or "ent"):
         cmd0 = "procpdb.py %s %s rot=%f,%f,%f trans=%f,%f,%f" % (targetPath, outfile, alt, az, phi, dx, dy, dz)
     else:
         print "bad file"
     print cmd0
     os.system(cmd0)
     chimera.openModels.open(outfile)
Пример #11
0
    def Apply(self):
        target = airsIO.cleanFileName(str(self.target.get()))
        targetPath = airsIO.getPath(target)

        output = str(self.outfile.get())
        apix = float(self.apix.get())
        res = float(self.res.get())
        mapsize = float(self.boxsize.get())
        centerFLAG = self.centeratoms.get()

        if centerFLAG == 1:
            cmd0 = "pdb2mrc %s %s apix=%f res=%f box=%f centeratoms" % (targetPath, output, apix, res, mapsize)

        else:
            cmd0 = "pdb2mrc %s %s apix=%f res=%f box=%f" % (targetPath, output, apix, res, mapsize)

        print cmd0
        os.system(cmd0)

        chimera.openModels.open(output)
Пример #12
0
	def Dock (self):
		apix=float(self.apix.get())
		res=float(self.res.get())
		angle=float(self.angle.get())
		trans=float(self.trans.get())
		
		target=airsIO.cleanFileName(str(self.target.get()))
		targetPath=airsIO.getPath(target)
		t=os.path.splitext(target)
		targetName=str(t[0])
		
		mapInfo=airsIO.getMapInfo(target)
		mapSize=mapInfo[0][0]
			
		probePDB=self.outfile
		cmdCenter="procpdb.py %s probe.pdb centeratoms"%(probePDB)
		os.system(cmdCenter)
		cmdMRC="pdb2mrc probe.pdb probe.mrc apix=%f res=%f box=%f"%(apix, res, mapSize)
		os.system(cmdMRC)
		self.outFit="fh-mode-%s"%(targetName)
		
		cmdDock="foldhunterP %s probe.mrc fh-mode.mrc log=log-mode-fit.txt da=1 startangle=0,0,0 range=%f sphere_region=0,0,0,%f"%(targetPath, angle, trans)
		print cmdDock
		os.system(cmdDock)
		
		file=open("log-mode-fit.txt", "r")
		lines=file.readlines()
		file.close()
		fh = {}
		pattern=re.compile(r"Solution\s(?P<solnum>\d+)\:\trotation\s=\s\(\s(?P<rotx>-?\d+(\.\d+)?(e.\d+)?)\s,\s(?P<rotz1>-?\d+(\.\d+)?(e.\d+)?)\s,\s(?P<rotz2>-?\d+(\.\d+)?(e.\d+)?)\s\)\ttranslation\s=\s\(\s(?P<dx>-?\d+(\.\d+)?(e.\d+)?)\s,\s(?P<dy>-?\d+(\.\d+)?(e.\d+)?)\s,\s(?P<dz>-?\d+(\.\d+)?(e.\d+)?)\s\)")
		for line in lines:
			ps=pattern.search(line)
			if ps:
				fh[int(ps.group('solnum'))]=[float(ps.group('rotx')),float(ps.group('rotz1')),float(ps.group('rotz2')),float(ps.group('dx')),float(ps.group('dy')),float(ps.group('dz'))]
 		outRefinePDB="flex-fh-%s.pdb"%(targetName)
		cmd1="procpdb.py %s r.pdb rot=%f,%f,%f"%(self.outfile,fh[0][0],fh[0][1],fh[0][2])
		os.system(cmd1)
		cmd2="procpdb.py r.pdb %s apix=%f trans=%f,%f,%f"%(outRefinePDB,apix,fh[0][3],fh[0][4],fh[0][5])
		os.system(cmd2)
		chimera.openModels.open(outRefinePDB)
Пример #13
0
	def Apply(self):
		target=airsIO.cleanFileName(str(self.target.get()))
		targetPath=airsIO.getPath(target)
		t=os.path.splitext(target)
		targetPRE=str(t[0])

		pseudoatoms=str(self.atoms.get())
		coeff=airsIO.cleanFileName(str(self.coeff.get()))
		apix=float(self.apix.get())
		thresh=float(self.thresh.get())
		res=float(self.res.get())
		
		mapinfo=airsIO.getMapInfo(target)
		mapSize=mapinfo[0][0]
		mapOrigin=mapinfo[1]  
		
		logfile="log-%s.txt"%(targetPRE)
		
		if coeff!="None":
			if pseudoatoms!="None":
				cmd1="ssehunter3.py %s %f %f %f coeff=%s atoms=%s > %s"%(target, apix, res, thresh, coeff, pseudoatoms, logfile)
			else:
				cmd1="ssehunter3.py %s %f %f %f coeff=%s > %s"%(target, apix, res, thresh, coeff, logfile)
		else:
			if pseudoatoms!="None":
				cmd1="ssehunter3.py %s %f %f %f atoms=%s > %s"%(target, apix, res, thresh, pseudoatoms, logfile)
			else:
				cmd1="ssehunter3.py %s %f %f %f > %s"%(target, apix, res, thresh, logfile)
		print cmd1
		os.system(cmd1)

		outfile="score-%s.pdb"%(targetPRE)
		if self.mapOri.get()==1:
			Ox=mapOrigin[0]
			Oy=mapOrigin[1]
			Oz=mapOrigin[2]			
			cmdt="procpdb.py %s %s trans=%f,%f,%f"%(outfile,outfile,Ox,Oy,Oz)
			os.system(cmdt)
		chimera.openModels.open(outfile)
Пример #14
0
	def Apply(self):
		target=airsIO.cleanFileName(str(self.target.get()))
		targetPath=airsIO.getPath(target).strip()
		shutil.copy(targetPath, 'target.mrc')
		t=target.split('.')
		targetExt=str(t[-1])
		
		refineFLAG=0
		maskFLAG=0		
		if (self.rs.get()==1):	
			refineFLAG=1
			if self.ms.get()==1:
				maskFLAG=1

        	probe=airsIO.cleanFileName(str(self.probe.get()))
		print str(self.probe.get())
		print probe
		probePath=airsIO.getPath(probe)
		print probePath
		probesplit=probe.split('.')
		probeExt=str(probesplit[-1])
		probeName=str(probesplit[0])
		print probeExt
		print probeName
		#probesplit=os.path.split(probe)
		#probeName=str(probesplit[0])

		mapinfo=airsIO.getMapInfo(target)
		mapSize=mapinfo[0][0]
		mapOrigin=mapinfo[1] 

		if probeExt=="mrc" or probeExt=="map" or probeExt=="ccp4":
			probeinfo=airsIO.getMapInfo(probe)
			tempSizeX=probeinfo[0][0]
			tempSizeY=probeinfo[0][1]
			tempSizeZ=probeinfo[0][2]
		 

		#openfiles=chimera.openModels.list()
		#mapSize=0
		#from VolumeViewer import volume_list
		#for v in volume_list():
		#	if v.data.name == volume_name.strip():
		#		mapSize = v.data.size[0]
		#		mapOrigin= v.data.origin
		#		if probeExt=="mrc":
		#			tempSizeX,tempSizeY,tempSizeZ = v.data.size
		apix=float(self.apix.get())
		res= float(self.res.get())
		shrink = int(self.shrink.get())
		keep=int(self.keep.get())

		if ((self.filter.get()=='None') or (self.filter.get()=='Normalize')): 
			value=None	
		else:
			value=float(self.filterValue.get())
		
		hs=0
		hs=int(self.hs.get())
					
		if hs==1:
			depth= int(self.depth.get())
			pixel=int(self.pixel.get())
		else:
			depth=1
			pixel=1
		########create user selection
		if (refineFLAG==1):
			selectedLength=0
			selected=chimera.selection.currentAtoms()
			selectedLength=len(selected)
			
			if (selectedLength!=0) and (probeExt=='pdb' or probeExt=='ent'):
				print "ENTERED USER SELECTION"	
				i=0
				selectedAtoms=[]
				while (i < selectedLength):
					selectedAtoms.append(chimera.selection.currentAtoms()[i].serialNumber)
					i=i+1
	
				selectedAtoms.sort()
				print selectedAtoms
				fileRefine=open(probe, "r")
				linesRefine=fileRefine.readlines()
				fileRefine.close()
				
				refinePDB=open("refine.pdb", "w")
				maskPDB=open("mask.pdb", "w")
				for lineRefine in linesRefine:
					isatom=str(lineRefine[0:6].strip())
					serialNum=str(lineRefine[6:11].strip())
					if (isatom=="ATOM"):
						serialNum=int(lineRefine[6:11].strip())
						if (serialNum in selectedAtoms):
							refinePDB.write(lineRefine)
						else :
							maskPDB.write(lineRefine)
				refinePDB.close()
				maskPDB.close()

				cmdRS0="pdb2mrc refine.pdb refine.mrc apix=%f res=%f box=%d"%(apix, res, mapSize)
				os.system(cmdRS0)
				cmdRS1="pdb2mrc mask.pdb mask.mrc apix=%f res=%f box=%d"%(apix, res, mapSize)
				os.system(cmdRS1)
				cmdRS2="proc3d refine.mrc refine.mrc norm"
				os.system(cmdRS2)

				if self.mask.get()!="Unselected":
					maskfile=str(self.mask.get())
					maskPath=airsIO.getPath(maskfile)
					maskEXT=str(maskfile[-1])
					
					if (maskExt=='pdb' or maskExt=='ent'):
						cmdRS3="pdb2mrc %s mask.mrc apix=%f res=%f box=%d"%(maskPath, apix, res, mapSize)
						os.system(cmdRS3)	
					else:
						shutil.copy(targetpath, 'mask.mrc')
					
#					for f in openfiles:
#        	        		        if f.name==maskfile:
#							mask=str(f.name)
#                                                       from VolumeViewer import Volume
#                                                       from chimera import Molecule
#							if isinstance(p,Volume):
#								maskpath=str(os.path.abspath(mask))
#    		   		                     	elif isinstance(p,Molecule):
#								mf=f.openedAs
#								maskpath=mf[0]
#
#
#						maskExt=str(probesplit2[-1])
#						maskName=str(probesplit2[0])
#
#						if (maskExt=='pdb' or maskExt=='ent'):
#							cmdRS3="pdb2mrc %s mask.mrc apix=%f res=%f box=%d"%(msplit, apix, res, mapSize)
#						else:
#							if os.system("copy")==1:
#								cmdRS3="copy %s mask.mrc"%(msplit)
#							else:
#								cmdRS3="cp %s mask.mrc"%(msplit)
#						os.system(cmdRS3)

				cmdRS9="proc3d mask.mrc mask.mrc norm"
				os.system(cmdRS9)
				
				if (maskFLAG!=0):
					cmdRS4="proc3d mask.mrc mask-bin.mrc bin=0.5"
					cmdRS5="proc3d mask-bin.mrc mask-inv.mrc mult=-1"
					cmdRS6="proc3d mask-inv.mrc mask-add.mrc add=1"
					cmdRS7="proc3d target.mrc target.mrc maskfile=mask-add.mrc"
					cmdRS8="proc3d target.mrc target.mrc rfilt=0,0.5"
					os.system(cmdRS4)
					os.system(cmdRS5)
					os.system(cmdRS6)
					os.system(cmdRS7)
					os.system(cmdRS8)
					tempfiles=["mask.mrc","mask-bin.mrc","mask-inv.mrc","mask-add.mrc"]
					airsIO.cleanTempFiles(tempfiles)

			else:
				shutil.copy(probePath, 'refine.mrc')	
			selected=chimera.selection.currentEmpty()
			selectedLength=0

		########Transform PDB file and generate MRC file
		if (probeExt=='pdb' or probeExt=='ent') and (refineFLAG==0):
                        print probe
			shutil.copy(probe, 'probe.pdb')
			cmd1="procpdb.py probe.pdb probe.pdb centeratoms"
			os.system(cmd1)
			cmd2="pdb2mrc probe.pdb probe.mrc apix=%f res=%f box=%d"%(apix, res, mapSize)
			os.system(cmd2)
			cmd3="proc3d probe.mrc probe.mrc norm"
			os.system(cmd3)
		elif (refineFLAG!=0):
			print "Selection transformed"
		else:
			shutil.copy(probePath, 'probe.mrc')
			if (tempSizeX!=tempSizeY!=tempSizeZ!=mapSize):
				cmd3a="proc3d probe.mrc probe.mrc clip=%d,%d,%d"%(mapSize,mapSize,mapSize)
				os.system(cmd3a)
		print "filter"		
		########Filter and Scale MRC files
		if (self.filter.get()=='Threshold'):
			print("Tresholding target map")
			cmdF1="proc3d target.mrc target.mrc rfilt=0,%f"%(value)
			os.system(cmdF1)
		if (self.filter.get()=='Binary'):
			print("Binerizing target map")
			cmdF2="proc3d target.mrc target.mrc rfilt=2,%f"%(value)
			os.system(cmdF2)
		if (self.filter.get()=='Normalize'):
			print("Normalizing target map")
			cmdF3="proc3d target.mrc target.mrc  norm"
			os.system(cmdF3)
		if (self.filter.get()=='Laplacian'):
			print("Laplacian filter")
			cmdF4="proc3d target.mrc target.mrc rfilt=80,%f"%(value)
			os.system(cmdF4)
		if (refineFLAG==0):	
			print("Shrinking maps")
			cmdST="proc3d target.mrc target-shrink.mrc shrink=%f"%(shrink)
			os.system(cmdST)
			cmdSP="proc3d probe.mrc probe-shrink.mrc shrink=%f"%(shrink)
			os.system(cmdSP)
		pattern=re.compile(r"Solution\s(?P<solnum>\d+)\:\trotation\s=\s\(\s(?P<rotx>-?\d+(\.\d+)?(e.\d+)?)\s,\s(?P<rotz1>-?\d+(\.\d+)?(e.\d+)?)\s,\s(?P<rotz2>-?\d+(\.\d+)?(e.\d+)?)\s\)\ttranslation\s=\s\(\s(?P<dx>-?\d+(\.\d+)?(e.\d+)?)\s,\s(?P<dy>-?\d+(\.\d+)?(e.\d+)?)\s,\s(?P<dz>-?\d+(\.\d+)?(e.\d+)?)\s\)")

		self.listResults=[]
		
		###############################
		####### Run foldhunterP #######
		###############################

		########SMART option
		if (self.smart.get()==1 and refineFLAG==0):
			print "RUNNING SMART FOLDHUNTER"
			logSmart="log-fh-%s.txt"%(probeName)
			outSmart="fh-smart-%s.mrc"%(probeName)
			cmdS1="foldhunterP target.mrc probe.mrc %s log=%s da=1 keep=%d "%(outSmart, logSmart, keep)
			print cmdS1
			os.system(cmdS1)
			if (probeExt=='pdb' or probeExt=='ent'):
				file0=open(logSmart, "r")
				lines0=file0.readlines()
				file0.close()
				fh0 = {}
				for line in lines0:
					ps=pattern.search(line)
					if ps:
						fh0[int(ps.group('solnum'))]=[float(ps.group('rotx')),float(ps.group('rotz1')),float(ps.group('rotz2')),float(ps.group('dx')),float(ps.group('dy')),float(ps.group('dz'))]

				fhSmart="fh-smart-%s.pdb"%(probeName)
				self.transformPDB('probe.pdb', fhSmart, apix, mapSize, mapOrigin,fh0[0][0],fh0[0][1],fh0[0][2],fh0[0][3],fh0[0][4],fh0[0][5])
 			else:
				chimera.openModels.open(outSmart)
				
		########Scale foldhunter	
		if (refineFLAG==0) and (self.smart.get()==0):
			print "RUNNING FOLDHUNTER ON SMALL MAPS"
			outShrink="fh-shrink-%s.mrc"%(probeName)
			da=((180*res)/(math.pi*(mapSize/(2*shrink))))*1.5
			if da>30:
				da=30
			cmdFHS="foldhunterP target-shrink.mrc probe-shrink.mrc %s log=log-fh-shrink.txt da=%f keep=%d"%(outShrink,da,keep)
			print cmdFHS
			os.system(cmdFHS)

			########Parse output and repeat foldhunterP
			file1=open('log-fh-shrink.txt', "r")
			lines1=file1.readlines()
			file1.close()
			fh1 = {}
			for line in lines1:
				ps=pattern.search(line)
				if ps:
					fh1[int(ps.group('solnum'))]=[float(ps.group('rotx')),float(ps.group('rotz1')),float(ps.group('rotz2')),float(ps.group('dx')),float(ps.group('dy')),float(ps.group('dz'))]
			print("RUNNING FOLDHUNTER")
			count=0
			children=0
			while ((count < depth) and (children < keep)):
				angle_range=da/2
				da2=1
				if ((angle_range >=10) and (mapSize>=80)):
					da2=2
				sphere_radius=mapSize/10

				x1=shrink*fh1[children][3]
				y1=shrink*fh1[children][4]
				z1=shrink*fh1[children][5]

				dist = []
				solution=0
				while (solution <= children):
					x2=shrink*fh1[solution][3]
					y2=shrink*fh1[solution][4]
					z2=shrink*fh1[solution][5]
					if (solution!=children):
						distance=math.sqrt((x1-x2)**2+(y1-y2)**2+(z1-z2)**2)
					else:
						distance=10000
					dist.append(distance)
					print "%d verse %d: %f"%(children,solution,dist[solution])
					solution=solution+1
				pixel_distance=min(dist)
	
				if ((pixel_distance >= pixel) or (count==0)):
					logfile="log-%s-%d.txt"%(probeName,count)
					cmdFH="foldhunterP target.mrc probe.mrc fh-%d.mrc log=%s da=%f startangle=%f,%f,%f range=%f sphere_region=%f,%f,%f,%f"%(children,logfile,da2,fh1[children][0],fh1[children][1],fh1[children][2],angle_range,x1,y1,z1,sphere_radius)
					print cmdFH
					os.system(cmdFH)
					num=count
					count=count+1
		
					########Transform PDB
					if (probeExt=='pdb' or probeExt=='ent'):
						print("Transforming PDB")
						file2=open(logfile, "r")
						lines2=file2.readlines()
						file2.close()
						fh2 = {}
						for line in lines2:
							ps=pattern.search(line)
							if ps:
								fh2[int(ps.group('solnum'))]=[float(ps.group('rotx')),float(ps.group('rotz1')),float(ps.group('rotz2')),float(ps.group('dx')),float(ps.group('dy')),float(ps.group('dz'))]
						addFile="fh-solution-%d-%s.pdb"%(num,probeName)
						self.transformPDB('probe.pdb', addFile, apix, mapSize, mapOrigin,fh2[0][0],fh2[0][1],fh2[0][2],fh2[0][3],fh2[0][4],fh2[0][5])

					else:
						addFile="fh-%d.mrc"%(children)
				children=children+1
				self.listResults.append(addFile)
#			bestResult=self.listResults[0]
#			chimera.openModels.open(bestResult)
			self.resultSelector()
		
		########Refinement option
		if (refineFLAG==1)and (self.smart.get()==0):
			print "RUNNING REFINEMENT"
			outRefine="fh-refine-%s.mrc"%(probeName)
			angl=float(self.angle.get())
			refdis=float(self.refdist.get())
			cmdREF1="foldhunterP target.mrc refine.mrc %s log=log-fh-refine.txt keep=%d da=1 startangle=0,0,0 range=%f sphere_region=0,0,0,%f"%(outRefine, keep, angl, refdis)
			os.system(cmdREF1)
			if (probeExt=='pdb' or probeExt=='ent'):
				fileR=open("log-fh-refine.txt", "r")
				linesR=fileR.readlines()
				fileR.close()
				fhR = {}
				for lineR in linesR:
					ps=pattern.search(lineR)
					if ps:
						fhR[int(ps.group('solnum'))]=[float(ps.group('rotx')),float(ps.group('rotz1')),float(ps.group('rotz2')),float(ps.group('dx')),float(ps.group('dy')),float(ps.group('dz'))]
 				outRefinePDB="fh-refine-%s.pdb"%(probeName)
				self.transformPDB('refine.pdb', outRefinePDB, apix, mapSize, mapOrigin,fhR[0][0],fhR[0][1],fhR[0][2],fhR[0][3],fhR[0][4],fhR[0][5])

			else:
				chimera.openModels.open(outRefine)		

		tempfiles=["target.mrc", "probe.mrc", "target-shrink.mrc", "probe-shrink.mrc", "r.pdb", "refine.mrc", "refine.pdb"] 
		airsIO.cleanTempFiles(tempfiles)
Пример #15
0
    def Apply(self):
        inputfile = airsIO.cleanFileName(str(self.infile.get()))
        fullPath = airsIO.getPath(inputfile)
        shutil.copy(fullPath, "hh.mrc")
        a = os.path.splitext(inputfile)
        name = str(a[0])

        apix = float(self.apix.get())
        da = float(self.da.get())
        percen = float(self.percen.get())

        if self.bf.get() == 1:
            sigma1 = float(self.sigma1.get())
            sigma2 = float(self.sigma2.get())
            it = int(self.iter.get())
            width = float(self.wid.get())
        else:
            sigma1 = 0
            sigma2 = 0
            it = 0
            width = 0

        if self.norm.get() == 1:
            print "Normalizing map"
            cmd2 = "proc3d hh.mrc hh.mrc norm"
            os.system(cmd2)

        if it >= 1:
            print "Filtering Map"
            cmd3 = "proc3d hh.mrc hh.mrc blfilt=%f,%f,%d,%f" % (sigma1, sigma2, iter, width)
            os.system(cmd3)

        print "Running helixhunter2"
        file0 = "hh2-%s-%f" % (name, percen)
        if self.coeff.get() == 1:
            cmd4 = (
                "helixhunter2 hh.mrc %s.iv %f percen=%f docylccffirst int=int-%s dejavu=%s.sse da=%d minlen=8 maxlen=50"
                % (file0, apix, percen, name, file0, da)
            )
            os.system(cmd4)
        else:
            cmd4 = "helixhunter2 hh.mrc %s.iv %f percen=%f dejavu=%s.sse minlen=8 maxlen=50 da=%d" % (
                file0,
                apix,
                percen,
                file0,
                da,
            )
            os.system(cmd4)

        print "Saving results as a PDB file"

        trash = ["hh.mrc"]
        airsIO.cleanTempFiles(trash)

        file1 = "%s.sse" % (file0)
        file2 = "%s.pdb" % (file0)

        check = os.path.exists(file1)
        if check == 1:
            cmd5 = "dejavu2pdb.py %s %s" % (file1, file2)
            os.system(cmd5)
            chimera.openModels.open(file2)
Пример #16
0
	def Build(self):
		inputfile=str(self.infile.get())
		inputPre=str((inputfile.split('.'))[0])
		infile='None'
		helixColor="%s,%s,%s"%(self.helixRed.get(),self.helixGreen.get(),self.helixBlue.get())
		index=0
                filename=airsIO.getPath(inputfile)
		
#		while index < len(self.names):
#                        if str(self.files[index].name) == inputfile:
#                                 filename=self.pdbpath(self.files[index])
#                        index=index+1
	
	
		outDejavu=open("helix.sse","w")
		outDejavu.write("!\n")
		outDejavu.write("!  ===  0dum\n")
		outDejavu.write("!\n")
		outDejavu.write("MOL   0dum\n")
		outDejavu.write("NOTE  from helixhunter3.py\n")
		outDejavu.write("PDB   1SSE\n")
		outDejavu.write("!\n")

		file=open(filename, "r")
		lines=file.readlines()
		file.close
		x=[]
		y=[]
		z=[]
		atomNumber=[]
		counter=0
		atomLine=[]

		for line in lines:
			isatom=str(line[0:6].strip())
			if (isatom=="ATOM"):
				atomLine.append(line)
				x.append(float(line[30:38].strip()))
				y.append(float(line[38:46].strip()))
				z.append(float(line[46:54].strip()))
				atomNumber.append(int(line[6:11].strip()))
				counter=counter+1
		
		k=0
		alphaAtoms=open("helix-atoms.pdb","w")
		betaAtoms=open("sheet-atoms.pdb","w")
		sheetFile="sheet-%s.wrl"%(inputPre)
		coilFile="coil-%s.wrl"%(inputPre)
		print sheetFile,coilFile
		outsheet=open(sheetFile,"w")	
		outsheet.write("#VRML V2.0 utf8\n")
		outcoil=open(coilFile,"w")
		outcoil.write("#VRML V2.0 utf8\n")	
		while k < len(self.displayinfo):
			buildlist=self.displayinfo[k]
			print buildlist
			if buildlist[0] == 'Helix':
				helixpoints=[]
				helixlength=0.0
				q=0
				while q < len(atomNumber):
					if atomNumber[q] in buildlist[2]:
						helixpoints.append(q)
						alphaAtoms.write(atomLine[q])
					q=q+1
				for point1 in helixpoints:
					for point2 in helixpoints:
						distance=math.sqrt((x[point1]-x[point2])**2+(y[point1]-y[point2])**2+(z[point1]-z[point2])**2)
						if distance >= helixlength:
							helixlength=distance
							hpoint1=[x[point1], y[point1], z[point1]]
							hpoint2=[x[point2], y[point2], z[point2]]
				intlength=int(math.ceil(helixlength/1.54))
				dejavuline="ALPHA 'A%d' '%d' '%d' %d %f %f %f %f %f %f\n"%(k,k*100,k*100+(intlength-1),intlength,hpoint1[0],hpoint1[1],hpoint1[2],hpoint2[0],hpoint2[1],hpoint2[2])
				outDejavu.write(dejavuline)	
			if buildlist[0] == 'Sheet':
				sheetpoints=[]
				templine=[0,0,0]
				q=0
				xsum=0.0
				ysum=0.0
				zsum=0.0
				
				while q < len(atomNumber):
					if atomNumber[q] in buildlist[2]:
						betaAtoms.write(atomLine[q])
						templine=[x[q], y[q], z[q]]
						xsum=xsum+x[q]
						ysum=ysum+y[q]
						zsum=zsum+z[q]
						sheetpoints.append(templine)
					q=q+1
				xOrigin=xsum/len(sheetpoints)
				yOrigin=ysum/len(sheetpoints)
				zOrigin=zsum/len(sheetpoints)
				
				points=0
				maxDistance=0.0
				while points < len(sheetpoints):
					point1=sheetpoints[points]
					x1=point1[0]
					y1=point1[1]
					z1=point1[2]
					distance=math.sqrt((x1-xOrigin)**2+(y1-yOrigin)**2+(z1-zOrigin)**2)
					if distance > maxDistance:
						maxDistance=distance				
					points=points+1
				print maxDistance
				sheetColor="            emissiveColor %s %s %s\n"%(self.sheetRed.get(), self.sheetGreen.get(), self.sheetBlue.get())
				outsheet.write("Shape {\n")
				outsheet.write("    appearance Appearance {\n")
				outsheet.write("        material Material {\n")
				#outsheet.write("            emissiveColor 0.0 1.0 1.0\n")
				outsheet.write(sheetColor)
				outsheet.write("        }\n")
				outsheet.write("    }\n")		
				outsheet.write("    geometry IndexedFaceSet {\n")
				outsheet.write("       coord Coordinate {\n")
				outsheet.write("            point [\n")
				counter=0
				
				originLine="                 %f %f %f,\n"%(xOrigin,yOrigin,zOrigin)
				outsheet.write(originLine)
				for item in sheetpoints:
					lineA="                 %f %f %f,\n"%(item[0],item[1],item[2])
					outsheet.write(lineA)
				outsheet.write("            ]\n")
				outsheet.write("        }\n")
				outsheet.write("        coordIndex [\n")
				counter1=0
				while counter1 < len(sheetpoints):
					counter2=0
					while counter2 < len(sheetpoints):
						distanceCheck=math.sqrt((sheetpoints[counter1][0]-sheetpoints[counter2][0])**2+(sheetpoints[counter1][1]-sheetpoints[counter2][1])**2+(sheetpoints[counter1][2]-sheetpoints[counter2][2])**2)								
						print buildlist[2][counter1],counter1+1,buildlist[2][counter2],counter2+1, distanceCheck
						if counter1!=counter2 and distanceCheck <=maxDistance:
							print buildlist[2][counter1],counter1,buildlist[2][counter2],counter2, distanceCheck					
							lineB="            0,%d,%d,0\n"%(counter1+1,counter2+1)
							outsheet.write(lineB)
						#counter3=0
						#while counter3<len(sheetpoints):
						#	if counter1!=counter!=counter3:
						#		lineB="            %d,%d,%d,%d,-1\n"%(counter1,counter2,counter3,counter1)
						#		outsheet.write(lineB)		
						#	counter3=counter3+1
						counter2=counter2+1
					counter1=counter1+1
				outsheet.write("        ]\n")
				outsheet.write("    }\n")
				outsheet.write("}\n")
			if buildlist[0] == 'Coil':
				coilpoints=[]
				templine=[0,0,0]
				q=0
				while q < len(atomNumber):
					if atomNumber[q] in buildlist[2]:
						templine=[x[q], y[q], z[q]]
						coilpoints.append(templine)
					q=q+1
				outcoil.write("Shape {\n")
				outcoil.write("    appearance Appearance {\n")
				outcoil.write("        material Material {\n")
				outcoil.write("            emissiveColor 1.0 0.5 0.0\n")
				outcoil.write("        }\n")
				outcoil.write("    }\n")		
				outcoil.write("    geometry IndexedLineSet {\n")
				outcoil.write("       coord Coordinate {\n")
				outcoil.write("            point [\n")
				counter=0
				for item in coilpoints:
					lineA="                 %f %f %f,\n"%(item[0],item[1],item[2])
					outcoil.write(lineA)
				counter1=0
				maxdistance=0
				endpoints=[]
				
				while counter1 < len(coilpoints):
					counter2=0
					while counter2 < len (coilpoints):
						distance=math.sqrt((coilpoints[counter1][0]-coilpoints[counter2][0])**2+(coilpoints[counter1][1]-coilpoints[counter2][1])**2+(coilpoints[counter1][2]-coilpoints[counter2][2])**2)
						if distance>maxdistance:
							maxdistance=distance		
							endpoints=[counter1,counter2]
						counter2=counter2+1
					counter1=counter1+1
				print endpoints
				counter3=0
				start=endpoints[0]
				listofdistances=[]
				sortedlistofdistances=[]
				while counter3<len(coilpoints):
					neighbordistance=math.sqrt((coilpoints[start][0]-coilpoints[counter3][0])**2+(coilpoints[start][1]-coilpoints[counter3][1])**2+(coilpoints[start][2]-coilpoints[counter3][2])**2)
					listofdistances.append(neighbordistance)
					sortedlistofdistances.append(neighbordistance)
					counter3=counter3+1
				sortedlistofdistances.sort()
				sortedlistofdistances.pop(0)
				connection=[]
				connection.append(start)
				counter4=0
				while counter4<len(sortedlistofdistances):					      
					comparedistance=sortedlistofdistances[counter4]
					print comparedistance
					print "versus"
					counter5=0
					while counter5<len(listofdistances):
						print counter5 , listofdistances[counter5]
						if comparedistance==listofdistances[counter5]:
							print counter5,
							print " is the same"
							connection.append(counter5)
						counter5=counter5+1
					counter4=counter4+1
				print 	connection
				outcoil.write("            ]\n")
				outcoil.write("        }\n")
				outcoil.write("        coordIndex [\n")
				coiltext=str(connection)
				coiltext2=coiltext[1:-1]
				lineS="            %s\n"%(coiltext2)
				outcoil.write(lineS)
				outcoil.write("        ]\n")
				outcoil.write("    }\n")
				outcoil.write("}\n")
				
				"""
				while counter4<len(coilpoints):
					counter3=0
					mindistance=999999
					while counter3<len(coilpoints):
						print excludelist, mindistance
						if counter3 not in excludelist:
							neighbordistance=math.sqrt((coilpoints[start][0]-coilpoints[counter3][0])**2+(coilpoints[start][1]-coilpoints[counter3][1])**2+(coilpoints[start][2]-coilpoints[counter3][2])**2)
							print neighbordistance
							if neighbordistance < mindistance:
								mindistance=neighbordistance
								start=counter3
								print start
					   	#start=nextpoint
						counter3=counter3+1
					excludelist.append(start)
					counter4=counter4+1
				print excludelist
				text=str(excludelist)
				"""
			k=k+1
		outcoil.close()
		outsheet.close()
		alphaAtoms.close()
		betaAtoms.close()
		chimera.openModels.open(sheetFile)		
		chimera.openModels.open(coilFile)
		outDejavu.close()
		outfile="helix-%s"%(inputfile)

		if str(self.style.get())=='VRML':
			cmdHH="dejavu2pdb.py helix.sse %s vrml helixColor=%s"%(outfile,helixColor)
			outfile="helix-%s.wrl"%(inputPre)
		else:
			cmdHH="dejavu2pdb.py helix.sse %s"%(outfile)	
		os.system(cmdHH)	
		chimera.openModels.open(outfile)