Beispiel #1
0
    def testFileNames(self):
        """Tests parsing and validity functions"""
        tests = [("D_000001_model_P1.cif.V1", True), ("D_000001_model_P1.cif", False), ("D_000001_P1.cif.V1", False), ("D_000001_model.cif.V1", False), ("D_000001.cif", False)]
        # Matches w/o version number
        tests2 = [("D_000001_model_P1.cif.V1", True), ("D_000001_model_P1.cif", True), ("D_000001_P1.cif.V1", False), ("D_000001_model.cif.V1", False), ("D_000001.cif", False)]

        for t in tests:
            pI = PathInfo(siteId=self.__siteId)
            ret = pI.isValidFileName(t[0])
            self.assertEqual(ret, t[1], "Parsing mismatch %s" % t[0])

        # Withot version
        for t in tests2:
            pI = PathInfo(siteId=self.__siteId)
            ret = pI.isValidFileName(t[0], False)
            self.assertEqual(ret, t[1], "Parsing mismatch %s" % t[0])

        pI = PathInfo(siteId=self.__siteId)
        self.assertEqual(pI.parseFileName("D_000001_model_P1.cif.V1"), ("D_000001", "model", "pdbx", 1, 1))

        self.assertEqual(pI.parseFileName("D_000001_model.cif.V1"), (None, None, None, None, None))

        # spiltFileName will give partials
        self.assertEqual(pI.splitFileName("D_000001_model_P1.cif.V1"), ("D_000001", "model", "pdbx", 1, 1))

        self.assertEqual(pI.splitFileName("D_000001_model.cif.V1"), ("D_000001", "model", None, None, 1))

        self.assertEqual(pI.getFileExtension("gif"), "gif", "Getting file extension")
        self.assertEqual(pI.getFileExtension("pdbx"), "cif", "Getting file extension")
        self.assertEqual(pI.getFileExtension("unk"), None, "Getting file extension")
Beispiel #2
0
 def __setup(self, siteId=None):
     self.__siteId = siteId
     self.__cI = ConfigInfo(self.__siteId)
     self.__sessionPath = None
     self.__pI = PathInfo(siteId=self.__siteId,
                          sessionPath=self.__sessionPath,
                          verbose=self.__verbose,
                          log=self.__lfh)
def get_model_file(depid, version_id, mileStone=None, siteId=None):
    if siteId is None:
        siteId = getSiteId()
    pi = PathInfo(siteId, sessionPath=".", verbose=True, log=sys.stderr)
    mmcif = pi.getModelPdbxFilePath(dataSetId=depid,
                                    fileSource="archive",
                                    versionId=version_id,
                                    mileStone=mileStone)
    logging.debug("mmcif file path: %s", mmcif)
    return mmcif
Beispiel #4
0
    def __setup(self):

        if self.__sessionPath is not None:
            self.__pI = PathInfo(siteId=self.__siteId,
                                 sessionPath=self.__sessionPath,
                                 verbose=self.__verbose,
                                 log=self.__lfh)
        else:
            self.__pI = PathInfo(siteId=self.__siteId,
                                 verbose=self.__verbose,
                                 log=self.__lfh)
        #
        self.__inpFilePath = None
        self.__entryId = None
        self.__pdbId = None
        self.__pio = PdbxStatusHistoryIo(verbose=self.__verbose,
                                         log=self.__lfh)
        self.__statusCategory = "pdbx_database_status_history"
        self.__timeFormat = "%Y-%m-%d:%H:%M"
