root/galaxy-central/eggs/bx_python-0.5.0_dev_f74aec067563-py2.6-macosx-10.6-universal-ucs2.egg/EGG-INFO/scripts/maf_thread_for_species.py @ 3

リビジョン 3, 1.5 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1#!/usr/bin/python2.6
2
3"""
4Read a maf file from stdin and write out a new maf with only blocks having all of
5the passed in species, after dropping any other species and removing columns
6containing only gaps. By default this will attempt to fuse together any blocks
7which are adjacent after the unwanted species have been dropped.
8
9usage: %prog species1 species2 ... < maf
10    -n, --nofuse: Don't attempt to join blocks, just remove rows.
11"""
12
13import psyco_full
14
15import bx.align.maf
16import copy
17import sys
18
19from bx.align.tools.thread import *
20from bx.align.tools.fuse import *
21
22from itertools import *
23
24from bx.cookbook import doc_optparse
25
26def main():
27
28    options, args = doc_optparse.parse( __doc__ )
29
30    try:
31        species = args
32        # Allow a comma separated list, TODO: allow a newick format tree
33        if len( species ) == 1 and ',' in species[0]: species = species[0].split( ',' )
34        fuse = not( bool( options.nofuse ) )
35    except:
36        doc_optparse.exit()
37
38    maf_reader = bx.align.maf.Reader( sys.stdin )
39    maf_writer = bx.align.maf.Writer( sys.stdout )
40
41    if fuse:
42        maf_writer = FusingAlignmentWriter( maf_writer )
43   
44    for m in maf_reader:           
45        new_components = get_components_for_species( m, species )       
46        if new_components:
47            remove_all_gap_columns( new_components )         
48            m.components = new_components
49            m.score = 0.0
50            maf_writer.write( m )
51
52    maf_reader.close()
53    maf_writer.close()
54   
55if __name__ == "__main__": main()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。