示例#1
0
	def post_processing(self):

		# group the per-atom density metrics for each dataset together

		txt = 'Combining density metric information for each dataset '+\
			  'together within the damage series'
		self.logFile.writeToLog(str = txt)

		txt = 'Input pkl files for post processing chosen from input file:'
		for file in self.pklFiles: 
			txt += '\n\t{}'.format(file.replace(self.outDir,""))
		self.logFile.writeToLog(str = txt)

		# next read in the pdb structure file as list of atom objects
		initialPDBlist = PDBtoList(pdbFileName = self.get1stDsetPDB())

		# retrieve object lists of atoms for each damage set
		ln = '\nReading in pkl files for higher dataset structures...'
		self.logFile.writeToLog(str = ln)

		dList = [] # dataset list
		for pkl_filename in self.pklFiles:
			ln = 'Damage file number: {}'.format(len(dList)+1)
			self.logFile.writeToLog(str = ln)
			PDB_ret = retrieve_objectlist(fileName = pkl_filename,
										  logFile  = self.logFile)
			# remove pkl file since no longer needed
			remove(pkl_filename)

			# add new retrieved damage set list to dList
			dList.append(PDB_ret)
		pklDir = '/'.join(pkl_filename.split('/')[:-1])+'/'

		# remove directory if it is now empty
		if listdir(pklDir) == []:
			rmdir(pklDir)

		# create a list of atom objects with attributes as lists varying over 
		# dose range, only including atoms present in ALL damage datasets
		ln = 'New list of atoms over full dose range calculated...'
		self.logFile.writeToLog(str = ln)
		combinedAtoms = combinedAtomList(datasetList    = dList,
										 numLigRegDsets = len(dList),
										 doseList       = self.doses,
										 initialPDBList = initialPDBlist,
										 outputDir      = self.outputDir,
										 seriesName     = self.seriesName,
										 inclFCmetrics  = self.inclFCmets)

		combinedAtoms.getMultiDoseAtomList()

		# calculate 'average' variant Dloss metrics
		combinedAtoms.calcAdditionalMetrics(newMetric = 'average')

		# calculate Calpha normalised metrics, if Calpha atoms exist
		if self.checkCalphasPresent(atomObjList = combinedAtoms):
			for m in ('loss','mean','gain','Bfactor'):
				combinedAtoms.calcAdditionalMetrics(metric = m)
		
		self.combinedAtoms = combinedAtoms
示例#2
0
	def post_processing(self):
		self.titleCaption('Post Processing')
		print 'Input pkl files for post processing chosen from input file:'
		for file in self.pklFiles: 
			print '\t{}'.format(file)

		# next read in the pdb structure file as list of atom objects
		print 'Reading in initial pdb file...'
		initialPDBlist = PDBtoList(self.where+self.initialPDB,[])

		# retrieve object lists of atoms for each damage set
		self.fillerLine()
		print 'Reading in damaged pkl files...'
		dList = [] # dataset list
		for pkl_filename in self.pklFiles:
			print 'Damage file number: {}\n'.format(len(dList)+1)
			PDB_ret = retrieve_objectlist(pkl_filename)

			# add new retrieved damage set list to dList
			dList.append(PDB_ret)

		# create a list of atom objects with attributes as lists varying over 
		# dose range, only including atoms present in ALL damage datasets
		print 'New list of atoms over full dose range calculated...'
		combinedAtoms = combinedAtomList(dList,len(dList),self.doses,initialPDBlist,
										 self.outputDir,True,self.seriesName)
		combinedAtoms.getMultiDoseAtomList()

		# calculate 'standardised' and 'average' variant Dloss metrics
		combinedAtoms.calcStandardisedMetrics('loss')
		combinedAtoms.calcAdditionalMetrics('loss','Standard','average')
		
		# write atom numbers and density metrics to simple text files - one for 
		# each density metric separately
		for densMet in combinedAtoms.getDensMetrics():
			print 'Writing .txt file for per-atom density metric: {}, normalisation: {}'.format(*densMet)
			combinedAtoms.writeMetric2File(self.outputDir,*densMet)
		
		self.combinedAtoms = combinedAtoms
		self.summaryStats()
示例#3
0
    def post_processing(self):

        # group the per-atom density metrics for each dataset together

        self.logFile.writeToLog(
            str='Combining density metric information for each dataset ' +
                'together within the damage series')

        txt = 'Input pkl files for post processing chosen from input file:'
        for file in self.pklFiles:
            txt += '\n\t{}'.format(file.replace(self.outDir, ""))
        self.logFile.writeToLog(str=txt)

        # next read in the pdb structure file as list of atom objects
        initialPDBlist = PDBtoList(pdbFileName=self.get1stDsetPDB())

        # retrieve object lists of atoms for each damage set
        ln = '\nReading in pkl files for higher dataset structures...'
        self.logFile.writeToLog(str=ln)

        dList = []
        for pkl_filename in self.pklFiles:
            ln = 'Damage file number: {}'.format(len(dList)+1)
            self.logFile.writeToLog(str=ln)
            PDB_ret = retrieve_objectlist(
                fileName=pkl_filename, logFile=self.logFile)

            # remove pkl file since no longer needed
            remove(pkl_filename)

            # add new retrieved damage set list to dList
            dList.append(PDB_ret)

        # create a list of atom objects with attributes as lists varying over
        # dose range, only including atoms present in ALL damage datasets
        self.logFile.writeToLog(
            str='New list of atoms over full dose range calculated...')
        combinedAtoms = combinedAtomList(
            datasetList=dList, numLigRegDsets=len(dList), doseList=self.doses,
            initialPDBList=initialPDBlist, outputDir=self.outputDataDir,
            seriesName=self.seriesName, inclFCmetrics=self.inclFCmets)

        combinedAtoms.getMultiDoseAtomList(logFile=self.logFile)

        # calculate 'average' variant Dloss metrics
        combinedAtoms.calcAdditionalMetrics(newMetric='average')

        # calculate normalised metrics, if suitable atoms exist
        if self.normSet != [[]]:
            if combinedAtoms.checkSpecificAtomsExist(self.normSet):

                metricsOfInterest = ['loss', 'mean', 'gain', 'Bfactor']

                if self.inclFCmets:
                    metricsOfInterest += ['density_weighted_mean_negOnly',
                                          'density_weighted_loss',
                                          'density_weighted_mean']

                for m in metricsOfInterest:
                    combinedAtoms.calcAdditionalMetrics(
                        metric=m, newMetric='X-normalised',
                        normalisationSet=self.normSet)
            else:
                # if there is a problem finding the set of atoms
                error(text='Failed to find the specified set of ' +
                      'atoms to normalise metrics', log=self.logFile)

        # save metric data to pkl file
        pklDataFile = saveGenericObject(
            obj=combinedAtoms, fileName=self.seriesName)

        move(pklDataFile, self.pklFileDir + pklDataFile)
        self.pklDataFile = self.pklFileDir + pklDataFile

        # append the pklfile name to the input RIDL file
        inputfile = open(self.RIDLinputFile, 'r')
        pklFound = False
        for l in inputfile.readlines():
            if l.startswith('pklDataFile'):
                pklFound = True
                break
        inputfile.close()
        if not pklFound:
            inputfile = open(self.RIDLinputFile, 'a')
            inputfile.write('\npklDataFile ' + self.pklDataFile)
            inputfile.close()