Exemplo n.º 1
0
    def refine(self, atmsel, actions):
        """Refine the optimized model with MD and CG"""
        # Save the current model:
        if self.fit_in_refine != 'NO_FIT':
            self.write(file='TO_BE_REFINED.TMP')

        # Possibly skip selecting hot atoms only and optimize all atoms:
        if self.refine_hot_only:
            self.initial_refine_hot(atmsel)

        # Do simulated annealing MD:
        if self.md_level:
            self.md_level(atmsel, actions)

        # Possibly skip 'HOT CG' after MD:
        if self.refine_hot_only:
            self.final_refine_hot(atmsel)

        # Get a final conjugate gradients refined structure:
        cg = conjugate_gradients()
        cg.optimize(atmsel,
                    max_iterations=200,
                    output=self.optimize_output,
                    actions=actions)

        # Evaluate gross changes between the initial and final refined model:
        if 'NO_FIT' not in self.fit_in_refine:
            aln = alignment(self.env)
            mdl2 = read_model(file='TO_BE_REFINED.TMP')
            casel = selection(self).only_atom_types('CA')
            casel.superpose(mdl2, aln)
            casel = selection(self)
            casel.superpose(mdl2, aln)
            modfile.delete('TO_BE_REFINED.TMP')
Exemplo n.º 2
0
 def get_normalized_dope_profile(self):
     """Return a normalized DOPE per-residue profile"""
     from modeller.selection import selection
     from modeller import normalized_dope, physical
     profile = selection(self).get_dope_profile()
     scorer = normalized_dope.DOPEScorer(self)
     return scorer.get_profile(profile)
Exemplo n.º 3
0
    def het_std_restraints(self, aln, selhet, ca_distance, bond_distance,
                           rsrgrp):
        """Constrain each atom in a HETATM or BLK residue by its distance to all
           protein atoms within C{bond_distance} (these interactions are also
           removed from the nonbonded list) and also to all protein CA atoms
           that are within C{ca_distance}. The former maintains any
           protein-HETATM bonding, and the latter maintains the residue in
           roughly the right position."""

        rsr = self.restraints
        selstd = selection(self).only_std_residues()
        selca = selstd.only_atom_types('CA')

        print "%d atoms in HETATM/BLK residues constrained\n" % len(selhet) \
              + "to protein atoms within %.2f angstroms\n" % bond_distance \
              + "and protein CA atoms within %.2f angstroms" % ca_distance
        # Build the bonds first; this avoids duplicated CA-ligand bonds since
        # make_distance() will not build restraints that are already on the
        # nonbond exclusion list
        for (sel, dist, excl) in ((selstd, bond_distance, bond_distance),
                                  (selca, ca_distance, 0.0)):
            rsr.make_distance(sel,
                              selhet,
                              aln=aln,
                              distance_rsr_model=7,
                              maximal_distance=dist,
                              spline_on_site=self.spline_on_site,
                              restraint_group=rsrgrp,
                              restraint_stdev=(0.2, 0.0),
                              residue_span_range=(1, 99999),
                              residue_span_sign=False,
                              exclude_distance=excl)
Exemplo n.º 4
0
    def homcsr(self, exit_stage):
        """Construct the initial model and restraints"""
        # Check the alignment
        aln = self.read_alignment()

        # Since in general we do not want to loose the original alignment file
        # (which is usually not a temporary scratch file):
        if self.accelrys:
            # Accelrys code here (Azat, you may want to add the .tmp.ali part
            # so that you do not change the input alignment file, unless you
            # want to have it changed here for some other use elsewhere):
            aln.write(file=self.alnfile)  # file='.tmp.ali'
            codes = [seq.code for seq in aln]
            aln.read(file=self.alnfile, align_codes=codes)
            # modfile.delete(file='.tmp.ali')

        self.check_alignment(aln)

        # make topology and build/read the atom coordinates:
        self.make_initial_model(aln)

        # exit early?
        if exit_stage == 2:
            return

        # make and write the stereochemical, homology, and special restraints?
        if self.create_restraints:
            self.mkhomcsr(selection(self), aln)
            self.restraints.condense()
            self.restraints.write(self.csrfile)
Exemplo n.º 5
0
def _unbuild_ring(r, atoms):
    s = selection()
    for a in atoms:
        try:
            s.add(r.atoms[a])
        except KeyError:
            continue
    s.unbuild()
Exemplo n.º 6
0
 def _check_model_hetatm_water(self):
     """Check to see if env.io.hetatm or water are set if we're using
        HETATMs or waters"""
     if not self.env.io.hetatm or not self.env.io.water:
         water = selection(self).only_water_residues()
         # Note that het is always a superset of water
         het = selection(self).only_het_residues() - water
         warn = """You have at least one %s residue in your model, but
           io_data.%s is False. (This means that Modeller will not read
           any %s data from your templates, which is usually not what
           you want. To fix this, set env.io.%s = True before creating
           the automodel or loopmodel object.)"""
         if len(water) > 0 and not self.env.io.water:
             log.warning("_check_model_hetatm_water",
                         warn % ('water', 'water', 'water', 'water'))
         if len(het) > 0 and not self.env.io.hetatm:
             log.warning("_check_model_hetatm_water",
                         warn % ('HETATM', 'hetatm', 'HETATM', 'hetatm'))
Exemplo n.º 7
0
 def assess_normalized_dopehr(self):
     """Assess the model, and return a normalized DOPE-HR score (z score)"""
     from modeller.selection import selection
     import normalized_dope
     sel = selection(self)
     dope_score = sel.assess_dopehr()
     scorer = normalized_dope.DOPEHRScorer(self)
     z_score = scorer.get_z_score(dope_score)
     print ">> Normalized DOPE-HR z score: %.3f" % z_score
     return z_score
Exemplo n.º 8
0
    def nonstd_restraints(self, aln):
        """Create restraints on HETATM and BLK residues."""
        # Select all HETATM residues plus any ATOM residues that have
        # no defined topology (generally speaking, BLK residues)
        allatoms = selection(self)
        selhet = allatoms.only_het_residues() | allatoms.only_no_topology()

        rsrgrp = physical.xy_distance
        self.het_std_restraints(aln, selhet, 10.0, 2.3, rsrgrp)
        self.het_het_restraints(aln, selhet, 7.0, 2.3, rsrgrp)
        self.het_internal_restraints(aln, selhet, rsrgrp)
Exemplo n.º 9
0
def fit(env, model, code, model2, code2, alnfile, model2_fit):
    """Superposes model2 on model, and writes out a file with model2 superposed
       on model."""
    m1 = modelobj(env, file=model)
    m2 = modelobj(env, file=model2)

    aln = alignment(env, file=alnfile, align_codes=(code, code2))
    atmsel = selection(m1).only_atom_types('CA')

    atmsel.superpose(m2, aln)

    m2.write(file=model2_fit)
Exemplo n.º 10
0
 def get_normalized_dope_profile(self):
     """Return a normalized DOPE per-residue profile"""
     from modeller.selection import selection
     import normalized_dope
     import physical
     sel = selection(self)
     edat = sel.get_dope_energy_data()
     oldgprsr = self.group_restraints
     self.group_restraints = sel.get_dope_potential()
     try:
         profile = sel.get_energy_profile(edat, physical.nonbond_spline)
     finally:
         self.group_restraints = oldgprsr
     scorer = normalized_dope.DOPEScorer(self)
     return scorer.get_profile(profile)
Exemplo n.º 11
0
 def select_sphere(self, radius):
     """Returns a selection of all atoms within the given distance"""
     inds = _modeller.mod_selection_sphere(self.mdl.modpt, self.x, self.y,
                                           self.z, radius)
     return selection.selection(AtomIndices(inds, self.mdl))
Exemplo n.º 12
0
 def select_atoms(self):
     """Select atoms to be optimized in the model building procedure. By
        default, this selects all atoms, but you can redefine this routine
        to select a subset instead."""
     return selection(self)