Esempio n. 1
0
    def __init__(self, pdb, identifier=0, path=""):
        """ :param pdb: :type string: pdb ID of the protein to be folded.
        """
        self.gen_last = 0                                 # Stores generation for which energy score was last calculated
        self.lowest = 100000000                           # Lowest score observed

        # Rosetta inits
        # This has ended up only using rosetta to get the sequence of the pdb file, which is of course not necessary
        rosetta.init()                                    # Initialize rosetta libraries
        pose_native = pose_from_rcsb(pdb)                 # Create rosetta pose of natively folded protein from pdb file

        self.sequence = pose_native.sequence()            # Get sequence of protein
        self.id = identifier                              # Id of process
        self.rot_iter = 200                               # Number of iterations to try to resolve side chain clashes
        self.rot_mover_size = 5                           # Size of rotamer mover
        self.new_conf = False                             # Switch to build with new rotamer conformations
        self.mod_dict = {}                                # Dictionary of modified rotamers
        self.path = path

        self.c_size = len(self.sequence)*2                     # Number of residues * 2 (phi and psi for each residue)

        # Ecspy inits
        rand = Random()
        rand.seed(int(time()))
        self.es = swarm.PSO(rand)                         # Create ecspy evolution strategy seeded with current time
        self.bounder = ec.Bounder(-180, 180)
        self.es.topology = topologies.star_topology
Esempio n. 2
0
def check_input(args):
    '''check the inputs, and create initial pose.'''
    #checking input
    print args
    if len(args)==3:
        number_of_decoys=args[2]
        pose_name=args[1]
        initial_pose=pose_from_rcsb(pose_name)
        g=open(pose_name+'.clean.pdb','r')
        new_pdb=open(pose_name+'.aa_only.pdb','w')
        # delete lines which are not amino acid
        for line in g.readlines():
            if len(line.split()[3])==3:
                new_pdb.write(line)
        g.close()
        new_pdb.close()
        initial_pose=pose_from_file(pose_name+'.aa_only.pdb')
    elif len(args)==4:
        number_of_decoys=args[3]
        aa_num=args[1]
        aa_name=args[2]
        initial_pose=pose_from_sequence(int(aa_num)*str(aa_name))
    return number_of_decoys, initial_pose
Esempio n. 3
0
    def __init__(self, pdb, mc_temperature=1, identifier=0, local=True, path=""):
        """
        :param pdb: PDB id of protein to be folded.
        :param mc_temperature: Temperature for MC simulation.
        :param identifier: ID of process.
        :param local: :type boolean: If True, test moves per residue.
        """
        self.gen_last = 0                                 # Stores generation for which energy score was last calculated
        self.lowest = 100000000                           # Lowest score observed
        self.conformation = []                            # Current conformation of protein
        self.mover_size = 20                              # Degrees to move at each step
        self.current_score = 0                            # The current energy at any state
        self.steps = 0                                    # Number of steps elapsed
        self.max_steps = 1000000                          # Maximum number of steps to run simulation
        self.temperature = mc_temperature                 # Monte carlo temperature
        self.accepted = 1.0                               # Number of MC steps accepted
        self.rejected = 1.0                               # Number of MC steps rejected
        self.id = identifier                              # Id of process, for running multiple simultaneously
        self.threshold = 1                                # Threshold counter for increasing mover range
        self.score_10 = 10000000                          # The lowest score 10 steps ago
        self.local = local                                # Whether to use local mover (global otherwise)
        self.rot_conformation = []                        # Container for rotamer conformations
        self.rot_conf_local = []                          # Container for rotamer conformation within loop
        self.rot_iter = 100                               # Number of iterations to try to resolve side chain clashes
        self.rot_mover_size = 5                           # Size of rotamer mover
        self.new_conf = False                             # Switch to build with new rotamer conformations
        self.mod_dict = {}                                # Dicitonary of modified rotamers
        self.path = path                                  # Path to directory to operate in

        # Rosetta inits
        # This has ended up only using rosetta for getting the sequence from pdb, which is of course not necessary
        rosetta.init()                                    # Initialize rosetta libraries
        pose_native = pose_from_rcsb(pdb)                 # Create rosetta pose of natively folded protein from pdb file
        self.sequence = pose_native.sequence()            # Get sequence of protein

        self.c_size = len(self.sequence)*2                     # Number of residues * 2 (phi and psi for each residue)
