Commit 7a921950 authored by mmassaviol's avatar mmassaviol
Browse files

remove gitignore and add prepare report scripts

parent 219797f5
# Ignore everything in this directory
*
# Except this file
!.gitignore
import oyaml as yaml
import sys
import re
import os
from collections import OrderedDict
config = dict()
with open(sys.argv[1], 'r') as paramfile:
config = yaml.load(paramfile, Loader=yaml.FullLoader)
config = config["params"]
def get_field(field, slog, fl=False):
"""parse sample log for field
set fl=True to return a float
otherwise, returns int
"""
field += r'\:\s+([\d\.]+)'
match = re.search(field, slog)
if match:
if fl:
return float(match.group(1))
return int(match.group(1))
return 0
def get_sample(logfile):
if "_flash_log.txt" in logfile:
return os.path.basename(logfile).replace("_flash_log.txt","")
else:
return "unknown"
out ="""# description: 'FLASh read combination statistics'
# section_name: 'FLASh combinations'
# plot_type: 'table'
"""
out += '\t'.join(['sample','totalpairs','discardpairs','%discard','combopairs','inniepairs','outiepairs','uncombopairs','%combo']) + '\n'
for file in os.listdir(os.path.join(config["results_dir"],"logs/flash")):
slog = ""
res = OrderedDict()
sample = get_sample(file)
with open(os.path.join(config["results_dir"],"logs/flash",file), 'r') as logfile:
slog = "".join(logfile.readlines())
res['totalpairs'] = get_field('Total pairs', slog)
res['discardpairs'] = get_field('Discarded pairs', slog)
res['percdiscard'] = get_field('Percent Discarded', slog, fl=True)
res['combopairs'] = get_field('Combined pairs', slog)
res['inniepairs'] = get_field('Innie pairs', slog)
res['outiepairs'] = get_field('Outie pairs', slog)
res['uncombopairs'] = get_field('Uncombined pairs', slog)
res['perccombo'] = get_field('Percent combined', slog, fl=True)
out += sample + '\t' + '\t'.join(str(x) for x in res.values()) + '\n'
with open(os.path.join(config["results_dir"],"flash/flash_combinations_mqc.csv"), "w") as outfile:
outfile.write(out)
\ No newline at end of file
import oyaml as yaml
import sys
import os
from collections import OrderedDict
config = dict()
with open(sys.argv[1], 'r') as paramfile:
config = yaml.load(paramfile, Loader=yaml.FullLoader)
config = config["params"]
def get_sample(logfile):
if "_lastz_sam_stats.tsv" in logfile:
return os.path.basename(logfile).replace("_lastz_sam_stats.tsv","")
else:
return "unknown"
out ="""# description: 'LASTZ mapping statistics'
# section_name: 'LASTZ stats'
# plot_type: 'table'
"""
#out += '\t'.join(['sample','totalpairs','discardpairs','%discard','combopairs','inniepairs','outiepairs','uncombopairs','%combo']) + '\n'
header = ""
stats = ""
for file in os.listdir(os.path.join(config["results_dir"],config["lastz_output_dir"],"stats")):
stat = ""
sample = get_sample(file)
with open(os.path.join(config["results_dir"],config["lastz_output_dir"],"stats",file), 'r') as logfile:
header = logfile.readline()
stat = logfile.readline()
stats += sample + '\t' + stat
header = "SAMPLE\t" + header
out += header + stats
with open(os.path.join(config["results_dir"],config["lastz_output_dir"],"lastz_stats_mqc.csv"), "w") as outfile:
outfile.write(out)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment