您的位置:首页 > 其它

排除指定的序列

2016-09-17 11:30 211 查看
from Bio import SeqIO
name = open('1.txt', 'r')
o = open('1.fa', 'w')
wanted = set(line.rstrip("\n") for line in name)
records = (r for r in SeqIO.parse('unigene_seq_5.fasta', "fasta") if r.id not in wanted)
SeqIO.write(records, o, "fasta")
@seqtools.command()@click.option('-i', type=click.File('rb'), help='fasta file')@click.option('-o', type=click.File('w'), help='out fasta file')@click.option('-name', type=click.File('rb'), help='name file store name of sequence')def get_seq(i, o, name):''' get sequence from a sequence name file'''from Bio import SeqIOwanted = set(line.rstrip("\n").split(None, 1)[0] for line in name)records = (r for r in SeqIO.parse(i, "fasta") if r.id in wanted)count = SeqIO.write(records, o, "fasta")if count < len(wanted):print("Warning %i IDs not found " % (len(wanted) - count))i.seek(0, 0)ids = [record.id for record in list(SeqIO.parse(i, "fasta"))]for id1 in wanted:if id1 not in ids:print '%s not found' % id1else:print ("Get all IDs ")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息