Exemplo n.º 1
0
 def copyThumbnailToPyarch(self, task):
     imagePath = task.inData["image"]
     thumbNailPath = task.outData["thumbNail"]
     pyarchThumbnailDir = UtilsPath.createPyarchFilePath(
         os.path.dirname(imagePath))
     if pyarchThumbnailDir is None:
         pyarchThumbnailPath = thumbNailPath
     else:
         if not os.path.exists(pyarchThumbnailDir):
             os.makedirs(pyarchThumbnailDir, 0o755)
         pyarchThumbnailPath = os.path.join(pyarchThumbnailDir,
                                            os.path.basename(thumbNailPath))
         shutil.copy2(thumbNailPath, pyarchThumbnailPath)
     return pyarchThumbnailPath
Exemplo n.º 2
0
 def run(self, inData):
     # Wait for file if it's not already on disk'
     if "file" not in inData:
         raise BaseException("No expected file path in input!")
     filePath = pathlib.Path(self.inData["file"])
     expectedSize = inData.get("expectedSize", None)
     configTimeOut = UtilsConfig.get(self, "timeOut", DEFAULT_TIMEOUT)
     timeOut = inData.get("timeOut", configTimeOut)
     hasTimedOut, finalSize = UtilsPath.waitForFile(
         filePath, expectedSize=expectedSize, timeOut=timeOut)
     outData = {"timedOut": hasTimedOut}
     if finalSize is not None:
         outData["finalSize"] = finalSize
     return outData
Exemplo n.º 3
0
 def executeRun(self):
     inData = self.getInData()
     hasValidInDataSchema = False
     hasValidOutDataSchema = False
     if self.getInDataSchema() is not None:
         instance = inData
         schema = self.getInDataSchema()
         try:
             jsonschema.validate(instance=instance, schema=schema)
             hasValidInDataSchema = True
         except Exception as e:
             logger.exception(e)
     else:
         hasValidInDataSchema = True
     if hasValidInDataSchema:
         self._workingDirectory = UtilsPath.getWorkingDirectory(
             self,
             inData,
             workingDirectorySuffix=self._workingDirectorySuffix)
         self.writeInputData(inData)
         self._oldDir = os.getcwd()
         os.chdir(str(self._workingDirectory))
         outData = self.run(inData)
         os.chdir(self._oldDir)
     else:
         raise RuntimeError("Schema validation error for inData")
     if self.getOutDataSchema() is not None:
         instance = outData
         schema = self.getOutDataSchema()
         try:
             jsonschema.validate(instance=instance, schema=schema)
             hasValidOutDataSchema = True
         except Exception as e:
             logger.exception(e)
     else:
         hasValidOutDataSchema = True
     if hasValidOutDataSchema:
         self.writeOutputData(outData)
     else:
         raise RuntimeError("Schema validation error for outData")
     if not os.listdir(str(self._workingDirectory)):
         os.rmdir(str(self._workingDirectory))
