@@ -298,3 +298,20 @@
Loading
298 298
    }
299 299
300 300
    return energies
301 +
302 +
303 +
def is_file_and_not_empty(file_path):
304 +
    """Util function to check if a file both exists at the specified ``path`` and is not empty.
305 +
306 +
    Parameters
307 +
    ----------
308 +
    file_path: os.PathLike
309 +
        The file path to check.
310 +
311 +
    Returns
312 +
    -------
313 +
    bool
314 +
        That a file both exists at the specified ``path`` and is not empty.
315 +
    """
316 +
    # This function is copied from OpenFF-Evaluator
317 +
    return os.path.isfile(file_path) and (os.path.getsize(file_path) != 0)

@@ -3,8 +3,22 @@
Loading
3 3
"""
4 4
5 5
import os
6 +
import shutil
6 7
7 -
from paprika.utils import make_window_dirs, strip_prmtop
8 +
import pytest
9 +
10 +
from paprika.utils import is_file_and_not_empty, make_window_dirs, strip_prmtop
11 +
12 +
13 +
@pytest.fixture
14 +
def clean_files(directory=os.path.join(os.path.dirname(__file__), "tmp")):
15 +
    # This happens before the test function call
16 +
    if os.path.isdir(directory):
17 +
        shutil.rmtree(directory)
18 +
    os.makedirs(directory)
19 +
    yield
20 +
    # This happens after the test function call
21 +
    shutil.rmtree(directory)
8 22
9 23
10 24
def test_mkdirs():
@@ -24,3 +38,32 @@
Loading
24 38
    residues = [r.name for r in cb6_only.residues]
25 39
    assert "CB6" in residues
26 40
    assert "BUT" not in residues
41 +
42 +
43 +
def test_is_file_and_not_empty(clean_files):
44 +
    # Check for existing file
45 +
    but_frcmod = os.path.abspath(
46 +
        os.path.join(os.path.dirname(__file__), "../data/cb6-but/but.frcmod")
47 +
    )
48 +
49 +
    assert os.path.isfile(but_frcmod)
50 +
    assert os.path.getsize(but_frcmod) != 0
51 +
    assert is_file_and_not_empty(but_frcmod)
52 +
53 +
    # Check for emtpy
54 +
    path = os.path.join(os.path.dirname(__file__), "tmp", "testfile1")
55 +
    with open(path, "w") as f:
56 +
        pass
57 +
58 +
    assert os.path.isfile(path)
59 +
    assert os.path.getsize(path) == 0
60 +
    assert not is_file_and_not_empty(path)
61 +
62 +
    # Check file after writing
63 +
    path = os.path.join(os.path.dirname(__file__), "tmp", "testfile2")
64 +
    with open(path, "w") as f:
65 +
        f.write("Hello World\n")
66 +
67 +
    assert os.path.isfile(path)
68 +
    assert os.path.getsize(path) != 0
69 +
    assert is_file_and_not_empty(path)

@@ -392,3 +392,77 @@
Loading
392 392
    assert "b = loadpdb cb6-but-minimized.pdb" in lines
393 393
    assert "combine" in lines
394 394
    assert "savepdb model multi.pdb" in lines
395 +
396 +
397 +
def test_conversions(clean_files):
398 +
    """ Test that conversion methods work in Tleap module. """
399 +
    temporary_directory = os.path.join(os.path.dirname(__file__), "tmp")
400 +
401 +
    but_frcmod = os.path.abspath(
402 +
        os.path.join(os.path.dirname(__file__), "../data/cb6-but/but.frcmod")
403 +
    )
404 +
    but_mol2 = os.path.abspath(
405 +
        os.path.join(os.path.dirname(__file__), "../data/cb6-but/but.mol2")
406 +
    )
407 +
408 +
    sys = System()
409 +
    sys.template_lines = [
410 +
        "source leaprc.gaff",
411 +
        f"loadamberparams {but_frcmod}",
412 +
        f"BUT = loadmol2 {but_mol2}",
413 +
        f"model = loadmol2 {but_mol2}",
414 +
    ]
415 +
    sys.output_path = temporary_directory
416 +
    sys.output_prefix = "but"
417 +
    sys.pbc_type = None
418 +
    sys.neutralize = False
419 +
    sys.build()
420 +
421 +
    from paprika.tleap import ConversionToolkit
422 +
    from paprika.utils import is_file_and_not_empty
423 +
424 +
    # Gromacs ParmEd test
425 +
    sys.convert_to_gromacs(overwrite=True)
426 +
    top_file = os.path.join(sys.output_path, sys.output_prefix + ".top")
427 +
    gro_file = os.path.join(sys.output_path, sys.output_prefix + ".gro")
428 +
    assert is_file_and_not_empty(top_file) is True
429 +
    assert is_file_and_not_empty(gro_file) is True
430 +
431 +
    # Gromacs InterMol test
432 +
    sys.convert_to_gromacs(toolkit=ConversionToolkit.InterMol)
433 +
    assert is_file_and_not_empty(top_file) is True
434 +
    assert is_file_and_not_empty(gro_file) is True
435 +
    top_file = os.path.join(sys.output_path, sys.output_prefix + "_from_amber.top")
436 +
    gro_file = os.path.join(sys.output_path, sys.output_prefix + "_from_amber.gro")
437 +
    assert is_file_and_not_empty(top_file) is True
438 +
    assert is_file_and_not_empty(gro_file) is True
439 +
440 +
    # CHARMM ParmEd test
441 +
    sys.convert_to_charmm()
442 +
    psf_file = os.path.join(sys.output_path, sys.output_prefix + ".psf")
443 +
    crd_file = os.path.join(sys.output_path, sys.output_prefix + ".crd")
444 +
445 +
    assert is_file_and_not_empty(psf_file) is True
446 +
    assert is_file_and_not_empty(crd_file) is True
447 +
448 +
    # CHARMM Intermol test
449 +
    sys.convert_to_charmm(toolkit=ConversionToolkit.InterMol)
450 +
    rtf_file = os.path.join(sys.output_path, sys.output_prefix + ".rtf")
451 +
    prm_file = os.path.join(sys.output_path, sys.output_prefix + ".prm")
452 +
453 +
    assert is_file_and_not_empty(psf_file) is True
454 +
    assert is_file_and_not_empty(crd_file) is True
455 +
    assert is_file_and_not_empty(rtf_file) is True
456 +
    assert is_file_and_not_empty(prm_file) is True
457 +
458 +
    # LAMMPS test
459 +
    sys.convert_to_lammps()
460 +
    input_file = os.path.join(sys.output_path, sys.output_prefix + ".input")
461 +
    lmp_file = os.path.join(sys.output_path, sys.output_prefix + ".lmp")
462 +
    assert is_file_and_not_empty(input_file) is True
463 +
    assert is_file_and_not_empty(lmp_file) is True
464 +
465 +
    # DESMOND test
466 +
    sys.convert_to_desmond()
467 +
    cms_file = os.path.join(sys.output_path, sys.output_prefix + ".cms")
468 +
    assert is_file_and_not_empty(cms_file) is True

@@ -2,6 +2,7 @@
Loading
2 2
import os as os
3 3
import re as re
4 4
import subprocess as sp
5 +
from enum import Enum
5 6
6 7
import numpy as np
7 8
import parmed as pmd
@@ -10,6 +11,17 @@
Loading
10 11
ANGSTROM_CUBED_TO_LITERS = 1 * 10 ** -27
11 12
12 13
14 +
# TODO: refactor System class, implement a build class for PSFGEN, PackMol and add TopoTools/VMD support for conversions
15 +
class ConversionToolkit(Enum):
16 +
    """
