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

# HG changeset patch
# User boris
# Date 1285739435 -14400
# Node ID 65c3e3aad2e4d36b613ab239403f13f407468b01
# Parent 49c82b7d09dca1fcbba19ba4dcb41260a1ee4d4a
start integration with biopython.PDB
pdb.py -> allpy_pdb.py to prevent overloading standart python pdb.py

diff -r 49c82b7d09dc -r 65c3e3aad2e4 blocks3d/wt/TODO
--- a/blocks3d/wt/TODO Wed Sep 29 08:26:17 2010 +0400
+++ b/blocks3d/wt/TODO Wed Sep 29 09:50:35 2010 +0400
@@ -1,2 +1,2 @@
mktemp -> mkstemp
-count number of running tasks (limit is N)
++ count number of running tasks (limit is N)
diff -r 49c82b7d09dc -r 65c3e3aad2e4 lib/allpy_pdb.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/allpy_pdb.py Wed Sep 29 09:50:35 2010 +0400
@@ -0,0 +1,60 @@
+
+import re
+
+# for pdb-codes
+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])")
+
+# for files
+re2 = re.compile(r"(^)([^^]+\.(ent|pdb))([^a-zA-Z0-9]([0-9A-Za-z ]?)([^a-zA-Z0-9]([0-9]{1,3}))?)?$")
+
+class Pdb(object):
+ """
+ """
+ @staticmethod
+ def std_id(pdb_id, pdb_chain, pdb_model=None):
+ if pdb_model:
+ return "%s_%s_%s" % pdb_id.lower().strip(), pdb_chain.upper().strip(), pdb_model
+ else:
+ return "%s_%s" % pdb_id.lower().strip(), pdb_chain.upper().strip()
+
+
+ def std_id_parse(ID):
+ """
+ Parse standart ID to pdb_code, chain and model
+ """
+ if '.ent' in ID.lower() or '.pdb' in ID.lower():
+ # it is file
+ parseO = self.re2.search(ID) # files
+ else:
+ parseO = self.re1.search(ID.lower()) # pdb codes
+ if not parseO:
+ return None
+ parse = parseO.groups()
+ if len(parse) < 2:
+ return None
+ code = parse[1]
+ chain = ''
+ model = None
+ if len(parse) >= 4:
+ chain = parse[3]
+ if chain:
+ chain = chain.upper()
+ if len(parse) >= 6:
+ if parse[5]:
+ model = parse[5]
+ return code, chain, model
+
+
+
+
+
+
+#~ class Coordinates(object):
+ """
+ float x, y, z
+
+ Coordinates(x, y, z) -> Coordinates
+ Coordinates() -> new Coordinates
+ """
+
+
diff -r 49c82b7d09dc -r 65c3e3aad2e4 lib/monomer.py
--- a/lib/monomer.py Wed Sep 29 08:26:17 2010 +0400
+++ b/lib/monomer.py Wed Sep 29 09:50:35 2010 +0400
@@ -1,12 +1,14 @@
#!/usr/bin/python

+import Bio.PDB
+
class Monomer(object):
"""
code -- one-letter code
-
- pdb: dict
- key: (pdb_object, chain_name)
- value: coordinates_object
+ pdb_residue -- Bio.PDB.Residue
"""
def __init__(self,code):
self.code=code
+
+ def pdb_residue_set(self, pdb_residue):
+ self.pdb_residue = pdb_residue
diff -r 49c82b7d09dc -r 65c3e3aad2e4 lib/pdb.py
--- a/lib/pdb.py Wed Sep 29 08:26:17 2010 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-
-class Pdb(object):
- """
- public:
- name -- in lower case
- chains -- list of chains in upper case
- get_coordinates(chain, number, alter_code)
- private:
- coordinates
- """
-
-
-class Coordinates(object):
- """
- float x, y, z
-
- Coordinates(x, y, z) -> Coordinates
- Coordinates() -> new Coordinates
- """
-
-
diff -r 49c82b7d09dc -r 65c3e3aad2e4 lib/sequence.py
--- a/lib/sequence.py Wed Sep 29 08:26:17 2010 +0400
+++ b/lib/sequence.py Wed Sep 29 09:50:35 2010 +0400
@@ -1,5 +1,7 @@
#!/usr/bin/python
-import monomer
+import monomer
+from Bio.PDB import PDBParser
+from allpy_pdb.Pdb import std_id

class Sequence(object):
"""
@@ -7,11 +9,30 @@
* name -- str with the name of sequence
* description -- str with description of the sequence
* monomers -- list of monomer objects (aminoacids or nucleotides)
+ * pdb_chain -- Bio.PDB.Chain
"""
def __init__(self, name, monomers, description=""):
- self.name=name
- self.description=description
- self.monomers=monomers
+ self.name = name
+ self.description = description
+ self.monomers = monomers

def __str__(self):
return self.name
+
+ def pdb_chain_set(self, pdb_file, pdb_id, pdb_chain, pdb_model=0):
+ """
+ Reads Pdb chain from file
+ and align each Monomer with PDB.Residue (TODO)
+ """
+ name = std_id(pdb_id, pdb_chain, pdb_model)
+ self.pdb_chain = PDBParser().get_structure(name, pdb_file)[pdb_model][pdb_chain]
+
+
+
+
+
+
+
+
+
+