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

allpy

view repeats/repeats.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 4e6e85851133
children
line source
1 """
2 Repeats joining tool
4 Rereats input format:
5 input_id pos_from pos_to
6 """
8 from allpy import config, alignment, block, sequence
9 from allpy.processors import Muscle
10 Sequence = sequence.Sequence
11 Block = block.Block
12 Alignment = alignment.Alignment
13 import argparse
14 import os
15 from tempfile import NamedTemporaryFile
17 r = argparse.FileType('r')
18 w = argparse.FileType('w')
20 p = argparse.ArgumentParser(
21 description='Repeats joining tool',
22 formatter_class=argparse.ArgumentDefaultsHelpFormatter,
23 #~ argument_default=argparse.SUPPRESS,
24 )
26 p.add_argument('-v','--version',action='version',version='%(prog)s 1.0')
27 p.add_argument('-i',help='Input fasta file with genome',metavar='FILE',type=r,required=True)
28 p.add_argument('-I',help='Input text file with repeats',metavar='FILE',type=r,required=True)
29 p.add_argument('-n',help='Fasta identifier',metavar='name',required=True)
30 p.add_argument('-r',help='Repeat identifier',metavar='name',type=int,required=True)
31 p.add_argument('-o',help='Output alignment file',metavar='FILE',type=w,required=True)
33 tmp_file = None
35 try:
36 args = p.parse_args()
37 repeat_copies_pos = []
38 for line in p.i:
39 line = line.strip()
40 if not line:
41 continue
42 try:
43 repeat_type, pos_from, pos_to = line.strip()
44 pos_from = int(pos_from)
45 pos_to = int(pos_to)
46 except:
47 print "Warning: wrong input line '%s'" % line
48 if repeat_type == p.r:
49 repeat_copies_pos.append((pos_from, pos_to))
50 repeat_copies = []
51 for pos_from, pos_to in repeat_copies_pos:
52 seq = Sequence.file_slice(p.I, pos_from, pos_to, p.r
53 repeat_copies.append(seq)
54 alignment = Alignment.from_sequences(*repeat_copies)
55 alignment.process(Muscle())
56 alignment.save_fasta(p.o)
58 except Exception, t:
59 print t
60 exit()
62 if tmp_file:
63 os.unlink(tmp_file)