17 +
    An enumeration of the different toolkits for converting MD files to other formats.
18 +
    """
19 +
20 +
    ParmEd = "parmed"
21 +
    InterMol = "intermol"
22 +
    # TopoTools = "topotools"
23 +
24 +
13 25
class System(object):
14 26
    """
15 27
    Class for building AMBER prmtop/rst7 files with ``tleap``.
@@ -89,12 +101,17 @@
Loading
89 101
90 102
    Example
91 103
    -------
92 -
        >>> system = tleap.System()
104 +
        >>> from paprika.tleap import System
105 +
        >>>
106 +
        >>> # Initialize System
107 +
        >>> system = System()
93 108
        >>> system.output_path = "windows"
94 109
        >>> system.output_prefix = "host-guest-sol"
95 110
        >>> system.target_waters = 2000
96 111
        >>> system.pbc_type = "rectangular"
97 112
        >>> system.neutralize = True
113 +
        >>>
114 +
        >>> # template_lines lists all structure files etc.
98 115
        >>> system.template_lines = [
99 116
        >>>     "source leaprc.gaff",
100 117
        >>>     "source leaprc.water.tip3p",
@@ -106,9 +123,17 @@
Loading
106 123
        >>>     "DM1 = loadmol2 dm1.mol2",
107 124
        >>>     "DM2 = loadmol2 dm2.mol2",
108 125
        >>>     "DM3 = loadmol2 dm3.mol2",
109 -
        >>>     "complex = loadpdb host-guest.pdb",
126 +
        >>>     "model = loadpdb host-guest.pdb",
110 127
        >>> ]
