source: trunk/G2importphase.py @ 484

Last change on this file since 484 was 484, checked in by vondreele, 11 years ago

change authorship
split GSASIIelem into a GUI & non-GUI parts
replace MsgDialogs? in GSASIIElem.py with simple prints
cleanup & refactor distance/angle/torsion calcs.

File size: 2.3 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 = 'PDF',
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            return False
35
36class EXP_ReaderClass(G2IO.ImportPhase):
37    ' Routines to import Phase information from GSAS .EXP files'
38    def __init__(self):
39        super(self.__class__,self).__init__( # fancy way to say ImportPhase.__init__
40            extensionlist=('.EXP',),
41            strictExtension=True,
42            formatName = 'GSAS .EXP',
43            longFormatName = 'GSAS Experiment (.EXP file) import'
44            )
45    def ContentsValidator(self, filepointer):
46        filepointer.seek(0) # rewind the file pointer
47        # first 13 characters should be VERSION tag -- I think
48        try:
49            if filepointer.read(13) == '     VERSION ':
50                return True
51        except: pass
52        return False
53
54    def Reader(self,filename,filepointer, ParentFrame=None):
55        try:
56            self.Phase = G2IO.ReadEXPPhase(ParentFrame, filename)
57            return True
58        except Exception as detail:
59            print 'GSAS .EXP read error:',detail # for testing
60            traceback.print_exc(file=sys.stdout)
61            return False
Note: See TracBrowser for help on using the repository browser.