Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
Bio.PDB.DSSP.DSSP Class Reference
Inheritance diagram for Bio.PDB.DSSP.DSSP:
Inheritance graph
[legend]
Collaboration diagram for Bio.PDB.DSSP.DSSP:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __contains__
def __getitem__
def __len__
def has_key
def keys
def __iter__

Public Attributes

 property_dict
 property_keys
 property_list

Detailed Description

Run DSSP on a pdb file, and provide a handle to the 
DSSP secondary structure and accessibility.

Note that DSSP can only handle one model.

Example:

    >>> p = PDBParser()
    >>> structure = p.get_structure("1MOT", "1MOT.pdb")
    >>> model = structure[0]
    >>> dssp = DSSP(model, "1MOT.pdb")
    >>> # DSSP data is accessed by a tuple (chain_id, res_id)
    >>> a_key = dssp.keys()[2]
    >>> # residue object, secondary structure, solvent accessibility,
    >>> # relative accessiblity, phi, psi
    >>> dssp[a_key]
    (<Residue ALA het=  resseq=251 icode= >,
    'H',
    72,
    0.67924528301886788,
    -61.200000000000003,
    -42.399999999999999)

Definition at line 162 of file DSSP.py.


Constructor & Destructor Documentation

def Bio.PDB.DSSP.DSSP.__init__ (   self,
  model,
  pdb_file,
  dssp = "dssp" 
)
@param model: the first model of the structure
@type model: L{Model}

@param pdb_file: a PDB file
@type pdb_file: string

@param dssp: the dssp executable (ie. the argument to os.system)
@type dssp: string

Reimplemented from Bio.PDB.AbstractPropertyMap.AbstractResiduePropertyMap.

Definition at line 188 of file DSSP.py.

