#! /usr/bin/env python # -*- coding: utf-8 -*- import xml.etree.ElementTree as ET import os, sys, json, subprocess import SELSLIB2 def __insert_plotly(): html = """ """ return html def __insert_css(): html = """ """ return html def __insert_sortable(): html = """ """ return html def __verification_graph(root): html = """

Verification

""" if root.find('VERIFICATION/message') is not None: html += """

"""+root.find('VERIFICATION/message').text+"""

\n
""" if root.find('VERIFICATION') is not None: cc = json.loads(root.find('VERIFICATION/CC').text) wMPD = json.loads(root.find('VERIFICATION/wMPE').text) incorrect = json.loads(root.find('VERIFICATION/incorrect').text) html += """
""" else: html += "

⚠ Information is not yet available

" html += """
""" return html def __insert_table_borges(root): html = """ """ else: html += "

⚠ Information is not yet available

" return html def __insert_table_lite(root): fran = 1 aden_show = "" aden_hide = "" html = "" html += """ " return html def __insert_aside_lite(coiled_coil): html = """ """ return html def __insert_aside_borges(): html = """ """ return html def __insert_aside_shredder(): html = """ """ return html def __insert_header(): html = """ Arcimboldo""" html += __insert_plotly() html += __insert_css() html += __insert_sortable() html += """""" return html def __insert_summary(root, nameOutput, coiled_coil=False): html = """

Summary

NAME: """+nameOutput+"""
SPACEGROUP: """ + root.find('data/spacegroup').text + """
CELL DIMENSIONS: """ + root.find('data/cell_dim/A').text + ", " + root.find('data/cell_dim/B').text + ", " + root.find( 'data/cell_dim/C').text + ", " + root.find('data/cell_dim/alpha').text + ", " + root.find( 'data/cell_dim/beta').text + ", " + root.find('data/cell_dim/gamma').text + """
RESOLUTION: """ + root.find('data/resolution').text + """
NUMBER OF UNIQUE REFLECTIONS: """ + root.find('data/unique_refl').text + """
""" if root.find('VERIFICATION/message') is not None: html += """

"""+root.find('VERIFICATION/message').text+"""

\n""" if root.find('LINKS') is not None: numblinks = int(root.find('LINKS/number').text) # print "===============NUBER OF LINKS=============",numblinks for qds in range(numblinks): # print root.find('LINKS/N'+str(qds)) if root.find('LINKS/N' + str(qds)) is not None: text_link = root.find('LINKS/N' + str(qds) + '/text').text text_link = text_link.strip('Click here') text_link = text_link.strip(':') url_link = root.find('LINKS/N' + str(qds) + '/url').text #html += """

"""+text_link+"""

""" html += """

Click here """+text_link if root.find('backtracing/EXP/finalcc') is not None: if float(root.find('backtracing/EXP/finalcc').text) >= 30: if not coiled_coil: html += """

It seems you have a good solution!
Here you can find the best solution and map for further refinement.

\n""" else: html += """

Here you can find the best solution and map for further refinement.

\n""" SELSLIB2.SOLVED = True html += """
""" return html def __backtracking_lite(root): html = """

Backtracking

""" if root.find('backtracing') is not None: html += "

The current best solution is: " + str( root.find('backtracing/model').text) + " with FINALCC: " + str( root.find('backtracing/finalcc').text) + " and n. residues traced " + str( root.find('backtracing/restraced').text) + "
file is: " + str( root.find('backtracing/file').text) + "

\n" # FRF if root.find('backtracing/FRF') is not None: html += """

\n""" if root.find('backtracing/EXP') is not None: if float(root.find('backtracing/EXP/finalcc').text) >= 30: if root.find('VERIFICATION/solved') is None or bool(root.find('VERIFICATION/solved').text): if float(root.find('data/resolution').text) < 2.1: html += """

It seems you have a good solution!
Here you can find the best solution and map for further refinement.

\n""" else: html += """

Here you can find the best solution and map for further refinement.

\n""" SELSLIB2.SOLVED = True else: html += "

⚠ Information is not yet available

" html += """
""" return html def __rotation_clustering(root): aden_show = "" aden_hide = "" html = """

Rotation clustering

""" if root.find('rot_clustering') is not None: full = json.loads(root.find('rot_clustering/full').text) reduced = json.loads(root.find('rot_clustering/reduced').text) full_graph = json.loads(root.find('rot_clustering/graphfull').text) reduced_graph = json.loads(root.find('rot_clustering/graphreduced').text) aden_show = "" aden_hide = "" for ldr in full: nclu, way = ldr aden_show += """ document.getElementById('FRF-""" + str(nclu) + """').style.display=""" + way + """;\n """ for ldr in reduced: nclu, way = ldr aden_hide += """ document.getElementById('FRF-""" + str(nclu) + """').style.display=""" + way + """;\n """ aden_show += """ document.getElementById('clusters_full').style.display = "";\n """ aden_show += """ document.getElementById('clusters_reduced').style.display = "none";\n """ aden_hide += """ document.getElementById('clusters_full').style.display = "none";\n """ aden_hide += """ document.getElementById('clusters_reduced').style.display = "";\n """ x_full = [i[0] for i in full_graph] bar_full = [i[1] for i in full_graph] line1_full = [i[3] for i in full_graph] line2_full = [i[2] for i in full_graph] x_reduced = [i[0] for i in reduced_graph] bar_reduced = [i[1] for i in reduced_graph] line1_reduced = [i[3] for i in reduced_graph] line2_reduced = [i[2] for i in reduced_graph] html += """
""" brins = 0 green = json.loads(root.find('rot_clustering/green').text) while 1: berd = root.find('rot_clustering/FRF-' + str(brins)) if berd == None: break html += """ """ if brins in green: html += """\n""" else: html += """\n""" html += """ """ brins += 1 html += """
#Cluster #Rotations #Distinct Pdb Top LLG LLG Mean Top Zscore Zscore Mean
\n \n
""" else: html += "

⚠ Information is not yet available

" return html def __backtracking_borges(root): html = """

Backtracking

""" html += "" if root.find('backtracing') is not None: html += "

The current best solution is: " + str( root.find('backtracing/model').text) + " with FINALCC: " + str( root.find('backtracing/finalcc').text) + " and n. residues traced " + str( root.find('backtracing/restraced').text) + "
file is: " + str( root.find('backtracing/file').text) + "

\n" # FRF if root.find('backtracing/FRF') is not None: html += """

\n""" if root.find('backtracing/EXP') is not None: if float(root.find('backtracing/EXP/finalcc').text) >= 30: html += """

It seems you have a good solution!
Here you can find the best solution and map for further refinement.

\n""" SELSLIB2.SOLVED = True else: html += "

⚠ Information is not yet available

" html += "
" return html def __insert_setup_log(root): setup_name = root.find('configuration/bor_name').text setup_path = root.find('configuration/bor_text').text working_dir = os.path.dirname(setup_name) html = """

Instruction file

""" if os.path.isfile(setup_name): html +="""

Input file at """+setup_name+""". Click here to download it

""" html += """
"""+setup_path+"""
""" log_path = setup_name.replace(os.path.basename(setup_name), "log.out") if not os.path.isfile(log_path): log_path = os.path.dirname(setup_name) + ".log" html += """

Log file

""" log_content = "" if os.path.isfile(log_path): html += """

Log file at """+log_path+""". Click here to download it

""" with open(log_path, 'r') as infile: log_content = [line for line in infile][:100] f = subprocess.Popen(['tail','-100',log_path],\ stdout=subprocess.PIPE,stderr=subprocess.PIPE) log_content += f.stdout.readlines() log_content = ''.join(map(str, log_content)).decode('ascii', 'ignore').replace("<","<") else: log_content = "Log file has not been found." timestamp = "" listatime = root.find('TIME') if listatime is not None: timestamp += "Timestamp information\n" timestamp += "\n" listatime = json.loads(listatime.text) for tim in listatime: mode, step, ti = tim timestamp += """Time MODE: """ + str(mode) + """ STEP: """ + str(step) + """ """ + str(ti) + """\n""" timestamp += """\n""" timestamp = ''.join(map(str, timestamp)) else: timestamp += "Timestamp information has not been found." html +="""
"""+log_content+timestamp+"""
""" return html def __insert_citation_lite(): html = """

Citations

Phaser crystallographic software.
McCoy, A. J., Grosse-Kunstleve, R. W., Adams, P. D., Winn, M. D., Storoni, L. C. & Read, R. J.
(2007) J Appl Cryst. 40, 658-674.

An introduction to experimental phasing of macromolecules illustrated by SHELX; new autotracing features.
Uson, I. & Sheldrick, G. M.
(2018) Acta Cryst. D74, 106-116.

ARCIMBOLDO-LITE: single-workstation implementation and use.
Sammito, M., Millan, C.,Frieske, D., Rodriguez-Freire, E., Borges, R. J., & Uson, I.
(2015) Acta Cryst. D71, 1921-1939.

""" return html def __insert_citation_coil(): html = """

Citations

Phaser crystallographic software.
McCoy, A. J., Grosse-Kunstleve, R. W., Adams, P. D., Winn, M. D., Storoni, L. C. & Read, R. J.
(2007) J Appl Cryst. 40, 658-674.

