bl2seq.py
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:1k
- #!/usr/bin/python
- # $Id: bl2seq.py,v 1000.0 2003/10/31 21:37:15 gouriano Exp $
- #
- # Author: Josh Cherry
- #
- # align two nucleotide sequences using bl2seq
- # (from gbench)
- import sys
- import string
- import commands
- import os
- def writefasta(seq, fname):
- s = ">" + fname + "n"
- for pos in range(0, len(seq), 60):
- s += seq[pos:pos+60]
- s += 'n'
- f = open(fname, "w")
- f.write(s)
- f.close
- input = sys.stdin.read()
- l = string.split(input)
- if len(l) != 2:
- sys.stderr.write("need exactly 2 sequences; you supplied %dn" % len(l))
- sys.exit(1)
- writefasta(l[0], 'seq1.fasta')
- writefasta(l[1], 'seq2.fasta')
- # run bl2seq, which must be on path
- os.system('bl2seq -p blastn -i seq1.fasta -j seq2.fasta')
- # then delete temporary fasta files
- os.system('rm seq1.fasta seq2.fasta')
- # ===========================================================================
- # $Log: bl2seq.py,v $
- # Revision 1000.0 2003/10/31 21:37:15 gouriano
- # PRODUCTION: IMPORTED [ORIGINAL] Dev-tree R1.1
- #
- # Revision 1.1 2003/06/24 16:41:12 jcherry
- # Initial versions of scripts for use with gbench
- #
- # ===========================================================================
- #
- # ===========================================================================
- # PRODUCTION $Log: bl2seq.py,v $
- # PRODUCTION Revision 1000.0 2003/10/31 21:37:15 gouriano
- # PRODUCTION PRODUCTION: IMPORTED [ORIGINAL] Dev-tree R1.1
- # PRODUCTION
- # ===========================================================================
- #