From 0f4f286b8c66e91bd338871a6107e8bc9ef0a1c6 Mon Sep 17 00:00:00 2001 From: Rami Rauch Date: Thu, 23 Apr 2009 22:44:13 +0000 Subject: [PATCH] added parse LibInfo by FlowcellId and count reads. This allows us to report data status on the Flowcell/DatRun level, besides the Library level. --- .../htswfrontend/htsw_reports/libinfopar.py | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/htswfrontend/htswfrontend/htsw_reports/libinfopar.py b/htswfrontend/htswfrontend/htsw_reports/libinfopar.py index 672af84..6d46880 100644 --- a/htswfrontend/htswfrontend/htsw_reports/libinfopar.py +++ b/htswfrontend/htswfrontend/htsw_reports/libinfopar.py @@ -18,7 +18,6 @@ Example library node from LibraryInfo.xml: ''' class LibInfoHandler(ContentHandler): - def __init__ (self, searchTerm): self.searchTerm= searchTerm self.currlibid = '' @@ -32,8 +31,6 @@ class LibInfoHandler(ContentHandler): elif name == 'Track' and self.searchTerm == self.currlibid: self.LanesCount += len(attrs.get('Lane',"")) self.ReadsCount += int(attrs.get('Count',"")) - #else: - # self.Msg += ' | name = '+name+', currlibid = '+ self.currlibid except: self.Msg = 'failed parsing xml file' return @@ -44,14 +41,35 @@ class LibInfoHandler(ContentHandler): #def endElement(self, name): # return .. +class LibInfoHandlerByFlowCell(ContentHandler): + def __init__ (self, searchTerm): + self.searchTerm = searchTerm + self.LanesCount, self.ReadsCount = 0, 0 + self.Msg = 'OK' + + def startElement(self, name, attrs): + try: + if name == 'Track' and attrs.get('Flowcell',"") == self.searchTerm: + self.LanesCount += len(attrs.get('Lane',"")) + self.ReadsCount += int(attrs.get('Count',"")) + except: + self.Msg = 'failed parsing xml file' + return + ## TO DO: Change this to read the LibraryInfo.xml only ONCE per ReoprtRequest (do it in the models.py). + Read it directly from the analysis_server -def getLibReads(libid): - searchTerm= libid - parser = make_parser() - curHandler = LibInfoHandler(searchTerm) +def getLibReads(search_term,search_by): + searchTerm= search_term + parser = make_parser() + + if search_by == 'ByLib': + curHandler = LibInfoHandler(searchTerm) + elif search_by == 'ByFC': + curHandler = LibInfoHandlerByFlowCell(searchTerm) + parser.setContentHandler(curHandler) + folder_loc = '/htsworkflow/htswfrontend/htswfrontend' # DEV #folder_loc = '/Library/WebServer/gaworkflow/gaworkflow/frontend' # PROD parser.parse(open(folder_loc+'/htsw_reports/LibInfo/LibraryInfo.xml')) -- 2.30.2