Beispiel #5
0
    def testSessionPath(self):
        tests = [("archive", "D_1000000000", "session_test/12345")]
        for (fs, dataSetId, session_dir) in tests:
            logger.debug("File source %s dataSetId %s  session dir %s" % (fs, dataSetId, session_dir))

            fileSource = ("session", "wf-session", "session-download")
            for fs in fileSource:
                pI = PathInfo(siteId=self.__siteId, sessionPath=session_dir)
                fp = pI.getDirPath(dataSetId=dataSetId, fileSource=fs)
                logger.debug("session path %s" % fp)
                self.assertIsNotNone(fp, "Failed to get session path")
 def __setup(self, siteId=None):
     if siteId is not None:
         self.__siteId = siteId
     else:
         self.__siteId = self.__reqObj.getValue("WWPDB_SITE_ID")
     #
     self.__lfh.write("+FileUtils.__setup() starting with entryId %r adjusted WWPDB_SITE_ID %r\n" % (self.__entryId, self.__siteId))
     #
     self.__sObj = self.__reqObj.getSessionObj()
     self.__sessionId = self.__sObj.getId()
     self.__sessionPath = self.__sObj.getPath()
     self.__pI = PathInfo(siteId=self.__siteId, sessionPath=self.__sessionPath, verbose=self.__verbose, log=self.__lfh)
     self.__cI = ConfigInfo(self.__siteId)
     self.__msL = self.__cI.get("CONTENT_MILESTONE_LIST")
    def __init__(self, siteId, verbose=False, log=sys.stderr):
        """
        :param `verbose`:  boolean flag to activate verbose logging.
        :param `log`:      stream for logging.

        """
        self.__verbose = verbose
        self.__lfh = log
        self.__siteId = siteId
        #
        self.__pI = PathInfo(siteId=self.__siteId,
                             sessionPath=".",
                             verbose=self.__verbose,
                             log=self.__lfh)
    def __init__(self, reqObj=None, verbose=False, log=sys.stderr):

        self.__reqObj = reqObj
        self.__verbose = verbose
        self.__lfh = log
        #
        self.__sessionObj = self.__reqObj.getSessionObj()
        self.__sessionPath = self.__sessionObj.getPath()
        self.__siteId = self.__reqObj.getValue("WWPDB_SITE_ID")

        self.__pI = PathInfo(siteId=self.__siteId, sessionPath=self.__sessionPath, verbose=self.__verbose, log=self.__lfh)
        #
        if self.__verbose:
            self.__lfh.write("+WebDownloadUtils.__setup() - session id   %s\n" % (self.__sessionObj.getId()))
            self.__lfh.write("+WebDownloadUtils.__setup() - session path %s\n" % (self.__sessionPath))
Beispiel #9
0
    def __setup(self, siteId=None):
        if siteId is not None:
            self.__siteId = siteId
        else:
            self.__siteId = self.__reqObj.getValue("WWPDB_SITE_ID")

        self.__sessionObj = self.__reqObj.getSessionObj()
        self.__sessionPath = self.__sessionObj.getPath()

        self.__cI = ConfigInfo(self.__siteId)
        self.__pI = PathInfo(siteId=self.__siteId, sessionPath=self.__sessionPath, verbose=self.__verbose, log=self.__lfh)

        #
        if self.__debug:
            self.__lfh.write("+DataExchange.__setup() - session id   %s\n" % (self.__sessionObj.getId()))
            self.__lfh.write("+DataExchange.__setup() - session path %s\n" % (self.__sessionObj.getPath()))

            self.__lfh.write("+DataExchange.__setup() - data set %s  instance %s file source %s\n" % (self.__depDataSetId, self.__wfInstanceId, self.__fileSource))
            self.__pI.setDebugFlag(flag=self.__debug)