128 +
        >>>
129 +
        >>> # Run TLeap
111 130
        >>> system.build()
131 +
        >>>
132 +
        >>> # Repartition masses of Hydrogen atoms
133 +
        >>> system.repartition_hydrogen_mass()
134 +
        >>>
135 +
        >>> # Convert AMBER files to GROMACS
136 +
        >>> system.convert_to_gromacs()
112 137
113 138
    """
114 139
@@ -218,7 +243,7 @@
Loading
218 243
219 244
    def write_input(self):
220 245
        """
221 -
        Write a tleap input file based on template_lines and other things we have set.
246 +
        Write a ``tleap`` input file based on template_lines and other things we have set.
222 247
        """
223 248
224 249
        file_path = os.path.join(self.output_path, self.output_prefix + ".tleap.in")
@@ -774,21 +799,29 @@
Loading
774 799
775 800
        structure.save(prmtop, overwrite=True)
776 801
777 -
    def convert_to_gromacs(self, overwrite=False, output_path=None, output_prefix=None):
802 +
    def convert_to_gromacs(
803 +
        self,
804 +
        overwrite=False,
805 +
        output_path=None,
806 +
        output_prefix=None,
807 +
        toolkit=ConversionToolkit.InterMol,
808 +
    ):
778 809
        """
779 -
        Convert `AMBER` topology and coordinate files to `GROMACS` format.
810 +
        Convert AMBER topology and coordinate files to GROMACS format.
780 811
781 812
        Parameters
782 813
        ----------
783 814
        overwrite: bool, optional, default=False
784 -
            Option to overwrite `GROMACS` ``.top`` and ``.gro`` files if they already
815 +
            Option to overwrite GROMACS ``.top`` and ``.gro`` files if they already
785 816
            exists in the folder.
786 817
        output_path: str, optional, default=None
787 -
            Alternate directory path where the `AMBER` files are located. Default is the
818 +
            Alternate directory path where the AMBER files are located. Default is the
788 819
            `path` parsed to the :class:`paprika.tleap.System` object.
789 820
        output_prefix: str, optional, default=None
790 821
            Alternate file name prefix for the Amber files. Default is the `prefix` parsed
791 822
            to the :class:`paprika.tleap.System` object.
823 +
        toolkit: :class:`ConversionToolkit`, default=ConversionToolkit.InterMol
824 +
            Option to choose the toolkit for converting the AMBER files, ParmEd or InterMol
