コード例 #1
0
ファイル: test_cmd.py プロジェクト: rtviii/ChimeraXTempy
    def test_tempy_sccc(self):
        ''' Test the tempy sccc score based on the files
    provided. Use this as a baseline for the second
    chimeraX test. '''

        # the sigma factor determines the width of the Gaussian distribution used to describe each atom
        sim_sigma_coeff = 0.187

        path_test = "./"
        m = os.path.join(path_test, '1akeA_10A.mrc')
        p = os.path.join(path_test, '1ake_mdl1.pdb')
        r = 10.0
        rb_file = os.path.join(path_test, '1ake_mdl1_rigid.txt')

        scorer = ScoringFunctions()

        # read map file
        emmap = MapParser.readMRC(m)

        # read PDB file
        structure_instance = PDBParser.read_PDB_file('pdbfile',
                                                     p,
                                                     hetatm=False,
                                                     water=False)
        SCCC_list_structure_instance = []

        # read rigid body file and generate structure instances for each segment
        listRB = RBParser.read_FlexEM_RIBFIND_files(rb_file,
                                                    structure_instance)

        # score each rigid body segment
        listsc_sccc = []

        for RB in listRB:
            # sccc score
            score_SCCC = scorer.SCCC(emmap, r, sim_sigma_coeff,
                                     structure_instance, RB)
            listsc_sccc.append(score_SCCC)

        self.assertTrue(len(listRB) == 6)
        self.assertTrue(abs(round(listsc_sccc[0], 4) - 0.954) < 0.01)
        self.assertTrue(abs(round(listsc_sccc[1], 4) - 0.427) < 0.01)
        self.assertTrue(abs(round(listsc_sccc[2], 4) - 0.624) < 0.01)
        self.assertTrue(abs(round(listsc_sccc[3], 4) - 0.838) < 0.01)
        self.assertTrue(abs(round(listsc_sccc[4], 4) - 0.971) < 0.01)
        self.assertTrue(abs(round(listsc_sccc[5], 4) - 0.928) < 0.01)
コード例 #2
0
                                             p,
                                             hetatm=False,
                                             water=False)
# generate atom density and blur to required resolution
#sim_map = blurrer.gaussian_blur(structure_instance, r,densMap=emmap,sigma_coeff=sim_sigma_coeff,normalise=True)

#sim_map = blurrer.gaussian_blur_real_space(structure_instance, r,densMap=emmap,sigma_coeff=sim_sigma_coeff,normalise=True)
SCCC_list_structure_instance = []
# read rigid body file and generate structure instances for each segment
listRB = RBParser.read_FlexEM_RIBFIND_files(rb_file, structure_instance)
# score each rigid body segment
listsc_sccc = []
print 'calculating scores'
for RB in listRB:
    # sccc score
    score_SCCC = scorer.SCCC(emmap, r, sim_sigma_coeff, structure_instance, RB)
    SCCC_list_structure_instance.append(score_SCCC)
    print '>>', score_SCCC
    listsc_sccc.append(score_SCCC)

listRB = RBParser.RBfileToRBlist(rb_file)
if len(listRB) == len(listsc_sccc):
    #include sccc scores as b-factor records
    for x in structure_instance.atomList:
        cur_chain = x.chain
        cur_res = x.get_res_no()
        ct = 0
        flage = 0
        if cur_chain in ['', ' ']: cur_chain = '-'
        for rb in listRB:
            '''
コード例 #3
0
                                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)
    print score_SCCC

listRB = RBParser.RBfileToRBlist(rb_file)
Plot.PrintOutChimeraAttributeFileSCCC_Score('3MFP',
                                            SCCC_list_structure_instance,
                                            listRB)

SCCC_list_structure_instance2 = []
listRB2 = RBParser.read_FlexEM_RIBFIND_files(rb_file, structure_instance2)

for RB in listRB2:
    score_SCCC = scorer.SCCC(emmap, 6.6, sim_sigma_coeff, structure_instance2,
                             RB)
    SCCC_list_structure_instance2.append(score_SCCC)
コード例 #4
0
ファイル: sccc.py プロジェクト: rtviii/ChimeraXTempy
def score(session,
          atomic_model,
          map_model,
          rigid_filename,
          rez,
          sim_sigma=0.187,
          colour_atoms=True):
    """ Perform the SCCC score 
  Takes a session, a single model, map, rigid file path and some tuneable 
  optional variables
  """

    print("Calculating SCCC Score")

    # make class instances for density simulation (blurring), scoring and plot scores
    blurrer = StructureBlurrer()
    scorer = ScoringFunctions()

    atomlist = []

    # Pre-defines
    bio_atom_structure = ""
    bio_map_structure = ""

    try:
        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)

        # read rigid body file and generate structure instances for each segment
        listRB = RBParser.read_FlexEM_RIBFIND_files(rigid_filename,
                                                    bio_atom_structure)
    except Exception as e:
        print(e)
        print(
            "Error in reading Model and Map. Make sure you have selected one model and one map, and the rigid file is correct."
        )
        return

    # score each rigid body segment
    listsc_sccc = []
    print('calculating SCCC')

    for RB in listRB:
        # sccc score
        score_SCCC = scorer.SCCC(bio_map_structure,
                                 rez,
                                 sim_sigma,
                                 bio_atom_structure,
                                 RB,
                                 c_mode=False)

        print('>>', score_SCCC)
        listsc_sccc.append((RB, score_SCCC))

        # Colour the atoms based on the rating from white (1.0) to red (0.0)
        # TODO - maybe a faster way? Also 'all_atoms' mentioned in the API doesnt exist but atoms does! :S
        # TODO - move this to somewhere better maybe?
        if colour_atoms:
            dr = 255
            dg = 255
            db = 255
            if score_SCCC >= 0.5:
                dr = 255 - int(math.floor(255 * ((score_SCCC - 0.5) * 2.0)))
                dg = dr
            else:
                db = int(math.floor(255 * (score_SCCC * 2.0)))
                dg = db

            residues = []
            for a in RB.atomList:
                if a.res_no not in residues:
                    residues.append(a.res_no)

            for r in residues:
                cr = atomic_model.residues[r]
                for catm in cr.atoms:
                    catm.color = [dr, dg, db, 255]
                cr.ribbon_color = [dr, dg, db, 255]

    return listsc_sccc