@@ -33,18 +33,24 @@ def get_menu(config, ns):
3333 menu .append ('<h1>Alignment QC:</h1>' )
3434 if enabled .has_key ("picard" ):
3535 menu .append ('<h2><a #highlight="" href="./picard.html">- Picard</a></h2>' )
36+ if enabled .has_key ("picard_IS" ):
37+ menu .append ('<h2><a #highlight="" href="./picard-is.html">- Picard Insert Size</a></h2>' )
3638 if enabled .has_key ("star" ):
3739 menu .append ('<h2><a #highlight="" href="./star.html">- STAR</a></h2>' )
40+ if enabled .has_key ("kallisto" ):
41+ menu .append ('<h2><a #highlight="" href="./kallisto.html">- KALLISTO</a></h2>' )
3842 if enabled .has_key ("htseq-gene" ):
3943 menu .append ('<h2><a #highlight="" href="./htseq-gene.html">- HTseq-Gene</a></h2>' )
4044 if enabled .has_key ("htseq-exon" ):
4145 menu .append ('<h2><a #highlight="" href="./htseq-exon.html">- HTseq-Exon</a></h2>' )
4246 if ns > 1 :
43- if enabled .has_key ("star" ) or enabled .has_key ("htseq-gene" ) or enabled .has_key ("htseq-exon" ):
47+ if enabled .has_key ("star" ) or enabled .has_key ("htseq-gene" ) or enabled .has_key ("htseq-exon" ) or enabled . has_key ( "kallisto" ) :
4448 menu .append ('<h1>Count statistics:</h1>' )
4549 menu .append ('<h2><a #highlight="" href="./downloads.html">- DOWNLOADS</a></h2>' )
4650 if enabled .has_key ("star" ):
4751 menu .append ('<h2><a #highlight="" href="./star2.html">- STAR</a></h2>' )
52+ if enabled .has_key ("kallisto" ):
53+ menu .append ('<h2><a #highlight="" href="./kallisto2.html">- KALLISTO</a></h2>' )
4854 if enabled .has_key ("htseq-gene" ):
4955 menu .append ('<h2><a href="./htseq-gene2.html">- HTseq-Gene</a></h2>' )
5056 if enabled .has_key ("htseq-exon" ):
@@ -62,8 +68,8 @@ def get_menu(config, ns):
6268 return menu
6369
6470def print_samples (path ,config ):
65- analysis = ['trimgalore' , 'fastqc' , 'kallisto' , 'star' , 'star-fusion' , 'picard' , "htseq-gene" , "htseq-exon" , "varscan" , 'gatk' ]
66- sta = {"trimgalore" :"TrimGalore" , "fastqc" :"FastQC" ,"star" :"STAR" ,"star-fusion" :"STAR-Fusion" ,"picard" :"PicardQC" ,"kallisto" :"Kallisto" ,"htseq-gene" :"HTseq-gene" ,"htseq-exon" :"HTseq-exon" , "varscan" :"VARSCAN" , "gatk" :"GATK" }
71+ analysis = ['trimgalore' , 'fastqc' , 'kallisto' , 'star' , 'star-fusion' , 'picard' , "htseq-gene" , "htseq-exon" , "picard_IS" , " varscan" , 'gatk' ]
72+ sta = {"trimgalore" :"TrimGalore" , "fastqc" :"FastQC" ,"star" :"STAR" ,"star-fusion" :"STAR-Fusion" ,"picard" :"PicardQC" ,"kallisto" :"Kallisto" ,"htseq-gene" :"HTseq-gene" ,"htseq-exon" :"HTseq-exon" , "picard_IS" : "Picard-InsertSize" , " varscan" :"VARSCAN" , "gatk" :"GATK" }
6773 # SAMPLES LIST
6874 samples = dict ()
6975 f = open (path + "/samples.list" ,'r' )
@@ -148,6 +154,16 @@ def print_samples(path,config):
148154 else :
149155 res .append ("FAIL" )
150156 results ["star-fusion" ][x ] = " / " .join (res )
157+ elif i == "picard_IS" :
158+ for x , y in sorted (samples .iteritems ()):
159+ res = []
160+ if sok .has_key (x ):
161+ link = "../results_picard_IS/" + x + ".txt"
162+ link = '<a href="LINK" target="_blank">OK</a>' .replace ("LINK" , link )
163+ res .append (link )
164+ else :
165+ res .append ("FAIL" )
166+ results ["picard_IS" ][x ] = " / " .join (res )
151167 elif i == "picard" :
152168 for x , y in sorted (samples .iteritems ()):
153169 res = []
@@ -330,6 +346,7 @@ def stats_picard(path,samples,config):
330346 if i + n [k ] in files :
331347 f = open (path + "/results_picard" + "/" + i + n [k ],'r' )
332348 nx = 0
349+ kdiff0 = 0
333350 for ii in f :
334351 if ii .startswith ("PF_BASES" ):
335352 head = ii .rstrip ().split ("\t " )
@@ -341,17 +358,26 @@ def stats_picard(path,samples,config):
341358 vals = ii .strip ("\n " ).split ("\t " )
342359 for kk in range (len (head )):
343360 stats [k ][head [kk ]] = vals [kk ]
361+ if vals [kk ] != "" :
362+ if float (vals [kk ]) > 0 :
363+ kdiff0 += 1
344364 nx = 0
365+ if kdiff0 == 0 :
366+ ex = 1
367+ break
345368 f .close ()
346369 else :
347370 ex = 1
371+ break
348372 if ex == 1 :
349373 tr = "<td bgcolor='#CC3300'>" + i + "</td>"
350374 o = i
351375 for ii in range (18 ):
352376 tr += "<td bgcolor='#CC3300'>NA</td>"
353377 o += "\t NA"
354378 tr = "<tr>" + tr + "</tr>"
379+ table .append (tr )
380+ s = ["NA" for ii in range (10 )]
355381 else :
356382 align = int (stats [0 ]["PF_ALIGNED_BASES" ])
357383 cod = int (stats [0 ]["CODING_BASES" ])
@@ -389,27 +415,56 @@ def stats_picard(path,samples,config):
389415 tr += "<td bgcolor='#99CC66'>0</td>"
390416 o += "\t 0"
391417 tr = "<tr>" + tr + "</tr>"
392- table .append (tr )
393- o = o .split ("\t " )
394- st = 0
395- s = []
396- for ind in [10 , 11 , 12 , 5 , 7 , 3 ]:
397- s .append (str (round (float (o [ind ]) * float (o [2 ])/ float (o [1 ]),3 )))
398- if ind != 3 :
399- st += float (o [ind ]) * float (o [2 ])/ float (o [1 ])
400- for ind in [15 ,16 ,17 ,18 ]:
401- if o [ind ] != "0" :
402- s .append (str (round (float (o [ind ]) * 100 ,3 )))
403- else :
404- s .append ("0" )
405- s [5 ] = str (round (100 - st ,3 ))
418+ table .append (tr )
419+ o = o .split ("\t " )
420+ st = 0
421+ s = []
422+ for ind in [10 , 11 , 12 , 5 , 7 , 3 ]:
423+ s .append (str (round (float (o [ind ]) * float (o [2 ])/ float (o [1 ]),3 )))
424+ if ind != 3 :
425+ st += float (o [ind ]) * float (o [2 ])/ float (o [1 ])
426+ for ind in [15 ,16 ,17 ,18 ]:
427+ if o [ind ] != "0" :
428+ s .append (str (round (float (o [ind ]) * 100 ,3 )))
429+ else :
430+ s .append ("0" )
431+ s [5 ] = str (round (100 - st ,3 ))
406432 print >> out , i + "\t " + "\t " .join (s )
407433 out .close ()
408434 return "<table>" + "\n " .join (table )+ "</table>"
409435 else :
410436 return ""
411437
412438
439+ def stats_picard_2 (path ,samples ,config ):
440+ n = os .listdir (path )
441+ hh = "\t " .join (['sample_id' ,'MEDIAN_INSERT_SIZE' ,'MEDIAN_ABSOLUTE_DEVIATION' ,'MIN_INSERT_SIZE' ,
442+ 'MAX_INSERT_SIZE' ,'MEAN_INSERT_SIZE' ,'STANDARD_DEVIATION' ,'READ_PAIRS' , 'LINK_TXT' , 'LINK_PDF' ])
443+ if config .has_key ("picard_IS" ) and ("results_picard_IS" in n ):
444+ files = os .listdir (path + "/results_picard_IS" )
445+ out = open (path + "/outputs/stats_picard2.txt" ,'w' )
446+ print >> out , hh
447+ data = list ()
448+ for i in sorted (samples .keys ()):
449+ if i + ".txt" in files :
450+ f = open (path + "/results_picard_IS" + "/" + i + ".txt" ,'r' )
451+ k = 0
452+ while (1 ):
453+ j = f .readline ()
454+ if j .startswith ("MEDIAN_INSERT_SIZE" ):
455+ j = f .readline ().strip ("\n " ).split ("\t " )
456+ break
457+ k += 1
458+ if k > 10 or len (j ) == 0 :
459+ j = ['NA' for i in range (7 )]
460+ break
461+ print >> out , "\t " .join ([i ] + j + ['<a href="../results_picard_IS/' + i + '.txt" target="_blank">+</a>' , '<a href="../results_picard_IS/' + i + '.pdf" target="_blank">+</a>' ])
462+ f .close ()
463+ else :
464+ print >> out , "\t " .join ([i ] + ['NA' for i in range (9 )])
465+ out .close ()
466+ return 1
467+
413468def skeleton (path , path2html ):
414469 print "> Building HTML and OUTPUT folders skeletons..."
415470 print " - Path: " + path
@@ -507,7 +562,7 @@ def check_config(path):
507562 # Parses the configuration file
508563 print "> Parsing configuration file..."
509564 try :
510- z = ["trimgalore" , "fastqc" , "star" , "star-fusion" , "picard" , "htseq-gene" , "htseq-exon" , "kallisto" , "varscan" , "gatk" ]
565+ z = ["trimgalore" , "fastqc" , "star" , "star-fusion" , "picard" , "htseq-gene" , "htseq-exon" , "kallisto" , "picard_IS" , " varscan" , "gatk" ]
511566 f = open (path + "/config.txt" , 'r' )
512567 analysis = dict ()
513568 analysis ["cluster" ] = dict ()
0 commit comments