[469] | 1 | # a set of short routines to read in phases from various file formats |
---|
| 2 | # |
---|
| 3 | import GSASIIIO as G2IO |
---|
| 4 | |
---|
| 5 | class PDB_ReaderClass(G2IO.ImportPhase): |
---|
| 6 | 'Routines to import Phase information from a PDB file' |
---|
| 7 | def __init__(self): |
---|
| 8 | super(self.__class__,self).__init__( # fancy way to say ImportPhase.__init__ |
---|
| 9 | extensionlist=('.pdb','.ent','.PDB','.ENT'), |
---|
| 10 | strictExtension=True, |
---|
| 11 | formatName = 'PDF', |
---|
| 12 | longFormatName = 'Original Protein Data Bank (.pdb file) import' |
---|
| 13 | ) |
---|
| 14 | # I don't know enough to validate the contents |
---|
| 15 | #def ContentsValidator(self, filepointer): |
---|
| 16 | # filepointer.seek(0) # rewind the file pointer |
---|
| 17 | # return True |
---|
| 18 | |
---|
| 19 | def Reader(self,filename,filepointer, ParentFrame=None): |
---|
| 20 | try: |
---|
| 21 | self.Phase = G2IO.ReadPDBPhase(filename) |
---|
| 22 | return True |
---|
| 23 | except: |
---|
| 24 | return False |
---|
| 25 | |
---|
| 26 | class EXP_ReaderClass(G2IO.ImportPhase): |
---|
| 27 | ' Routines to import Phase information from GSAS .EXP files' |
---|
| 28 | def __init__(self): |
---|
| 29 | super(self.__class__,self).__init__( # fancy way to say ImportPhase.__init__ |
---|
| 30 | extensionlist=('.EXP',), |
---|
| 31 | strictExtension=True, |
---|
| 32 | formatName = 'GSAS .EXP', |
---|
| 33 | longFormatName = 'GSAS Experiment (.EXP file) import' |
---|
| 34 | ) |
---|
| 35 | def ContentsValidator(self, filepointer): |
---|
| 36 | filepointer.seek(0) # rewind the file pointer |
---|
| 37 | # first 13 characters should be VERSION tag -- I think |
---|
| 38 | try: |
---|
| 39 | if filepointer.read(13) == ' VERSION ': |
---|
| 40 | return True |
---|
| 41 | except: pass |
---|
| 42 | return False |
---|
| 43 | |
---|
| 44 | def Reader(self,filename,filepointer, ParentFrame=None): |
---|
| 45 | try: |
---|
| 46 | self.Phase = G2IO.ReadEXPPhase(ParentFrame, filename) |
---|
| 47 | return True |
---|
| 48 | except: |
---|
| 49 | return False |
---|