コード例 #1
0
            pos = random.sample(Pose.dict.keys(), 1)[0]  # pick a residue number to start with
            null_frag_id = (args.mer, pos, 0, 0)

            Boltzmann = PerRsdBoltzmann(working_temp)

            """ After picking a position to optimize, calculate compatibility scores for all the candidate placements at that residue """
            for candidate_frag_id in Scorefxn.density_score_dict[
                pos
            ].keys():  # loop over all candidate frags at the pos
                # skip null fragment
                if (candidate_frag_id[2], candidate_frag_id[3]) == (0, 0):
                    Boltzmann.probability(null_frag_id, args.null_frag_score)
                    continue

                Container = Scorefxn.score_evaluator(candidate_frag_id)
                Boltzmann.probability(candidate_frag_id, Container.score_)
            #### end of calculating all the candidate_frags at the residue to the selected ones ####

            # normalize it
            Boltzmann.normalization()

            # pick one frag
            selected_frag_id = Boltzmann.pick_frag()
            print "frag_id: %s %s got picked!!\n" % (selected_frag_id, Boltzmann.dict[selected_frag_id])

            # update pose
            SelectedContainer = Scorefxn.score_evaluator(selected_frag_id)
            SelectedContainer.boltzmann_prob_ = Boltzmann.dict[selected_frag_id]
            SelectedContainer.per_rsd_boltz_dict = Boltzmann.dict
コード例 #2
0
ファイル: oop_sampling.py プロジェクト: raywangyr/scripts
            pkl = open( args.starts_with , "rb" )
            scorefxn.selected_frags_dict = pickle.load( pkl )
        else:
            scorefxn.initialize( args.initialization )

        for each_step in range( args.steps ):
            print "round: %s  cycle: %s" %( each_round, each_step )
            pos = pos_list[ random.randrange( 0, len( pos_list ) ) ] # pick a residue number to start with

            boltzmann_prob_Dict = {}
            ''' After picking a position to optimize, calculate compatibility scores for all the candidate placements at that residue'''
            for each_candidate_frag_id in density_score_Dict[ pos ].keys():  # loop over all candidate frags at the pos

                if ( each_candidate_frag_id[2], each_candidate_frag_id[3] ) == ( 0, 0 ): continue # skip null fragment

                container = scorefxn.score_evaluator( each_candidate_frag_id )
                boltzmann_prob_Dict[ each_candidate_frag_id ] = ( boltzmann_prob( container.score_, args.temperature_ ), container.score, container.rmsd )

                if args.verbose:
                    print "each_candidate_frag_id %3s %3s %3s %3s    rmsd: %5.4f    score: %5.4f    density: %5.4f    overlap: %5.4f    nonoverlap: %5.4f    boltzmann: %s" %( each_candidate_frag_id[0], each_candidate_frag_id[1], each_candidate_frag_id[2], each_candidate_frag_id[3], container.rmsd, container.score, container.density_score, container.all_overlap_score, container.all_nonoverlap_score, boltzmann_prob_Dict[ each_candidate_frag_id ] )
                                                                                        
            #### end of calculating all the candidate_frags at the residue to the selected ones ####

            # assign a null frag for each position
            null_frag_id = ( args.mer, pos, 0, 0 )
            boltzmann_prob_Dict[ null_frag_id ] = ( boltzmann_prob( args.null_frag_score, args.temperature ), args.null_frag_score, 0.0 )

            # normalize it - watch out this step
            normalized_boltzmann_prob_Dict = normalization( boltzmann_prob_Dict )
            # pick one frag
            selected_frag_id = pick_frags( normalized_boltzmann_prob_Dict )
コード例 #3
0
            mer  = mer_list[ random.randrange( 0, len(mer_list) ) ]

            # pick a residue number to start with
            if args.designated_position: pos = args.designated_position
            else: pos = pos_list[ random.randrange( 0, len( pos_list ) ) ]

            boltzmann_prob_Dict = {}
            ''' After picking a position to optimize,
                calculate compatibility scores for all the candidate placements at that residue'''
            for each_candidate_frag_id in density_score_Dict[ pos ].keys():  # loop over all candidate frags at the pos
                if ( each_candidate_frag_id[2], each_candidate_frag_id[3] ) == ( 0, 0 ): continue # skip null fragment
                total_score, density_score, all_overlap_score, all_nonoverlap_score, rmsd = ( 0.0, )*5

                #each_candidate_frag_id = ( key[0], pos, key[1], key[2] ) # frag_id = ( mer, pos, picker_rank, SHD_rank )
                # calculate score
                total_score, density_score, all_overlap_score, all_nonoverlap_score, rmsd = scorefxn.score_evaluator( each_candidate_frag_id )

                boltzmann_prob_Dict[ each_candidate_frag_id ] = ( boltzmann_prob( total_score, args.temperature ), total_score, rmsd )

                if args.verbose:
                    print "each_candidate_frag_id %3s %3s %3s %3s    rmsd: %5.4f    score: %5.4f    density: %5.4f    overlap: %5.4f    nonoverlap: %5.4f    boltzmann: %s" %(
                      each_candidate_frag_id[0], each_candidate_frag_id[1], each_candidate_frag_id[2], each_candidate_frag_id[3],
                      rmsd, total_score, 
                      density_score, all_overlap_score, all_nonoverlap_score,
                      boltzmann_prob_Dict[ each_candidate_frag_id ] )
                                                                                        
            #### end of calculating all the candidate_frags at the residue to the selected ones ####

            # assign a null frag for each position
            null_frag_id = ( mer, pos, 0, 0 )
            boltzmann_prob_Dict[ null_frag_id ] = ( boltzmann_prob( args.null_frag_score, args.temperature ), args.null_frag_score, 0.0 )