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

allpy

changeset 897:cae08a1f7517

structure: allow to load custom pdbs Add new sequence name pattern to auto_pdb() method: file:path:chain:model:resi_begin:resi_end Like regular expression: file(:path(:chain(:model(:resi_begin(:resi_end)?)?)?)?)? close #124
author Boris Nagaev <bnagaev@gmail.com>
date Wed, 05 Oct 2011 20:42:15 +0300
parents 6134ae1dfdae
children 8454b8206bd8
files allpy/structure.py
diffstat 1 files changed, 15 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- a/allpy/structure.py	Fri Sep 23 14:10:25 2011 +0400
     1.2 +++ b/allpy/structure.py	Wed Oct 05 20:42:15 2011 +0300
     1.3 @@ -27,11 +27,18 @@
     1.4  
     1.5  
     1.6  # for pdb-codes
     1.7 +pdb_file_pattern = re.compile(r"^file:(?P<path>[^:]+)(:(?P<chain>[0-9a-z ])(:(?P<model>[0-9]{1,3})(:(?P<resi_begin>-?\d+)(:(?P<resi_end>-?\d+))?)?)?)?", re.I)
     1.8 +
     1.9 +# for pdb-codes
    1.10  re1 = re.compile(r"(^|[^a-z0-9])(?P<code>[0-9][0-9a-z]{3})([^a-z0-9](?P<chain>[0-9a-z ]?)([^a-z0-9/](?P<model>[0-9]{1,3}))?)?(/(?P<resi_begin>-?\d+):(?P<resi_end>-?\d+))?", re.I)
    1.11  
    1.12  def pdb_id_parse(ID):
    1.13 -    match = re1.search(ID)
    1.14 +    if ID.startswith('file:'):
    1.15 +        match = pdb_file_pattern.search(ID)
    1.16 +    else:
    1.17 +        match = re1.search(ID)
    1.18      if not match:
    1.19 +        print 21
    1.20          return None
    1.21      d = match.groupdict()
    1.22      if 'chain' not in d or not d['chain']:
    1.23 @@ -226,12 +233,17 @@
    1.24          """
    1.25          match = pdb_id_parse(self.name)
    1.26          assert match
    1.27 -        code = match['code']
    1.28 +        if 'path' in match:
    1.29 +            code = 'path'
    1.30 +            pdb_file = open(match['path'])
    1.31 +            print match['path']
    1.32 +        else:
    1.33 +            code = match['code']
    1.34 +            pdb_file = pdb_getter(code)
    1.35          chain = match['chain']
    1.36          model = match['model']
    1.37          resi_begin = resi_begin or match['resi_begin']
    1.38          resi_end = resi_end or match['resi_end']
    1.39 -        pdb_file = pdb_getter(code)
    1.40          self.set_pdb_chain(pdb_file, code, chain, model, xyz_only=xyz_only,
    1.41              resi_begin=resi_begin, resi_end=resi_end)
    1.42