Exemplo n.º 4
0
 def createHdf5HeaderData(cls,
                          imagePath,
                          skipNumberOfImages=False,
                          hasOverlap=False,
                          isFastMesh=False):
     h5MasterFilePath, h5DataFilePath, h5FileNumber = UtilsImage.getH5FilePath(
         pathlib.Path(imagePath),
         isFastMesh=isFastMesh,
         hasOverlap=hasOverlap)
     # Waiting for file
     timedOut, finalSize = UtilsPath.waitForFile(h5MasterFilePath,
                                                 expectedSize=100000,
                                                 timeOut=DEFAULT_TIME_OUT)
     if timedOut:
         errorMessage = "Timeout when waiting for image %s" % imagePath
         logger.error(errorMessage)
         raise BaseException(errorMessage)
     dictHeader = cls.readHdf5Header(h5MasterFilePath)
     description = dictHeader['description']
     if 'Eiger 4M' in description:
         detectorName = 'EIGER 4M'
         detectorType = 'eiger4m'
         numberPixelX = 2070
         numberPixelY = 2167
     else:
         raise RuntimeError(
             '{0} cannot read image header from images with detector type {1}'
             .format(cls.__class__.__name__, description))
     # Find out size of data set
     prefix = str(h5MasterFilePath).split('master')[0]
     listDataImage = []
     noImages = 0
     if not skipNumberOfImages:
         for data in dictHeader['data']:
             dataFilePath = prefix + data + '.h5'
             timedOut, finalSize = UtilsPath.waitForFile(
                 dataFilePath,
                 expectedSize=1000000,
                 timeOut=DEFAULT_TIME_OUT)
             if timedOut:
                 raise RuntimeError(
                     'Timeout waiting for file {0}'.format(dataFilePath))
             # listDataImage.append({
             #     'path': dataFilePath
             # })
             f = h5py.File(dataFilePath, 'r')
             dataShape = f['entry']['data']['data'].shape
             noImages += dataShape[0]
             f.close()
     experimentalCondition = {}
     # Pixel size and beam position
     detector = {
         'numberPixelX':
         int(numberPixelX),
         'numberPixelY':
         int(numberPixelY),
         'pixelSizeX':
         round(dictHeader['x_pixel_size'] * 1000, 3),
         'pixelSizeY':
         round(dictHeader['y_pixel_size'] * 1000, 3),
         'beamPositionX':
         round(
             float(dictHeader['beam_center_x'] *
                   dictHeader['x_pixel_size'] * 1000), 3),
         'beamPositionY':
         round(
             float(dictHeader['beam_center_y'] *
                   dictHeader['y_pixel_size'] * 1000), 3),
         'distance':
         round(float(dictHeader['detector_distance']) * 1000, 3),
         'serialNumber':
         dictHeader['detector_number'],
         'name':
         detectorName,
         'type':
         detectorType
     }
     experimentalCondition['detector'] = detector
     # Beam object
     beam = {
         'wavelength': round(float(dictHeader['wavelength']), 6),
         'exposureTime': round(float(dictHeader['count_time']), 6)
     }
     experimentalCondition['beam'] = beam
     # Goniostat object
     goniostat = {}
     rotationAxisStart = round(float(dictHeader['omega_start']), 4)
     oscillationWidth = round(float(dictHeader['omega_increment']), 4)
     goniostat['rotationAxisStart'] = rotationAxisStart
     goniostat[
         'rotationAxisEnd'] = rotationAxisStart + oscillationWidth * noImages
     goniostat['oscillationWidth'] = oscillationWidth
     experimentalCondition['goniostat'] = goniostat
     # Create the image object
     masterImage = {
         'path': imagePath,
         'date': dictHeader['data_collection_date'],
         'number': 1
     }
     # imageNumber = UtilsImage.getImageNumber(imagePath)
     # image['number'] = imageNumber
     subWedge = {
         'experimentalCondition': experimentalCondition,
         'image': [masterImage] + listDataImage
     }
     return subWedge
Exemplo n.º 5
0
 def createCBFHeaderData(cls, imagePath):
     # Waiting for file
     timedOut, finalSize = UtilsPath.waitForFile(imagePath,
                                                 expectedSize=100000,
                                                 timeOut=DEFAULT_TIME_OUT)
     if timedOut:
         errorMessage = "Timeout when waiting for image %s" % imagePath
         logger.error(errorMessage)
         raise BaseException(errorMessage)
     dictHeader = cls.readCBFHeader(imagePath)
     detector = dictHeader['Detector:']
     if 'PILATUS 3M' in detector or 'PILATUS3 2M' in detector or \
             'PILATUS 2M' in detector or 'PILATUS2 3M' in detector:
         detectorName = 'PILATUS2 3M'
         detectorType = 'pilatus2m'
         numberPixelX = 1475
         numberPixelY = 1679
     elif 'PILATUS 6M' in detector or 'PILATUS3 6M' in detector:
         detectorName = 'PILATUS2 6M'
         detectorType = 'pilatus6m'
         numberPixelX = 2463
         numberPixelY = 2527
     else:
         raise RuntimeError(
             '{0} cannot read image header from images with dector type {1}'
             .format(cls.__class__.__name__, detector))
     experimentalCondition = {}
     detector = {'numberPixelX': numberPixelX, 'numberPixelY': numberPixelY}
     # Pixel size
     listPixelSizeXY = dictHeader['Pixel_size'].split(' ')
     detector['pixelSizeX'] = float(listPixelSizeXY[0]) * 1000
     detector['pixelSizeY'] = float(listPixelSizeXY[3]) * 1000
     # Beam position
     listBeamPosition = dictHeader['Beam_xy'].replace('(', ' ').replace(
         ')', ' ').replace(',', ' ').split()
     detector['beamPositionX'] = float(listBeamPosition[0]) * \
                                 detector['pixelSizeX']
     detector['beamPositionY'] = float(listBeamPosition[1]) * \
                                 detector['pixelSizeY']
     distance = float(dictHeader['Detector_distance'].split(' ')[0]) * 1000
     detector['distance'] = distance
     detector['serialNumber'] = dictHeader['Detector:']
     detector['name'] = detectorName
     detector['type'] = detectorType
     experimentalCondition['detector'] = detector
     # Beam object
     beam = {
         'wavelength': float(dictHeader['Wavelength'].split(' ')[0]),
         'exposureTime': float(dictHeader['Exposure_time'].split(' ')[0])
     }
     experimentalCondition['beam'] = beam
     # Goniostat object
     goniostat = {}
     rotationAxisStart = float(dictHeader['Start_angle'].split(' ')[0])
     oscillationWidth = float(dictHeader['Angle_increment'].split(' ')[0])
     goniostat['rotationAxisStart'] = rotationAxisStart
     goniostat['rotationAxisEnd'] = rotationAxisStart + oscillationWidth
     goniostat['oscillationWidth'] = oscillationWidth
     experimentalCondition['goniostat'] = goniostat
     # Create the image object
     image = {'path': imagePath}
     if 'DateTime' in dictHeader:
         image['date'] = dictHeader['DateTime']
     imageNumber = UtilsImage.getImageNumber(imagePath)
     image['number'] = imageNumber
     subWedge = {
         'experimentalCondition': experimentalCondition,
         'image': [image]
     }
     return subWedge
