Пример #1
0
def cyclic_shift(monomer_file,fit_file,fits_dir,N,symetry_axis = (0,0,1) ,symetry_center = (0,0,0)):
    os.system("mkdir cycledFits")
    rc("open " + monomer_file)
    rc("cd "+fits_dir)
    transArray=[]
    for i in range(N):
        print fit_file
        rc("open " + fit_file)
        if i == 0: 
	    rc("match #" + str(i+1) + " #0 showMatrix true move false")
            continue
        command = get_turn_command(i*360/N,symetry_axis,symetry_center,i+1) #changed for output
        if DEBUG:
            print command
        rc(command)
	rc("match #" + str(i+1) + " #0 showMatrix true move false")
        #FIX
    filePath= "after"+fit_file
    rc("close 0")
    rc("combine #0,#1 close 1")
    rc("cd ..")
    saveReplyLog("transformsLog.txt")
    transform= findTranform(fit_file) 
	
    return transform
Пример #2
0
def fitToSegment(monomer_file):
    """
    Fits the monomer to each of the segments maps in segmentationsDir
    """
    os.system("rm -r fitDir ; mkdir fitDir")
    i=0
    for segmentedMapFile in os.listdir( "segmentationsDir" ) :
        rc( "open " + monomer_file)
        v= VolumeViewer.open_volume_file("segmentationsDir/" + segmentedMapFile)[0]
        d=v.data
        #We move the monomer close to the segmented-region map to improve FitMap, so we measure the position of the monomer in atomic coordinates
        #measure the position of the segmented-map in grid indices, convert it to atomic corrdinates, and move the monomer in the coordinates       
        #difference axis, then running fitmap to fit the monomer to the region-map when they are closed to each other
        rc( "measure center #0")
        rc( "measure center #1")
        saveReplyLog("log.txt")
        log= open("log.txt", 'r')
        lines=log.readlines()
        centerLine1=lines[len(lines)-2]
        centerLine0=lines[len(lines)-3] 
        line0Array=centerLine0.split()
        line1Array=centerLine1.split()
        monomerCenter= (float(line0Array[-3][1:-1]), float(line0Array[-2][:-1]), float(line0Array[-1][:-1]))
        segmentCenter= (float(line1Array[-3][1:-1]), float(line1Array[-2][:-1]), float(line1Array[-1][:-1]))
        x,y,z= d.ijk_to_xyz(segmentCenter) 
        moveAxis= (x-monomerCenter[0], y-monomerCenter[1], z-monomerCenter[2])
        rc("move "+str(moveAxis[0]) +","+ str(moveAxis[1]) + "," + str(moveAxis[2])
        + " models #0")
        rc( "fitmap #0 #1" )
        rc("write format pdb #0 fitDir/model" + str(i)+".pdb")
        rc("close all")
        i+=1
Пример #3
0
def get_principal_axes(map_file):
    """
    Recives a map file, returns it's three axes and the center of it.
    The return value is: [axis 1, axis 2, axis 3, center]
    Each component is a tuple of three numbers
    """
    rc("open "+map_file)
    rc("measure inertia #0")
    saveReplyLog("log.txt")
    log= open("log.txt", 'r')
    for line in log:
        if "v1" in line:
            lineVec1=line.split()
        elif "v2" in line:
            lineVec2=line.split()
        elif "v3" in line:
            lineVec3=line.split()
        elif "center" in line:
            centerLine=line.split()
            break
    rc("close all")
    for i in range(2,5):
        lineVec1[i]=float(lineVec1[i])
        lineVec2[i]=float(lineVec2[i])
        lineVec3[i]=float(lineVec3[i])
        centerLine[i]=float(centerLine[i])
    vec1= (lineVec1[2], lineVec1[3], lineVec1[4])
    vec2= (lineVec2[2], lineVec2[3], lineVec2[4])
    vec3= (lineVec3[2], lineVec3[3], lineVec3[4])
    centerTup= (centerLine[2], centerLine[3], centerLine[4])
    
    return [vec1, vec2, vec3, centerTup]
