Compare commits
2 Commits
d8829a3c46
...
055078fc60
| Author | SHA1 | Date |
|---|---|---|
|
|
055078fc60 | |
|
|
cb89ec1ef9 |
|
|
@ -91,6 +91,7 @@ class PostProcess:
|
||||||
# 突变的等级分类
|
# 突变的等级分类
|
||||||
if '证据等级' in df.columns:
|
if '证据等级' in df.columns:
|
||||||
df['AMP_mut_level'] = df['证据等级'].replace(['A', 'B', 'C', 'D'], ['I', 'I', 'II', 'II'])
|
df['AMP_mut_level'] = df['证据等级'].replace(['A', 'B', 'C', 'D'], ['I', 'I', 'II', 'II'])
|
||||||
|
# df['NCCN_mut_level'] = df['证据等级'].replace(['A', 'B', 'C', 'D'], ['I', 'II', 'II', 'II'])
|
||||||
|
|
||||||
# 药物等级划分
|
# 药物等级划分
|
||||||
if 'Response_Type_C' in df.columns and '证据等级' in df.columns:
|
if 'Response_Type_C' in df.columns and '证据等级' in df.columns:
|
||||||
|
|
@ -527,7 +528,8 @@ class PostProcess:
|
||||||
if qc_files:
|
if qc_files:
|
||||||
if os.path.getsize(qc_files[0]) > 0:
|
if os.path.getsize(qc_files[0]) > 0:
|
||||||
qc = pd.read_csv(qc_files[0], sep='\t', header=None)
|
qc = pd.read_csv(qc_files[0], sep='\t', header=None)
|
||||||
qc_res = [qc.set_index(0)[1].to_dict()]
|
qc_content = qc.set_index(0)[1].to_dict()
|
||||||
|
qc_res = [qc_content]
|
||||||
self.sheet['qc'] = qc_res
|
self.sheet['qc'] = qc_res
|
||||||
|
|
||||||
def drugs(self):
|
def drugs(self):
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,100 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
|
||||||
|
def check(outputf, tumorf, normalf=None, genderf=None, cms=None):
|
||||||
|
# qc_check = {
|
||||||
|
# 'Q30(%)': 85,
|
||||||
|
# 'clean_reads_rate(%)': 90,
|
||||||
|
# 'mapped_rate(%)': 90,
|
||||||
|
# 'capture_rate(reads)': 50,
|
||||||
|
# 'mean_depth(dedup)': 500,
|
||||||
|
# 'mean_depth(dedup)_umi': 1000,
|
||||||
|
# 'coverage(>=80%)': 500,
|
||||||
|
# 'coverage(>=80%)_umi': 1000,
|
||||||
|
# 'coverage(>=0.2*meanx)': 95,
|
||||||
|
# 'coverage(>10x)': 90,
|
||||||
|
# 'coverage(>=0.1*meanx)': 90,
|
||||||
|
# 'concordence': 99,
|
||||||
|
# 'contamination_n': 1,
|
||||||
|
# 'contamination_t': 1,
|
||||||
|
# }
|
||||||
|
|
||||||
|
qc_t = pd.read_csv(tumorf, sep="\t", index_col=0, header=None).T
|
||||||
|
|
||||||
|
out = open(outputf, 'w')
|
||||||
|
|
||||||
|
##tumor
|
||||||
|
if float(qc_t['Q30(%)'][1]) < 85:
|
||||||
|
out.write('\t'.join(("Tumor:", "Q30(%)", str(qc_t['Q30(%)'][1]), "(<85%)\n")))
|
||||||
|
if float(qc_t['clean_reads_rate(%)'][1]) < 90:
|
||||||
|
out.write('\t'.join(("Tumor:", "clean_reads_rate(%)", str(qc_t['clean_reads_rate(%)'][1]), "(<90%)\n")))
|
||||||
|
if float(qc_t['mapped_rate(%)'][1]) < 90:
|
||||||
|
out.write('\t'.join(("Tumor:", "mapped_rate(%)", str(qc_t['mapped_rate(%)'][1]), "(<90%)\n")))
|
||||||
|
if float(qc_t['capture_rate(reads)'][1]) < 50:
|
||||||
|
out.write('\t'.join(("Tumor:", "capture_rate(reads)", str(qc_t['capture_rate(reads)'][1]), "(<50%)\n")))
|
||||||
|
if float(qc_t['mean_depth(dedup)'][1]) < 500:
|
||||||
|
out.write('\t'.join(("Tumor:", "mean_depth(dedup)", str(qc_t['mean_depth(dedup)'][1]), "(<500X)\n")))
|
||||||
|
if float(qc_t['coverage(>=80%)'][1]) < 500:
|
||||||
|
out.write('\t'.join(("Tumor:", "coverage(>=80%)", str(qc_t['coverage(>=80%)'][1]), "(<500X)\n")))
|
||||||
|
if float(qc_t['coverage(>=0.2*meanx)'][1]) < 95:
|
||||||
|
out.write('\t'.join(("Tumor:", "coverage(>=0.2*meanx)", str(qc_t['coverage(>=0.2*meanx)'][1]), "(<95%)\n")))
|
||||||
|
if float(qc_t['coverage(>10x)'][1]) < 95:
|
||||||
|
out.write('\t'.join(("Tumor:", "coverage(>10x)", str(qc_t['coverage(>10x)'][1]), "(<95%)\n")))
|
||||||
|
|
||||||
|
if os.path.exists(normalf):
|
||||||
|
qc_n = pd.read_csv(normalf, sep="\t", index_col=0, header=None).T
|
||||||
|
##normal
|
||||||
|
if float(qc_n['Q30(%)'][1]) < 85:
|
||||||
|
out.write('\t'.join(("Normal:", "Q30(%)", str(qc_n['Q30(%)'][1]), "(<85%)\n")))
|
||||||
|
if float(qc_n['clean_reads_rate(%)'][1]) < 90:
|
||||||
|
out.write('\t'.join(("Normal:", "clean_reads_rate(%)", str(qc_n['clean_reads_rate(%)'][1]), "(<90%)\n")))
|
||||||
|
if float(qc_n['mapped_rate(%)'][1]) < 90:
|
||||||
|
out.write('\t'.join(("Normal:", "mapped_rate(%)", str(qc_n['mapped_rate(%)'][1]), "(<90%)\n")))
|
||||||
|
if float(qc_n['capture_rate(reads)'][1]) < 50:
|
||||||
|
out.write('\t'.join(("Normal:", "capture_rate(reads)", str(qc_n['capture_rate(reads)'][1]), "(<50%)\n")))
|
||||||
|
if float(qc_n['coverage(>=80%)'][1]) < 100:
|
||||||
|
out.write('\t'.join(("Normal:", "coverage(>=80%)", str(qc_n['coverage(>=80%)'][1]), "(<100X)\n")))
|
||||||
|
if float(qc_n['coverage(>=0.2*meanx)'][1]) < 95:
|
||||||
|
out.write(
|
||||||
|
'\t'.join(("Normal:", "coverage(>=0.2*meanx)", str(qc_n['coverage(>=0.2*meanx)'][1]), "(<95%)\n")))
|
||||||
|
if float(qc_n['coverage(>10x)'][1]) < 95:
|
||||||
|
out.write('\t'.join(("Normal:", "coverage(>10x)", str(qc_n['coverage(>10x)'][1]), "(<95%)\n")))
|
||||||
|
if os.path.exists(str(genderf)):
|
||||||
|
genderf_df = pd.read_csv(genderf, sep='\t')
|
||||||
|
genderf_dict = genderf_df.to_dict(orient='records')[0]
|
||||||
|
gender_cms = ''
|
||||||
|
if os.path.exists(str(cms)):
|
||||||
|
cmsf = open(cms, "r")
|
||||||
|
cmsj = json.load(cmsf)
|
||||||
|
gender_cms_data = cmsj.get('data', [])
|
||||||
|
if gender_cms_data:
|
||||||
|
gender_cms = gender_cms_data[0].get('gender', '')
|
||||||
|
if gender_cms:
|
||||||
|
genderf_dict['gender_cms'] = gender_cms
|
||||||
|
genderf_r = [k for k, v in genderf_dict.items() if list(genderf_dict.values()).count(v) == 1]
|
||||||
|
if genderf_r:
|
||||||
|
out.write('\t'.join(("性别鉴定不一致:", str(genderf_dict))))
|
||||||
|
else:
|
||||||
|
out.write('\t'.join(("性别鉴定:", 'lims系统提供信息有误,请核查')))
|
||||||
|
else:
|
||||||
|
out.write('\t'.join(("性别鉴定:", '流程未进行性别鉴定评估')))
|
||||||
|
|
||||||
|
out.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser(description="Check qcfile")
|
||||||
|
parser.add_argument('-n', '--barcode', help="sample's qcfile", required=True)
|
||||||
|
parser.add_argument('-s', '--normal', help="normal's file", default='', required=False, nargs='?')
|
||||||
|
parser.add_argument('-p', '--gender', help="gender file", default='', required=False, nargs='?')
|
||||||
|
parser.add_argument('-c', '--cms', help="cms's file", default='', required=False, nargs='?')
|
||||||
|
parser.add_argument('-o', '--output_file', help="Output directory, default ", required=True)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
check(args.output_file, args.barcode, args.normal, args.gender, args.cms)
|
||||||
|
|
@ -66,12 +66,13 @@ def get_catecode(project, start_node='addQc'):
|
||||||
return cate_dict
|
return cate_dict
|
||||||
|
|
||||||
|
|
||||||
def send_ding(msg):
|
def send_ding(msg, isat=True):
|
||||||
'''
|
'''
|
||||||
发送钉钉消息功能
|
发送钉钉消息功能
|
||||||
'''
|
'''
|
||||||
url = 'https://oapi.dingtalk.com/robot/send?access_token=0c4b2dc1b6a1b459826512cc27adbd14e4f6aa2e661b7a7c284669065bbccfc5'
|
url = 'https://oapi.dingtalk.com/robot/send?access_token=0c4b2dc1b6a1b459826512cc27adbd14e4f6aa2e661b7a7c284669065bbccfc5'
|
||||||
data = {"msgtype": "text", "text": {"content": "pipeline:" + str(msg)}, "at": {"isAtAll": True}}
|
# url = 'https://oapi.dingtalk.com/robot/send?access_token=d4a0749cc7ff87bd12079a79dd74ca3423becb1ce161c3088acc6628a7a188dd'
|
||||||
|
data = {"msgtype": "text", "text": {"content": "pipeline:" + str(msg)}, "at": {"isAtAll": isat}}
|
||||||
headers = {'Content-Type': 'application/json;charset=UTF-8'}
|
headers = {'Content-Type': 'application/json;charset=UTF-8'}
|
||||||
send_data = json.dumps(data).encode('utf-8')
|
send_data = json.dumps(data).encode('utf-8')
|
||||||
session.post(url=url, data=send_data, headers=headers)
|
session.post(url=url, data=send_data, headers=headers)
|
||||||
|
|
@ -116,7 +117,7 @@ def run(barcode, normal, umi, input_dir, output_dir, project, cancer, probe, wdl
|
||||||
# 记录开始时间
|
# 记录开始时间
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
if not debug:
|
if not debug:
|
||||||
send_ding(msg=f'\n样本: {barcode}\n分析地址: \n{output_dir} \n 开始分析')
|
send_ding(msg=f'\n样本: {barcode}\n分析地址: \n{output_dir} \n 开始分析', isat=False)
|
||||||
ret = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8")
|
ret = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8")
|
||||||
pidnum = ret.pid
|
pidnum = ret.pid
|
||||||
with open(os.path.join(output_dir, 'pid'), 'w') as pidfile:
|
with open(os.path.join(output_dir, 'pid'), 'w') as pidfile:
|
||||||
|
|
@ -163,12 +164,12 @@ def run(barcode, normal, umi, input_dir, output_dir, project, cancer, probe, wdl
|
||||||
# 按照文件的修改时间倒序排序
|
# 按照文件的修改时间倒序排序
|
||||||
sorted_stdout_files = sorted(stdout_files, key=lambda x: os.path.getmtime(x), reverse=True)
|
sorted_stdout_files = sorted(stdout_files, key=lambda x: os.path.getmtime(x), reverse=True)
|
||||||
sorted_stderr_files = sorted(stderr_files, key=lambda x: os.path.getmtime(x), reverse=True)
|
sorted_stderr_files = sorted(stderr_files, key=lambda x: os.path.getmtime(x), reverse=True)
|
||||||
|
|
||||||
for file_path in sorted_stdout_files:
|
for file_path in sorted_stdout_files:
|
||||||
with open(file_path, 'r') as f:
|
with open(file_path, 'r') as f:
|
||||||
stdout.write('#' * 50 + '\n')
|
stdout.write('#' * 50 + '\n')
|
||||||
stdout.write(file_path + '\n')
|
stdout.write(file_path + '\n')
|
||||||
stdout.write(f.read())
|
f_read = f.read()
|
||||||
|
stdout.write(f_read)
|
||||||
stdout.write('\n\n')
|
stdout.write('\n\n')
|
||||||
|
|
||||||
for file_path in sorted_stderr_files:
|
for file_path in sorted_stderr_files:
|
||||||
|
|
@ -177,8 +178,18 @@ def run(barcode, normal, umi, input_dir, output_dir, project, cancer, probe, wdl
|
||||||
stderr.write(file_path + '\n')
|
stderr.write(file_path + '\n')
|
||||||
stderr.write(f.read())
|
stderr.write(f.read())
|
||||||
stderr.write('\n\n')
|
stderr.write('\n\n')
|
||||||
|
|
||||||
|
qcfail_f = os.path.join(output_dir, 'report', f'{barcode}_qcfail.txt')
|
||||||
|
if os.path.exists(qcfail_f):
|
||||||
|
with open(qcfail_f, "r") as qcfail_f_out:
|
||||||
|
qcfail = qcfail_f_out.read()
|
||||||
|
else:
|
||||||
|
qcfail = '流程失败,请核查!!!'
|
||||||
|
if not qcfail:
|
||||||
|
qcfail = '合格'
|
||||||
if not debug:
|
if not debug:
|
||||||
send_ding(msg=f'\n样本: {barcode}\n分析地址: \n{output_dir} \n 分析完成,请查看!')
|
send_ding(msg=f'\n样本: {barcode}\n分析地址: \n{output_dir} \n 分析完成,请查看!\n\n qcfail: \n {qcfail}\n')
|
||||||
|
|
||||||
stdout.close()
|
stdout.close()
|
||||||
stderr.close()
|
stderr.close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ task run_post {
|
||||||
fi
|
fi
|
||||||
indication.pl ${output_dir} ${cancer} ${project}
|
indication.pl ${output_dir} ${cancer} ${project}
|
||||||
sample_post.py -s ${name} -o ${output_dir}
|
sample_post.py -s ${name} -o ${output_dir}
|
||||||
|
qc_check.py -n ${output_dir}/qc/${name}_qc.txt -s ${output_dir}/qc/${normal}_qc.txt -p ${output_dir}/pollution/${name}_gender_res.txt -c ${output_dir}/qc/${name}_post.json -o ${output_dir}/report/${name}_qcfail.txt
|
||||||
postprocess.py -n ${name} -s ${normal} -c ${output_dir} -o ${output_dir}/report/${name}.merged_file.xlsx
|
postprocess.py -n ${name} -s ${normal} -c ${output_dir} -o ${output_dir}/report/${name}.merged_file.xlsx
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue