Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/rev/65c3e3aad2e4
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 00:06:03 2012
Кодировка:
allpy: 65c3e3aad2e4

allpy

changeset 79:65c3e3aad2e4

start integration with biopython.PDB pdb.py -> allpy_pdb.py to prevent overloading standart python pdb.py
author boris <bnagaev@gmail.com>
date Wed, 29 Sep 2010 09:50:35 +0400
parents 49c82b7d09dc
children 52ca670d6368
files blocks3d/wt/TODO lib/allpy_pdb.py lib/monomer.py lib/pdb.py lib/sequence.py
diffstat 5 files changed, 92 insertions(+), 30 deletions(-) [+]
line diff
     1.1 --- a/blocks3d/wt/TODO	Wed Sep 29 08:26:17 2010 +0400
     1.2 +++ b/blocks3d/wt/TODO	Wed Sep 29 09:50:35 2010 +0400
     1.3 @@ -1,2 +1,2 @@
     1.4  mktemp -> mkstemp 
     1.5 -count number of running tasks (limit is N)
     1.6 ++ count number of running tasks (limit is N)
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/lib/allpy_pdb.py	Wed Sep 29 09:50:35 2010 +0400
     2.3 @@ -0,0 +1,60 @@
     2.4 +
     2.5 +import re
     2.6 +
     2.7 +# for pdb-codes
     2.8 +re1 = re.compile(r"(^|[^a-z0-9])([0-9][0-9a-z]{3})([^a-z0-9]([0-9a-z ]?)([^a-z0-9]([0-9]{1,3}))?)?($|[^a-z0-9])")
     2.9 +
    2.10 +# for files
    2.11 +re2 = re.compile(r"(^)([^^]+\.(ent|pdb))([^a-zA-Z0-9]([0-9A-Za-z ]?)([^a-zA-Z0-9]([0-9]{1,3}))?)?$")
    2.12 +
    2.13 +class Pdb(object):
    2.14 +    """
    2.15 +    """
    2.16 +	@staticmethod
    2.17 +	def std_id(pdb_id, pdb_chain, pdb_model=None):
    2.18 +		if pdb_model:
    2.19 +			return "%s_%s_%s" % pdb_id.lower().strip(), pdb_chain.upper().strip(), pdb_model
    2.20 +		else:
    2.21 +			return "%s_%s" % pdb_id.lower().strip(), pdb_chain.upper().strip()
    2.22 +	
    2.23 +	
    2.24 +	def std_id_parse(ID):
    2.25 +		"""
    2.26 +		Parse standart ID to pdb_code, chain and model
    2.27 +		"""
    2.28 +		if '.ent' in ID.lower() or '.pdb' in ID.lower():
    2.29 +			# it is file
    2.30 +			parseO = self.re2.search(ID) # files
    2.31 +		else:
    2.32 +			parseO = self.re1.search(ID.lower()) # pdb codes
    2.33 +		if not parseO:
    2.34 +			return None
    2.35 +		parse = parseO.groups()
    2.36 +		if len(parse) < 2:
    2.37 +			return None
    2.38 +		code = parse[1]
    2.39 +		chain = ''
    2.40 +		model = None
    2.41 +		if len(parse) >= 4:
    2.42 +			chain = parse[3]
    2.43 +			if chain:
    2.44 +				chain = chain.upper()
    2.45 +			if len(parse) >= 6:
    2.46 +				if parse[5]:
    2.47 +					model = parse[5]
    2.48 +		return code, chain, model
    2.49 +	
    2.50 +	
    2.51 +	
    2.52 +	
    2.53 +	
    2.54 +
    2.55 +#~ class Coordinates(object):
    2.56 +    """
    2.57 +    float x, y, z
    2.58 +    
    2.59 +    Coordinates(x, y, z) -> Coordinates
    2.60 +    Coordinates() -> new Coordinates
    2.61 +    """
    2.62 +
    2.63 +
     3.1 --- a/lib/monomer.py	Wed Sep 29 08:26:17 2010 +0400
     3.2 +++ b/lib/monomer.py	Wed Sep 29 09:50:35 2010 +0400
     3.3 @@ -1,12 +1,14 @@
     3.4  #!/usr/bin/python
     3.5  
     3.6 +import Bio.PDB
     3.7 +
     3.8  class Monomer(object):
     3.9      """
    3.10      code -- one-letter code
    3.11 -    
    3.12 -    pdb: dict
    3.13 -        key: (pdb_object, chain_name)
    3.14 -        value: coordinates_object
    3.15 +    pdb_residue -- Bio.PDB.Residue
    3.16      """
    3.17      def __init__(self,code):
    3.18          self.code=code
    3.19 +        
    3.20 +    def pdb_residue_set(self, pdb_residue):
    3.21 +        self.pdb_residue = pdb_residue
     4.1 --- a/lib/pdb.py	Wed Sep 29 08:26:17 2010 +0400
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,21 +0,0 @@
     4.4 -
     4.5 -class Pdb(object):
     4.6 -    """
     4.7 -    public:
     4.8 -		name -- in lower case
     4.9 -		chains -- list of chains in upper case
    4.10 -		get_coordinates(chain, number, alter_code)
    4.11 -	private:
    4.12 -		coordinates
    4.13 -    """
    4.14 -
    4.15 -
    4.16 -class Coordinates(object):
    4.17 -    """
    4.18 -    float x, y, z
    4.19 -    
    4.20 -    Coordinates(x, y, z) -> Coordinates
    4.21 -    Coordinates() -> new Coordinates
    4.22 -    """
    4.23 -
    4.24 -
     5.1 --- a/lib/sequence.py	Wed Sep 29 08:26:17 2010 +0400
     5.2 +++ b/lib/sequence.py	Wed Sep 29 09:50:35 2010 +0400
     5.3 @@ -1,5 +1,7 @@
     5.4  #!/usr/bin/python
     5.5 -import monomer 
     5.6 +import monomer
     5.7 +from Bio.PDB import PDBParser
     5.8 +from allpy_pdb.Pdb import std_id
     5.9  
    5.10  class Sequence(object):
    5.11      """
    5.12 @@ -7,11 +9,30 @@
    5.13      *   name -- str with the name of sequence
    5.14      *   description -- str with description of the sequence
    5.15      *   monomers -- list of monomer objects (aminoacids or nucleotides)
    5.16 +    *   pdb_chain -- Bio.PDB.Chain
    5.17      """
    5.18      def __init__(self, name, monomers, description=""):
    5.19 -        self.name=name
    5.20 -        self.description=description
    5.21 -        self.monomers=monomers 
    5.22 +        self.name = name
    5.23 +        self.description = description
    5.24 +        self.monomers = monomers 
    5.25  
    5.26      def __str__(self):
    5.27          return self.name
    5.28 +        
    5.29 +    def pdb_chain_set(self, pdb_file, pdb_id, pdb_chain, pdb_model=0):
    5.30 +        """
    5.31 +        Reads Pdb chain from file 
    5.32 +        and align each Monomer with PDB.Residue (TODO)
    5.33 +        """
    5.34 +        name = std_id(pdb_id, pdb_chain, pdb_model)
    5.35 +        self.pdb_chain = PDBParser().get_structure(name, pdb_file)[pdb_model][pdb_chain]
    5.36 +        
    5.37 +        
    5.38 +        
    5.39 +        
    5.40 +        
    5.41 +        
    5.42 +        
    5.43 +        
    5.44 +        
    5.45 +