Пример #4
0
def get_score(map_file, N, density):
    #We make a density map out of the structure of the protein we made in cycle_shift
    rc("molmap #"+ str(N) + " " + str(density))
    rc("open " + str(map_file))
    rc("measure correlation #0 #" +str(N)) #Assumption: the cycled protein map is model #0 and the map we just opened is model #1
    #again, reading from reply log
    saveReplyLog("log.txt")
    log= open("log.txt", 'r')
    for line in log:
        if "Correlation" in line:
            corrLine=line.split()
            ind= corrLine.index("=")
            score= float((corrLine[ind+1])[:-1])
            score*=1000 #in order to make the score nicer than a number between -1 to 1.
    return score
Пример #5
0
def get_score(map_file, N, density):
    """
    Given a map, the number of symm and the density, computes and returns the
    correlation between the original map and the current tested model.
    Assums that the current model is open.
    """
    rc("molmap #"+str(N)+" " + str(density))
    rc("open " + str(map_file))
    rc("measure correlation #0 #"+str(N)) #Assumption: the cycled protein map is model #0 and the map we just opened is model #1
    #again, reading from reply log
    saveReplyLog("log.txt")
    log= open("log.txt", 'r')
    for line in log:
        if "Correlation" in line:
            corrLine=line.split()
            ind= corrLine.index("=")
            score= float((corrLine[ind+1])[:-1])
            score*=1000 #in order to make the score nicer than a number between -1 to 1.
    return score
Пример #6
0
def get_principal_axes(map_file):
    rc("open "+map_file)
    rc("measure inertia #0")
    saveReplyLog("log.txt")
    log= open("log.txt", 'r')
    for line in log:
        if "v3" in line:
            symVec=line.split()
        elif "center" in line:
            centerLine=line.split()
            break
    rc("close all")
    for i in range(2,5):
        symVec[i]=float(symVec[i])
        centerLine[i]=float(centerLine[i])
    vecTup= (symVec[2], symVec[3], symVec[4])
    centerTup= (centerLine[2], centerLine[3], centerLine[4])
    
    return [vecTup, centerTup] #array of the two tupples
Пример #7
0
def cyclicForOutput(monomer_file,fit_file,fits_dir,N,symetry_axis,symetry_center):
    """
    Shifting again the monomer in cyclic transformation to compute the translations and rotations
    of the monomers to the original monomer. Chimera's match outputs the rotation matrix between two same structures
    """
    rc("open " + monomer_file) 
    rc("cd " + fits_dir)
    for i in range(N):
        rc("open " + fit_file)
        if i == 0: 
            print "Calculating transformations and translations " + fit_file #important! Do not remove
            rc("match #" + str(i+1) + " #0 showMatrix true move false")
            continue
        command = get_turn_command(i*360/N,symetry_axis,symetry_center,i+1) 
        rc(command)
        print "Calculating transformations and translations " + fit_file #important! Do not remove
        rc("match #" + str(i+1) + " #0 showMatrix true move false")
    rc("cd ..")
    saveReplyLog("log.txt")
    transform= findTransform(fit_file)
    rc("close all") 

    return transform
    for i in range(1,pdbno+1):
        rc('match #'+str(i)+':1500-1600@ca #0:1500-1600@ca')

    # Save matrix file for restoring structural alignmemnt
    rc('matrixget '+dir+'/RMSD/RMSD_alignment_matrix')

    # Clear reply log ready for gathering RMSD
    clearReplyLog()

    # Do RMSD measurements in a matrix
    for i in range(1,pdbno+1):
        for j in range(1,pdbno+1):
            rc('rmsd #'+str(i)+' #'+str(j))

    # Save reply log ready for calculated RMSD values
    saveReplyLog(dir+'/RMSD/RMSD.log')

    # Save session
    rc('~modeldisplay #; modeldisplay #0; focus; ~modeldisplay #; modeldisplay #1-#'+str(pdbno))
    rc('save '+dir+'/RMSD/RMSD_'+str(signature)+'_session.py')

    #####################################################################################
    # Make images of fits and set up directory with PDB's and images with geometry signature prefix
    #####################################################################################

    # Open map for cross-correlation and making images, into #999
    rc('open #999 '+str(cwd)+'/map/'+str(map))
    rc('volume #999 sdLevel 4 color grey transparency 0.8')
    #Save default cage and model orientation
    rc('savepos p2')
    rc('combine #1 modelId #0; combine #2 modelId #0; combine #3 modelId #0; combine #4 modelId #0; combine #5 modelId #0'
       )
    rc('close #1-5')
    rc('write #0 ' + str(dir) + '/' + str(directory) + '_angles/' + str(name) +
       '_segments.pdb')

    clearReplyLog()

    #Run inertiapdb_coc.py script to calculate principal axes for all segments
    rc('runscript ' + str(dir) + '/scripts/angles/inertiapdb_coc.py')

    #Ready for next round
    rc('close #')

    #Save reply log with key principal axes definitions
    saveReplyLog(
        str(dir) + '/' + str(directory) + '_angles/' + str(name) + '.axes')