792 825
        """
793 826
794 827
        if output_path is None:
@@ -798,16 +831,28 @@
Loading
798 831
            output_prefix = self.output_prefix
799 832
800 833
        file_name = os.path.join(output_path, output_prefix)
801 -
        prmtop = f"{file_name}.prmtop"
802 834
803 -
        # Check if Amber Topology file exist
804 -
        if not os.path.isfile(prmtop):
835 +
        # Check if Amber Topology file(s) exist
836 +
        topology = np.array([f"{file_name}.{ext}" for ext in ["prmtop", "parm7"]])
837 +
        check_topology = [os.path.isfile(file) for file in topology]
838 +
        if not any(check_topology):
805 839
            raise FileNotFoundError("Cannot find any AMBER topology file.")
806 840
841 +
        # Get the first topology file in the list of file(s) that exists
842 +
        prmtop = topology[check_topology][0]
843 +
807 844
        # Check if Amber Coordinate file(s) exist
808 -
        coordinates = np.array(
809 -
            [f"{file_name}.{ext}" for ext in ["rst7", "inpcrd", "pdb"]]
810 -
        )
845 +
        if toolkit == ConversionToolkit.ParmEd:
846 +
            coordinates = np.array(
847 +
                [
848 +
                    f"{file_name}.{ext}"
849 +
                    for ext in ["rst7", "inpcrd", "rst", "crd", "pdb"]
850 +
                ]
851 +
            )
852 +
        else:  # InterMol does not support PDB for loading Amber files
853 +
            coordinates = np.array(
854 +
                [f"{file_name}.{ext}" for ext in ["rst7", "inpcrd", "rst", "crd"]]
855 +
            )
811 856
        check_coordinates = [os.path.isfile(file) for file in coordinates]
812 857
        if not any(check_coordinates):
813 858
            raise FileNotFoundError("Cannot find any AMBER coordinates file.")
@@ -815,23 +860,282 @@
Loading
815 860
        # Get the first coordinate file in the list of file(s) that exists
816 861
        inpcrd = coordinates[check_coordinates][0]
817 862
818 -
        # Load Amber structure
819 -
        structure = pmd.load_file(prmtop, inpcrd, structure=True)
820 -
821 -
        # Save to Gromacs *.top and *.gro file
863 +
        # Gromacs file names
822 864
        top_file = f"{file_name}.top"
823 865
        gro_file = f"{file_name}.gro"
824 866
825 -
        if overwrite:
826 -
            structure.save(top_file, format="gromacs", overwrite=True)
827 -
            structure.save(gro_file, overwrite=True)
828 -
        else:
829 -
            if not os.path.isfile(top_file):
830 -
                structure.save(top_file, format="gromacs")
867 +
        # Convert with ParmEd
868 +
        if toolkit == ConversionToolkit.ParmEd:
869 +
            # Load Amber files
870 +
            structure = pmd.load_file(prmtop, inpcrd, structure=True)
871 +
872 +
            if overwrite:
873 +
                structure.save(top_file, format="gromacs", overwrite=True)
874 +
                structure.save(gro_file, format="gro", overwrite=True)
831 875
            else:
832 -
                log.info(f"Topology file {top_file} exists, skipping writing file.")
876 +
                if not os.path.isfile(top_file):
877 +
                    structure.save(top_file, format="gromacs")
878 +
                else:
879 +
                    log.info(f"Topology file {top_file} exists, skipping writing file.")
880 +
881 +
                if not os.path.isfile(gro_file):
882 +
                    structure.save(gro_file, format="gro")
883 +
                else:
884 +
                    log.info(
885 +
                        f"Coordinates file {gro_file} exists, skipping writing file."
886 +
                    )
887 +
888 +
        # Convert with InterMol
889 +
        elif toolkit == ConversionToolkit.InterMol:
890 +
            from intermol.convert import _load_amber, _save_gromacs
891 +
892 +
            # Load Amber files
893 +
            system, prefix, prmtop_in, crd_in, amb_structure = _load_amber(
894 +
                [prmtop, inpcrd]
895 +
            )
896 +
897 +
            # Save Gromacs files
898 +
            output_status = dict()
899 +
            _save_gromacs(system, file_name, output_status)
833 900
834 -
            if not os.path.isfile(gro_file):
835 -
                structure.save(gro_file)
901 +
            if output_status["gromacs"] != "Converted":
902 +
                raise Exception(
903 +
                    f"Converting AMBER to GROMACS with Intermol unsuccesful: {output_status['gromacs']}"
904 +
                )
905 +
906 +
    def convert_to_charmm(
907 +
        self,
908 +
        overwrite=False,
909 +
        output_path=None,
910 +
        output_prefix=None,
911 +
        toolkit=ConversionToolkit.InterMol,
912 +
    ):
913 +
        """
