gc.py
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:2k
- #!/usr/bin/python
- # $Id: gc.py,v 1000.0 2003/10/31 21:38:33 gouriano Exp $
- #
- # Author: Josh Cherry
- #
- # calculate G+C+S content
- # (from gbench)
- import sys
- import cgi
- def gc_content(seq):
- gc_count = 0;
- for base in seq:
- if(base == 'G' or base == 'C' or base == 'S'):
- gc_count = gc_count + 1
- return float(gc_count) / len(seq)
- 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 "gc.py",
- menu-item "Test scripts/GC content",
- tooltip "G+C+S content by a python script ",
- commands algo {
- {
- command 3,
- args {
- {
- name "locs",
- desc "Locations to evaluate",
- data array {
- object {
- docaddr "(nil)",
- objaddr "(nil)",
- subtype "Seq-loc"
- }
- }
- }
- }
- }
- }
- }
- '''
- sys.exit(0)
- # otherwise, run
- locs = args['locs']
- for loc in locs:
- seq = cgi.parse_qs(loc);
- print seq['short_title'][0], 't', gc_content(seq['seq'][0])
- # ===========================================================================
- # $Log: gc.py,v $
- # Revision 1000.0 2003/10/31 21:38:33 gouriano
- # PRODUCTION: IMPORTED [ORIGINAL] Dev-tree R1.3
- #
- # Revision 1.3 2003/10/29 20:12:05 jcherry
- # Reflect new spec for plugin args
- #
- # Revision 1.2 2003/10/07 19:12:25 jcherry
- # Reflected change of PluginURL to PluginValue (changed addr to
- # value in asn.1)
- #
- # Revision 1.1 2003/07/28 18:24:31 jcherry
- # Initial version
- #
- # ===========================================================================
- #
- # ===========================================================================
- # PRODUCTION $Log: gc.py,v $
- # PRODUCTION Revision 1000.0 2003/10/31 21:38:33 gouriano
- # PRODUCTION PRODUCTION: IMPORTED [ORIGINAL] Dev-tree R1.3
- # PRODUCTION
- # ===========================================================================
- #