Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/file/9b601bbb1fde/lib/fasta.py
Дата изменения: Unknown
Дата индексирования: Sun Feb 3 17:58:01 2013
Кодировка:
allpy: 9b601bbb1fde lib/fasta.py

allpy

view lib/fasta.py @ 155:9b601bbb1fde

implemented
author boris <bnagaev@gmail.com>
date Wed, 27 Oct 2010 08:25:11 +0400
parents
children 0ffdb88c13bd
line source
1 def save_fasta(out_file, string, name, description='', long_line=70):
2 """ Saves given string to out_file in fasta_format
4 Splits long lines to substrings of length=long_line
5 To prevent this, set long_line=None
6 """
7 out_file.write(">%(name)s %(description)s \n" % {'name':name, 'description':description})
8 if long_line:
9 for i in range(0, len(string) // long_line + 1):
10 out_file.write("%s \n" % string[i*long_line : i*long_line + long_line])
11 else:
12 out_file.write("%s \n" % string)
14 def determine_long_line(in_file):
15 """ Returns maximum sequence line length in fasta file """
16 max_length = 70
17 start = False
18 for line in in_file:
19 if line[0:] != '>':
20 if start:
21 max_length = max(max_length, line.strip())
22 else:
23 start = True
24 return max_length