from CCP4ReportParser import *
import sys
from lxml import etree
import math
from refmac_report import refmac_report
class PrepareDeposit_report(Report):
    # Specify which gui task and/or pluginscript this applies to
    TASKNAME = 'PrepareDeposit'
    RUNNING = True

    def __init__(self, *args, **kws):
        '''
        kws['additionalJsFiles'] = ['jsme/jsme.nocache.js']
        kws['additionalScript'] = 'function jsmeOnLoad() { jsmeApplet = new JSApplet.JSME("jsme_container", "380px", "340px");'
        '''
        Report.__init__(self, *args, **kws)
        if self.jobStatus is None or self.jobStatus.lower() is 'nooutput': return
        self.addDiv(style='clear:both;')
        self.defaultReport()

    def defaultReport(self, parent=None):
        if parent is None: parent=self
        alignChainNodes = self.xmlnode.xpath('//AlignChain')
        for alignChainNode in alignChainNodes:
            chainIdNode = alignChainNode.xpath('ChainId')[0]
            alignChainFold = parent.addFold(label="Alignments for chain "+chainIdNode.text)
            alignChainFold.addPre(text = alignChainNode.xpath('Clustalw/Alignment')[0].text)
        if self.xmlnode.xpath0('REFMAC') is not None:
            rmReport = refmac_report(xmlnode=self.xmlnode.xpath0('REFMAC'),jobStatus='nooutput')
            rmReport.addSummary(parent=self)

