更新qcfail

master
chaopower 2024-02-22 16:45:19 +08:00
parent d8829a3c46
commit cb89ec1ef9
3 changed files with 21 additions and 7 deletions

View File

@ -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):

View File

@ -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()

View File

@ -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
} }