Exemplo n.º 6
0
 def run(self, inData):
     # Format suffix
     format = inData.get("format", "jpeg")
     if format == "jpeg":
         thumbSuffix = ".jpeg"
     elif format == "jpg":
         thumbSuffix = ".jpg"
     else:
         raise RuntimeError("Unsupported format: {0}".format(format))
     # Loop through all images
     listJPEGTask = []
     listThumbTask = []
     forcedOutputDirectory = inData.get("forcedOutputDirectory", None)
     for imagePath in inData["image"]:
         # Check image file extension
         imageFileName, suffix = os.path.splitext(
             os.path.basename(imagePath))
         if not suffix in [".img", ".marccd", ".mccd", ".cbf", ".h5"]:
             raise RuntimeError(
                 "Unknown image file name extension for pyarch thumbnail generator: %s"
                 % imagePath)
         # Wait for image file
         if suffix == ".h5":
             h5MasterFilePath, h5DataFilePath, h5FileNumber = UtilsImage.getH5FilePath(
                 imagePath, isFastMesh=True)
             waitFilePath = h5DataFilePath
         else:
             waitFilePath = imagePath
         expectedSize = self.getExpectedSize(imagePath)
         hasTimedOut, finalSize = UtilsPath.waitForFile(
             waitFilePath, expectedSize=expectedSize, timeOut=600)
         if hasTimedOut:
             raise RuntimeError(
                 "Waiting for file {0} timed out!".format(imagePath))
         outputFileName = imageFileName + thumbSuffix
         if forcedOutputDirectory is not None:
             outputPath = os.path.join(forcedOutputDirectory,
                                       outputFileName)
         else:
             outputPath = None
         # Create JPEG with resolution rings
         inDataReadHeader = {
             "imagePath": [imagePath],
             "skipNumberOfImages": True,
             "isFastMesh": True
         }
         readHeader = ReadImageHeader(
             inData=inDataReadHeader,
             workingDirectorySuffix=imageFileName,
         )
         readHeader.execute()
         experimentalCondition = readHeader.outData["subWedge"][0][
             "experimentalCondition"]
         detector = experimentalCondition["detector"]
         beam = experimentalCondition["beam"]
         inDataCreateJPEG = {
             "image": imagePath,
             "height": 1024,
             "width": 1024,
             "outputFileName": outputFileName,
             "outputPath": outputPath,
             "doResolutionRings": True,
             "pixelSizeX": detector["pixelSizeX"],
             "pixelSizeY": detector["pixelSizeY"],
             "beamPositionX": detector["beamPositionX"],
             "beamPositionY": detector["beamPositionY"],
             "distance": detector["distance"],
             "wavelength": beam["wavelength"],
         }
         createJPEG = CreateThumbnail(inData=inDataCreateJPEG,
                                      workingDirectorySuffix=imageFileName +
                                      "_JPEG")
         createJPEG.start()
         listJPEGTask.append(createJPEG)
         # Create thumbnail
         outputFileName = imageFileName + ".thumb" + thumbSuffix
         if forcedOutputDirectory is not None:
             outputPath = os.path.join(forcedOutputDirectory,
                                       outputFileName)
         else:
             outputPath = None
         inDataCreateThumb = {
             "image": imagePath,
             "height": 256,
             "width": 256,
             "outputFileName": outputFileName,
             "outputPath": outputPath,
             "doResolutionRings": True,
             "pixelSizeX": detector["pixelSizeX"],
             "pixelSizeY": detector["pixelSizeY"],
             "beamPositionX": detector["beamPositionX"],
             "beamPositionY": detector["beamPositionY"],
             "distance": detector["distance"],
             "wavelength": beam["wavelength"],
         }
         createThumb = CreateThumbnail(
             inData=inDataCreateThumb,
             workingDirectorySuffix=imageFileName + "_thumbnail")
         createThumb.start()
         listThumbTask.append(createThumb)
     outData = {"pathToJPEGImage": [], "pathToThumbImage": []}
     for task in listJPEGTask:
         task.join()
         if forcedOutputDirectory:
             outData["pathToJPEGImage"].append(task.outData["thumbNail"])
         else:
             pyarchPath = self.copyThumbnailToPyarch(task)
             outData["pathToJPEGImage"].append(pyarchPath)
     for task in listThumbTask:
         task.join()
         if forcedOutputDirectory:
             outData["pathToThumbImage"].append(task.outData["thumbNail"])
         else:
             pyarchPath = self.copyThumbnailToPyarch(task)
             outData["pathToThumbImage"].append(pyarchPath)
     return outData
