Skip to content

Commit

Permalink
Restory NmrStarToCif.py -- still depended on it
Browse files Browse the repository at this point in the history
  • Loading branch information
Ezra Peisach committed Sep 27, 2024
1 parent 1bb42b0 commit ec3f603
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
File renamed without changes.
2 changes: 1 addition & 1 deletion wwpdb/utils/tests-nmr-tox/ImportTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
83 changes: 83 additions & 0 deletions wwpdb/utils/tests-nmr-tox/NmrStarToCifTests.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit ec3f603

Please sign in to comment.