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 notin 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 SeqIO
wanted = 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' % id1
else:
print ("Get all IDs ")
from Bio import SeqIOname = open('1.txt', 'r')o = open('1.fa', 'r')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