def createSubset(log, inputFile, inputFileLabel, subsetFile, subsetFileLabel, outputFile): mdInputFile = MetaData(inputFile) mdSubsetFile = MetaData(subsetFile) mdOutputFile = MetaData() print inputFile, inputFileLabel, subsetFile, subsetFileLabel, outputFile mdOutputFile.join2( mdInputFile , mdSubsetFile , str2Label(inputFileLabel) , str2Label(subsetFileLabel) , INNER_JOIN) mdOutputFile.write(outputFile)
def joinMetaDatas(log,InputFile,UntiltedMetadata,TiltedMetadata): mDInput=MetaData(InputFile) mDstack = MetaData(UntiltedMetadata) mDstack.removeLabel(MDL_MICROGRAPH) mDstack.removeLabel(MDL_XCOOR) mDstack.removeLabel(MDL_YCOOR) mdPart1=MetaData() mdPart1.join2(mDstack,mDInput,MDL_IMAGE_ORIGINAL,MDL_IMAGE,INNER_JOIN) mdPart1.removeLabel(MDL_IMAGE_ORIGINAL) mDstack = MetaData(TiltedMetadata) mDstack.removeLabel(MDL_MICROGRAPH) mDstack.removeLabel(MDL_XCOOR) mDstack.removeLabel(MDL_YCOOR) mDstack.renameColumn(MDL_IMAGE,MDL_IMAGE_TILTED) mdJoined=MetaData() mdJoined.join2(mDstack,mdPart1,MDL_IMAGE_ORIGINAL,MDL_IMAGE_TILTED,INNER_JOIN) mdJoined.removeLabel(MDL_IMAGE_ORIGINAL) mdJoined.write(InputFile)
def gatherPairs(log, WorkingDir, ExtraDir, ClassSelection, ClassFile, ExtractDir, PickingDir): mdImages = getImagesMd(ExtractDir) fnMicrographs = getProtocolFilename("micrographs", WorkingDir=ExtractDir) mdTiltAngles = MetaData("micrographPairs@" + fnMicrographs) mdU = getImagesMd(ExtractDir, "untilted") mdUAux = MetaData() mdUAux.setColumnValues(MDL_IMAGE, mdU.getColumnValues(MDL_IMAGE)) mdUAux.setColumnValues(MDL_MICROGRAPH, mdU.getColumnValues(MDL_MICROGRAPH)) mdT = getImagesMd(ExtractDir, "tilted") mdTAux = MetaData() mdTAux.setColumnValues(MDL_IMAGE_TILTED, mdT.getColumnValues(MDL_IMAGE)) mdTAux.setColumnValues(MDL_MICROGRAPH_TILTED, mdT.getColumnValues(MDL_MICROGRAPH)) fnExtractImages = os.path.join(ExtractDir, "images.xmd") mdJoin1 = MetaData() mdJoin2 = MetaData() mdJoin3 = MetaData() mdJoin4 = MetaData() fixedMdClass = MetaData() fnOut = join(ExtraDir, "rct_classes.xmd") for classNo in ClassSelection: MDclass = MetaData(getClassBlock(classNo, ClassFile)) if not MDclass.containsLabel(MDL_IMAGE_TILTED): if MDclass.containsLabel(MDL_IMAGE_ORIGINAL): fixedMdClass.join2(MDclass, mdImages, MDL_IMAGE_ORIGINAL, MDL_IMAGE, INNER_JOIN) else: fixedMdClass.join1(MDclass, mdImages, MDL_IMAGE, INNER_JOIN) else: fixedMdClass = MDclass mdJoin1.join1(fixedMdClass, mdImages, MDL_IMAGE, LEFT_JOIN) mdJoin2.join1(mdJoin1, mdUAux, MDL_IMAGE, LEFT_JOIN) mdJoin3.join1(mdJoin2, mdTAux, MDL_IMAGE_TILTED, LEFT_JOIN) mdJoin4.join1(mdJoin3, mdTiltAngles, MDL_MICROGRAPH, LEFT_JOIN) fnClassOut = getClassBlock(classNo, fnOut) mdJoin4.write(fnClassOut, MD_APPEND)