def score(session, atomic_model, map_model, rez): ''' Perform the CCC score. Takes a session, a single model and map.''' print("Calculating CCC Score") # make class instances for density simulation (blurring), scoring and plot scores blurrer = StructureBlurrer() scorer = ScoringFunctions() atomlist = [] for atom in atomic_model.atoms: atomlist.append(chimera_to_tempy_atom(atom, len(atomlist))) bio_atom_structure = BioPy_Structure(atomlist) bio_map_structure = chimera_to_tempy_map(map_model) map_probe = blurrer.gaussian_blur(bio_atom_structure, rez, densMap=bio_map_structure) score = scorer.CCC(bio_map_structure, map_probe) print(score) return score
os.mkdir(path_out) os.chdir(path_out) structure_instance=PDBParser.read_PDB_file('1J6Z','1J6Z.pdb',hetatm=False,water=False) print structure_instance blurrer = StructureBlurrer() EnsembleGeneration=EnsembleGeneration() scorer = ScoringFunctions() map_target=MapParser.readMRC('emd_5168_monomer.mrc') #read target map map_probe = blurrer.gaussian_blur(structure_instance, 6.6,densMap=map_target)#create a simulated map from the structure instance #Create a Random ensemble of 10 structures randomly within 5 A translation and 60 deg rotation. list_rotate_models=EnsembleGeneration.randomise_structs(structure_instance, 10, 5, 60, v_grain=30, rad=False,write=True) #CCC score from starting fit line='%s %s\n'%('1J6Z',scorer.CCC(map_probe,map_target)) count=0 #loop to score each of the alternative fits in the ensemble for mod in list_rotate_models: count+=1 mod_name=mod[0] mod_structure_instance=mod[1] map_probe = blurrer.gaussian_blur(mod_structure_instance, 6.6,densMap=map_target,sigma_coeff=0.187) line+='%s %s\n'%(mod_name,scorer.CCC(map_probe,map_target)) print line
water=False) print structure_instance2 blurrer = StructureBlurrer() scorer = ScoringFunctions() Plot = Plot() emmap = MapParser.readMRC('emd_5168_monomer.mrc') #read target map print emmap sim_map = blurrer.gaussian_blur(structure_instance, 6.6, densMap=emmap, sigma_coeff=sim_sigma_coeff, normalise=True) print 'structure_instance', scorer.CCC(sim_map, emmap) print sim_map sim_map2 = blurrer.gaussian_blur(structure_instance2, 6.6, densMap=emmap, sigma_coeff=sim_sigma_coeff, normalise=True) print 'structure_instance_same', scorer.CCC(sim_map2, emmap) SCCC_list_structure_instance = [] listRB = RBParser.read_FlexEM_RIBFIND_files(rb_file, structure_instance2) for RB in listRB: score_SCCC = scorer.SCCC(emmap, 6.6, sim_sigma_coeff, structure_instance2, RB) SCCC_list_structure_instance.append(score_SCCC)
map_probe = blurrer.gaussian_blur(structure_instance, 6.6,densMap=map_target)#create a simulated map from the structure instance map_probe.write_to_MRC_file("map_probe_actin.mrc") #write simulated map to a MRC file format ##SCORING FUNCTION print "Calculate Envelope Score (ENV):" molecualr_weight=structure_instance.get_prot_mass_from_atoms() #Mmolecualr_weight=structure_instance.get_prot_mass_from_res() first_bound=map_target.get_primary_boundary(molecualr_weight, map_target.min(), map_target.max()) #print scorer.envelope_score_APJ(map_target, first_bound, structure_instance,norm=True) print scorer.envelope_score(map_target, first_bound, structure_instance,norm=True) print "Calculate Mutual information Score (MI)" print scorer.MI(map_target,map_probe) print "Calculate Laplacian cross-correlation Score (LAP)" print scorer.laplace_CCC(map_target,map_probe) print "Calculate cross-correlation Score (CCC)" print scorer.CCC(map_target,map_probe) print "Calculate Normal Vector (NV):" #Number of points to use in the normal vector score points= round((map_target.map_size())*0.01) first_bound=map_target.get_primary_boundary(structure_instance.get_prot_mass_from_atoms(), map_target.min(), map_target.max()) second_bound=map_target.get_second_boundary(first_bound, points, first_bound, map_target.max(),err_percent=1) print scorer.normal_vector_score(map_target,map_probe, first_bound, second_bound) print "Calculate Normal Vector (NV) with Sobel Filter:" print scorer.normal_vector_score(map_target,map_probe, first_bound, second_bound,Filter='Sobel')