Esempio n. 1
0
 def test_check_read_lipids_topH_failure(self):
     """Test check_read_lipids_topH() with a file in a wrong format."""
     bad_file = "Berger_wrongformat.json"
     with pytest.raises(ValueError) as err:
         lipids.read_lipids_topH([PATH_ROOT_DATA / bad_file])
     assert f"{bad_file} is in a bad format: keyword 'resname' is missing." in str(
         err.value)
Esempio n. 2
0
 def setup_class(self):
     """Initialize attributes."""
     # Create correct lipid topology dict
     lipids_tops = lipids.read_lipids_topH(
         [lipids.PATH_JSON / "Berger_POPC.json"])
     dic_lipid = lipids_tops["Berger_POPC"]
     self.args["dic_lipid"] = dic_lipid
Esempio n. 3
0
    def setup_class(self):
        """Initialize all data."""
        lipids_tops = lipids.read_lipids_topH(
            [lipids.PATH_JSON / "Berger_POPC.json"])

        # Input parameters
        self.pdb = self.PATH_DATA / "10POPC.pdb"
        self.defop = self.PATH_DATA / "OP_def_BergerPOPC.def"
        self.dic_lipid = lipids_tops["Berger_POPC"]

        self.begin = 0
        self.end = 1

        # attributes
        self.universe_woH = mda.Universe(str(self.pdb))
        self.dic_atname2genericname = init_dics.make_dic_atname2genericname(
            self.defop)
        self.dic_OP, self.dic_corresp_numres_index_dic_OP = init_dics.init_dic_OP(
            self.universe_woH, self.dic_atname2genericname,
            self.dic_lipid['resname'])
        self.dic_Cname2Hnames = init_dics.make_dic_Cname2Hnames(self.dic_OP)

        # Compute the order parameter
        core.fast_build_all_Hs_calc_OP(self.universe_woH, self.begin, self.end,
                                       self.dic_OP, self.dic_lipid,
                                       self.dic_Cname2Hnames)
Esempio n. 4
0
    def test_fail_main_coord_topology_mismatch(self):
        """Test when coord file and topology doesn't match."""
        args = self.args.copy()

        lipids_tops = lipids.read_lipids_topH(
            [lipids.PATH_JSON / "CHARMM36_POPC.json"])
        dic_lipid = lipids_tops["CHARMM36_POPC"]
        args["dic_lipid"] = dic_lipid

        with pytest.raises(BuildHError) as err:
            UI.main(**args)
        assert "The topology chosen does not match the structure provided" in str(
            err.value)
Esempio n. 5
0
def inputs():
    """Define some input parameters for the tests."""
    # Input parameters
    path_data = PATH_ROOT_DATA / "Berger_POPC"

    pdb = path_data / "10POPC.pdb"
    defop = path_data / "OP_def_BergerPOPC.def"
    lipids_tops = lipids.read_lipids_topH(
        [lipids.PATH_JSON / "Berger_POPC.json"])
    dic_lipid = lipids_tops["Berger_POPC"]

    universe_woH = mda.Universe(str(pdb))
    dic_atname2genericname = init_dics.make_dic_atname2genericname(defop)
    return {
        'universe': universe_woH,
        'defop': defop,
        'dic_lipid': dic_lipid,
        'dic_atname2genericname': dic_atname2genericname
    }
Esempio n. 6
0
    def setup_class(self):
        """Initialize attributes."""
        lipids_tops = lipids.read_lipids_topH(
            [lipids.PATH_JSON / "Berger_POPC.json"])

        # Input parameters
        self.pdb = self.PATH_DATA / "2POPC.pdb"
        self.defop = self.PATH_DATA / "OP_def_BergerPOPC.def"
        self.dic_lipid = lipids_tops["Berger_POPC"]

        # attributes
        self.universe_woH = mda.Universe(str(self.pdb))

        self.dic_atname2genericname = init_dics.make_dic_atname2genericname(
            self.defop)
        self.dic_OP, self.dic_corresp_numres_index_dic_OP = init_dics.init_dic_OP(
            self.universe_woH, self.dic_atname2genericname,
            self.dic_lipid['resname'])
        self.dic_Cname2Hnames = init_dics.make_dic_Cname2Hnames(self.dic_OP)
Esempio n. 7
0
    def test_check_read_lipids_topH_success(self):
        """Test check_read_lipids_topH() with correct files."""
        lipids_tops = lipids.read_lipids_topH(self.path_files)

        # key : key of the outer dict
        # values : number of atoms in each dict
        reference = {
            'Berger_POPC': 41,
            'Berger_PLA': 41,
            'Berger_POP': 41,
            'CHARMM36_POPC': 41
        }

        assert len(lipids_tops) == 4
        assert lipids_tops.keys() == set(
            ['Berger_POPC', 'Berger_PLA', 'Berger_POP', 'CHARMM36_POPC'])

        # Test if each dic contains the right number of atoms
        for name in lipids_tops.keys():
            assert len(lipids_tops[name]) == reference[name]