Beispiel #10
0
    def testGetStandardPaths(self):
        """Test getting standard file names within session paths."""
        ok = True
        # fileSource, id, partionId, versionId
        tests = [
            ("archive", "D_1000000000", None, 1, "latest"),
            ("archive", "D_1000000000", None, "latest", "latest"),
            ("archive", "D_1000000000", None, "next", "latest"),
            ("archive", "D_1000000000", None, "previous", "latest"),
            ("deposit", "D_1000000000", None, 1, "latest"),
        ]
        eId = "1"
        for (fs, dataSetId, wfInst, pId, vId) in tests:
            logger.debug("File source %s dataSetId %s  partno  %s wfInst %s version %s" % (fs, dataSetId, pId, wfInst, vId))

            pI = PathInfo(siteId=self.__siteId)
            pI.setDebugFlag(False)
            #
            fp = pI.getModelPdbxFilePath(dataSetId, wfInstanceId=wfInst, fileSource=fs, versionId=vId)
            logger.debug("Model path (PDBx):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find model file - default")

            fp = pI.getModelPdbxFilePath(dataSetId, wfInstanceId=wfInst, fileSource=fs, versionId=vId, mileStone="deposit")
            logger.debug("Model path (deposit) (PDBx):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find model file - deposit")

            fp = pI.getModelPdbxFilePath(dataSetId, wfInstanceId=wfInst, fileSource=fs, versionId=vId, mileStone="upload")
            logger.debug("Model path (upload) (PDBx):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find model file - upload")

            fp = pI.getModelPdbFilePath(dataSetId, wfInstanceId=wfInst, fileSource=fs, versionId=vId)
            logger.debug("Model path (PDB):    %s" % fp)
            self.assertIsNotNone(fp, "Failed to find PDB model file")

            fp = pI.getStructureFactorsPdbxFilePath(dataSetId, wfInstanceId=wfInst, fileSource=fs, versionId=vId)
            logger.debug("SF path (pdbx):    %s" % fp)
            self.assertIsNotNone(fp, "Failed to find SF file")

            fp = pI.getPolyLinkFilePath(dataSetId, wfInstanceId=wfInst, fileSource=fs, versionId=vId)
            logger.debug("Link dist  (PDBx):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find PDBx model file")

            fp = pI.getPolyLinkReportFilePath(dataSetId, wfInstanceId=wfInst, fileSource=fs, versionId=vId)
            logger.debug("Link Report dist  (PDBx):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find link report file")

            fp = pI.getSequenceStatsFilePath(dataSetId, wfInstanceId=wfInst, fileSource=fs, versionId=vId)
            logger.debug("Sequence stats (PIC):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find sequence stats file")

            fp = pI.getSequenceAlignFilePath(dataSetId, wfInstanceId=wfInst, fileSource=fs, versionId=vId)
            logger.debug("Sequence align (PIC):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find sequence align file")

            fp = pI.getReferenceSequenceFilePath(dataSetId, entityId=eId, wfInstanceId=wfInst, fileSource=fs, versionId=vId)
            logger.debug("Reference match entity %s (PDBx):   %s" % (eId, fp))
            self.assertIsNotNone(fp, "Failed to find reference sequence file")

            fp = pI.getSequenceAssignmentFilePath(dataSetId, wfInstanceId=wfInst, fileSource=fs, versionId=vId)
            logger.debug("Sequence assignment (PDBx):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find sequence assignment")

            fp = pI.getAssemblyAssignmentFilePath(dataSetId, wfInstanceId=wfInst, fileSource=fs, versionId=vId)
            logger.debug("Assembly assignment (PDBx):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find assembly assignment")

            fp = pI.getBlastMatchFilePath(dataSetId, wfInstanceId=wfInst, fileSource=fs, versionId=vId)
            logger.debug("Blast match (xml):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find blast match file")

            fp = pI.getFilePath(dataSetId, wfInstanceId=wfInst, contentType="seqdb-match", formatType="pdbx", fileSource=fs, versionId=vId, partNumber=pId, mileStone=None)
            logger.debug("Sequence match (getFilePath) (PDBx):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find seq-db match")
            #
            fp = pI.getFilePathContentTypeTemplate(dataSetId, wfInstanceId=wfInst, contentType="model", fileSource=fs)
            logger.debug("Model template:   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find model template")

            fp = pI.getArchivePath(dataSetId)
            logger.debug("getArchivePath (PDBx):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find dir path")

            fp = pI.getDepositPath(dataSetId)
            logger.debug("getDepositPath (PDBx):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find deposit path")

            fp = pI.getInstancePath(dataSetId, wfInstanceId="W_099")
            logger.debug("getWfInstancePath (PDBx):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find wf instance path")

            fp = pI.getInstanceTopPath(
                dataSetId,
            )
            logger.debug("getWfInstanceTopPath (PDBx):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find wf Top instance path")

            fp = pI.getTempDepPath(dataSetId)
            logger.debug("getTempDepPath):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find TempDep path")
            #
            fp = pI.getDirPath(dataSetId, wfInstanceId=wfInst, fileSource=fs, versionId=vId, partNumber=pId, mileStone=None)
            logger.debug("Sequence match (getDirPath) (PDBx):   %s" % fp)
            self.assertIsNotNone(fp, "Failed to find dir path")

            ft = pI.getFilePathVersionTemplate(dataSetId, wfInstanceId=wfInst, contentType="em-volume", formatType="map", fileSource="archive", partNumber=pId, mileStone=None)
            logger.debug("EM volume version template:   %r" % ft)
            ft = pI.getFilePathPartitionTemplate(dataSetId, wfInstanceId=wfInst, contentType="em-mask-volume", formatType="map", fileSource="archive", mileStone=None)
            logger.debug("EM mask partition template:   %r" % ft)
            self.assertIsNotNone(ft, "Failed to mask model file")

        self.assertEqual(ok, True)