from CCP4ReportParser import *
import sys
from lxml import etree
from refmac_report import refmac_report
from csymmatch_report import csymmatch_report

class phaser_pipeline_report(Report):
    # Specify which gui task and/or pluginscript this applies to
    TASKNAME = 'phaser_pipeline'
    RUNNING = True
    SEPARATEDATA=True
    
    def __init__(self,jobStatus=None,**kw):
        Report.__init__(self, jobStatus=jobStatus, **kw)
        from phaser_MR_AUTO_report import phaser_MR_AUTO_report

        if jobStatus == None or jobStatus.lower() =='nooutput': return
        self.addDiv(style='clear:both;')

        pmaNode = self.xmlnode.xpath0('PhaserMrResults')
        if pmaNode is None: return
        
        phaser_MRAReport = phaser_MR_AUTO_report(xmlnode=pmaNode, jobStatus='nooutput')
        
        phaser_MRAReport.drawContent(jobStatus=jobStatus, parent=self)

        csymmatchNode = self.xmlnode.xpath0('Csymmatch')
        if csymmatchNode is not None:
            csymmatchReport = csymmatch_report(xmlnode=csymmatchNode, jobStatus='nooutput')
            csymmatchFold = self.addFold(label='Output from CSYMMATCH',initiallyOpen=False,brief='Symmatch')
            csymmatchReport.drawContent(jobStatus=jobStatus, parent=csymmatchFold)
        
        refmacNode = self.xmlnode.xpath0('REFMAC')
        if refmacNode is None: return

        rM_report = refmac_report(xmlnode=refmacNode, jobStatus='nooutput')

        rM_report.addSummary(parent=self)


