生物信息学python脚本_使用Python/Biopython/Clustalw的生物信息学脚本,使用stdout迭代蛋白质目录...

所以我在python中做了一些生物信息学的工作,利用Biopython和Clustalw2来对齐蛋白质序列。我对此相当陌生(只有几个月的经验),而且我在使用stdout和遍历整个目录时遇到了一个问题。任何帮助都将不胜感激。在

所以我写了这个,一次处理一个文件,产生期望的结果。。。在#!/usr/bin/python

import Bio

import os

from Bio.Align.Applications import ClustalwCommandline

from Bio import Seq

from Bio import SeqIO

from Bio import AlignIO

from Bio.SeqRecord import SeqRecord

clustal_loc=r"/Users/Wes/Desktop/eggNOG_files/clustalw-2.1-macosx/clustalw2"

try:

f_in=raw_input("Enter the filepath of the FASTA to align: ")

f_out= raw_input("Enter the output filename: ")

fh= open(f_in)

fo=open(f_out,'w')

for record in SeqIO.parse(fh,"fasta"):

id = record.id

seq = record.seq

print("Name: %s, size: %s"%(id,len(seq)))

try:

cl = ClustalwCommandline(clustal_loc,infile=f_in, outfile=f_out, align=True, outorder="ALIGNED", convert=True, output="pir")

assert os.path.isfile(clustal_loc), "Clustal W not found"

stdout, stderr = cl()

print cl

except:

print("There was a problem aligning. Check ClustalW path and .fasta input.")

fh.close()

fo.close()

except:

print("Could not parse. Check to make sure filepath is correct and that file is in FASTA format")

……这似乎很管用。当我试图在整个目录(比如1000多个需要对齐的蛋白质序列文件)上迭代时,问题就来了。我知道问题出在stdout上,但我现在太业余了,不知道如何解决它。下面是坏代码-

^{pr2}$

如你所见,我把这件事搞得一团糟。谢谢你能提供的任何帮助。在

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值