def test_init_one_residue(self, molecule_top_bmim: MoleculeTop, residue_bmim: Residue): """ Tests Molecule initialization with only one residue and some basic attributes and methods. """ # Wrong residue new_residue = Residue(residue_bmim[:-1]) with pytest.raises(IOError): molec = Molecule(molecule_top_bmim, [new_residue]) molec = Molecule(molecule_top_bmim, [residue_bmim]) assert len(molec) == len(molecule_top_bmim) assert len(molec) == len(residue_bmim) assert len(molec) == 25 assert str(molec) == 'Molecule of BMIM.' for atom, atom_top, atom_gro in zip(molec, molecule_top_bmim, residue_bmim): atom_compare = Atom(atom_top, atom_gro) assert atom == atom_compare for atom, atom_comp in zip(molec, molec.atoms): assert atom == atom_comp assert molec[-1] == atom_compare assert atom_compare != molec[0] assert molec.index(atom_compare) == 24 with pytest.raises(ValueError): _ = molec.index(34) # type: ignore assert molec._each_atom_resid == [0] * len(molec) assert molec == molec assert molec is molec copy_mol = molec.copy() assert copy_mol == molec assert copy_mol is not molec assert len(molec.residues) == 1 assert molec.residues[0] == residue_bmim assert molec.residues[0] is not residue_bmim assert molec.molecule_top is molecule_top_bmim with pytest.raises(NotImplementedError): _ = molec + 1 # type: ignore with pytest.raises(NotImplementedError): _ = 1 + molec # type: ignore for key in dir(molec.molecule_top): assert key in dir(molec)
def molecule_VTE_AA() -> Molecule: """ Molecule instance of E vitamin in all-atom resolution. """ fitpVTE = os.path.join(ACTUAL_PATH, '../../gaddlemaps/data/VTE_AA.itp') fgroVTE = os.path.join(ACTUAL_PATH, '../../gaddlemaps/data/VTE_AA.gro') VTEgro = SystemGro(fgroVTE)[0] VTEitp = MoleculeTop(fitpVTE) return Molecule(VTEitp, [VTEgro])
def molecule_popc_AA() -> Molecule: """ Molecule instance of POPC in all-atom resolution. """ fitppopc = os.path.join(ACTUAL_PATH, '../../gaddlemaps/data/popc-AA.itp') fgropopc = os.path.join(ACTUAL_PATH, '../../gaddlemaps/data/popc-AA.gro') popcgro = SystemGro(fgropopc)[0] popcitp = MoleculeTop(fitppopc) return Molecule(popcitp, [popcgro])
def molecule_VTE_map() -> Molecule: """ Molecule instance of E vitamin in coarse-grained resolution after being mapped. """ fitpVTE = os.path.join(ACTUAL_PATH, '../../gaddlemaps/data/vitamin_E_CG.itp') fgroVTE = os.path.join(ACTUAL_PATH, '../../gaddlemaps/data/VTE_map.gro') VTEgro = SystemGro(fgroVTE)[0] VTEitp = MoleculeTop(fitpVTE) return Molecule(VTEitp, [VTEgro])
def vte_aa() -> Molecule: """ Molecule instance of vitamin E all-atom. """ fgro = os.path.join(ACTUAL_PATH, '../../gaddlemaps/data/VTE_AA.gro') with GroFile(fgro) as _file: atoms = [AtomGro(line) for line in _file] mgro = Residue(atoms) fitp = os.path.join(ACTUAL_PATH, '../../gaddlemaps/data/VTE_AA.itp') mitp = MoleculeTop(fitp) return Molecule(mitp, [mgro])
def molecule_cg() -> Molecule: """ Molecule instance of curcumine coarse-grained. """ fgro = os.path.join(ACTUAL_PATH, '../../gaddlemaps/data/CUR_map.gro') with GroFile(fgro) as _file: atoms = [AtomGro(line) for line in _file] mgro = Residue(atoms) fitp = os.path.join(ACTUAL_PATH, '../../gaddlemaps/data/CUR_CG.itp') mitp = MoleculeTop(fitp) return Molecule(mitp, [mgro])
def molecule_aa() -> Molecule: """ Molecule instance of curcumine in all-atom resolution. """ fgro = os.path.join(ACTUAL_PATH, '../../gaddlemaps/data/CUR_AA.gro') with GroFile(fgro) as _file: atoms = [AtomGro(line) for line in _file] mgro = Residue(atoms) fitp = os.path.join(ACTUAL_PATH, '../../gaddlemaps/data/CUR_AA.itp') mitp = MoleculeTop(fitp) return Molecule(mitp, [mgro])
def vte_map_cg() -> Molecule: """ Molecule instance of vitamin E coarse-grained coming from the map process. """ fgro = os.path.join(ACTUAL_PATH, '../../gaddlemaps/data/VTE_map.gro') with GroFile(fgro) as _file: atoms = [AtomGro(line) for line in _file] mgro = Residue(atoms) fitp = os.path.join(ACTUAL_PATH, '../../gaddlemaps/data/vitamin_E_CG.itp') mitp = MoleculeTop(fitp) return Molecule(mitp, [mgro])
def test_init_multi_residue(self, molecule_top_protein: MoleculeTop, residue_protein: List[Residue]): """ Tests Molecule initialization with multiple residues and some basic attributes and methods. """ molec = Molecule(molecule_top_protein, residue_protein) assert len(molec) == len(molecule_top_protein) assert len(molec) == sum(len(res) for res in residue_protein) assert len(molec) == 34 index = 0 for res in residue_protein: for atom_gro in res: atom_compare = Atom(molecule_top_protein[index], atom_gro) assert molec[index] == atom_compare index += 1 for atom, atom_comp in zip(molec, molec.atoms): assert atom == atom_comp assert molec[-1] == atom_compare assert molec.index(atom_compare) == 33 assert molec._each_atom_resid == [0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12] assert molec != 0 assert molec == molec assert molec is molec assert molec.copy() == molec assert molec.copy() is not molec assert len(molec.residues) == 13 for res1, res2 in zip(molec.residues, residue_protein): assert res1 == res2 assert res1 is not res2 assert molec.molecule_top is molecule_top_protein
def molecule_bmim(molecule_top_bmim: MoleculeTop, residue_bmim: Residue) -> Molecule: """ BMIM Molecule instance. """ return Molecule(molecule_top_bmim, [residue_bmim])
def molecule_protein(molecule_top_protein: MoleculeTop, residue_protein: List[Residue]) -> Molecule: """ Molecule instance with multiple residues. """ return Molecule(molecule_top_protein, residue_protein)