示例#1
0
def from_mol2(f):
    path = str(datapath / f)
    u = Universe(path)
    elements = [guess_atom_element(n) for n in u.atoms.names]
    u.add_TopologyAttr("elements", np.array(elements, dtype=object))
    u.atoms.types = np.array([x.upper() for x in u.atoms.types], dtype=object)
    return Molecule.from_mda(u, force=True)
示例#2
0
文件: util.py 项目: htz1992213/mdgo
def assign_name(u: Universe, names: np.ndarray):
    """
    Assign resnames to residues in a MDAnalysis.universe object. The function will not overwrite existing names.

    Args:
        u: The universe object to assign resnames to.
        names: The element name array.
    """
    u.add_TopologyAttr("name", values=names)
示例#3
0
文件: util.py 项目: htz1992213/mdgo
def assign_resname(u: Universe, res_dict: Dict[str, str]):
    """
    Assign resnames to residues in a MDAnalysis.universe object. The function will not overwrite existing resnames.

    Args:
        u: The universe object to assign resnames to.
        res_dict: A dictionary of resnames, where each resname is a key
            and the corresponding values are the selection language.
    """
    u.add_TopologyAttr("resname")
    for key, val in res_dict.items():
        res_group = u.select_atoms(val)
        res_names = res_group.residues.resnames
        res_names[res_names == ""] = key
        res_group.residues.resnames = res_names
示例#4
0
def write_betafactor(u:mda.Universe,data:np.ndarray,pdb_name:str, selection=None, skip=1):
    """
    write cosine theta data for all atoms into a multi frame pdb file
    """
    u.add_TopologyAttr("tempfactors")
    with mda.Writer(pdb_name, multiframe=True, bonds=None, n_atoms=len(u.atoms)) as PDB:
        for i in range(0,len(data),skip):
            index = int(data[i,0])
            print("printing frame {}".format(index))
            u.trajectory[index]

            atoms = u.atoms
            if selection:
                atoms = u.select_atoms("resname {}".format(selection))

            atoms.tempfactors = data[i,1:]

            PDB.write(atoms)