source: trunk/G2importphase.py @ 572

Last change on this file since 572 was 500, checked in by vondreele, 13 years ago

minor fix up

File size: 2.4 KB
Line 
1########### SVN repository information ###################
2# $Date: 2012-02-13 11:33:35 -0600 (Mon, 13 Feb 2012) $
3# $Author: vondreele & toby $
4# $Revision: 482 $
5# $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/G2importphase.py $
6# $Id: G2importphase.py 482 2012-02-13 17:33:35Z vondreele $
7########### SVN repository information ###################
8# a set of short routines to read in phases from various file formats
9#
10import sys
11import traceback
12import GSASIIIO as G2IO
13
14class PDB_ReaderClass(G2IO.ImportPhase):
15    'Routines to import Phase information from a PDB file'
16    def __init__(self):
17        super(self.__class__,self).__init__( # fancy way to say ImportPhase.__init__
18            extensionlist=('.pdb','.ent','.PDB','.ENT'),
19            strictExtension=True,
20            formatName = 'PDB',
21            longFormatName = 'Original Protein Data Bank (.pdb file) import'
22            )
23    # I don't know enough to validate the contents
24    #def ContentsValidator(self, filepointer):
25    #    filepointer.seek(0) # rewind the file pointer
26    #    return True
27
28    def Reader(self,filename,filepointer, ParentFrame=None):
29        try:
30            self.Phase = G2IO.ReadPDBPhase(filename)
31            return True
32        except Exception as detail:
33            print 'PDB read error:',detail # for testing
34            traceback.print_exc(file=sys.stdout)
35            return False
36
37class EXP_ReaderClass(G2IO.ImportPhase):
38    ' Routines to import Phase information from GSAS .EXP files'
39    def __init__(self):
40        super(self.__class__,self).__init__( # fancy way to say ImportPhase.__init__
41            extensionlist=('.EXP','.exp'),
42            strictExtension=True,
43            formatName = 'GSAS .EXP',
44            longFormatName = 'GSAS Experiment (.EXP file) import'
45            )
46    def ContentsValidator(self, filepointer):
47        filepointer.seek(0) # rewind the file pointer
48        # first 13 characters should be VERSION tag -- I think
49        try:
50            if filepointer.read(13) == '     VERSION ':
51                return True
52        except: pass
53        return False
54
55    def Reader(self,filename,filepointer, ParentFrame=None):
56        try:
57            self.Phase = G2IO.ReadEXPPhase(ParentFrame, filename)
58            return True
59        except Exception as detail:
60            print 'GSAS .EXP read error:',detail # for testing
61            traceback.print_exc(file=sys.stdout)
62            return False
Note: See TracBrowser for help on using the repository browser.