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
2 """Flush all monomers in given range to the left, all gaps to the right.
4 All position indexes are counting from 1.
9 from allpy import protein
12 alignment = protein.Alignment().append_file(open(options.in_file))
16 options.end = len(alignment.columns)
17 columns = alignment.columns[options.begin-1:options.end]
18 block = protein.Block.from_alignment(alignment, columns=columns)
20 alignment.to_file(open(options.out_file, "w"))
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",
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()
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.")
48 # vim: set et ts=4 sts=4 sw=4: