dotter.py
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:3k
- #!/usr/bin/python
- # $Id: dotter.py,v 1000.1 2003/11/21 21:44:13 gouriano Exp $
- #
- # Author: Josh Cherry
- #
- # launch dotter (from gbench) using sequences we're handed
- import sys
- import cgi
- import os
- import tempfile
- def writefasta(seq, fname, seqname):
- s = ">" + seqname + "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()
- args = cgi.parse_qs(input)
- action = args['action'][0]
- # if a get info call ...
- if action == 'info':
- print '''
- PluginInfo ::= {
- ver-major 0,
- ver-minor 0,
- ver-revision 0,
- ver-build-date "",
- class-name "dotter.py",
- menu-item "Alignments/Dot matrix comparison",
- tooltip "Dot matrix comparison of sequences using dotter",
- commands algo {
- {
- command 3,
- args {
- {
- name "hseq",
- desc "Horizontal sequence",
- data single object {
- docaddr "(nil)",
- objaddr "(nil)",
- subtype "Seq-loc"
- }
- },
- {
- name "vseq",
- desc "Vertical sequence",
- data single object {
- docaddr "(nil)",
- objaddr "(nil)",
- subtype "Seq-loc"
- }
- }
- }
- }
- }
- }
- '''
- sys.exit(0)
- # otherwise, run
- hseq = args['hseq'][0]
- vseq = args['vseq'][0]
- # write temporary fasta files containing the sequences
- fname0 = tempfile.mktemp('.fasta')
- fname1 = tempfile.mktemp('.fasta')
- loc0 = cgi.parse_qs(hseq);
- loc1 = cgi.parse_qs(vseq);
- writefasta(loc0['seq'][0], fname0, loc0['title'][0])
- writefasta(loc1['seq'][0], fname1, loc1['title'][0])
- # run dotter in background
- # redirect all output to /dev/null (otherwise interpreter goes zombie)
- os.system('dotter %s %s >& /dev/null &' % (fname0, fname1))
- # cheesy: wait a few seconds so dotter can read its files,
- # then delete them
- import time
- time.sleep(5)
- os.system('rm %s %s' % (fname0, fname1))
- # ===========================================================================
- # $Log: dotter.py,v $
- # Revision 1000.1 2003/11/21 21:44:13 gouriano
- # PRODUCTION: UPGRADED [ORIGINAL] Dev-tree R1.4
- #
- # Revision 1.4 2003/11/17 21:55:40 jcherry
- # Ask for two single Seq-locs rather than one array
- #
- # Revision 1.3 2003/10/29 20:12:05 jcherry
- # Reflect new spec for plugin args
- #
- # Revision 1.2 2003/10/07 13:47:02 dicuccio
- # Renamed CPluginURL* to CPluginValue*
- #
- # Revision 1.1 2003/07/28 18:24:31 jcherry
- # Initial version
- #
- # ===========================================================================
- #
- # ===========================================================================
- # PRODUCTION $Log: dotter.py,v $
- # PRODUCTION Revision 1000.1 2003/11/21 21:44:13 gouriano
- # PRODUCTION PRODUCTION: UPGRADED [ORIGINAL] Dev-tree R1.4
- # PRODUCTION
- # ===========================================================================
- #