00188 
00189     def __init__(self, model, pdb_file, dssp="dssp"):
00190         """
00191         @param model: the first model of the structure
00192         @type model: L{Model}
00193 
00194         @param pdb_file: a PDB file
00195         @type pdb_file: string
00196 
00197         @param dssp: the dssp executable (ie. the argument to os.system)
00198         @type dssp: string
00199         """
00200         # create DSSP dictionary
00201         dssp_dict, dssp_keys = dssp_dict_from_pdb_file(pdb_file, dssp)
00202         dssp_map = {}
00203         dssp_list = []
00204 
00205         def resid2code(res_id):
00206             """Serialize a residue's resseq and icode for easy comparison."""
00207             return '%s%s' % (res_id[1], res_id[2])
00208 
00209         # Now create a dictionary that maps Residue objects to 
00210         # secondary structure and accessibility, and a list of 
00211         # (residue, (secondary structure, accessibility)) tuples
00212         for key in dssp_keys:
00213             chain_id, res_id = key
00214             chain = model[chain_id]
00215             try:
00216                 res = chain[res_id]
00217             except KeyError:
00218                 # In DSSP, HET field is not considered in residue identifier.
00219                 # Thus HETATM records may cause unnecessary exceptions.
00220                 # (See 3jui chain A res 593.)
00221                 # Try the lookup again with all HETATM other than water
00222                 res_seq_icode = resid2code(res_id)
00223                 for r in chain:
00224                     if r.id[0] not in (' ', 'W'):
00225                         # Compare resseq + icode
00226                         if resid2code(r.id) == res_seq_icode:
00227                             # Found a matching residue
00228                             res = r
00229                             break
00230                 else:
00231                     raise KeyError(res_id)
00232 
00233             # For disordered residues of point mutations, BioPython uses the
00234             # last one as default, But DSSP takes the first one (alternative
00235             # location is blank, A or 1). See 1h9h chain E resi 22.
00236             # Here we select the res in which all atoms have altloc blank, A or
00237             # 1. If no such residues are found, simply use the first one appears
00238             # (as DSSP does).
00239             if res.is_disordered() == 2:
00240                 for rk in res.disordered_get_id_list():
00241                     # All atoms in the disordered residue should have the same
00242                     # altloc, so it suffices to check the altloc of the first
00243                     # atom.
00244                     altloc = res.child_dict[rk].get_list()[0].get_altloc()
00245                     if altloc in tuple('A1 '):
00246                         res.disordered_select(rk)
00247                         break
00248                 else:
00249                     # Simply select the first one
00250                     res.disordered_select(res.disordered_get_id_list()[0])
00251 
00252             # Sometimes point mutations are put into HETATM and ATOM with altloc
00253             # 'A' and 'B'.
00254             # See 3piu chain A residue 273:
00255             #   <Residue LLP het=H_LLP resseq=273 icode= >
00256             #   <Residue LYS het=  resseq=273 icode= >
00257             # DSSP uses the HETATM LLP as it has altloc 'A'
00258             # We check the altloc code here.
00259             elif res.is_disordered() == 1:
00260                 # Check altloc of all atoms in the DisorderedResidue. If it
00261                 # contains blank, A or 1, then use it.  Otherwise, look for HET
00262                 # residues of the same seq+icode.  If not such HET residues are
00263                 # found, just accept the current one.
00264                 altlocs = set(a.get_altloc() for a in res.get_unpacked_list())
00265                 if altlocs.isdisjoint('A1 '):
00266                     # Try again with all HETATM other than water
00267                     res_seq_icode = resid2code(res_id)
00268                     for r in chain:
00269                         if r.id[0] not in (' ', 'W'):
00270                             if (resid2code(r.id) == res_seq_icode and
00271                                 r.get_list()[0].get_altloc() in tuple('A1 ')):
00272                                 res = r
00273                                 break
00274 
00275             aa, ss, acc, phi, psi = dssp_dict[key]
00276             res.xtra["SS_DSSP"] = ss
00277             res.xtra["EXP_DSSP_ASA"] = acc
00278             res.xtra["PHI_DSSP"] = phi
00279             res.xtra["PSI_DSSP"] = psi
00280             # Relative accessibility
00281             resname = res.get_resname()
00282             try:
00283                 rel_acc = acc/MAX_ACC[resname]
00284             except KeyError:
00285                 # Invalid value for resname
00286                 rel_acc = 'NA'
00287             else:
00288                 if rel_acc > 1.0:
00289                     rel_acc = 1.0
00290             res.xtra["EXP_DSSP_RASA"] = rel_acc
00291             # Verify if AA in DSSP == AA in Structure
00292             # Something went wrong if this is not true!
00293             # NB: DSSP uses X often
00294             resname = to_one_letter_code.get(resname, 'X')
00295             if resname == "C":
00296                 # DSSP renames C in C-bridges to a,b,c,d,...
00297                 # - we rename it back to 'C'
00298                 if _dssp_cys.match(aa):
00299                     aa = 'C'
00300             # Take care of HETATM again
00301             if (resname != aa) and (res.id[0] == ' ' or aa != 'X'):
00302                 raise PDBException("Structure/DSSP mismatch at %s" % res)
00303             dssp_map[key] = ((res, ss, acc, rel_acc, phi, psi))
00304             dssp_list.append((res, ss, acc, rel_acc, phi, psi))
00305 
00306         AbstractResiduePropertyMap.__init__(self, dssp_map, dssp_keys,
00307                 dssp_list)
00308 

Here is the call graph for this function:


Member Function Documentation

True if the mapping has a property for this residue.

Example:
    >>> if (chain_id, res_id) in apmap:
    ...     res, prop = apmap[(chain_id, res_id)]

@param chain_id: chain id
@type chain_id: char 

@param res_id: residue id
@type res_id: char 

Definition at line 18 of file AbstractPropertyMap.py.

00018 
00019     def __contains__(self, id):
00020         """True if the mapping has a property for this residue.
00021 
00022         Example:
00023             >>> if (chain_id, res_id) in apmap:
00024             ...     res, prop = apmap[(chain_id, res_id)]
00025 
00026         @param chain_id: chain id
00027         @type chain_id: char 
00028 
00029         @param res_id: residue id
00030         @type res_id: char 
00031         """
00032         translated_id = self._translate_id(id)
00033         return (translated_id in self.property_dict)

Here is the call graph for this function:

