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

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

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

行番号 
1#!/usr/bin/python2.6
2
3"""
4For each block in a maf file (read from stdin) write a sequence of ints
5corresponding to the columns of the block after applying the provided sequence
6mapping.
7
8The 'correct' number of species is determined by the mapping file, blocks not having
9this number of species will be ignored.
10
11usage: %prog mapping_file
12"""
13
14from __future__ import division
15
16import psyco_full
17
18import bx.align.maf
19from bx import seqmapping
20import string
21import sys
22
23def main():
24
25    if len( sys.argv ) > 1:
26        _, alpha_map = seqmapping.alignment_mapping_from_file( file( sys.argv[1] ) )
27    else:
28        alpha_map = None
29
30    for maf in bx.align.maf.Reader( sys.stdin ):
31        # Translate alignment to ints
32        int_seq = seqmapping.DNA.translate_list( [ c.text for c in maf.components ] )
33        # Apply mapping
34        if alpha_map:
35            int_seq = alpha_map.translate( int_seq )
36        # Write ints separated by spaces
37        for i in int_seq: print i,
38        print
39
40if __name__ == "__main__": main()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。