#! /usr/bin/env ccp4-python # # Copyright (C) 2005 Ronan Keegan # # This code is distributed under the terms and conditions of the # CCP4 Program Suite Licence Agreement as a CCP4 Application. # A copy of the CCP4 licence can be obtained by writing to the # CCP4 Secretary, Daresbury Laboratory, Warrington WA4 4AD, UK. # # # Output the job details to an XML file # Ronan Keegan 5/3/07 import os, sys, string import time, shutil import os import string import sys import MRBUMP_target_info class writeXML: def __init__(self): self.outXML_file="" try: self.debug=eval(os.environ['MRBUMP_DEBUG']) except: self.debug=False self.local_debug = False def write_details(self, init, mstat, target_info, filename): """ Write target details to an XML file. """ sys.stdout.write("Outputting job details to an XML file\n") sys.stdout.write("XML file name:\n %s\n" % filename) sys.stdout.write("\n") self.outXML_file=filename outfile=open(self.outXML_file, "w") outfile.write('\n') outfile.write('\n') outfile.write('\n' % target_info.chainID) outfile.write(' \n' % time.ctime()) outfile.write(' \n') outfile.write(' %d \n' % init.keywords.MRNUM) outfile.write(' %d \n' % init.keywords.ENSMODNUM) if init.keywords.NMASU == None: outfile.write(' %d \n' % int(init.keywords.PACK)) else: outfile.write(' %d \n' % (int(init.keywords.PACK)*int(init.keywords.NMASU))) outfile.write(' %d \n' % init.keywords.NCYC) outfile.write(' %s \n' % `init.keywords.NMASU`) outfile.write(' %.3f \n' % init.keywords.E_value) outfile.write(' \n') outfile.write(' \n') outfile.write(' %s\n' % target_info.chainID) outfile.write(' C. jejuni\n') outfile.write(' dUTPase\n') outfile.write(' %s\n' % target_info.sequence) outfile.write(' %d\n' % target_info.no_of_res) outfile.write(' %.3f\n' % target_info.mol_weight) outfile.write(' %d\n' % target_info.no_of_mols) outfile.write(' \n' % target_info.hklin) outfile.write(' \n') outfile.write(' %s\n' % target_info.mtz_coldata["F"]) outfile.write(' %s\n' % target_info.mtz_coldata["SIGF"]) outfile.write(' %s\n' % target_info.mtz_coldata["FREE"]) outfile.write(' \n') outfile.write(' XXXXX\n') outfile.write(' %.4f\n' % target_info.resolution) outfile.write(' \n') outfile.write(' \n') outfile.write(' %.3f\n' % target_info.cell_dimensions["a"]) outfile.write(' %.3f\n' % target_info.cell_dimensions["b"]) outfile.write(' %.3f\n' % target_info.cell_dimensions["c"]) outfile.write(' %.3f\n' % target_info.cell_dimensions["alpha"]) outfile.write(' %.3f\n' % target_info.cell_dimensions["beta"]) outfile.write(' %.3f\n' % target_info.cell_dimensions["gamma"]) outfile.write(' \n') outfile.write(' \n') outfile.write(' %s\n' % target_info.space_group) outfile.write(' P 2ac 2ab?????\n') outfile.write(' ?????\n') outfile.write(' ?????\n') outfile.write(" %s\n" % target_info.enant_SG_code) outfile.write(" %s\n" % target_info.symmetry_no) outfile.write(' \n') outfile.write(' \n') outfile.write(' \n') outfile.write('\n') # Output the template details count=0 for chain in mstat.sorted_list: chain_ID=chain[0] outfile.write(' \n') outfile.write('\n') count=count+1 # Multiple Alignment Details outfile.write('\n') outfile.write(' \n') outfile.write(' %s\n' % init.keywords.MAPROGRAM) outfile.write(' %d\n' % mstat.no_of_hits) outfile.write(' \n') outfile.write('\n') # Output the search model details outfile.write('\n') outfile.write('\n') outfile.write('\n') outfile.write('\n') outfile.write('\n') for model in mstat.sorted_model_list: outfile.write(' \n' % mstat.model_list[model].MR_jobID) outfile.write(' \n') outfile.write(' %s\n' % mstat.model_list[model].chain_source) outfile.write(' \n') outfile.write(' \n') outfile.write(' %s\n' % mstat.model_list[model].type) outfile.write(' ??????\n') outfile.write(' \n') outfile.write('\n') # Output the MR and refinement details outfile.write('\n') outfile.write('\n') outfile.write('\n') outfile.write('\n') outfile.write('\n') for model in mstat.sorted_model_list: outfile.write(' \n' % mstat.model_list[model].MR_jobID) outfile.write('\n') outfile.write(' \n') outfile.write(' ??????\n') outfile.write(' \n') outfile.write('\n') # Output the molrep and refmac results if molrep was used for this model if "MOLREP" in init.keywords.MR_PROGRAM_LIST and mstat.model_list[model].molrep_smartie_log != None: # Set the molrep smartie log molrep_log=mstat.model_list[model].molrep_smartie_log outfile.write(' \n') outfile.write(' \n' \ % (molrep_log.program(0).name, \ molrep_log.program(0).ccp4version, \ molrep_log.program(0).date)) outfile.write(' \n' % mstat.model_list[model].PDBfile[0]) outfile.write(' \n' % target_info.hklin) outfile.write(' \n') outfile.write(' %s \n' % mstat.model_list[model].molrep_keywords["DOC"]) outfile.write(' %s \n' % mstat.model_list[model].molrep_keywords["LABIN"]) outfile.write(' %s \n' % mstat.model_list[model].molrep_keywords["SIM"]) outfile.write(' %s \n' % mstat.model_list[model].molrep_keywords["NMON"]) outfile.write(' %s \n' % mstat.model_list[model].molrep_keywords["FILE_T"]) outfile.write(' \n') outfile.write(' ??????\n') outfile.write(' \n') outfile.write(' 2\n') outfile.write(' 2.14356 \n') outfile.write(' \n' % mstat.model_list[model].molrep_PDBfile) outfile.write(' \n') outfile.write(' \n') outfile.write(' 0\n') outfile.write(' %s \n' \ % molrep_log.program(0).termination_message) outfile.write(' information\n') outfile.write(' \n') outfile.write(' \n') outfile.write('\n') if mstat.model_list[model].refmac_molrep_smartie_log != None: # Set the refmac smartie log and pick out the final table with Rfree/Rfactor refmac_log=mstat.model_list[model].refmac_molrep_smartie_log table=refmac_log.findtable("Rfactor analysis, stats vs cycle") outfile.write(' \n') outfile.write(' \n' \ % (refmac_log.program(0).name, \ refmac_log.program(0).ccp4version, \ refmac_log.program(0).date)) outfile.write(' \n' % mstat.model_list[model].molrep_PDBfile) outfile.write(' \n' % mstat.model_list[model].refmac_molrep_MTZINfile) outfile.write(' \n') outfile.write(' %s \n' % mstat.model_list[model].refmac_molrep_keywords["LABIN"]) outfile.write(' %s \n' % mstat.model_list[model].refmac_molrep_keywords["NCYC"]) outfile.write(' %s \n' % mstat.model_list[model].refmac_molrep_keywords["MAKE"]) outfile.write(' %s \n' % mstat.model_list[model].refmac_molrep_keywords["WEIGHT"]) outfile.write(' \n') outfile.write(' %.3f \n' % float(table.col("Rfact")[0])) outfile.write(' %.3f \n' % float(table.col("Rfact")[-1])) outfile.write(' %.3f \n' % float(table.col("Rfree")[0])) outfile.write(' %.3f \n' % float(table.col("Rfree")[-1])) outfile.write(' \n' % mstat.model_list[model].refmac_molrep_PDBfile) outfile.write(' \n' % mstat.model_list[model].refmac_molrep_MTZOUTfile) outfile.write(' \n') outfile.write(' 0\n') outfile.write(' %s \n' \ % refmac_log.program(0).termination_message) outfile.write(' information\n') outfile.write(' \n') outfile.write(' \n') outfile.write('\n') # Output the phaser and refmac results if phaser was used for this model if "PHASER" in init.keywords.MR_PROGRAM_LIST and mstat.model_list[model].phaser_smartie_log != None: # Set the phaser smartie log and pick out the final rotation and translation tables phaser_log=mstat.model_list[model].phaser_smartie_log tableRot = phaser_log.findtable("Rotation Function Summary", -1) tableTran = phaser_log.findtable("Final Translation Function Summary for model %s" % model, -1) if self.local_debug: sys.stdout.write("Final Translation Function Summary for model %s\n\n\n" % model) sys.stdout.write("Number of tables in phaser log file: %d\n" % phaser_log.ntables()) sys.stdout.write("\n") n=phaser_log.ntables() sys.stdout.write("Titles of tables:\n") for i in range(n): sys.stdout.write("============================================================\n") sys.stdout.write("%d. %s\n" % (i, phaser_log.table(i).title())) sys.stdout.write("============================================================\n") sys.stdout.write("\n") sys.stdout.write(phaser_log.table(i).loggraph()) sys.stdout.write("\n") outfile.write(' \n') outfile.write(' \n' \ % (phaser_log.program(0).name, \ phaser_log.program(0).ccp4version, \ phaser_log.program(0).date)) outfile.write(' \n' % mstat.model_list[model].PDBfile[0]) outfile.write(' \n' % target_info.hklin) outfile.write(' \n') outfile.write(' %s \n' % mstat.model_list[model].phaser_keywords["MODE"]) outfile.write(' %s \n' % mstat.model_list[model].phaser_keywords["HKLIN"]) outfile.write(' %s \n' % mstat.model_list[model].phaser_keywords["LABIN"]) outfile.write(' %s \n' % mstat.model_list[model].phaser_keywords["COMPosition"]) outfile.write(' %s \n' % mstat.model_list[model].phaser_keywords["ENSEmble"]) outfile.write(' %s \n' % mstat.model_list[model].phaser_keywords["SEARCH"]) outfile.write(' %s \n' % mstat.model_list[model].phaser_keywords["XYZOUT"]) outfile.write(' %s \n' \ % (int(mstat.model_list[model].phaser_keywords["PACK"])*int(init.keywords.NMASU))) outfile.write(' %s \n' % mstat.model_list[model].phaser_keywords["ROOT"]) if init.keywords.ENANT: outfile.write(' %s \n' % mstat.model_list[model].phaser_keywords["SGALTERNATIVE"]) outfile.write(' \n') outfile.write(' 1\n') outfile.write(' \n') outfile.write(' 2\n') outfile.write(' %s\n' % mstat.model_list[model].phaser_PDBfile) outfile.write(' %s\n' % mstat.model_list[model].phaser_MTZfile) if tableTran != None: outfile.write(' %s \n' % tableTran.col("LL-gain")[0]) outfile.write(' %s \n' % tableTran.col("Z-Score")[0]) else: outfile.write(' %.3f \n' % 0.000) outfile.write(' %.3f \n' % 0.000) if tableRot != None: outfile.write(' %s \n' % tableRot.col("Z-Score")[0]) else: outfile.write(' %.3f \n' % 0.000) outfile.write(' \n') outfile.write(' \n') outfile.write(' 0\n') outfile.write(' %s \n' \ % phaser_log.program(0).termination_message) outfile.write(' information\n') outfile.write(' \n') outfile.write(' \n') outfile.write('\n') if mstat.model_list[model].refmac_phaser_smartie_log != None: # Set the refmac smartie log and pick out the final table with Rfree/Rfactor refmac_log=mstat.model_list[model].refmac_phaser_smartie_log table=refmac_log.findtable("Rfactor analysis, stats vs cycle") outfile.write(' \n') outfile.write(' \n' \ % (refmac_log.program(0).name, \ refmac_log.program(0).ccp4version, \ refmac_log.program(0).date)) outfile.write(' \n' % mstat.model_list[model].phaser_PDBfile) outfile.write(' \n' % mstat.model_list[model].refmac_phaser_MTZINfile) outfile.write(' \n') outfile.write(' %s \n' % mstat.model_list[model].refmac_phaser_keywords["LABIN"]) outfile.write(' %s \n' % mstat.model_list[model].refmac_phaser_keywords["NCYC"]) outfile.write(' %s \n' % mstat.model_list[model].refmac_phaser_keywords["MAKE"]) outfile.write(' %s \n' % mstat.model_list[model].refmac_phaser_keywords["WEIGHT"]) outfile.write(' \n') outfile.write(' %.3f \n' % float(table.col("Rfact")[0])) outfile.write(' %.3f \n' % float(table.col("Rfact")[-1])) outfile.write(' %.3f \n' % float(table.col("Rfree")[0])) outfile.write(' %.3f \n' % float(table.col("Rfree")[-1])) outfile.write(' \n' % mstat.model_list[model].refmac_phaser_PDBfile) outfile.write(' \n' % mstat.model_list[model].refmac_phaser_MTZOUTfile) outfile.write(' \n') outfile.write(' 0\n') outfile.write(' %s \n' \ % refmac_log.program(0).termination_message) outfile.write(' information\n') outfile.write(' \n') outfile.write(' \n') outfile.write('\n') outfile.write(' %s \n' % mstat.model_list[model].solution_type_MOLREP) outfile.write(' %s \n' % mstat.model_list[model].solution_type_PHASER) outfile.write('\n') outfile.write(' \n') outfile.write('\n') outfile.write('\n') outfile.write(' \n') outfile.write(' 0\n') outfile.write(' Normal Termination\n') outfile.write(' information\n') outfile.write(' \n') outfile.write('\n') outfile.write('\n') outfile.close() if __name__ == "__main__": target_info=MRBUMP_target_info.TargetInfo() target_info.seqfile="/tmp/seq.pir" target_info.sequence="ABCDEFGHIJKLMNOP" xml=writeXML() xml.target_details(target_info, "test.xml")