#Call shell script for parsing angle data
subprocess.call(str(dir) + '/scripts/angles/seshscriptrun.sh', shell=True)

rc('stop')

#####################################################################################
# Save the session and data
#####################################################################################

#Move angles folder to directory you were working in
shutil.move(
    str(dir) + '/PDB_angles',
    str(dir) + '/' + str(directory) + '/PDB_angles')
Пример #10
0
        print(fn)
        replyobj.status("Processing " + fn)  # show what file we're working on
        rc("open " + fn)

    if args.sec_struct:
        if args.sec_frac:
            rc("mm #0 #1 ss {}".format(args.sec_frac))
        else:
            rc("mm #0 #1")
    else:
        rc("mm #0 #1 ss False")

    from chimera.tkgui import saveReplyLog
    ## could probably strip extensions if you want shorter file name for reply log file
    try:
        saveReplyLog("{}_{}_match.txt".format(file_names[0], file_names[1]))
    except IndexError:
        print("Need 2 files")
"""
Not implemented Match > Align

1) Getting the list of open molecules:

from chimera import openModels, Molecule
mols = openModels.list(modelTypes=[Molecule])

2) Getting the list of chains to use.  This example code assumes they're chain A:

chains = [m.sequence('A') for m in mols]

3)  Call Match->Align to create the alignment.
Пример #11
0
    PDB = filelist[i - 1]
    #measure cmm markers, centre of map mass, cmm_markers will be in #1, model in #2
    #rc('measure center #0 mark true radius 10 color red model '+str(i))

    #Place center of rotation origin cmm marker if not using centre of mass marker
    rc('volume #0 showOutlineBox true')
    rc('reset; cofr #0; ac mc')

    #measure cmm marker centre of PDB defining subparticle
    rc('open #2 ' + str(dir) + '/PDB/' + str(PDB))
    rc('measure center #2 mark true radius 10 color blue model #1')
    #save cmm marker as vector for localrec subparticle extraction
    rc('savemarkers #1 "' + str(dir) + '/cmm_markers/marker_' + str(i) +
       '.cmm"')

    #Record the distance between centre and subparticle marker
    clearReplyLog()
    rc('distance #1:1 #1:2')
    rc('getcrd #1:1')
    rc('getcrd #1:2')
    saveReplyLog(str(dir) + "/cmm_markers/marker_" + str(i) + "_distance.log")

    #Close ready for next round
    rc('close #1')
    rc('close #2')

rc('close #')

#close chimera
rc('stop')
    if i < 4:
        volSAXS = 2.0 * vol[prots[i]]
    else:
        volSAXS = 2.0 * vol[prots[i]]
    runCommand('volume #' + str(i) +
               ' step 1 transparency 0.50 encloseVolume ' + str(volSAXS))
    num += 1

for i in range(len(prots)):
    print i, num
    runCommand('open ' + prots[i] + ".mrc")
    runCommand('color #FFCCCC #' + str(num))
    runCommand('volume #' + str(num) +
               ' step 1 transparency 0.50 encloseVolume ' + str(vol[prots[i]]))
    runCommand('move cofr mod #' + str(num))

    runCommand('vop gaussian #' + str(num) + ' sd ' + str(stdev[prots[i]]))
    num += 1

    runCommand('volume #' + str(num) +
               ' step 1 transparency 0.50 encloseVolume ' + str(vol[prots[i]]))
    runCommand('fitmap #' + str(i) + ' #' + str(num) +
               ' metric correlation listFits false search 1000 placement rs')
    runCommand('measure correlation #' + str(i) + ' #' + str(num))
    runCommand('measure correlation #' + str(num) + ' #' + str(i))

    num += 1

saveReplyLog("Results_cross_correlation.txt")
##exit()