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

リビジョン 3, 0.9 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
5of the required in species, after dropping any other species and removing
6columns containing only gaps.
7
8usage: %prog species,species2,... < maf
9"""
10
11import psyco_full
12
13import bx.align.maf
14import copy
15import sys
16
17from itertools import *
18
19def main():
20
21    species = sys.argv[1].split( ',' )
22
23    maf_reader = bx.align.maf.Reader( sys.stdin )
24    maf_writer = bx.align.maf.Writer( sys.stdout )
25
26    for m in maf_reader:       
27        new_components = []   
28        for comp in m.components:
29            if comp.src.split( '.' )[0] in species:
30                new_components.append( comp )
31        m.components = new_components
32        m.remove_all_gap_columns()
33        if len( m.components ) > 1:
34            maf_writer.write( m )
35       
36    maf_reader.close()
37    maf_writer.close()
38
39if __name__ == "__main__":
40    main()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。