Exemplo n.º 7
0
 def setWorkingDirectory(self, inData):
     self._workingDirectory = UtilsPath.getWorkingDirectory(self, inData)
Exemplo n.º 8
0
 def createHdf5HeaderData(cls,
                          imagePath,
                          skipNumberOfImages=False,
                          hasOverlap=False,
                          isFastMesh=True):
     h5MasterFilePath, h5DataFilePath, h5FileNumber = UtilsImage.getH5FilePath(
         pathlib.Path(imagePath),
         isFastMesh=isFastMesh,
         hasOverlap=hasOverlap)
     # Waiting for file
     timedOut, finalSize = UtilsPath.waitForFile(h5MasterFilePath,
                                                 expectedSize=2000000,
                                                 timeOut=DEFAULT_TIME_OUT)
     if timedOut:
         errorMessage = "Timeout when waiting for image %s" % imagePath
         logger.error(errorMessage)
         raise BaseException(errorMessage)
     logger.info("Final size for {0}: {1}".format(h5MasterFilePath,
                                                  finalSize))
     noTrialsLeft = 5
     dictHeader = None
     while noTrialsLeft > 0:
         try:
             dictHeader = cls.readHdf5Header(h5MasterFilePath)
             noTrialsLeft = 0
         except Exception as e:
             logger.warning(
                 "Cannot read header from {0}, no trials left: {1}".format(
                     h5MasterFilePath, noTrialsLeft))
             time.sleep(5)
             noTrialsLeft -= 1
     if dictHeader is None:
         raise RuntimeError(
             "Cannot read header from {0}!".format(h5MasterFilePath))
     description = dictHeader["description"]
     if "Eiger 4M" in description:
         detectorName = "EIGER 4M"
         detectorType = "eiger4m"
         numberPixelX = 2070
         numberPixelY = 2167
     elif "eiger" in description.lower() and "16M" in description:
         detectorName = "EIGER 16M"
         detectorType = "eiger16m"
         numberPixelX = 4148
         numberPixelY = 4362
     else:
         raise RuntimeError(
             "{0} cannot read image header from images with detector type {1}"
             .format(cls.__class__.__name__, description))
     # Image number
     image_number = UtilsImage.getImageNumber(imagePath)
     # Find out size of data set
     prefix = str(h5MasterFilePath).split("master")[0]
     listDataImage = []
     noImages = 0
     if not skipNumberOfImages:
         for data in dictHeader["data"]:
             dataFilePath = prefix + data + ".h5"
             timedOut, finalSize = UtilsPath.waitForFile(
                 dataFilePath,
                 expectedSize=100000,
                 timeOut=DEFAULT_TIME_OUT)
             if timedOut:
                 raise RuntimeError(
                     "Timeout waiting for file {0}".format(dataFilePath))
             # listDataImage.append({
             #     'path': dataFilePath
             # })
             f = h5py.File(dataFilePath, "r")
             dataShape = f["entry"]["data"]["data"].shape
             noImages += dataShape[0]
             f.close()
     experimentalCondition = {}
     # Pixel size and beam position
     detector = {
         "numberPixelX":
         int(numberPixelX),
         "numberPixelY":
         int(numberPixelY),
         "pixelSizeX":
         round(dictHeader["x_pixel_size"] * 1000, 3),
         "pixelSizeY":
         round(dictHeader["y_pixel_size"] * 1000, 3),
         "beamPositionX":
         round(
             float(dictHeader["beam_center_x"] *
                   dictHeader["x_pixel_size"] * 1000),
             3,
         ),
         "beamPositionY":
         round(
             float(dictHeader["beam_center_y"] *
                   dictHeader["y_pixel_size"] * 1000),
             3,
         ),
         "distance":
         round(float(dictHeader["detector_distance"]) * 1000, 3),
         "serialNumber":
         dictHeader["detector_number"],
         "name":
         detectorName,
         "type":
         detectorType,
     }
     experimentalCondition["detector"] = detector
     # Beam object
     beam = {
         "wavelength": round(float(dictHeader["wavelength"]), 6),
         "exposureTime": round(float(dictHeader["count_time"]), 6),
     }
     experimentalCondition["beam"] = beam
     # Goniostat object
     goniostat = {}
     rotationAxisStart = round(float(dictHeader["omega_start"]), 4)
     oscillationWidth = round(float(dictHeader["omega_range_average"]), 4)
     # Offset for the image number
     rotationAxisStart += (image_number - 1) * oscillationWidth
     goniostat["rotationAxisStart"] = rotationAxisStart
     goniostat["rotationAxisEnd"] = rotationAxisStart + oscillationWidth
     goniostat["oscillationWidth"] = oscillationWidth
     experimentalCondition["goniostat"] = goniostat
     # Create the image object
     image_dict = {
         "path": imagePath,
         "date": dictHeader["data_collection_date"],
         "number": 1,
     }
     # imageNumber = UtilsImage.getImageNumber(imagePath)
     # image['number'] = imageNumber
     subWedge = {
         "experimentalCondition": experimentalCondition,
         "image": [image_dict],
     }
     return subWedge
