def prepare(self): self.Logfile.insert('======== preparing HTML summary ========') self.makeFolders() self.copy_jscss() html = XChemMain.html_header() firstFile = True for xtal in self.db.samples_for_html_summary(): self.db_dict = self.db.get_db_dict_for_sample(xtal) if firstFile: if self.db_dict['ProteinName'] == 'None': self.Logfile.warning('could not determine protein name') try: self.protein_name = xtal.split('-')[0] self.Logfile.warning( 'xtal name = %s => setting protein name to %s' % (xtal, self.protein_name)) except IndexError: self.Logfile.warning( 'could not determine protein name from cystal name; setting to None' ) self.protein_name = '' else: self.protein_name = self.db_dict['ProteinName'] self.Logfile.insert('protein name is: ' + self.protein_name) self.copy_pdb(xtal) self.copy_mtz(xtal) # self.copy_electron_density(xtal) self.copy_ligand_files(xtal) for ligand in self.ligands_in_pdbFile(xtal): ligName = ligand.split('-')[0] ligChain = ligand.split('-')[1] ligNumber = ligand.split('-')[2] eventMap = self.find_matching_event_map_from_database( xtal, ligand) if eventMap: self.cut_and_copy_map(xtal, ligand + '.pdb', eventMap, xtal + '_' + ligand + '_event.ccp4', 'F', 'PHIF') x, y, z = self.pdb.get_centre_of_gravity_of_residue(ligand) self.copy_spider_plot(xtal, ligand) pdbID = self.db_dict['Deposition_PDB_ID'] compoundImage = xtal + '_' + self.db_dict[ 'CompoundCode'] + '.png' compoundCIF = xtal + '_' + self.db_dict['CompoundCode'] + '.cif' residuePlot = xtal + '_' + ligand + '.png' pdb = xtal + '.pdb' event = xtal + '_' + ligand + '_event.ccp4' thumbNail = xtal + '_' + ligand + '_thumb.png' resoHigh = self.db_dict['DataProcessingResolutionHigh'] spg = self.db_dict['RefinementSpaceGroup'] unitCell = self.db_dict['DataProcessingUnitCell'] os.chdir(os.path.join(self.projectDir, xtal)) FWT = xtal + '-' + ligand + '_2fofc.ccp4' self.cut_and_copy_map(xtal, ligand + '.pdb', '2fofc.map', FWT, 'FWT', 'PHWT') DELFWT = xtal + '-' + ligand + '_fofc.ccp4' self.cut_and_copy_map(xtal, ligand + '.pdb', 'fofc.map', DELFWT, 'DELFWT', 'PHDELWT') ligConfidence = self.db.get_ligand_confidence_for_ligand( xtal, ligChain, ligNumber, ligName) if ligConfidence.startswith('0'): self.Logfile.warning( '%s: ligand confidence of %s-%s-%s is %s; ignoring...' % (xtal, ligChain, ligNumber, ligName, ligConfidence)) continue modelStatus = self.db_dict['RefinementOutcome'] if firstFile: html += XChemMain.html_ngl( pdb, eventMap.replace(self.projectDir, ''), FWT, DELFWT, ligand) html += XChemMain.html_download(self.protein_name) html += XChemMain.html_guide() html += XChemMain.html_table_header() firstFile = False html += XChemMain.html_table_row(xtal, pdbID, ligand, compoundImage, residuePlot, pdb, event, thumbNail, resoHigh, spg, unitCell, FWT, DELFWT, ligConfidence, modelStatus) self.make_thumbnail(xtal, x, y, z, ligand, eventMap) self.prepare_for_download(xtal, pdb, event, compoundCIF, ligand) self.prepare_zip_archives() # html = XChemMain.html_download_all_section(html,self.protein_name) self.write_html_file(html) self.Logfile.insert( '======== finished preparing HTML summary ========')
def prepare(self, whichSamples): self.Logfile.insert('======== preparing HTML summary ========') self.makeFolders() self.copy_jscss() html = XChemMain.html_header() firstFile = True for xtal in self.db.samples_for_html_summary(whichSamples): self.db_dict = self.db.get_db_dict_for_sample(xtal) if firstFile: if self.db_dict['ProteinName'] == 'None': self.Logfile.warning('could not determine protein name') try: self.protein_name = xtal.split('-')[0] self.Logfile.warning( 'xtal name = %s => setting protein name to %s' % (xtal, self.protein_name)) except IndexError: self.Logfile.warning( 'could not determine protein name from cystal name; setting to None' ) self.protein_name = '' else: self.protein_name = self.db_dict['ProteinName'] self.Logfile.insert('protein name is: ' + self.protein_name) self.copy_pdb(xtal) self.copy_mtz(xtal) # self.copy_electron_density(xtal) self.copy_ligand_files(xtal) os.chdir(os.path.join(self.projectDir, xtal)) ligandDict = XChemUtils.pdbtools_gemmi( 'refine.pdb').center_of_mass_ligand_dict('LIG') self.Logfile.insert( xtal + ': saving ligand(s) of type LIG in refine.pdb as PDB files...') XChemUtils.pdbtools_gemmi('refine.pdb').save_ligands_to_pdb('LIG') for ligand in ligandDict: self.Logfile.insert(xtal + ': current ligand -> ' + ligand) os.chdir(os.path.join(self.projectDir, xtal)) # for ligand in self.ligands_in_pdbFile(xtal): ligName = ligand.split('-')[0] ligChain = ligand.split('-')[1] ligNumber = ligand.split('-')[2] # eventMap = self.find_matching_event_map_from_database(xtal, ligand) # if eventMap: # self.Logfile.insert('%s: using the following event map -> %s' %(xtal,eventMap)) # self.cut_and_copy_map(xtal, ligand+'.pdb', eventMap, xtal + '_' + ligand + '_event.ccp4','F','PHIF') # eventMap = xtal + '_' + ligand + '_event.ccp4' # else: # self.Logfile.error('%s: value of event map -> %s' %(xtal,eventMap)) eventMap = '' # self.Logfile.insert(xtal + ': looking for' + xtal + '_' + ligand + '_event.ccp4') if os.path.isfile(xtal + '_' + ligand + '_event.ccp4'): eventMap = xtal + '_' + ligand + '_event.ccp4' # self.Logfile.insert(xtal + ': found ' + eventMap) # else: # self.Logfile.error(xtal + ': cannot find' + xtal + '_' + ligand + '_event.ccp4') # x,y,z = self.pdb.get_centre_of_gravity_of_residue(ligand) x = ligandDict[ligand][0] y = ligandDict[ligand][1] z = ligandDict[ligand][2] self.copy_spider_plot(xtal, ligand) pdbID = self.db_dict['Deposition_PDB_ID'] compoundImage = xtal + '_' + self.db_dict[ 'CompoundCode'] + '.png' compoundCIF = xtal + '_' + self.db_dict['CompoundCode'] + '.cif' residuePlot = xtal + '_' + ligand + '.png' pdb = xtal + '.pdb' event = xtal + '_' + ligand + '_event.ccp4' thumbNail = xtal + '_' + ligand + '_thumb.png' resoHigh = self.db_dict['DataProcessingResolutionHigh'] spg = self.db_dict['RefinementSpaceGroup'] unitCell = self.db_dict['DataProcessingUnitCell'] t = '' for ax in unitCell.split(): t += str(round(float(ax), 1)) + ' ' unitCell = t[:-1] os.chdir(os.path.join(self.projectDir, xtal)) # FWT = xtal + '-' + ligand + '_2fofc.ccp4' # self.cut_and_copy_map(xtal, ligand + '.pdb', '2fofc.map', FWT,'FWT','PHWT') # DELFWT = xtal + '-' + ligand + '_fofc.ccp4' # self.cut_and_copy_map(xtal, ligand + '.pdb', 'fofc.map', DELFWT,'DELFWT','PHDELWT') if os.path.isfile('refine.mtz'): self.Logfile.insert('%s: found refine.mtz' % xtal) FWTmap, DELFWTmap = self.prepare_e_density_maps( xtal, ligand) self.copy_electron_density(xtal, ligand, eventMap) ligConfidence = self.db.get_ligand_confidence_for_ligand( xtal, ligChain, ligNumber, ligName) if ligConfidence.startswith('0'): self.Logfile.warning( '%s: ligand confidence of %s-%s-%s is %s; ignoring...' % (xtal, ligChain, ligNumber, ligName, ligConfidence)) self.Logfile.warning( '%s: this seems unlikely because this structure is apparently ready for deposition' % xtal) self.Logfile.warning( '%s: will set it to "not assigned" for now, but please update in soakDB' % xtal) ligConfidence = 'not assigned' modelStatus = self.db_dict['RefinementOutcome'] if firstFile: html += XChemMain.html_ngl( pdb, eventMap.replace(self.projectDir, ''), FWTmap, DELFWTmap, ligand) html += XChemMain.html_download(self.protein_name) html += XChemMain.html_guide() html += XChemMain.html_table_header() firstFile = False html += XChemMain.html_table_row(xtal, pdbID, ligand, compoundImage, residuePlot, pdb, event, thumbNail, resoHigh, spg, unitCell, FWTmap, DELFWTmap, ligConfidence, modelStatus) self.make_thumbnail(xtal, x, y, z, ligand, eventMap) self.prepare_for_download(xtal, pdb, event, compoundCIF, ligand) self.prepare_zip_archives() # html = XChemMain.html_download_all_section(html,self.protein_name) self.write_html_file(html) self.Logfile.insert( '======== finished preparing HTML summary ========')