914 +
        Convert AMBER topology and coordinate files to CHARMM format.
915 +
916 +
        Parameters
917 +
        ----------
918 +
        overwrite: bool, optional, default=False
919 +
            Option to overwrite CHARMM ``.psf`` and ``.pdb`` files if they already
920 +
            exists in the folder.
921 +
        output_path: str, optional, default=None
922 +
            Alternate directory path where the AMBER files are located. Default is the
923 +
            `path` parsed to the :class:`paprika.tleap.System` object.
924 +
        output_prefix: str, optional, default=None
925 +
            Alternate file name prefix for the Amber files. Default is the `prefix` parsed
926 +
            to the :class:`paprika.tleap.System` object.
927 +
        toolkit: :class:`ConversionToolkit`, default=ConversionToolkit.InterMol
928 +
            Option to choose the toolkit for converting the AMBER files, ParmEd or InterMol
929 +
        """
930 +
931 +
        if output_path is None:
932 +
            output_path = self.output_path
933 +
934 +
        if output_prefix is None:
935 +
            output_prefix = self.output_prefix
936 +
937 +
        file_name = os.path.join(output_path, output_prefix)
938 +
939 +
        # Check if Amber Topology file(s) exist
940 +
        topology = np.array([f"{file_name}.{ext}" for ext in ["prmtop", "parm7"]])
941 +
        check_topology = [os.path.isfile(file) for file in topology]
942 +
        if not any(check_topology):
943 +
            raise FileNotFoundError("Cannot find any AMBER topology file.")
944 +
945 +
        # Get the first topology file in the list of file(s) that exists
946 +
        prmtop = topology[check_topology][0]
947 +
948 +
        # Check if Amber Coordinate file(s) exist
949 +
        if toolkit == ConversionToolkit.ParmEd:
950 +
            coordinates = np.array(
951 +
                [
952 +
                    f"{file_name}.{ext}"
953 +
                    for ext in ["rst7", "inpcrd", "rst", "crd", "pdb"]
954 +
                ]
955 +
            )
956 +
        else:  # InterMol does not support PDB for loading Amber files
957 +
            coordinates = np.array(
958 +
                [f"{file_name}.{ext}" for ext in ["rst7", "inpcrd", "rst", "crd"]]
959 +
            )
960 +
        check_coordinates = [os.path.isfile(file) for file in coordinates]
961 +
        if not any(check_coordinates):
962 +
            raise FileNotFoundError("Cannot find any AMBER coordinates file.")
963 +
964 +
        # Get the first coordinate file in the list of file(s) that exists
965 +
        inpcrd = coordinates[check_coordinates][0]
966 +
967 +
        # Charmm file names
968 +
        psf_file = f"{file_name}.psf"
969 +
        crd_file = f"{file_name}.crd"
970 +
971 +
        # Convert with ParmEd
972 +
        if toolkit == ConversionToolkit.ParmEd:
973 +
            # Load Amber files
974 +
            structure = pmd.load_file(prmtop, inpcrd, structure=True)
975 +
976 +
            if overwrite:
977 +
                structure.save(psf_file, format="psf", overwrite=True)
978 +
                structure.save(crd_file, format="charmmcrd", overwrite=True)
836 979
            else:
837 -
                log.info(f"Coordinates file {gro_file} exists, skipping writing file.")
980 +
                if not os.path.isfile(psf_file):
981 +
                    structure.save(psf_file, format="psf")
982 +
                else:
983 +
                    log.info(f"Topology file {psf_file} exists, skipping writing file.")
984 +
985 +
                if not os.path.isfile(crd_file):
986 +
                    structure.save(crd_file)
987 +
                else:
988 +
                    log.info(
989 +
                        f"Coordinates file {crd_file} exists, skipping writing file."
990 +
                    )
991 +
992 +
        # Convert with InterMol
993 +
        elif toolkit == ConversionToolkit.InterMol:
994 +
            from intermol.convert import _load_amber, _save_charmm
995 +
996 +
            # Load Amber files
997 +
            system, prefix, prmtop_in, crd_in, amb_structure = _load_amber(
998 +
                [prmtop, inpcrd]
999 +
            )
1000 +
1001 +
            # Save Charmm files
1002 +
            output_status = dict()
1003 +
            _, _ = _save_charmm(amb_structure, file_name, output_status)
1004 +
1005 +
            if output_status["charmm"] != "Converted":
1006 +
                raise Exception(
1007 +
                    f"Converting AMBER to CHARMM with Intermol unsuccesful: {output_status['charmm']}"
1008 +
                )
1009 +
1010 +
    def convert_to_lammps(
1011 +
        self,
1012 +
        pair_style=None,
1013 +
        output_path=None,
1014 +
        output_prefix=None,
1015 +
    ):
1016 +
        """