Exemplo n.º 9
0
 def createCBFHeaderData(cls, imagePath):
     # Waiting for file
     timedOut, finalSize = UtilsPath.waitForFile(imagePath,
                                                 expectedSize=100000,
                                                 timeOut=DEFAULT_TIME_OUT)
     if timedOut:
         errorMessage = "Timeout when waiting for image %s" % imagePath
         logger.error(errorMessage)
         raise BaseException(errorMessage)
     dictHeader = cls.readCBFHeader(imagePath)
     detector = dictHeader["Detector:"]
     if ("PILATUS 3M" in detector or "PILATUS3 2M" in detector
             or "PILATUS 2M" in detector or "PILATUS2 3M" in detector):
         detectorName = "PILATUS2 3M"
         detectorType = "pilatus2m"
         numberPixelX = 1475
         numberPixelY = 1679
     elif "PILATUS 6M" in detector or "PILATUS3 6M" in detector:
         detectorName = "PILATUS2 6M"
         detectorType = "pilatus6m"
         numberPixelX = 2463
         numberPixelY = 2527
     elif "eiger" in detector.lower() and "4m" in detector.lower():
         detectorName = "EIGER 4M"
         detectorType = "eiger4m"
         numberPixelX = 2070
         numberPixelY = 2167
     elif "eiger2" in detector.lower() and "16m" in detector.lower():
         detectorName = "EIGER2 16M"
         detectorType = "eiger16m"
         numberPixelX = 4148
         numberPixelY = 4362
     else:
         raise RuntimeError(
             "{0} cannot read image header from images with dector type {1}"
             .format(cls.__class__.__name__, detector))
     experimentalCondition = {}
     detector = {"numberPixelX": numberPixelX, "numberPixelY": numberPixelY}
     # Pixel size
     listPixelSizeXY = dictHeader["Pixel_size"].split(" ")
     detector["pixelSizeX"] = float(listPixelSizeXY[0]) * 1000
     detector["pixelSizeY"] = float(listPixelSizeXY[3]) * 1000
     # Beam position
     listBeamPosition = (dictHeader["Beam_xy"].replace("(", " ").replace(
         ")", " ").replace(",", " ").split())
     detector["beamPositionX"] = float(
         listBeamPosition[0]) * detector["pixelSizeX"]
     detector["beamPositionY"] = float(
         listBeamPosition[1]) * detector["pixelSizeY"]
     distance = float(dictHeader["Detector_distance"].split(" ")[0]) * 1000
     detector["distance"] = distance
     detector["serialNumber"] = dictHeader["Detector:"]
     detector["name"] = detectorName
     detector["type"] = detectorType
     experimentalCondition["detector"] = detector
     # Beam object
     beam = {
         "wavelength": float(dictHeader["Wavelength"].split(" ")[0]),
         "exposureTime": float(dictHeader["Exposure_time"].split(" ")[0]),
     }
     experimentalCondition["beam"] = beam
     # Goniostat object
     goniostat = {}
     rotationAxisStart = float(dictHeader["Start_angle"].split(" ")[0])
     oscillationWidth = float(dictHeader["Angle_increment"].split(" ")[0])
     goniostat["rotationAxisStart"] = rotationAxisStart
     goniostat["rotationAxisEnd"] = rotationAxisStart + oscillationWidth
     goniostat["oscillationWidth"] = oscillationWidth
     experimentalCondition["goniostat"] = goniostat
     # Create the image object
     image = {"path": imagePath}
     if "DateTime" in dictHeader:
         image["date"] = dictHeader["DateTime"]
     imageNumber = UtilsImage.getImageNumber(imagePath)
     image["number"] = imageNumber
     subWedge = {
         "experimentalCondition": experimentalCondition,
         "image": [image]
     }
     return subWedge
