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