Topology

Topology

class topology.CharmmTopology[source]

Bases: object

This class contains charmm topology information used other modules.

The output topology dictionary looks like the following examples:

Examples

>>> import pprint
>>> import sasmol.topology as topology
>>> test = topology.CharmmTopology()
>>> test.read_charmm_topology()
>>> pprint.pprint(test.topology_info['NTER'],width=100)
{'ATOM': [['N', 'NH3', '-0.30'],
      ['HT1', 'HC', '0.33'],
      ['HT2', 'HC', '0.33'],
      ['HT3', 'HC', '0.33'],
      ['CA', 'CT1', '0.21'],
      ['HA', 'HB', '0.10']],
'BOND': [['HT1', 'N'], ['HT2', 'N'], ['HT3', 'N']],
'DELE': [['ATOM', 'HN']],
'DONO': ['HT1', 'N', 'HT2', 'N', 'HT3', 'N'],
'IC': [['HT1', 'N', 'CA', 'C', '0.0000', '0.0000', '180.0000', '0.0000', '0.0000'],
        ['HT2', 'CA', '*N', 'HT1', '0.0000', '0.0000', '120.0000', '0.0000', '0.0000'],
        ['HT3', 'CA', '*N', 'HT2', '0.0000', '0.0000', '120.0000', '0.0000', '0.0000']],
'TOTAL_CHARGE': '1.00'}
>>> import pprint
>>> import sasmol.topology as topology
>>> test = topology.CharmmTopology()
>>> test.read_charmm_topology()
>>> pprint.pprint(test.topology_info['ALA'],width=100)
{'ACCE': ['O', 'C'],
'ATOM': [['N', 'NH1', '-0.47'],
        ['HN', 'H', '0.31'],
        ['CA', 'CT1', '0.07'],
        ['HA', 'HB', '0.09'],
        ['CB', 'CT3', '-0.27'],
        ['HB1', 'HA', '0.09'],
        ['HB2', 'HA', '0.09'],
        ['HB3', 'HA', '0.09'],
        ['C', 'C', '0.51'],
        ['O', 'O', '-0.51']],
'BOND': [['CB', 'CA'],
        ['N', 'HN'],
        ['N', 'CA'],
        ['C', 'CA'],
        ['C', '+N'],
        ['CA', 'HA'],
        ['CB', 'HB1'],
        ['CB', 'HB2'],
        ['CB', 'HB3']],
'DONO': ['HN', 'N'],
'DOUB': [['O', 'C']],
'IC': [['-C', 'CA', '*N', 'HN', '1.3551', '126.4900', '180.0000', '115.4200', '0.9996'],
        ['-C', 'N', 'CA', 'C', '1.3551', '126.4900', '180.0000', '114.4400', '1.5390'],
        ['N', 'CA', 'C', '+N', '1.4592', '114.4400', '180.0000', '116.8400', '1.3558'],
        ['+N', 'CA', '*C', 'O', '1.3558', '116.8400', '180.0000', '122.5200', '1.2297'],
        ['CA', 'C', '+N', '+CA', '1.5390', '116.8400', '180.0000', '126.7700', '1.4613'],
        ['N', 'C', '*CA', 'CB', '1.4592', '114.4400', '123.2300', '111.0900', '1.5461'],
        ['N', 'C', '*CA', 'HA', '1.4592', '114.4400', '-120.4500', '106.3900', '1.0840'],
        ['C', 'CA', 'CB', 'HB1', '1.5390', '111.0900', '177.2500', '109.6000', '1.1109'],
        ['HB1', 'CA', '*CB', 'HB2', '1.1109', '109.6000', '119.1300', '111.0500', '1.1119'],
        ['HB1', 'CA', '*CB', 'HB3', '1.1109', '109.6000', '-119.5800', '111.6100', '1.1114']],
'IMPR': [['N', '-C', 'CA', 'HN'], ['C', 'CA', '+N', 'O']],
self parameter is not shown in the Parameters section in the documentation
add(dictionary, key, value, **kwargs)[source]

This method is used by the self.read_topology method.

It will check whether the key is in the dictionary: if yes, append value to dictionary[key] if no, initialize dictionary[key] as [value]

Parameters:
  • dictionary – dictionary : containing existing key, value pairs
  • key – dictionary key : key to query and perhaps intialize
  • value – dictionary value : value add
  • kwargs – optional future arguments
Returns:

Return type:

updated dictionary

Examples

>>> import sasmol.topology as topology
>>> d = {}
>>> d['ALA'] = 'RESI ALA'
>>> test = topology.CharmmTopology()
>>> test.add(d, 'GLU', 'GLU')
>>> d
{'GLU': ['GLU'], 'ALA': 'RESI ALA'}
>>> test.add(d, 'ASP', 'RESI ASP')
>>> d
{'ASP': ['RESI ASP'], 'GLU': ['GLU'], 'ALA': 'RESI ALA'}
check_charmm_atomic_order_reorganize(**kwargs)[source]

re-organize the atomic list according to the charmm topology contract do nothing if the atomic order alreay match that in the charmm topology file meanwhile make sure there are no missing or extra atoms H-atoms are required Patch N-ter for the first residue and C-ter for the last residue in each segment

Parameters:kwargs – optional future arguments

Examples

>>> import sasmol.system as system
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> molecule.check_charmm_atomic_order_reorganize()
Returns:list : with error code
Return type:error

Note

error code needs to be addressed and handled globally

compare_list_ignore_order(l1, l2, **kwargs)[source]

Compare two lists while ignoring order

Parameters:
  • l1 – list : list 1
  • l2 – list : list 2
  • kwargs – optional future arguments

Examples

>>> import sasmol.topology as topology
>>> test = topology.CharmmTopology()
>>> l1 = [1, 2, 4]
>>> l2 = [2, 1, 4]
>>> test.compare_list_ignore_order(l1, l2)
True
Returns:
Return type:Boolean
patch_charmm_residue_atoms(residue, patch, **kwargs)[source]

Applies ‘patch’ to ‘residue’ based on the charmm topology definition to add / remove atoms as needed. Only ATOM and DELE records are accommodated

Parameters:
  • residue – string : residue name
  • patch – string : patch name
  • kwargs – optional future arguments

Examples

>>> import sasmol.system as system
>>> molecule = system.Molecule('hiv1_gag.pdb')
>>> molecule.check_charmm_atomic_order_reorganize()
>>> molecule.patch_charmm_residue_atoms('GLY','GLYP')
Returns:
Return type:updated dictionary entry for residue in question

Note

Error list is defined and used, but not returned. Needs to be handled globally.

read_charmm_topology(topology_file_path='', topology_file_name='top_all27_prot_na.inp', **kwargs)[source]

Read and parse the charmm topology file A comprehensive dictionary (topology_info) will be built to store all the topology information The strategy for parsing topology file is to split words in each line

Parameters:
  • topology_file_path – string : default = ‘’
  • topology_file_name – string : default = ‘top_all27_prot_na.inp’
  • kwargs – optional future arguments

Examples

>>> import pprint
>>> import sasmol.topology as topology
>>> test = topology.CharmmTopology()
>>> test.read_charmm_topology()
>>> pprint.pprint(test.topology_info['NTER'],width=100)
{'ATOM': [['N', 'NH3', '-0.30'],
    ['HT1', 'HC', '0.33'],
    ['HT2', 'HC', '0.33'],
    ['HT3', 'HC', '0.33'],
    ['CA', 'CT1', '0.21'],
    ['HA', 'HB', '0.10']],
'BOND': [['HT1', 'N'], ['HT2', 'N'], ['HT3', 'N']],
'DELE': [['ATOM', 'HN']],
'DONO': ['HT1', 'N', 'HT2', 'N', 'HT3', 'N'],
'IC': [['HT1', 'N', 'CA', 'C', '0.0000', '0.0000', '180.0000', '0.0000', '0.0000'],
        ['HT2', 'CA', '*N', 'HT1', '0.0000', '0.0000', '120.0000', '0.0000', '0.0000'],
        ['HT3', 'CA', '*N', 'HT2', '0.0000', '0.0000', '120.0000', '0.0000', '0.0000']],
'TOTAL_CHARGE': '1.00'}
Returns:list : with error code
Return type:error

Note

error code needs to be addressed and handled globally

setup_charmm_residue_atoms(**kwargs)[source]

Build the atom list of all the residues in the charmm topology file

Parameters:kwargs – optional future arguments

Examples

>>> import sasmol.topology as topology
>>> test = topology.CharmmTopology()
>>> test.read_charmm_topology()
>>> test.setup_charmm_residue_atoms()
Returns:self.charmm_residue_atoms
Return type:new dictionary entry for residue in question
setup_cys_patch_atoms_simple(**kwargs)[source]

A way to set up cys patch atoms simply remove HG1 atom from the atom list

Parameters:kwargs – optional future arguments

Examples

>>> import sasmol.topology as topology
>>> import pprint
>>> test = topology.CharmmTopology()
>>> test.read_charmm_topology()
>>> pprint.pprint(self.topology_info['CYS']['ATOM'])
[['N', 'NH1', '-0.47'],
['HN', 'H', '0.31'],
['CA', 'CT1', '0.07'],
['HA', 'HB', '0.09'],
['CB', 'CT2', '-0.11'],
['HB1', 'HA', '0.09'],
['HB2', 'HA', '0.09'],
['SG', 'S', '-0.23'],
['HG1', 'HS', '0.16'],
['C', 'C', '0.51'],
['O', 'O', '-0.51']]
>>> pprint.pprint(test.setup_cys_patch_atoms_simple(), width=80)
[['N', 'NH1', '-0.47'],
['HN', 'H', '0.31'],
['CA', 'CT1', '0.07'],
['HA', 'HB', '0.09'],
['CB', 'CT2', '-0.11'],
['HB1', 'HA', '0.09'],
['HB2', 'HA', '0.09'],
['SG', 'S', '-0.23'],
['C', 'C', '0.51'],
['O', 'O', '-0.51']]
Returns:
Return type:updated dictionary entry for residue in question