Exemplo n.º 1
0
def to_mdtraj_Trajectory(item,
                         molecular_system=None,
                         atom_indices='all',
                         structure_indices='all'):

    from openmm.unit import nanometers
    from mdtraj.core.trajectory import Trajectory as mdtraj_Trajectory

    tmp_topology, _ = to_mdtraj_Topology(item,
                                         molecular_system,
                                         atom_indices=atom_indices,
                                         structure_indices=structure_indices)
    coordinates = get_coordinates_from_atom(
        item, indices=atom_indices, structure_indices=structure_indices)
    coordinates = coordinates.in_units_of(nanometers)._value
    tmp_item = mdtraj_Trajectory(coordinates, tmp_topology)

    if molecular_system is not None:
        tmp_molecular_system = molecular_system.combine_with_items(
            tmp_item,
            atom_indices=atom_indices,
            structure_indices=structure_indices)
    else:
        tmp_molecular_system = None

    return tmp_item, tmp_molecular_system
Exemplo n.º 2
0
def to_mdtraj_Trajectory(item, atom_indices='all', check=True):

    if check:

        try:
            is_pdbfixer_PDBFixer(item)
        except:
            raise WrongFormError('pdbfixer.PDBFixer')

        try:
            atom_indices = digest_atom_indices(atom_indices)
        except:
            raise WrongAtomIndicesError()

    try:
        from mdtraj.core.trajectory import Trajectory as mdtraj_Trajectory
    except:
        raise LibraryNotFoundError('MDTraj')

    from molsysmt import puw
    from . import to_mdtraj_Topology
    from . import get_coordinates_from_atom

    tmp_item = to_mdtraj_Topology(item, atom_indices=atom_indices, check=False)
    coordinates = get_coordinates_from_atom(tmp_item,
                                            indices=atom_indices,
                                            check=False)
    coordinates = puw.convert(coordinates,
                              to_units='nanometer',
                              to_form='openmm.unit')
    tmp_item = mdtraj_Trajectory(coordinates, tmp_item)

    return tmp_item
Exemplo n.º 3
0
def to_mdtraj_Trajectory(item, atom_indices='all', structure_indices='all', check=True):

    if check:

        digest_item(item, 'openmm.Modeller')
        atom_indices = digest_atom_indices(atom_indices)
        structure_indices = digest_structure_indices(structure_indices)

    try:
        from mdtraj.core.trajectory import Trajectory as mdtraj_Trajectory
    except:
        raise LibraryNotFound('MDTraj')

    from . import to_mdtraj_Topology
    from ..mdtraj_Trajectory import extract as extract_mdtraj_Trajectory
    from molsysmt import puw

    tmp_topology  = to_mdtraj_Topology(item, check=False)
    positions = puw.get_value(item.positions, to_unit='nanometers')
    tmp_item = mdtraj_Trajectory(positions, tmp_topology)
    tmp_item = extract_mdtraj_Trajectory(tmp_item, atom_indices=atom_indices,
                                         structure_indices=structure_indices, copy_if_all=False,
                                         check=False)

    return tmp_item
Exemplo n.º 4
0
def to_mdtraj_Trajectory(item,
                         atom_indices='all',
                         structure_indices='all',
                         check=True):

    if check:

        digest_item(item, 'molsysmt.MolSys')
        atom_indices = digest_atom_indices(atom_indices)
        structure_indices = digest_structure_indices(structure_indices)

    from molsysmt import puw
    from . import to_mdtraj_Topology
    from . import get_box_lengths_from_system, get_box_angles_from_system, get_coordinates_from_atom, get_time_from_system

    try:
        from mdtraj.core.trajectory import Trajectory as mdtraj_Trajectory
    except:
        raise LibraryNotFound('mdtraj')

    tmp_item_topology = to_mdtraj_Topology(item,
                                           atom_indices=atom_indices,
                                           check=False)

    tmp_box_lengths = get_box_lengths_from_system(
        item, structure_indices=structure_indices, check=False)
    if tmp_box_lengths is not None:
        tmp_box_lengths = puw.get_value(tmp_box_lengths, to_unit='nm')

    tmp_box_angles = get_box_angles_from_system(
        item, structure_indices=structure_indices, check=False)
    if tmp_box_angles is not None:
        tmp_box_angles = puw.get_value(tmp_box_angles, to_unit='degrees')

    tmp_coordinates = get_coordinates_from_atom(
        item,
        indices=atom_indices,
        structure_indices=structure_indices,
        check=False)
    tmp_coordinates = puw.get_value(tmp_coordinates, to_unit='nm')

    tmp_time = get_time_from_system(item,
                                    structure_indices=structure_indices,
                                    check=False)
    if tmp_time is not None:
        tmp_time = puw.get_value(tmp_time, to_unit='ps')

    tmp_item = mdtraj_Trajectory(tmp_coordinates,
                                 tmp_item_topology,
                                 tmp_time,
                                 unitcell_lengths=tmp_box_lengths,
                                 unitcell_angles=tmp_box_angles)

    return tmp_item
Exemplo n.º 5
0
def to_mdtraj_Trajectory(item,
                         atom_indices='all',
                         structure_indices='all',
                         check=True):

    if check:

        try:
            is_openmm_PDBFile(item)
        except:
            raise WrongFormError('openmm.PDBFile')

        try:
            atom_indices = digest_atom_indices(atom_indices)
        except:
            raise WrongAtomIndicesError()

        try:
            structure_indices = digest_structure_indices(structure_indices)
        except:
            raise WrongStructureIndicesError()

    from .to_mdtraj_Topology import to_mdtraj_Topology
    from .get import get_coordinates_from_atom

    try:
        from mdtraj.core.trajectory import Trajectory as mdtraj_Trajectory
    except:
        raise LibraryNotFoundError()

    topology = to_mdtraj_Topology(item, atom_indices=atom_indices)
    coordinates = get_coordinates_from_atom(
        item,
        indices=atom_indices,
        structure_indices=structure_indices,
        check=False)
    tmp_item = mdtraj_Trajectory(positions, topology)

    return tmp_item