def readStr(self, s, format='auto'): """Same as Structure.readStr, but update spcgr value in self.pdffit when parser can get spacegroup. Return instance of StructureParser used to load the data. See Structure.readStr() for more info. """ p = Structure.readStr(self, s, format) sg = getattr(p, 'spacegroup', None) if sg: self.pdffit['spcgr'] = sg.short_name return p
def readStr(self, s, format = 'pwinput'): """Load structure from a string, any original data become lost. filename -- file to be loaded format -- structure formats 'pwinput' ( pw.x input, default), 'pwoutput' (pw.x output), 'bratoms', 'cif', 'discus', 'pdb', 'pdffit', 'rawxyz', 'xcfg', 'xyz' Return instance of data Parser used to process file. This can be inspected for information related to particular format. """ from qecalc.qetask.qeparser.qestructureparser import parser_index #from qecalc.qetask.qeparser.pwinput import PWInput if self._qeInput == None: from qecalc.qetask.qeparser.pwinput import PWInput self._qeInput = PWInput() self._qeInput.structure = self #if self._qeInput == None: # self._qeInput = PWInput() #self._qeInput.parse() if format in parser_index: module = __import__("qestructureparser.P_" + format, globals(), \ locals(), ['P_' + format], -1) parser = module.getParser(self._qeInput) new_structure = parser.parseStr(s) else: diffpyStruct = Structure() parser = diffpyStruct.readStr(s, format = format) new_structure = QEStructure(qeInput = self._qeInput) new_structure._setStructureFromDiffpyStructure(diffpyStruct, \ massList = [], psList = [], ibrav = 0) new_structure.lattice._qeInput.update( forceUpdate = True ) #new_structure._qeInput = new_structure.lattice._qeInput #print 'toString: ', new_structure._qeInput.toString() #self = QEStructure(new_structure) self.__Init(new_structure) return parser
def readStr(self, s, format='pwinput'): """Load structure from a string, any original data become lost. filename -- file to be loaded format -- structure formats 'pwinput' ( pw.x input, default), 'pwoutput' (pw.x output), 'bratoms', 'cif', 'discus', 'pdb', 'pdffit', 'rawxyz', 'xcfg', 'xyz' Return instance of data Parser used to process file. This can be inspected for information related to particular format. """ from qecalc.qetask.qeparser.qestructureparser import parser_index #from qecalc.qetask.qeparser.pwinput import PWInput if self._qeInput == None: from qecalc.qetask.qeparser.pwinput import PWInput self._qeInput = PWInput() self._qeInput.structure = self #if self._qeInput == None: # self._qeInput = PWInput() #self._qeInput.parse() if format in parser_index: module = __import__("qestructureparser.P_" + format, globals(), \ locals(), ['P_' + format], -1) parser = module.getParser(self._qeInput) new_structure = parser.parseStr(s) else: diffpyStruct = Structure() parser = diffpyStruct.readStr(s, format=format) new_structure = QEStructure(qeInput=self._qeInput) new_structure._setStructureFromDiffpyStructure(diffpyStruct, \ massList = [], psList = [], ibrav = 0) new_structure.lattice._qeInput.update(forceUpdate=True) #new_structure._qeInput = new_structure.lattice._qeInput #print 'toString: ', new_structure._qeInput.toString() #self = QEStructure(new_structure) self.__Init(new_structure) return parser