def createOutputStep(self): imgSet = self.inputParticles.get() partSet = self._createSetOfParticles() partSet.copyInfo(imgSet) outImagesMd = self._getExtraPath('expanded_particles.star') # remove repeating rlnImageId column tableName = '' if Plugin.IS_GT30(): tableName = 'particles' mdOptics = Table(fileName=outImagesMd, tableName='optics') mdOut = Table(fileName=outImagesMd, tableName=tableName) mdOut.removeColumns("rlnImageId") with open(outImagesMd, "w") as f: mdOut.writeStar(f, tableName=tableName) if Plugin.IS_GT30(): mdOptics.writeStar(f, tableName='optics') reader = convert.createReader() reader.readSetOfParticles( outImagesMd, partSet, alignType=ALIGN_PROJ, postprocessImageRow=self._postprocessImageRow) self._defineOutputs(outputParticles=partSet) self._defineSourceRelation(imgSet, partSet)
def test_removeColumns(self): print("Checking removeColumns...") dataFile = testfile('star', 'refine3d', 'run_it016_data.star') table = Table(fileName=dataFile, tableName='particles') expectedCols = [ 'rlnCoordinateX', 'rlnCoordinateY', 'rlnAutopickFigureOfMerit', 'rlnClassNumber', 'rlnAnglePsi', 'rlnImageName', 'rlnMicrographName', 'rlnOpticsGroup', 'rlnCtfMaxResolution', 'rlnCtfFigureOfMerit', 'rlnDefocusU', 'rlnDefocusV', 'rlnDefocusAngle', 'rlnCtfBfactor', 'rlnCtfScalefactor', 'rlnPhaseShift', 'rlnGroupNumber', 'rlnAngleRot', 'rlnAngleTilt', 'rlnOriginXAngst', 'rlnOriginYAngst', 'rlnNormCorrection', 'rlnLogLikeliContribution', 'rlnMaxValueProbDistribution', 'rlnNrOfSignificantSamples', 'rlnRandomSubset' ] colsToRemove = [ 'rlnOriginXAngst', 'rlnOriginYAngst', 'rlnNormCorrection', 'rlnAnglePsi', 'rlnMaxValueProbDistribution' ] # Check all columns were read properly self.assertEqual(expectedCols, table.getColumnNames()) # Check also using hasAllColumns method self.assertTrue(table.hasAllColumns(expectedCols)) table.removeColumns(colsToRemove) self.assertEqual([c for c in expectedCols if c not in colsToRemove], table.getColumnNames()) # Check also using hasAnyColumn method self.assertFalse(table.hasAnyColumn(colsToRemove))