An introduction to experimental phasing of macromolecules illustrated by SHELX; new autotracing features.
Uson, I. & Sheldrick, G. M.
(2018) Acta Cryst. D74, 106-116.

ARCIMBOLDO on coiled coils.
Caballero, I., Sammito, M., Millan, C., Lebedev, A., Soler, N., & Uson, I.
(2018) Acta Cryst. D74, 194-204.

""" return html def __insert_citation_borges(): html = """

Citations

Phaser crystallographic software.
McCoy, A. J., Grosse-Kunstleve, R. W., Adams, P. D., Winn, M. D., Storoni, L. C. & Read, R. J.
(2007) J Appl Cryst. 40, 658-674.

An introduction to experimental phasing of macromolecules illustrated by SHELX; new autotracing features.
Uson, I. & Sheldrick, G. M.
(2018) Acta Cryst. D74, 106-116.

Exploiting tertiary structure through local folds for ab initio phasing.
Sammito, M., Millan, C., Rodriguez, D. D., M. de Ilarduya, I., Meindl, K., De Marino, I., Petrillo, G., Buey, R. M., de Pereda, J. M., Zeth, K., Sheldrick, G. M. & Uson, I.
(2013) Nat Methods. 10, 1099-1101.

""" return html def __insert_citation_shredder(): html = """

Citations

Phaser crystallographic software.
McCoy, A. J., Grosse-Kunstleve, R. W., Adams, P. D., Winn, M. D., Storoni, L. C. & Read, R. J.
(2007) J Appl Cryst. 40, 658-674.

An introduction to experimental phasing of macromolecules illustrated by SHELX; new autotracing features.
Uson, I. & Sheldrick, G. M.
(2018) Acta Cryst. D74, 106-116.

Exploiting distant homologues for phasing through the generation of compact fragments, local fold refinement and partial solution combination.
Millan, C., Sammito, M., McCoy, A. J., Nascimento, A.F.Z., Petrillo, G., Oeffner, R., Dominguez-Gil, Teresa., Hermoso, A., Read, R. J. & Uson I.

Structure solution with ARCIMBOLDO using fragments derived from distant homology models.
Sammito, M., Meindl, K., M. de Ilarduya, I., Millan, C., Artola-Recolons, C., Hermoso, J. A. & Uson, I.
(2014) FEBS Journal 281, 4029-4045.

""" return html def __insert_support(): html = """

Support

For online documentation and tutorials visit www.chango.ibmb.csic.es
For developer support send an email to bugs-borges@ibmb.csic.es
Crystallographic Methods Group
Structural Biology Unit
Molecular Biology Institute of Barcelona

""" return html def generateHTML(lock, current_directory, nameOutput, coiled_coil=False): #def generateHTML(current_directory, nameOutput, coiled_coil=False): htmlfile = os.path.join(current_directory, nameOutput + ".html") html = "" if os.path.exists(htmlfile): os.remove(htmlfile) print "Generation HTML....." lock.acquire() xmlfile = os.path.join(current_directory, nameOutput + ".xml") htmlfile = os.path.join(current_directory, nameOutput + ".html") if not os.path.exists(xmlfile): lock.release() return tree = ET.parse(xmlfile) root = tree.getroot() coiled_coil = coiled_coil or root.find('VERIFICATION') is not None html += __insert_header() html += """""" html += __insert_aside_lite(coiled_coil) html += """
""" html += """

ARCIMBOLDO-LITE: Fragment search with PHASER and density modification and map interpretation with SHELXE

""" html += __insert_summary(root, nameOutput, coiled_coil) html += __insert_table_lite(root) html += __backtracking_lite(root) if coiled_coil is not False: html += __verification_graph(root) html += __insert_setup_log(root) if coiled_coil is not False: html += __insert_citation_coil() else: html += __insert_citation_lite() elif root.tag == "borges-arcimboldo": html += """

ARCIMBOLDO-BORGES

\n""" html += """""" html += __insert_aside_borges() html += """
""" html += """

ARCIMBOLDO-BORGES: Library search with PHASER and density modification and map interpretation with SHELXE

""" html += __insert_summary(root, nameOutput, coiled_coil) html += __rotation_clustering(root) html += __insert_table_borges(root) html += __backtracking_borges(root) html += __insert_setup_log(root) html += __insert_citation_borges() else: html += """

ARCIMBOLDO-SHREDDER

\n""" html += """""" html += __insert_aside_shredder() html += """
""" html += __insert_summary(root, nameOutput, coiled_coil) html += __insert_setup_log(root) html += __insert_citation_shredder() html += __insert_support() html +="""
""" f = open(htmlfile, "w") f.write(html) f.close() lock.release() print "release the lock HTML!!!" #if __name__ == "__main__": # generateHTML("/cri4/pep/Documents/output_test","shredder")