Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/annotate/675b402094be/lib/fasta.py
Дата изменения: Unknown
Дата индексирования: Sun Mar 2 02:36:28 2014
Кодировка:
allpy: lib/fasta.py annotate

allpy

annotate lib/fasta.py @ 151:675b402094be

day commit -- a lot of changes fasta.py: universal save_fasta() determine_long_line -- for determine length of fasta sequence string in user input everywhere: standart long_line=60 --> 70 blocK.sequences_chains: returns sequences in order as in project added monomer pdb_secstr to store secondary structure pdb adding: some improvements and fixes fix in from_pdb_chain: use all peptides, not only first Sequence.pdb_files added to store information about pdb file for each chain dssp bindings to get secondary structure /sec_str -- tool to map secondary structure on each sequence of alignment
author boris (netbook) <bnagaev@gmail.com>
date Tue, 26 Oct 2010 00:40:36 +0400
parents
children 0ffdb88c13bd
rev   line source
bnagaev@151 1 def save_fasta(out_file, string, name, description='', long_line=70):
bnagaev@151 2 """ Saves given string to out_file in fasta_format
bnagaev@151 3
bnagaev@151 4 Splits long lines to substrings of length=long_line
bnagaev@151 5 To prevent this, set long_line=None
bnagaev@151 6 """
bnagaev@151 7 out_file.write(">%(name)s %(description)s \n" % {'name':name, 'description':description})
bnagaev@151 8 if long_line:
bnagaev@151 9 for i in range(0, len(string) // long_line + 1):
bnagaev@151 10 out_file.write("%s \n" % string[i*long_line : i*long_line + long_line])
bnagaev@151 11 else:
bnagaev@151 12 out_file.write("%s \n" % string)
bnagaev@151 13
bnagaev@151 14 def determine_long_line(in_file):
bnagaev@151 15 """ Returns maximum sequence line length in fasta file """
bnagaev@151 16 max_length = 70
bnagaev@151 17 start = False
bnagaev@151 18 for line in in_file:
bnagaev@151 19 if line[0:] != '>':
bnagaev@151 20 if start:
bnagaev@151 21 max_length = max(max_length, line.strip())
bnagaev@151 22 else:
bnagaev@151 23 start = True
bnagaev@151 24 return max_length