Ejemplo n.º 1
0
def info_atoms(session, atoms=None, attribute="idatm_type"):
    if atoms is None:
        from chimerax.core.commands import atomspec
        atoms = atomspec.everything(session)
    results = atoms.evaluate(session)
    residues = results.atoms.unique_residues
    report_atoms(session.logger, results.atoms, attribute)
Ejemplo n.º 2
0
def info_distmat(session, atoms):
    from scipy.spatial.distance import pdist, squareform
    if atoms is None:
        from chimerax.core.commands import atomspec
        atoms = atomspec.everything(session)
    results = atoms.evaluate(session)
    atoms = results.atoms
    coords = atoms.scene_coords
    distmat = pdist(coords, "euclidean")
    report_distmat(session.logger, atoms, distmat)
Ejemplo n.º 3
0
def info_models(session, atoms=None, type_=None, attribute="name"):
    if atoms is None:
        from chimerax.core.commands import atomspec
        atoms = atomspec.everything(session)
    results = atoms.evaluate(session)
    if type_ is not None:
        type_ = type_.lower()
    models = [
        m for m in results.models
        if type_ is None or type(m).__name__.lower() == type_
    ]
    report_models(session.logger, models, attribute)
Ejemplo n.º 4
0
def info_chains(session, atoms=None, attribute="chain_id"):
    if atoms is None:
        from chimerax.core.commands import atomspec
        atoms = atomspec.everything(session)
    results = atoms.evaluate(session)
    chains = []
    for m in results.models:
        try:
            chains.extend(m.chains)
        except AttributeError:
            # No chains, no problem
            pass
    report_chains(session.logger, chains, attribute)
Ejemplo n.º 5
0
def info_polymers(session, atoms=None):
    if atoms is None:
        from chimerax.core.commands import atomspec
        atoms = atomspec.everything(session)
    results = atoms.evaluate(session)
    polymers = []
    residues = results.atoms.unique_residues
    from chimerax.atomic import AtomicStructure
    for m in results.atoms.unique_structures:
        try:
            for p, ptype in m.polymers(AtomicStructure.PMS_TRACE_CONNECTS,
                                       False):
                if p.intersects(residues):
                    polymers.append(p)
        except AttributeError:
            # No chains, no problem
            pass
    report_polymers(session.logger, polymers)
Ejemplo n.º 6
0
def findclash(session,
              spec=None,
              make_pseudobonds=False,
              log=True,
              naming_style="command",
              overlap_cutoff=0.6,
              hbond_allowance=0.4,
              bond_separation=4,
              test="other",
              intra_residue=False):
    from chimerax.core.errors import LimitationError
    from chimerax.atomic import Atoms
    from chimerax.core.commands import atomspec
    from chimerax.atomic.settings import settings
    if test != "self":
        raise LimitationError("findclash test \"%s\" not implemented" % test)
    if hbond_allowance != 0:
        session.logger.warning("Hydrogen bond finding is not implemented.  "
                               "Setting hbond_allowance to 0.0.")
        hbond_allowance = 0
    if naming_style != "command" and naming_style != "command-line":
        raise LimitationError("findclash naming style \"%s\" not implemented" %
                              naming_style)
    if make_pseudobonds:
        raise LimitationError("findclash make pseudobonds not implemented")
    if spec is None:
        spec = atomspec.everything(session)
    results = spec.evaluate(session)
    atoms = results.atoms
    neighbors = _find_neighbors(atoms, bond_separation)
    clashes = []
    for i in range(len(atoms) - 1):
        a = atoms[i]
        if intra_residue:
            # Want intra-residue contacts, so check all atoms
            others = atoms[i + 1:]
        else:
            # Do not want intra-residue contacts, so remove atoms from residue
            from numpy import logical_not
            others = atoms[i + 1:]
            residues = others.residues
            # Generate mask for atoms from same residue
            mask = others.residues.mask(Atoms([a.residue]))
            others = others.filter(logical_not(mask))
        # Remove atoms within "separation" bonds of this atom
        others -= neighbors[a]
        if len(others) > 0:
            clashes.extend(
                _find_clash_self(a, others, overlap_cutoff, hbond_allowance))
    if log:
        session.logger.info("Allowed overlap: %g" % overlap_cutoff)
        session.logger.info("H-bond overlap reduction: %g" % hbond_allowance)
        session.logger.info("Ignored contact between atoms separated by %d "
                            "bonds or less" % bond_separation)
        session.logger.info("%d contacts" % len(clashes))
        session.logger.info("atom1\tatom2\toverlap\tdistance")
        save = settings.atomspec_contents
        settings.atomspec_contents = "command"
        msgs = ["%s\t%s\t%.3f\t%.3f" % c for c in clashes]
        settings.atomspec_contents = save
        session.logger.info('\n'.join(msgs))
        session.logger.info("%d contacts" % len(clashes))