1017 +
        Convert AMBER topology and coordinate files to LAMMPS format.
1018 +
1019 +
        Parameters
1020 +
        ----------
1021 +
        pair_style: str, optional, default=None
1022 +
            LAMMPS option for ``pair_style``, if set to ``None`` (default) the setting will be for a periodic Ewald
1023 +
            simulation.
1024 +
        output_path: str, optional, default=None
1025 +
            Alternate directory path where the AMBER files are located. Default is the
1026 +
            `path` parsed to the :class:`paprika.tleap.System` object.
1027 +
        output_prefix: str, optional, default=None
1028 +
            Alternate file name prefix for the Amber files. Default is the `prefix` parsed
1029 +
            to the :class:`paprika.tleap.System` object.
1030 +
        """
1031 +
        if output_path is None:
1032 +
            output_path = self.output_path
1033 +
1034 +
        if output_prefix is None:
1035 +
            output_prefix = self.output_prefix
1036 +
1037 +
        file_name = os.path.join(output_path, output_prefix)
1038 +
1039 +
        # Check if Amber Topology file(s) exist
1040 +
        topology = np.array([f"{file_name}.{ext}" for ext in ["prmtop", "parm7"]])
1041 +
        check_topology = [os.path.isfile(file) for file in topology]
1042 +
        if not any(check_topology):
1043 +
            raise FileNotFoundError("Cannot find any AMBER topology file.")
1044 +
1045 +
        # Get the first topology file in the list of file(s) that exists
1046 +
        prmtop = topology[check_topology][0]
1047 +
1048 +
        # Check if Amber Coordinate file(s) exist
1049 +
        coordinates = np.array(
1050 +
            [f"{file_name}.{ext}" for ext in ["rst7", "inpcrd", "rst", "crd"]]
1051 +
        )
1052 +
        check_coordinates = [os.path.isfile(file) for file in coordinates]
1053 +
        if not any(check_coordinates):
1054 +
            raise FileNotFoundError("Cannot find any AMBER coordinates file.")
1055 +
1056 +
        # Get the first coordinate file in the list of file(s) that exists
1057 +
        inpcrd = coordinates[check_coordinates][0]
1058 +
1059 +
        # Pair style settings
1060 +
        args = dict()
1061 +
        if pair_style is None:
1062 +
            args[
1063 +
                "lmp_settings"
1064 +
            ] = "pair_style lj/cut/coul/long 9.0 9.0\npair_modify tail yes\nkspace_style pppm 1e-8"
1065 +
        else:
1066 +
            args["lmp_settings"] = pair_style
1067 +
1068 +
        # Convert
1069 +
        from intermol.convert import _load_amber, _save_lammps
1070 +
1071 +
        # Load Amber files
1072 +
        system, prefix, prmtop_in, crd_in, amb_structure = _load_amber([prmtop, inpcrd])
1073 +
1074 +
        # Save Lammps files
1075 +
        output_status = dict()
1076 +
        _save_lammps(system, file_name, output_status, args)
1077 +
1078 +
        if output_status["lammps"] != "Converted":
1079 +
            raise Exception(
1080 +
                f"Converting AMBER to LAMMPS with Intermol unsuccesful: {output_status['lammps']}"
1081 +
            )
1082 +
1083 +
    def convert_to_desmond(
1084 +
        self,
1085 +
        output_path=None,
1086 +
        output_prefix=None,
1087 +
    ):
1088 +
        """