def Bio.PDB.AbstractPropertyMap.AbstractPropertyMap.__getitem__ (   self,
  key 
) [inherited]
Return property for a residue.

@param chain_id: chain id
@type chain_id: char 

@param res_id: residue id
@type res_id: int or (char, int, char) 

@return: some residue property 
@rtype: anything (can be a tuple)

Definition at line 34 of file AbstractPropertyMap.py.

00034 
00035     def __getitem__(self, key):
00036         """
00037         Return property for a residue.
00038 
00039         @param chain_id: chain id
00040         @type chain_id: char 
00041 
00042         @param res_id: residue id
00043         @type res_id: int or (char, int, char) 
00044 
00045         @return: some residue property 
00046         @rtype: anything (can be a tuple)
00047         """
00048         translated_id=self._translate_id(key)
00049         return self.property_dict[translated_id]

Here is the call graph for this function:

Here is the caller graph for this function:

Iterate over the (entity, property) list. Handy alternative to 
the dictionary-like access.

Example:
    >>> for (res, property) in iter(map):
    ...     print res, property

@return: iterator

Definition at line 93 of file AbstractPropertyMap.py.

00093 
00094     def __iter__(self):
00095         """
00096         Iterate over the (entity, property) list. Handy alternative to 
00097         the dictionary-like access.
00098 
00099         Example:
00100             >>> for (res, property) in iter(map):
00101             ...     print res, property
00102 
00103         @return: iterator
00104         """
00105         for i in range(0, len(self.property_list)):
00106             yield self.property_list[i]
00107 

Here is the caller graph for this function:

Return number of residues for which the property is available.

@return: number of residues
@rtype: int

Definition at line 50 of file AbstractPropertyMap.py.

00050 
00051     def __len__(self):
00052         """
00053         Return number of residues for which the property is available.
00054 
00055         @return: number of residues
00056         @rtype: int
00057         """
00058         return len(self.property_dict)

def Bio.PDB.AbstractPropertyMap.AbstractPropertyMap.has_key (   self,
  id 
) [inherited]
True if the mapping has a property for this residue.

(Obsolete; use "id in mapping" instead.)

Example:

    >>> if apmap.has_key((chain_id, res_id)):
    ...     res, prop = apmap[(chain_id, res_id)]

Is equivalent to:

    >>> if (chain_id, res_id) in apmap:
    ...     res, prop = apmap[(chain_id, res_id)]

@param chain_id: chain id
@type chain_id: char 

@param res_id: residue id
@type res_id: char 

Definition at line 59 of file AbstractPropertyMap.py.

00059 
00060     def has_key(self, id):
00061         """True if the mapping has a property for this residue.
00062 
00063         (Obsolete; use "id in mapping" instead.)
00064 
00065         Example:
00066 
00067             >>> if apmap.has_key((chain_id, res_id)):
00068             ...     res, prop = apmap[(chain_id, res_id)]
00069 
00070         Is equivalent to:
00071 
00072             >>> if (chain_id, res_id) in apmap:
00073             ...     res, prop = apmap[(chain_id, res_id)]
00074 
00075         @param chain_id: chain id
00076         @type chain_id: char 
00077 
00078         @param res_id: residue id
00079         @type res_id: char 
00080         """
00081         import warnings
00082         warnings.warn("This function is obsolete; use 'id in mapping' instead", PendingDeprecationWarning)
00083         return (id in self)

Return the list of residues.

@return: list of residues for which the property was calculated
@rtype: [(chain_id, res_id), (chain_id, res_id),...] 

Definition at line 84 of file AbstractPropertyMap.py.

00084 
00085     def keys(self):
00086         """
00087         Return the list of residues.
00088 
00089         @return: list of residues for which the property was calculated
00090         @rtype: [(chain_id, res_id), (chain_id, res_id),...] 
00091         """
00092         return self.property_keys

Here is the caller graph for this function:


Member Data Documentation

Definition at line 11 of file AbstractPropertyMap.py.

Definition at line 12 of file AbstractPropertyMap.py.

Definition at line 13 of file AbstractPropertyMap.py.


The documentation for this class was generated from the following file: