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

allpy

view allpy/fasta.py @ 239:292b74612a42

allpy: add base.py base.py will be module with all base (maybe abstract) classes
author boris (netbook) <bnagaev@gmail.com>
date Fri, 03 Dec 2010 22:19:13 +0300
parents 0ffdb88c13bd
children 4e6e85851133
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 sequences = in_file.read().split('>')
17 for sequence in sequences[1:]:
18 lines = sequence.split('\n')[1:]
19 if len(lines) >= 2:
20 return len(lines[0].strip())
21 return 70