Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/diff/675b402094be/lib/block.py
Дата изменения: Unknown
Дата индексирования: Sun Feb 3 18:21:06 2013
Кодировка:
allpy: lib/block.py diff

allpy

diff lib/block.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 f7dead025719
children 0c7f6117481b
line diff
     1.1 --- a/lib/block.py	Mon Oct 25 13:30:11 2010 +0400
     1.2 +++ b/lib/block.py	Tue Oct 26 00:40:36 2010 +0400
     1.3 @@ -10,6 +10,7 @@
     1.4  from Bio.PDB import Superimposer
     1.5  from tempfile import NamedTemporaryFile
     1.6  import os
     1.7 +from fasta import save_fasta
     1.8  
     1.9  class Block(object):
    1.10      """ Block of alignment
    1.11 @@ -44,25 +45,17 @@
    1.12          self.sequences = sequences
    1.13          self.positions = positions
    1.14      
    1.15 -    def save_fasta(self, out_file, long_line=60, gap='-'):
    1.16 +    def save_fasta(self, out_file, long_line=70, gap='-'):
    1.17          """ Saves alignment to given file in fasta-format 
    1.18          
    1.19 -        Splits long lines to substrings of length=long_line
    1.20 -        To prevent this, set long_line=None 
    1.21 -        
    1.22          No changes in the names, descriptions or order of the sequences
    1.23          are made.
    1.24          """
    1.25          for sequence in self.sequences:
    1.26 -            out_file.write(">%(name)s %(description)s \n" % sequence.__dict__)
    1.27              alignment_monomers = self.project.alignment[sequence]
    1.28              block_monomers = [alignment_monomers[i] for i in self.positions]
    1.29              string = ''.join([m.type.code1 if m else '-' for m in block_monomers])
    1.30 -            if long_line:
    1.31 -                for i in range(0, len(string) // long_line + 1):
    1.32 -                    out_file.write("%s \n" % string[i*long_line : i*long_line + long_line])
    1.33 -            else:
    1.34 -                out_file.write("%s \n" % string)
    1.35 +            save_fasta(out_file, string, sequence.name, sequence.description, long_line)
    1.36      
    1.37      def geometrical_cores(self, max_delta=config.delta, 
    1.38      timeout=config.timeout, minsize=config.minsize, 
    1.39 @@ -125,12 +118,9 @@
    1.40              monomers[i] = True
    1.41          return ''.join([x if m else gap for m in monomers])
    1.42      
    1.43 -    def save_xstring(self, out_file, name, description='', x='X', gap='-'):
    1.44 +    def save_xstring(self, out_file, name, description='', x='X', gap='-', long_line=70):
    1.45          """ Save xstring and name in fasta format """
    1.46 -        out_file.write(">%(name)s %(description)s \n" % \
    1.47 -        {'name':name, 'description':description})
    1.48 -        
    1.49 -        out_file.write("%(xstring)s \n" % {'xstring':self.xstring(x=x, gap=gap)})
    1.50 +        save_fasta(out_file, self.xstring(x=x, gap=gap), name, description, long_line)
    1.51      
    1.52      def monomers(self, sequence):
    1.53          """ Iterates monomers of this sequence from this block """
    1.54 @@ -143,9 +133,10 @@
    1.55      
    1.56      def sequences_chains(self):
    1.57          """ Iterates pairs (sequence, chain) """
    1.58 -        for sequence in self.sequences:
    1.59 -            for chain in sequence.pdb_chains:
    1.60 -                yield (sequence, chain)
    1.61 +        for sequence in self.project.sequences:
    1.62 +            if sequence in self.sequences:
    1.63 +                for chain in sequence.pdb_chains:
    1.64 +                    yield (sequence, chain)
    1.65      
    1.66      def superimpose(self):
    1.67          """ Superimpose all pdb_chains in this block """
    1.68 @@ -177,4 +168,3 @@
    1.69          
    1.70          os.unlink(NamedTemporaryFile)
    1.71      
    1.72 -