构建单拷贝同源蛋白系统发育树,一条命令提序列!

由于基因重组与基因突变的存在,利用16S rRNA构建的系统发育树通常不够可靠,而使用基于全基因组的单拷贝同源蛋白系统发育树则不会存在这方面的困扰,16S rRNA序列也就1500个碱基左右,而全基因组单拷贝同源蛋白可达十几二十万个氨基酸长度,建树用它,绝对准!一条命令出序列,建树再也不难~

  1. 前期准备

首先需要从NCBI下载fasta格式的基因组序列,之后到rast服务器完成注释,然后下载fasta格式的蛋白序列作为准备,需要注意的是,各基因组蛋白序列的文件名不可以有空格,推荐使用_代替空格。RAST服务器

  1. 调用软件

计算单拷贝同源蛋白需要调用proteinortho6,因此要确保服务器已安装proteinortho6并可正常调用。proteinortho6下载
序列比对使用muscle,因此muscle也是必须的。MUSCLE下载

  1. 一条命令出序列

将蛋白序列文件夹上传到服务器,同目录下运行脚本即可。

python3 protein_ortho.py <file_name> <bacteria_num>

<file_name>是蛋白序列文件夹的名称
<bacteria_num>是文件夹内序列来自多少个细菌
例如:

python3 protein_ortho.py Nature 30

proteinortho6使用了diamond比对,比proteinortho6速度快了很多,实测使用30个细菌的基因组,脚本执行完成共用时10分钟左右,具具体运行时间与服务器配置有关。

##构建单拷贝同源蛋白
##在linux下运行,需要安装proteinortho与muscle,proteinortho安装地址:http://www.bioinf.uni-leipzig.de/Software/proteinortho/,muscle地址:http://www.drive5.com/muscle/。
##作者:刘宁华  山东大学青岛校区  1039438318@qq.com

#1. 处理序列文本
def chuli_seq(in_file_0):
	import os
	path = os.getcwd()
	path = path + "/" + in_file_0 + "/"
	files = os.listdir(path)
	file_path = []
	for file in files:
		file_path_1 = path + file
		file_path.append(file_path_1)
	for file in file_path:
		cmd = "sed -i 's/ /_/g' " + file
		os.system(cmd)
	return print("1. 序列预处理")


#2. 运行同源比对命令
def protein_ortho(file):
	import os
	cmd = "proteinortho6.pl -project=" + file + "_work -e=1e-5 -cov=50 -identity=50 -clean " + file + "/*.faa"
	os.system(cmd)
	return print("
好的,以下是一段 Python 代码,可以用于用拷贝基因构建物种: ```python import dendropy # 定义函数,用于构建个物种的系统发育 def build_phylogeny(species_name, gene_sequence_file): # 读取基因序列文件 gene_sequence = dendropy.DnaCharacterMatrix.get( path=gene_sequence_file, schema="fasta" ) # 拷贝基因序列 single_copy_genes = dendropy.utility.find_unique_elements( gene_sequence, ignore_unbranched=False, threshold_freq=1.0 ) # 构建物种的基因序列 species_sequence = dendropy.DnaCharacterMatrix( taxon_namespace=gene_sequence.taxon_namespace ) for gene in single_copy_genes: species_sequence[gene.taxon].append([c for c in gene]) # 构建物种的系统发育 tree = dendropy.Tree.get( data=species_sequence, schema="fasta", taxon_namespace=dendropy.TaxonNamespace([species_name]) ) # 返回构建好的系统发育 return tree # 定义函数,用于批量构建物种的系统发育 def build_phylogenies(species_data): # 定义空列表,用于存储所有系统发育 phylogenies = [] # 遍历物种数据 for species_name, gene_sequence_file in species_data.items(): # 构建个物种的系统发育 phylogeny = build_phylogeny(species_name, gene_sequence_file) # 将构建好的系统发育添加到列表中 phylogenies.append(phylogeny) # 返回所有构建好的系统发育 return phylogenies # 定义物种数据,其中键为物种名称,值为基因序列文件路径 species_data = { "human": "human_genes.fasta", "mouse": "mouse_genes.fasta", "rat": "rat_genes.fasta" } # 构建所有物种的系统发育 phylogenies = build_phylogenies(species_data) # 打印所有系统发育的摘要信息 for phylogeny in phylogenies: print(phylogeny.as_string("newick")) ``` 以上代码中,`build_phylogeny` 函数用于构建个物种的系统发育,使用 `find_unique_elements` 函数拷贝基因序列,并将其合并为物种的基因序列,然后构建系统发育。`build_phylogenies` 函数用于批量构建所有物种的系统发育。`species_data` 变量定义了所有物种的基因序列文件路径,可以根据需要进行修改。最后,使用 `print` 函数打印所有系统发育的摘要信息。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值