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

allpy

view allpy/fasta.py @ 251:9369dbad919d

Incompatible changes to Monomer interfaces. This branch does not work! - (!!) only changed allpy._monomer, not uses - (!!) removed (temporarily) classes for specific monomer types (DNAMonomer, etc) - refurbished allpy.data.AAcodes to allpy.data.codes with much cleaner interface - refurbished allpy._monomer for simplicity and more friendly interface Now it will (someday) be possible to say: a = Monomer.from_name("alanine") b = protein.Monomer.from_code1("a") c = protein.MonomerType.from_code3("ala") d = dna.Monomer.from_code3("DA") but impossible to say: d = protein.Monomer.from_code3("DA")
author Daniil Alexeyevsky <me.dendik@gmail.com>
date Mon, 13 Dec 2010 20:12:11 +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