Exemplo n.º 10
0
 def test_createPyarchFilePath(self):
     self.assertEqual("None", str(UtilsPath.createPyarchFilePath("/")), "/")
     self.assertEqual("None", str(UtilsPath.createPyarchFilePath("/data")), "/data")
     self.assertEqual(
         "None",
         str(UtilsPath.createPyarchFilePath("/data/visitor")),
         "/data/visitor",
     )
     self.assertEqual(
         "None",
         str(UtilsPath.createPyarchFilePath("/data/visitor/mx415/id14eh2")),
         "/data/visitor/mx415/id14eh2",
     )
     self.assertEqual(
         "/data/pyarch/2010/id14eh2/mx415/20100212",
         str(UtilsPath.createPyarchFilePath("/data/visitor/mx415/id14eh2/20100212")),
         "/data/visitor/mx415/id14eh2/20100212",
     )
     self.assertEqual(
         "/data/pyarch/2010/id14eh2/mx415/20100212/1",
         str(
             UtilsPath.createPyarchFilePath("/data/visitor/mx415/id14eh2/20100212/1")
         ),
         "/data/visitor/mx415/id14eh2/20100212/1",
     )
     self.assertEqual(
         "/data/pyarch/2010/id14eh2/mx415/20100212/1/2",
         str(
             UtilsPath.createPyarchFilePath(
                 "/data/visitor/mx415/id14eh2/20100212/1/2"
             )
         ),
         "/data/visitor/mx415/id14eh2/20100212/1/2",
     )
     # Test with inhouse account...
     self.assertEqual("None", str(UtilsPath.createPyarchFilePath("/")), "/")
     self.assertEqual("None", str(UtilsPath.createPyarchFilePath("/data")), "/data")
     self.assertEqual(
         "None",
         str(UtilsPath.createPyarchFilePath("/data/id23eh2")),
         "/data/id23eh2",
     )
     self.assertEqual(
         "None",
         str(UtilsPath.createPyarchFilePath("/data/id23eh2/inhouse")),
         "/data/id23eh2/inhouse",
     )
     self.assertEqual(
         "None",
         str(UtilsPath.createPyarchFilePath("/data/id23eh2/inhouse/opid232")),
         "/data/id23eh2/inhouse/opid232",
     )
     self.assertEqual(
         "/data/pyarch/2010/id23eh2/opid232/20100525",
         str(
             UtilsPath.createPyarchFilePath("/data/id23eh2/inhouse/opid232/20100525")
         ),
         "/data/id23eh2/inhouse/opid232/20100525",
     )
     self.assertEqual(
         "/data/pyarch/2010/id23eh2/opid232/20100525/1",
         str(
             UtilsPath.createPyarchFilePath(
                 "/data/id23eh2/inhouse/opid232/20100525/1"
             )
         ),
         "/data/id23eh2/inhouse/opid232/20100525/1",
     )
     self.assertEqual(
         "/data/pyarch/2010/id23eh2/opid232/20100525/1/2",
         str(
             UtilsPath.createPyarchFilePath(
                 "/data/id23eh2/inhouse/opid232/20100525/1/2"
             )
         ),
         "/data/id23eh2/inhouse/opid232/20100525/1/2",
     )
     self.assertEqual(
         "/data/pyarch/2014/id30a1/opid30a1/20140717/RAW_DATA/opid30a1_1_dnafiles",
         str(
             UtilsPath.createPyarchFilePath(
                 "/data/id30a1/inhouse/opid30a1/20140717/RAW_DATA/opid30a1_1_dnafiles"
             )
         ),
         "/data/id30a1/inhouse/opid30a1/20140717/RAW_DATA/opid30a1_1_dnafiles",
     )
     # Visitor
     self.assertEqual(
         "None",
         str(UtilsPath.createPyarchFilePath("/data/visitor/mx415/id30a3")),
         "/data/visitor/mx415/id30a3",
     )
     self.assertEqual(
         "/data/pyarch/2010/id30a3/mx415/20100212",
         str(UtilsPath.createPyarchFilePath("/data/visitor/mx415/id30a3/20100212")),
         "/data/visitor/mx415/id30a3/20100212",
     )
     self.assertEqual(
         "/data/pyarch/2010/id30a3/mx415/20100212/1",
         str(
             UtilsPath.createPyarchFilePath("/data/visitor/mx415/id30a3/20100212/1")
         ),
         "/data/visitor/mx415/id30a3/20100212/1",
     )
     self.assertEqual(
         "/data/pyarch/2010/id30a3/mx415/20100212/1/2",
         str(
             UtilsPath.createPyarchFilePath(
                 "/data/visitor/mx415/id30a3/20100212/1/2"
             )
         ),
         "/data/visitor/mx415/id30a3/20100212/1/2",
     )
     self.assertEqual(
         "/data/pyarch/2010/id30a3/opid232/20100525",
         str(
             UtilsPath.createPyarchFilePath("/data/id30a3/inhouse/opid232/20100525")
         ),
         "/data/id30a3/inhouse/opid232/20100525",
     )
     self.assertEqual(
         "/data/pyarch/2010/id30a3/opid232/20100525/1",
         str(
             UtilsPath.createPyarchFilePath(
                 "/data/id30a3/inhouse/opid232/20100525/1"
             )
         ),
         "/data/id30a3/inhouse/opid232/20100525/1",
     )
     self.assertEqual(
         "/data/pyarch/2010/id30a3/opid232/20100525/1/2",
         str(
             UtilsPath.createPyarchFilePath(
                 "/data/id30a3/inhouse/opid232/20100525/1/2"
             )
         ),
         "/data/id30a3/inhouse/opid232/20100525/1/2",
     )
     self.assertEqual(
         "/data/pyarch/2014/id30a3/opid30a1/20140717/RAW_DATA/opid30a1_1_dnafiles",
         str(
             UtilsPath.createPyarchFilePath(
                 "/data/id30a3/inhouse/opid30a1/20140717/RAW_DATA/opid30a1_1_dnafiles"
             )
         ),
         "/data/id30a3/inhouse/opid30a1/20140717/RAW_DATA/opid30a1_1_dnafiles",
     )
     # Test with different prefix...:
     self.assertEqual(
         "/data/pyarch/2010/id23eh2/opid232/20100525",
         str(
             UtilsPath.createPyarchFilePath("/mnt/multipath-shares/data/id23eh2/inhouse/opid232/20100525")
         ),
         "/data/id23eh2/inhouse/opid232/20100525",
     )
Exemplo n.º 11
0
 def test_stripDataDirectoryPrefix(self):
     data_directory = "/gpfs/easy/data/id30a2/inhouse/opid30a2"
     new_data_directory = UtilsPath.stripDataDirectoryPrefix(data_directory)
     self.assertEqual(str(new_data_directory), "/data/id30a2/inhouse/opid30a2")