def to_mdanalysis_Universe(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'file:mmtf') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) try: from MDAnalysis import Universe except: raise LibraryNotFoundError('MDAnalysis') from ..mdanalysis_Universe import extract as extract_mdanalysis_Universe tmp_item = Universe(item) tmp_item = extract_mdanalysis_Universe(tmp_item, atom_indices=atom_indices, structure_indices=structure_indices, copy_if_all=False, check=False) return tmp_item
def to_openmm_Simulation(item, atom_indices='all', structure_indices='all', forcefield=None, non_bonded_method='no_cutoff', non_bonded_cutoff='1.0 nm', constraints=None, rigid_water=True, remove_cm_motion=True, hydrogen_mass=None, switch_distance=None, flexible_constraints=False, integrator='Langevin', temperature='300.0 K', collisions_rate='1.0 1/ps', integration_timestep='2.0 fs', platform='CUDA', check=True): if check: digest_item(item, 'file:pdb') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from . import to_openmm_Modeller from ..openmm_Modeller import to_openmm_Simulation as openmm_Modeller_to_openmm_Simulation tmp_item = to_openmm_Modeller(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) tmp_item = openmm_Modeller_to_openmm_Simulation(tmp_item, forcefield=forcefield, non_bonded_method=non_bonded_method, non_bonded_cutoff=non_bonded_cutoff, constraints=constraints, rigid_water=rigid_water, remove_cm_motion=remove_cm_motion, hydrogen_mass=hydrogen_mass, switch_distance=switch_distance, flexible_constraints=flexible_constraints, integrator=integrator, temperature=temperature, collisions_rate=collisions_rate, integration_timestep=integration_timestep, platform=platform, check=False) return tmp_item
def extract(item, atom_indices='all', structure_indices='all', copy_if_all=True, check=True): if check: digest_item(item, 'parmed.Structure') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) if (atom_indices is 'all') and (structure_indices is 'all'): if copy_if_all: from copy import deepcopy tmp_item = deepcopy(item) else: tmp_item = item else: from molsysmt._private.atom_indices import atom_indices_to_AmberMask from molsysmt._private.atom_indices import complementary_atom_indices tmp_atom_indices = complementary_atom_indices(item, atom_indices) mask = atom_indices_to_AmberMask(item, tmp_atom_indices) tmp_item = copy(item) tmp_item.strip( atom_indices2AmberMask(atom_indices, len(item.atoms), inverse=True)) return tmp_item
def to_molsysmt_MolSys(item, selection='all', structure_indices='all', syntaxis='MolSysMT'): if check: digest_item(item, 'openmm.GromacsGroFile') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from molsysmt.native.molsys import MolSys from .to_molsysmt_Topology import to_molsysmt_Topology from .to_molsysmt_Structures import to_molsysmt_Structures tmp_item = MolSys() tmp_item.topology = to_molsysmt_Topology( item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) tmp_item.structures = to_molsysmt_Structures( item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) return tmp_item
def to_mdtraj_Trajectory(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'parmed.Structure') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from . import to_mdtraj_Topology from . import get_coordinates_from_atom, get_box_from_system from ..mdtraj_Topology import to_mdtraj_Trajectory as openmm_Topology_to_openmm_Modeller tmp_item = to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) coordinates = get_coordinates_from_atom( item, indices=atom_indices, structure_indices=structure_indices, check=False) box = get_box_from_system(item, structure_indices=structure_indices, check=False) tmp_item = mdtraj_Topology_to_mdtraj_Trajectory(tmp_item, coordinates=coordinates, box=box, check=False) return tmp_item
def to_pytraj_Trajectory(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'file:pdb') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) try: from pytraj import load except: raise LibraryNotFoundError('pytraj') from ..pytraj_Trajectory import extract as extract_pytraj_Trajectory tmp_item = load(item) tmp_item = extract_pytraj_Trajectory(tmp_item, atom_indices=atom_indices, structure_indices=structure_indices, copy_if_all=False, check=False) return tmp_item
def to_string_pdb_text(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'string:pdb_id') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from ..file_pdb import download as download_file_pdb from ..string_pdb_text import extract as extract_string_pdb_text from os import remove tmp_item = download_file_pdb(item.replace('pdb_id:', ''), output_filename) tmp_file = tmp_item fff = open(tmp_item, 'r') tmp_item = fff.read() fff.close() remove(tmp_file) tmp_item = extract_string_pdb_text(tmp_item, atom_indices=atom_indices, structure_indices=structure_indices, copy_if_all=False, check=False) return tmp_item
def to_molsysmt_MolSys(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'pytraj.Trajectory') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from molsysmt.native.molsys import MolSys from . import to_molsysmt_Topology from . import to_molsysmt_Structures tmp_item = MolSys() tmp_item.topology = to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) tmp_item.structures = to_molsysmt_Structures( item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) return tmp_item
def to_openmm_Modeller(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'file:mol2') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from . import to_openmm_Topology from . import get_coordinates_from_atom, get_box_from_system from ..openmm_Topology import to_openmm_Modeller as openmm_Topology_to_openmm_Modeller tmp_item = to_openmm_Topology(item, atom_indices=atom_indices, check=False) coordinates = get_coordinates_from_atom( item, indices=atom_indices, structure_indices=structure_indices, check=False) box = get_box_from_system(item, structure_indices=structure_indices, check=False) tmp_item = openmm_Topology_to_openmm_Modeller(tmp_item, coordinates=coordinates, box=box, check=False) return tmp_item
def to_pdbfixer_PDBFixer(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'mdtraj.Trajectory') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from . import to_openmm_Topology from . import get_coordinates_from_atom from ..openmm_Topology import to_pdbfixer_PDBFixer as openmm_Topology_to_pdbfixer_PDBFixer tmp_item = to_openmm_Topology(item, atom_indices=atom_indices, check=False) coordinates = get_coordinates_from_atom( item, indices=atom_indices, structure_indices=structure_indices, check=False) tmp_item = openmm_Topology_to_pdbfixer_PDBFixer(tmp_item, coordinates=coordinates, check=False) return tmp_item
def extract(item, atom_indices='all', structure_indices='all', copy_if_all=True, check=True): if check: digest_item(item, 'mdtraj.Trajectory') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) if (atom_indices is 'all') and (structure_indices is 'all'): if copy_if_all: from copy import deepcopy tmp_item = deepcopy(item) else: tmp_item = item else: tmp_item = item if atom_indices is not 'all': tmp_item = tmp_item.atom_slice(atom_indices) if structure_indices is not 'all': tmp_item = tmp_item.slice(structure_indices) return tmp_item
def to_file_pdb(item, atom_indices='all', structure_indices='all', output_filename=None, check=True): if check: digest_item(item, 'mmtf.MMTFDecoder') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from . import to_molsysmt_MolSys from ..molsysmt_MolSys import to_file_pdb as molsysmt_MolSys_to_file_pdb tmp_item = to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices) tmp_item = molsysmt_MolSys_to_file_pdb(tmp_item, output_filename=output_filename) return tmp_item
def to_openmm_Topology(item, atom_indices='all', check=True): if check: digest_item(item, 'mdtraj.Trajectory') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from . import to_mdtraj_Topology from ..mdtraj_Topology import to_openmm_Topology as mdtraj_Topology_to_openmm_Topology tmp_item = to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) tmp_item = mdtraj_Topology_to_openmm_Topology(tmp_item, check=False) return tmp_item
def to_molsysmt_Structures(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'file:xtc') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from . import to_mdtraj_XTCTrajectoryFile from ..mdtraj_XTCTrajectoryFile import to_molsysmt_Structures as mdtraj_XTCTrajectoryFile_to_molsysmt_Structures tmp_item = to_mdtraj_XTCTrajectoryFile(item, check=False) tmp_item = mdtraj_XTCTrajectoryFile_to_molsysmt_Structures(tmp_item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) return tmp_item
def to_file_xyznpy(item, atom_indices='all', structure_indices='all', output_filename=None, check=True): if check: digest_item(item, 'XYZ') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) tmp_item = output_filename with open(tmp_item, 'wb') as fff: np.save(fff, item.shape, allow_pickle=True) np.save(fff, puw.get_value(item, to_unit='nm'), allow_pickle=True) return tmp_item
def to_biopython_Seq(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'mdtraj.Trajectory') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from . import to_string_aminoacids1 from ..string_aminoacids1 import to_biopython_Seq as string_aminoacids1_to_biopython_Seq tmp_item = to_string_amionacids1(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) tmp_item = string_aminoacids1_to_biopython_Seq(tmp_item, check=False) return tmp_item
def to_mdtraj_Trajectory(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'mmtf.MMTFDecoder') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from . import to_molsysmt_MolSys from ..molsysmt_MolSys import to_mdtraj_Trajectory as molsysmt_MolSys_to_mdtraj_Trajectory tmp_item = to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) tmp_item = molsysmt_MolSys_to_mdtraj_Trajectory(tmp_item, check=False) return tmp_item
def to_mdtraj_Topology(item, atom_indices='all', check=True): if check: digest_item(item, 'mdtraj.Trajectory') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from ..mdtraj_Topology import extract as extract_mdtraj_Topology tmp_item = item.topology tmp_item = extract_mdtraj_Topology(tmp_item, atom_indices=atom_indices, check=False) return tmp_item
def to_nglview_NGLWidget(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'mdtraj.Trajectory') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from . import extract from nglview import show_mdtraj as show_mdtraj tmp_item = extract(item, atom_indices=atom_indices, structure_indices=structure_indices, copy_if_all=False, check=False) tmp_item = show_mdtraj(tmp_item) return tmp_item
def to_nglview_NGLWidget(item, atom_indices='all', structure_indices='all', output_filename=None, check=True): if check: digest_item(item, 'file:mol2') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from nglview import show_file as nglview_show_file tmp_item = nglview_show_file(item) return tmp_item
def to_mdtraj_Trajectory(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'file:mol2') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from mdtraj import load_mol2 from ..mdtraj_Trajectory import extract as extract_mdtraj_Trajectory tmp_item = load_mol2(item) tmp_item = extract_mdtraj_Trajectory(tmp_item) return tmp_item
def to_molsysmt_Structures(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'pdbfixer.PDBFixer') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from molsysmt.native.structures import Structures from . import get_coordinates_from_atom, get_box_from_system tmp_item = Structures() coordinates = get_coordinates_from_atom(item, indices=atom_indices, check=False) box = get_box_from_system(item, check=False) tmp_item.append_structures(coordinates=coordinates, box=box) return tmp_item
def to_file_pdb(item, atom_indices='all', structure_indices='all', output_filename=None, multiframe=True, check=True): if check: digest_item(item, 'mdanalysis.Universe') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) tmp_item = extract(item, atom_indices=atom_indices, structure_indices=structure_indices) tmp_item.atoms.write(output_filename, multiframe=multiframe) tmp_item = output_filename return tmp_item
def to_molsysmt_Structures(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'XYZ') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from molsysmt.native.trajectory import Structures from . import get_coordinates_from_atom tmp_item = Structures() coordinates = get_coordinates_from_atom( item, indices=atom_indices, structure_indices=structure_indices) tmp_item.append_structures(coordinates=coordinates) return tmp_item
def to_parmed_Structure(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'file:mol2') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) try: from parmed import load_file except: raise LibraryNotFound('parmed') from molsysmt.form.parmed_Structure import extract tmp_item = load_file(item) tmp_item = tmp_item.to_structure() tmp_item = extract(tmp_item, atom_indices=atom_indices, structure_indices=structure_indices, copy_if_all=False) return tmp_item
def to_file_pdb(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'mdtraj.Trajectory') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from . import extract tmp_item = extract(item, atom_indices=atom_indices, structure_indices=structure_indices, copy_if_all=False, check=False) tmp_item.save_pdb(output_filename) tmp_item = output_filename return tmp_item
def to_molsysmt_Structures(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'openmm.PDBFile') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from molsysmt.native.structures import Structures from .get import get_coordinates_from_atom, get_box_from_system, get_step_from_system, get_time_from_system coordinates = get_coordinates_from_atom(item, indices=atom_indices, structure_indices=structure_indices, check=False) box = get_box_from_system(item, structure_indices=structure_indices, check=False) step = get_step_from_system(item, structure_indices=structure_indices, check=False) time = get_time_from_system(item, structure_indices=structure_indices, check=False) tmp_item = Structures() tmp_item.append(coordinates=coordinates, step=step, time=time, box=box) return tmp_item
def to_openmm_System(item, atom_indices='all', structure_indices='all', forcefield=None, non_bonded_method='no_cutoff', non_bonded_cutoff='1.0 nm', constraints=None, rigid_water=True, remove_cm_motion=True, hydrogen_mass=None, switch_distance=None, flexible_constraints=False, check=True): if check: digest_item(item, 'file:pdb') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from . import to_openmm_Modeller from ..openmm_Modeller import to_openmm_System as openmm_Modeller_to_openmm_System tmp_item = to_openmm_Modeller(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) tmp_item = openmm_Modeller_to_openmm_System( tmp_item, forcefield=forcefield, non_bonded_method=non_bonded_method, non_bonded_cutoff=non_bonded_cutoff, constraints=constraints, rigid_water=rigid_water, remove_cm_motion=remove_cm_motion, hydrogen_mass=hydrogen_mass, switch_distance=switch_distance, flexible_constraints=flexible_constraints, check=False) return tmp_item
def to_nglview_NGLWidget(item, atom_indices='all', structure_indices='all', check=True): if check: digest_item(item, 'file:gro') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from . import to_molsysmt_MolSys from .molsysmt_MolSys import to_nglview_NGLWidget as molsysmt_MolSys_to_nglview_NGLWidget tmp_item = to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) tmp_item = molsysmt_MolSys_to_nglview_NGLWidget(tmp_item) return tmp_item
def to_molsysmt_MolSys(item, atom_indices='all', check=True): if check: digest_item(item, 'pdbfixer.PDBFixer') atom_indices = digest_atom_indices(atom_indices) structure_indices = digest_structure_indices(structure_indices) from molsysmt.native.molsys import MolSys from . import to_molsysmt_Topology from . import to_molsysmt_Structures as pdbfixer_PDBFixer_to_molsysmt_Structures tmp_item = MolSys() tmp_item.topology = to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) tmp_item.structures = pdbfixer_PDBFixer_to_molsysmt_Structures( item, atom_indices=atom_indices, check=False) return tmp_item