Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/file/tip/utils/flush_left.py
Дата изменения: Unknown
Дата индексирования: Tue Apr 12 07:56:07 2016
Кодировка:
allpy: b556c96c6719 utils/flush_left.py

allpy

view utils/flush_left.py @ 1168:b556c96c6719

blocks3d/www Makefile: never check certificates of github, they are too confusing for wget
author Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru>
date Mon, 26 May 2014 17:20:29 +0400
parents efca47965dc3
children
line source
1 #!/usr/bin/python
2 """Flush all monomers in given range to the left, all gaps to the right.
4 All position indexes are counting from 1.
5 """
6 import optparse
7 import sys
8 import os
9 from allpy import protein
11 def main():
12 alignment = protein.Alignment().append_file(open(options.in_file))
13 if not options.begin:
14 options.begin = 1
15 if not options.end:
16 options.end = len(alignment.columns)
17 columns = alignment.columns[options.begin-1:options.end]
18 block = protein.Block.from_alignment(alignment, columns=columns)
19 block.flush("left")
20 alignment.to_file(open(options.out_file, "w"))
21 if options.msf:
22 os.system("seqret " + options.out_file + " msf::" + options.out_file.split(".")[0] + ".msf")
23 os.system("rm " + options.out_file)
25 if __name__ == "__main__":
26 usage = "Usage: %s [options]\n\n%s" % (sys.argv[0], __doc__.strip())
27 parser = optparse.OptionParser(usage=usage)
28 parser.add_option("-i", "--in-file",
29 help="Input alignment file (in FASTA format)")
30 parser.add_option("-o", "--out-file",
31 help="Output file")
32 parser.add_option("-b", "--begin", type=int,
33 help="Position in alignment to start from")
34 parser.add_option("-e", "--end", type=int,
35 help="Position in alignment to end with")
36 parser.add_option("-m", "--msf", action='store_true',
37 help="Output in MSF format (FASTA by default)")
39 options, args = parser.parse_args()
41 if args:
42 parser.error("We take no positional arguments.")
43 if not options.in_file or not options.out_file:
44 parser.error("Both -i and -o parameters must be given.")
46 main()
48 # vim: set et ts=4 sts=4 sw=4: