Ignore:
Timestamp:
Mar 24, 2014 5:22:41 PM (8 years ago)
Author:
toby
Message:

reorg exports to implement directory selection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/exports/G2export_PDB.py

    r1123 r1261  
    127127        # create a dict with refined values and their uncertainties
    128128        self.loadParmDict()
    129         if self.ExportSelect(AskFile=True):    # set export parameters
    130             return
     129        if self.ExportSelect():    # set export parameters; ask for file name
     130            return
     131        filename = self.filename
    131132        for phasenam in self.phasenam:
    132133            phasedict = self.Phases[phasenam] # pointer to current phase info
    133134            General = phasedict['General']
    134135            if General['Type'] != 'macromolecular':
    135                 print 'not macromolecular phase'
    136                 return
     136                print 'phase '+str(phasenam)+' not macromolecular, skipping'
     137                continue
    137138            i = self.Phases[phasenam]['pId']
    138139            if len(self.phasenam) > 1: # if more than one filename is included, add a phase #
    139                 nam,ext = os.path.splitext(self.filename)
    140                 fil = nam+"_"+str(i)+ext
    141             else:
    142                 fil = self.filename
    143             fp = self.OpenFile(fil)
     140                self.filename = os.path.splitext(filename)[1] + "_" + str(i) + self.extension
     141            fp = self.OpenFile()
    144142            Atoms = phasedict['Atoms']
    145143            cx,ct,cs,cia = General['AtomPtrs']
     
    199197            self.Write('END')
    200198            self.CloseFile()
    201             print('Phase '+str(phasenam)+' written to file '+str(fil))
     199            print('Phase '+str(phasenam)+' written to PDB file '+str(self.fullpath))
    202200
    203201class ExportPhaseCartXYZ(G2IO.ExportBaseclass):
     
    225223        # create a dict with refined values and their uncertainties
    226224        self.loadParmDict()
    227         if self.ExportSelect(AskFile=True):    # set export parameters
    228             return
     225        if self.ExportSelect():    # set export parameters; ask for file name
     226            return
     227        filename = self.filename
    229228        for phasenam in self.phasenam:
    230229            phasedict = self.Phases[phasenam] # pointer to current phase info
    231230            General = phasedict['General']
    232231            i = self.Phases[phasenam]['pId']
    233             if len(self.phasenam) > 1: # if more than one filename is included, add a phase #
    234                 nam,ext = os.path.splitext(self.filename)
    235                 fil = nam+"_"+str(i)+ext
    236             else:
    237                 fil = self.filename
    238             fp = self.OpenFile(fil)
    239232            Atoms = phasedict['Atoms']
    240233            if not len(Atoms):
    241234                print('**** ERROR - Phase '+str(phasenam)+' has no atoms! ****')
    242                 return
     235                continue
     236            if len(self.phasenam) > 1: # if more than one filename is included, add a phase #
     237                self.filename = os.path.splitext(filename)[1] + "_" + str(i) + self.extension
     238            fp = self.OpenFile()
    243239            cx,ct,cs,cia = General['AtomPtrs']
    244240            Cell = General['Cell'][1:7]
     
    251247                self.Write(fmt.format(atom[ct],*xyz))
    252248            self.CloseFile()
    253             print('Phase '+str(phasenam)+' written to file '+str(fil))
     249            print('Phase '+str(phasenam)+' written to XYZ file '+str(self.fullpath))
    254250   
Note: See TracChangeset for help on using the changeset viewer.