Пример #1
0
 def test_load(self):
     sut = PQRReader()
     pqr_imput = (
         pathlib.Path(__file__).parent.parent.parent.parent.absolute()
         / "examples/actin-dimer/mol1.pqr"
     )
     atomlist: AtomList = sut.load(pqr_imput)
     assert len(atomlist.atoms) == 5861
Пример #2
0
 def test_load_all(self):
     """Test to load all the data from all the example files"""
     sut = PQRReader()
     # NOTE: There are 77 files under the examples directory
     matches = pathlib.Path(search_dir("")).glob("**/*.pqr")
     for match in matches:
         print(f"FILE: {match}")
         atomlist: AtomList = sut.load(match)
         assert len(atomlist) > 0
Пример #3
0
    def test_bad(self):
        """This test will fail because there is a typo in the sample data"""
        sut = PQRReader()
        sample = r"""
ATOM   5226  HD1 TYR   337     -24.642  -2.718  30.187  0.115 1.358
REMARK The next line is incorrect on purpose (e.g. ATAM instead of ATOM)
ATAM     39 O3PB ADP     1  D   -16.362  -6.763  26.980 -0.900 1.700
"""
        atomlist: AtomList = sut.loads(sample)
Пример #4
0
def get_atom_list(tmp_path) -> AtomList:
    """Return the AtomList from the file generated."""

    fqpn = tmp_path / "atom.pdb"

    with open(fqpn, "w") as f:
        f.write("HETATM    1  C    ALK    1       "
                "1.000   4.000   7.000 0.000 1.000\n")
        f.write("HETATM    1  C    ALK    1       "
                "2.000   5.000   8.000 0.000 2.000\n")
        f.write("HETATM    1  C    ALK    1       "
                "3.000   6.000   9.000 0.000 3.000\n")

    reader = PQRReader()
    return reader.load(fqpn)
Пример #5
0
    def test_ctor(self):
        sut = PQRReader()
        sample = r"""
ATOM   5226  HD1 TYR   337     -24.642  -2.718  30.187  0.115 1.358
ATOM      7  CD   LYS D   1      44.946 37.289  9.712    -0.0608  1.9080
REMARK This is just a comment hiding in the data
HETATM     39 O3PB ADP     1     -16.362  -6.763  26.980 -0.900 1.700
ATOM     39 O3PB ADP     1  D   -16.362  -6.763  26.980 -0.900 1.700
REMARK The next line is incorrect on purpose (e.g. ATAM instead of ATOM)
ATAM     39 O3PB ADP     1  D   -16.362  -6.763  26.980 -0.900 1.700
"""
        atomlist: AtomList = sut.loads(sample)
        for idx in range(1):
            assert abs(atomlist.atoms[idx].x - -24.642) < 0.001
            assert int(atomlist.atoms[idx].x) == -24
        print(atomlist.atoms)
Пример #6
0
    def test_basic(self):
        """This test values in the records in the sample data"""
        sut = PQRReader()
        sample = r"""
ATOM   5226  HD1 TYR   337     -24.642  -2.718  30.187  0.115 1.358
                  
HETATM     39 O3PB ADP     1     -16.362  -6.763  26.980 -0.900 1.700
ATOM      7  CD   LYS D   1      44.946 37.289  9.712    -0.0608  1.9080
REMARK This is just a   comment hid ing in the data
ATOM     39 O3PB ADP     1  D   -16.362  -6.763  26.980 -0.900 1.700
"""
        atomlist: AtomList = sut.loads(sample)
        assert len(atomlist) == 4
        assert atomlist[1].field_name in "HETATM"
        for idx in range(1):
            assert abs(atomlist[idx].x - -24.642) < 0.001
            assert int(atomlist[idx].x) == -24
Пример #7
0
 def test_load(self):
     """Test to load all the data from an example file"""
     sut = PQRReader()
     pqr_imput = search_dir("actin-dimer/mol1.pqr")
     atomlist: AtomList = sut.load(pqr_imput)
     assert len(atomlist) == 5877