Esempio n. 4
0
    def __init__(self, pdb, centroid=False, pdb_file='', frag=False, nine_mer=False, local=False, local_size=3,
                 full=False, rosetta_refinement=False):
        """ :param pdb: :type string: pdb ID of the protein to be folded
            :param centroid: :type boolean: Option for use of centroid model
        """
        self.loops = 0                                    # Stores generation for which energy score was last calculated
        self.scores = {}                                  # Dictionary container for current gen genomes/scores
        self.scores_list = []                             # List container of current gen scores for search
        self.gen_added = 0                                # Last gen in which a point was added to novelty archive
        self.threshold = 10                               # Novelty threshold for which point is added to archive
        self.acceptance_threshold = 100                   # Novelty threshold for which move is accepted automatically
        self.num_added = 0                                # Number of points added to novelty archive
        self.switch = False                               # All atom switch
        self.temperature = 5                              # Monte Carlo temperature
        self.mover_range = 10                             # +-range of the angle in degrees in which mover moves residue
        self.local_size = local_size                      # For local mover, size of fragment to move
        self.local = local                                # Whether to use local mover
        self.novelty_archive = deque()                    # Initialize novelty archive
        self.centroid = centroid                          # If true use centroid scoring
        self.last_lowest = 0                              # For use in novelty loop
        self.last_lowest_10 = 0                           # For use in clear main loop
        self.frag = frag                                  # If true use frag mover
        self.rosetta_refinement = rosetta_refinement      # If true refine rosetta fold

        # Rosetta inits
        rosetta.init()                                    # Initialize rosetta libraries
        pose_native = pose_from_rcsb(pdb)                 # Create rosetta pose of natively folded protein from pdb file
        sequence = pose_native.sequence()                 # Get sequence of protein
        self.scorefxn = rosetta.get_fa_scorefxn()         # Create the rosetta energy score function for all atom
        
        if pdb_file != '':
            self.pose = rosetta.pose_from_pdb(pdb_file)   # If a starting pdb is given search from this pose
        elif rosetta_refinement:                          # If rosetta refinement, start from fastrelax structure
            self.pose = rosetta.pose_from_sequence(sequence)
            relax = rosetta.FastRelax()
            relax.set_scorefxn(self.scorefxn)
            relax.apply(self.pose)
        else:
            self.pose = rosetta.pose_from_sequence(sequence)  # Create the rosetta pose that will be manipulated
            
        if centroid:                                      # Switch pose to centroid if centroid option is true
            switch = rosetta.SwitchResidueTypeSetMover("centroid")
            switch.apply(self.pose)
        self.c_size = len(sequence)*2                     # Number of residues * 2 (phi and psi for each residue)
        self.native_energy = self.scorefxn(pose_native)   # Energy of the natively folded protein
        
        if centroid:                                      # Switch rosetta score function if centroid
            self.scorefxn = rosetta.create_score_function('score3')
        self.conformation = []
        
        i = 1
        while i <= len(sequence):
            self.conformation.append(self.pose.phi(i))
            self.conformation.append(self.pose.psi(i))
            i += 1

        self.mc_energy = self.scorefxn(self.pose) + 500   # Energy to be used as minimal criteria
        self.lowest = self.scorefxn(self.pose)            # Lowest energy in archive
        
        if frag:
            if nine_mer:
                fragset = rosetta.ConstantLengthFragSet(9)
                fragset.read_fragment_file("aat000_09_05-1.200_v1_3")
            else:
                fragset = rosetta.ConstantLengthFragSet(3)
                fragset.read_fragment_file("aat000_03_05-1.200_v1_3")
            movemap = rosetta.MoveMap()
            movemap.set_bb(True)
            self.mover_3mer = rosetta.ClassicFragmentMover(fragset, movemap)

        if local:                                         # For local, initialize na with appropriate number of deques
            self.novelty_archive = [deque() for i in range(self.c_size/2/self.local_size)]

        self.full = full                                  # If true use full mover