From ec3f603ded27d474a3ad05b648c06cfcf07a5349 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Fri, 27 Sep 2024 08:58:35 -0400 Subject: [PATCH 1/3] Restory NmrStarToCif.py -- still depended on it --- .../utils/nmr/{obsolete => }/NmrStarToCif.py | 0 wwpdb/utils/tests-nmr-tox/ImportTests.py | 2 +- .../utils/tests-nmr-tox/NmrStarToCifTests.py | 83 +++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) rename wwpdb/utils/nmr/{obsolete => }/NmrStarToCif.py (100%) create mode 100644 wwpdb/utils/tests-nmr-tox/NmrStarToCifTests.py diff --git a/wwpdb/utils/nmr/obsolete/NmrStarToCif.py b/wwpdb/utils/nmr/NmrStarToCif.py similarity index 100% rename from wwpdb/utils/nmr/obsolete/NmrStarToCif.py rename to wwpdb/utils/nmr/NmrStarToCif.py diff --git a/wwpdb/utils/tests-nmr-tox/ImportTests.py b/wwpdb/utils/tests-nmr-tox/ImportTests.py index 93adddb8..8532a088 100644 --- a/wwpdb/utils/tests-nmr-tox/ImportTests.py +++ b/wwpdb/utils/tests-nmr-tox/ImportTests.py @@ -21,7 +21,7 @@ from wwpdb.utils.nmr.NmrDpUtility import NmrDpUtility from wwpdb.utils.nmr.NmrDpReport import NmrDpReport # NmrStarToCif class has been deprecated -# from wwpdb.utils.nmr.NmrStarToCif import NmrStarToCif +from wwpdb.utils.nmr.NmrStarToCif import NmrStarToCif from wwpdb.utils.nmr.rci.RCI import RCI from wwpdb.utils.nmr.BMRBChemShiftStat import BMRBChemShiftStat diff --git a/wwpdb/utils/tests-nmr-tox/NmrStarToCifTests.py b/wwpdb/utils/tests-nmr-tox/NmrStarToCifTests.py new file mode 100644 index 00000000..f969ef5d --- /dev/null +++ b/wwpdb/utils/tests-nmr-tox/NmrStarToCifTests.py @@ -0,0 +1,83 @@ +## +# File: test_NmrStarToCif.py +# Date: 02-Apr-2020 M. Yokochi +# +# Updates: +# 20-Oct-2021 M. Yokochi - add unit test for case-sensitive saveframe name (DAOTHER-7398, 7407) +# +import unittest +import os +import sys +from shutil import copyfile + +if __package__ is None or __package__ == "": + from os import path + + sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) + from commonsetup import TESTOUTPUT # noqa: F401 pylint: disable=import-error,unused-import +else: + from .commonsetup import TESTOUTPUT # noqa: F401 pylint: disable=relative-beyond-top-level + +try: + from wwpdb.utils.nmr.NmrStarToCif import NmrStarToCif +except ImportError: + from nmr.NmrStarToCif import NmrStarToCif + + +if __package__ is None or __package__ == "": + from os import path + + sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) + from commonsetup import TESTOUTPUT # noqa: F401, pylint: disable=import-error,unused-import +else: + from .commonsetup import TESTOUTPUT # noqa: F401, pylint: disable=relative-beyond-top-level + + +class TestNmrStarToCif(unittest.TestCase): + def setUp(self): + here = os.path.abspath(os.path.dirname(__file__)) + self.data_dir_path = os.path.join(here, os.pardir, "tests-nmr", "mock-data") + self.nmrstar_to_cif = NmrStarToCif() + + def tearDown(self): + pass + + def test_unified(self): + strPath = os.path.join(self.data_dir_path, "D_800269_nmr-data-str_P1.str.V1") + outPath = os.path.join(TESTOUTPUT, "D_800269_nmr-data-str_P1.cif") + ret = self.nmrstar_to_cif.convert(strPath=strPath, cifPath=outPath, originalFileName="2png.nef") + + self.assertTrue(ret) + self.assertTrue(os.path.isfile(outPath)) + + def test_legacy(self): + refPathIn = os.path.join(self.data_dir_path, "D_800262_cs-upload-convert_P1.cif.V1") + tempCif = os.path.join(TESTOUTPUT, "D_800262_cs-upload-convert_P1.cif.V8") + copyfile(refPathIn, tempCif) + ret = self.nmrstar_to_cif.clean(cifPath=tempCif, originalCsFileNameList=["D_800262_cs.str"]) + self.assertTrue(ret) + + def test_daother_5829(self): + refPathIn = os.path.join(self.data_dir_path, "D_800350_cs_P1.cif.V2") + tempCif = os.path.join(TESTOUTPUT, "D_800350_cs_P1.cif.V1") + copyfile(refPathIn, tempCif) + ret = self.nmrstar_to_cif.clean(cifPath=tempCif, originalCsFileNameList=["Ost4V23D.star"]) + self.assertTrue(ret) + + def test_D_1292117503(self): + strPath = os.path.join(self.data_dir_path, "D_800439_nmr-data-str_P1.str.V2") + cifPath = os.path.join(TESTOUTPUT, "D_800439_nmr-data-str_P1.cif.V2") + ret = self.nmrstar_to_cif.convert(strPath=strPath, cifPath=cifPath, originalFileName="KpbK.str") + self.assertTrue(ret) + self.assertTrue(os.path.isfile(cifPath)) + + def test_daother_7389(self): + strPath = os.path.join(self.data_dir_path, "D_800444_nmr-data-str-upload-convert_P1.str.V1") + cifPath = os.path.join(TESTOUTPUT, "D_800444_nmr-data-str-upload-convert_P1.cif.V1") + ret = self.nmrstar_to_cif.convert(strPath=strPath, cifPath=cifPath, originalFileName="kbpk_letterCaseTest.nef") + self.assertTrue(ret) + self.assertTrue(os.path.isfile(cifPath)) + + +if __name__ == "__main__": + unittest.main() From 42610f0088a4727fc255c1e379eef9244204c369 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Fri, 27 Sep 2024 09:12:05 -0400 Subject: [PATCH 2/3] Fix tests --- wwpdb/utils/tests-nmr-tox/ImportTests.py | 2 +- wwpdb/utils/tests-nmr-tox/NmrStarToCifTests.py | 14 +------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/wwpdb/utils/tests-nmr-tox/ImportTests.py b/wwpdb/utils/tests-nmr-tox/ImportTests.py index 8532a088..5d63e8ae 100644 --- a/wwpdb/utils/tests-nmr-tox/ImportTests.py +++ b/wwpdb/utils/tests-nmr-tox/ImportTests.py @@ -31,7 +31,7 @@ def testInstantiate(self): _c = NEFTranslator() # noqa: F841 _npu = NmrDpUtility() # noqa: F841 _ndp = NmrDpReport() # noqa: F841 - # _nstc = NmrStarToCif() # noqa: F841 + _nstc = NmrStarToCif() # noqa: F841 _rci = RCI() # noqa: F841 _bmrb = BMRBChemShiftStat() # noqa: F841 diff --git a/wwpdb/utils/tests-nmr-tox/NmrStarToCifTests.py b/wwpdb/utils/tests-nmr-tox/NmrStarToCifTests.py index f969ef5d..692e78da 100644 --- a/wwpdb/utils/tests-nmr-tox/NmrStarToCifTests.py +++ b/wwpdb/utils/tests-nmr-tox/NmrStarToCifTests.py @@ -18,19 +18,7 @@ else: from .commonsetup import TESTOUTPUT # noqa: F401 pylint: disable=relative-beyond-top-level -try: - from wwpdb.utils.nmr.NmrStarToCif import NmrStarToCif -except ImportError: - from nmr.NmrStarToCif import NmrStarToCif - - -if __package__ is None or __package__ == "": - from os import path - - sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) - from commonsetup import TESTOUTPUT # noqa: F401, pylint: disable=import-error,unused-import -else: - from .commonsetup import TESTOUTPUT # noqa: F401, pylint: disable=relative-beyond-top-level +from wwpdb.utils.nmr.NmrStarToCif import NmrStarToCif class TestNmrStarToCif(unittest.TestCase): From 99703d9842736debca781c06d3f269b89c3f7455 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Fri, 27 Sep 2024 09:22:37 -0400 Subject: [PATCH 3/3] v0.40.1 --- wwpdb/utils/nmr/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wwpdb/utils/nmr/__init__.py b/wwpdb/utils/nmr/__init__.py index 040511f3..5715d7ea 100644 --- a/wwpdb/utils/nmr/__init__.py +++ b/wwpdb/utils/nmr/__init__.py @@ -2,4 +2,4 @@ __author__ = "Ezra Peisach" __email__ = "ezra.peisach@rcsb.org" __license__ = "Apache 2.0" -__version__ = "0.40" +__version__ = "0.40.1"