1089 +
        Convert AMBER topology and coordinate files to DESMOND format.
1090 +
1091 +
        Parameters
1092 +
        ----------
1093 +
        output_path: str, optional, default=None
1094 +
            Alternate directory path where the AMBER files are located. Default is the
1095 +
            `path` parsed to the :class:`paprika.tleap.System` object.
1096 +
        output_prefix: str, optional, default=None
1097 +
            Alternate file name prefix for the Amber files. Default is the `prefix` parsed
1098 +
            to the :class:`paprika.tleap.System` object.
1099 +
        """
1100 +
        if output_path is None:
1101 +
            output_path = self.output_path
1102 +
1103 +
        if output_prefix is None:
1104 +
            output_prefix = self.output_prefix
1105 +
1106 +
        file_name = os.path.join(output_path, output_prefix)
1107 +
1108 +
        # Check if Amber Topology file(s) exist
1109 +
        topology = np.array([f"{file_name}.{ext}" for ext in ["prmtop", "parm7"]])
1110 +
        check_topology = [os.path.isfile(file) for file in topology]
1111 +
        if not any(check_topology):
1112 +
            raise FileNotFoundError("Cannot find any AMBER topology file.")
1113 +
1114 +
        # Get the first topology file in the list of file(s) that exists
1115 +
        prmtop = topology[check_topology][0]
1116 +
1117 +
        # Check if Amber Coordinate file(s) exist
1118 +
        coordinates = np.array(
1119 +
            [f"{file_name}.{ext}" for ext in ["rst7", "inpcrd", "rst", "crd"]]
1120 +
        )
1121 +
        check_coordinates = [os.path.isfile(file) for file in coordinates]
1122 +
        if not any(check_coordinates):
1123 +
            raise FileNotFoundError("Cannot find any AMBER coordinates file.")
1124 +
1125 +
        # Get the first coordinate file in the list of file(s) that exists
1126 +
        inpcrd = coordinates[check_coordinates][0]
1127 +
1128 +
        # Convert
1129 +
        from intermol.convert import _load_amber, _save_desmond
1130 +
1131 +
        # Load Amber files
1132 +
        system, prefix, prmtop_in, crd_in, amb_structure = _load_amber([prmtop, inpcrd])
1133 +
1134 +
        # Save Desmond files
1135 +
        output_status = dict()
1136 +
        _save_desmond(system, file_name, output_status)
1137 +
1138 +
        if output_status["desmond"] != "Converted":
1139 +
            raise Exception(
1140 +
                f"Converting AMBER to DESMOND with Intermol unsuccesful: {output_status['desmond']}"
1141 +
            )
Files Coverage
paprika 75.37%
setup.py 16.16%
Project Totals (34 files) 73.34%
971.1
TRAVIS_OS_NAME=osx
971.2
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
1
# Codecov configuration to make it a bit less noisy
2
coverage:
3
  status:
4
    patch: false
5
    project:
6
      default:
7
        threshold: 50%
8
comment:
9
  layout: "header"
10
  require_changes: false
11
  branches: null
12
  behavior: default
13
  flags: null
14
  paths: null
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading