您现在的位置是:网站首页> 编程资料编程资料
python实现GATK多线程加速示例_python_
2023-05-26
363人已围观
简介 python实现GATK多线程加速示例_python_
GATK 变异分析
对于大数据样本可能会比较慢,因此可以按照染色体拆分后进行多线程并行计算。
下面是我写的一个python多线程脚本,仅供参考,拙劣之处敬请指正。
#!/usr/bin/python3 import _thread import os import threading import time muthreads=[] bam_file="a.mkdup.bam" out_file_prefix="flower" chr_list=["CHR01","CHR02","CHR03","CHR04","CHR05","CHR06","CHR07","CHR08","CHR09","CHR10","CHR11","CHR12","CHR13"] for chr in chr_list: threads_comonder_name= "gatk HaplotypeCaller --intervals " + chr +" -R /mnt/j/BSA/02-read-align/Tifrunner2.fasta -I " + bam_file + " -ERC GVCF -O "+ out_file_prefix +"-"+chr+".erc.g.vcf" muthreads.append(threads_comonder_name) exitFlag = 0 class myThread (threading.Thread): def __init__(self, threadID, name, counter, comander): threading.Thread.__init__(self) self.threadID = threadID self.name = name self.counter = counter self.comander = comander def run(self): print ("开始线程:" + self.name) print_time(self.name, self.counter, 5, self.comander) print ("退出线程:" + self.name) def print_time(threadName, delay, counter,comander): # while counter: if exitFlag: threadName.exit() time.sleep(delay) print(comander) os.system(comander)#调用操作系统命令行处理数据 # counter -= 1 # 创建新线程 threadlist=[] for i, threadsnu in enumerate(muthreads[0:11]): print(i) print(threadsnu) threadsnew=myThread(1, "Thread-" + str(i), 2, threadsnu) threadlist.append(threadsnew) # 开启新线程 for threads in threadlist: threads.start() for threads in threadlist: threads.join() print ("运行结束退出主线程") 下面的来自网络未验证
多条染色体的同样本的vcf文件合并
# for i in {1..22} X Y ;do echo "-I final_chr$i.vcf" '\';done # for i in {10..19} {1..9} M X Y ;do echo "-I final_chr$i.vcf" '\';done module load java/1.8.0_91 GATK=/home/jianmingzeng/biosoft/GATK/gatk-4.0.3.0/gatk $GATK GatherVcfs \ -I final_chr1.vcf \ -I final_chr2.vcf \ -I final_chr3.vcf \ -I final_chr4.vcf \ -I final_chr5.vcf \ -I final_chr6.vcf \ -I final_chr7.vcf \ -I final_chr8.vcf \ -I final_chr9.vcf \ -I final_chr10.vcf \ -I final_chr11.vcf \ -I final_chr12.vcf \ -I final_chr13.vcf \ -I final_chr14.vcf \ -I final_chr15.vcf \ -I final_chr16.vcf \ -I final_chr17.vcf \ -I final_chr18.vcf \ -I final_chr19.vcf \ -I final_chr20.vcf \ -I final_chr21.vcf \ -I final_chr22.vcf \ -I final_chrX.vcf \ -I final_chrY.vcf \ -O merge.vcf 合并的时候需要注意,vcf文件的顺序跟每个vcf文件里面头文件顺序是相同的。
以上就是python实现GATK多线程加速示例的详细内容,更多关于python GATK多线程加速的资料请关注其它相关文章!
您可能感兴趣的文章:
相关内容
- Python+Selenium实现在Geoserver批量发布Mongo矢量数据_python_
- 使用matplotlib绘制并排柱状图的实战案例_python_
- python PyVCF文件处理VCF文件格式实例详解_python_
- Selenium多窗口切换解决方案_python_
- 如何用Python 实现景区安防系统_python_
- 使用Python脚本提取基因组指定位置序列_python_
- Python matplotlib如何简单绘制不同类型的表格_python_
- python3.7安装matplotlib失败问题的完美解决方法_python_
- Python可视化模块altair的使用详解_python_
- Python实现GB格式序列文件转换Fasta格式文件_python_
