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

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

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

行番号 
1#!/usr/bin/python2.6
2
3"""
4Application to convert AXT file to FASTA file. Reads an AXT file from standard
5input and writes a FASTA file to standard out.
6
7usage: %prog < axt_file > fasta_file
8"""
9
10__author__ = "Bob Harris (rsharris@bx.psu.edu)"
11
12import sys
13import bx.align.axt
14
15def usage(s=None):
16        message = """
17axt_to_fasta < axt_file > fasta_file
18"""
19        if (s == None): sys.exit (message)
20        else:           sys.exit ("%s\n%s" % (s,message))
21
22
23def main():
24
25        # check the command line
26
27        if (len(sys.argv) > 1):
28                usage("give me no arguments")
29
30        # convert the alignment blocks
31
32        reader = bx.align.axt.Reader(sys.stdin,support_ids=True,\
33                                     species1="",species2="")
34
35        for a in reader:
36                if ("id" in a.attributes): id = a.attributes["id"]
37                else:                      id = None
38                print_component_as_fasta(a.components[0],id)
39                print_component_as_fasta(a.components[1],id)
40                print
41
42
43# $$$ this should be moved to a bx.align.fasta module
44
45def print_component_as_fasta(c,id=None):
46        header = ">%s_%s_%s" % (c.src,c.start,c.start+c.size)
47        if (id != None): header += " " + id
48        print header
49        print c.text
50
51
52if __name__ == "__main__": main()
53
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。