def test_getListFromRangeString(self): inputStrings = ["1,5-8,10", "2,6,9-11", "2 5, 6-8"] outputLists = [[1, 5, 6, 7, 8, 10], [2, 6, 9, 10, 11], [2, 5, 6, 7, 8]] for s, o in zip(inputStrings, outputLists): self.assertEqual(o, pwutils.getListFromRangeString(s)) # Check that also works properly with spaces as delimiters s2 = s.replace(',', ' ') self.assertEqual(o, pwutils.getListFromRangeString(s2))
def writeModesMetaData(self): """ Iterate over the input SetOfNormalModes and write the proper Xmipp metadata. Take into account a possible selection of modes (This option is just a shortcut for testing. The recommended way is just create a subset from the GUI and use that as input) """ modeSelection = [] if self.modeList.empty(): modeSelection = [] else: modeSelection = getListFromRangeString(self.modeList.get()) md = xmipp.MetaData() inputModes = self.inputModes.get() for mode in inputModes: # If there is a mode selection, only # take into account those selected if not modeSelection or mode.getObjId() in modeSelection: row = XmippMdRow() modeToRow(mode, row) row.writeToMd(md, md.addObject()) md.write(self.modesFn)
def writeModesMetaData(self): """ Iterate over the input SetOfNormalModes and write the proper Xmipp metadata. Take into account a possible selection of modes (This option is just a shortcut for testing. The recommended way is just create a subset from the GUI and use that as input) """ modeSelection = [] if self.modeList.empty(): modeSelection = [] else: modeSelection = getListFromRangeString(self.modeList.get()) mdModes = md.MetaData() inputModes = self.inputModes.get() for mode in inputModes: # If there is a mode selection, only # take into account those selected if not modeSelection or mode.getObjId() in modeSelection: row = XmippMdRow() modeToRow(mode, row) row.writeToMd(mdModes, mdModes.addObject()) mdModes.write(self.modesFn)