Topology¶
Topology¶
- class sasmol.topology.Topology[source]¶
Bases:
sasmol.charmm_topology.CharmmTopologyThis class contains topology information used other modules.
- add(dictionary, key, value, **kwargs)¶
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
- 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'}
- charmm_names(**kwargs)¶
- Parameters
kwargs – optional future arguments
- Returns
dictionary : atom_name and list of atom names for hydrogen, carbon, nitrogen, oxygen, sulfur, phosphorus, other
- Return type
charmm_names
Examples
>>> import sasmol.properties as properties >>> properties = properties.Atomic() >>> properties.charmm_names()['sulfur'] ['SG', 'SD', '1SG', '2SG']
- check_charmm_atomic_order_reorganize(**kwargs)¶
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)¶
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
- Return type
Boolean
- create_fasta(**kwargs)[source]¶
Method to make a fasta file compatible lists of residue names
http://en.wikipedia.org/wiki/FASTA_format
- Parameters
kwargs – optional future arguments
- Returns
sets the fasta attribute in a system object
- Return type
self._fasta
Examples
>>> import sasmol.system as system >>> molecule = system.Molecule("hiv1_gag.pdb") >>> molecule.create_fasta() >>> print(molecule.fasta()[:5]) ['G', 'A', 'R', 'A', 'S']
>>> molecule.create_fasta(fasta_format=True) >>> print(molecule.fasta()[:5]) > GAR >>> molecule.create_fasta(fasta_format=True,width='60') >>> print(molecule.fasta()[:-1]) > GARASVLSGGELDKWEKIRLRPGGKKQYKLKHIVWASRELERFAVNPGLLETSEGCRQIL GQLQPSLQTGSEELRSLYNTIAVLYCVHQRIDVKDTKEALDKIEEEQNKSKKKAQQAAAD TGNNSQVSQNYPIVQNLQGQMVHQAISPRTLNAWVKVVEEKAFSPEVIPMFSALSEGATP QDLNTMLNTVGGHQAAMQMLKETINEEAAEWDRVHPVHAGPIAPGQMREPRGSDIAGTTS TLQEQIGWMTNNPPIPVGEIYKRWIILGLNKIVRMYSPTSILDIRQGPKEPFRDYVDRFY KTLRAEQASQEVKNAATETLLVQNANPDCKTILKALGPAATLEEMMTACQGVGGPGHKAR VIAEAMSQVTNSATIMMQKGNFRNQRKTVKCFNCGKEGHIAKNCRAPRKKGCWKCGKEGH QMKDCTERQAN
>>> molecule.create_fasta(fasta_format=True,width='60',name='aar') >>> print(molecule.fasta()[:90]) >aar GARASVLSGGELDKWEKIRLRPGGKKQYKLKHIVWASRELERFAVNPGLLETSEGCRQIL GQLQPSLQTGSEELRSLYNTIAVL
Note
Other use types below
molecule.create_fasta(fasta_format=True,exclude_hetatm=True,by_chain=True) print(molecule.fasta())
print(‘>>> testing by_chain with HETATM (t.py): ‘)
molecule.create_fasta(fasta_format=True,by_chain=True) print(molecule.fasta())
print(‘>>> testing by_segname (t.py): ‘)
molecule.create_fasta(fasta_format=True,exclude_hetatm=True,by_segname=True) print(molecule.fasta())
Note that this creates a simple string that is associated with the molecule (self) and it will return without assigning a string if a non-standard three letter code is supplied.
- make_backbone_pdb_from_fasta(filename, moltype, **kwargs)[source]¶
Method to write a PDB file of one atom per residue based on input FASTA sequence
http://en.wikipedia.org/wiki/FASTA_format
- Parameters
string (moltype) –
string – -> ‘protein’ ; fasta sequence of a protein -> ‘nucleic’ ; fasta sequence of a nucleic acid
kwargs – optional future arguments
- Returns
sets the fasta attribute in a system object
- Return type
self._fasta
Examples
>>> import sasmol.system as system >>> molecule = system.Molecule("hiv1_gag.pdb") >>> molecule.create_fasta() >>> molecule.fasta()[:5] ['G', 'A', 'R', 'A', 'S']
>>> molecule.make_backbone_pdb_from_fasta('sequence.pdb', 'protein')
Note
Only protein and nucleic acid one-letter codes are supported Protein PDB files are written with one “CA” atom per residue Nucleic acid PDF files are written with on “O5’” atom per residue
Protein PDB residue names are written as standard residue names; terminal patch names such as GLYP and PROP belong in topology/psfgen contexts.
All coordinate values are set to 0.000
- make_constraint_pdb(filename, basis_type, **kwargs)[source]¶
Method to rename attribute fields and assign values of 1.00 for the given basis type.
“beta” is the default attribute field to reassign
Default usage sets all attribute fields to zero prior to re-assigning basis type atoms to 1.00
- Parameters
string (filename) –
types (basis) –
‘heavy : all atoms except hydrogen
’protein’ : all atoms in moltype protein
’nucleic’ : all atoms in moltype nucleic
- ’backbone’
-> proteins: N, CA, C, O
’solute’ : all protein and nucleic
- kwargs
optional arguments
field=’beta’ : write 1.00 to beta field
field=’occupancy’ : write 1.00 to occupancy field
- reset=Trueset all values to 0.00 before setting
individual vaules to 1.00
- reset=False: only change desired values to 1.00
ignoring all other values
- Returns
updated system object writes pdb to disk
- Return type
None
Examples
>>> import sasmol.system as system >>> molecule = system.Molecule('hiv1_gag.pdb') >>> molecule.make_constraint_pdb('constrainted_backbone_hiv1_gag.pdb', 'backbone')
>>> molecule.make_constraint_pdb('constrainted_backbone_occupancy_hiv1_gag.pdb', 'backbone', field='occupancy')
constrtain all heavy atoms
>>> molecule.make_constraint_pdb('constrainted_heavy_hiv1_gag.pdb', 'heavy')
constrain all protein atoms
>>> molecule.make_constraint_pdb('constrainted_protein_hiv1_gag.pdb', 'protein')
constrain all non-solvent atoms
>>> molecule.make_constraint_pdb('constrainted_solute_hiv1_gag.pdb', 'solute')
Note
Only moltype protein and nucleic are supported.
Output PDB file will contain coordinates from frame 0
- patch_charmm_residue_atoms(residue, patch, **kwargs)¶
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')
- 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)¶
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
- renumber(**kwargs)[source]¶
Method to renumber index and resid fields
- Parameters
kwargs – index : resid :
- Returns
- updated system object
index resid
- Return type
None
Examples
>>> import sasmol.system as system >>> molecule = system.Molecule('hiv1_gag.pdb') >>> molecule.index()[0] 1 >>> molecule.resid()[0] 1
default renumber() with no arguments renumbers both index and resid starting at 1
>>> molecule.renumber() >>> molecule.index()[0] 1 >>> molecule.resid()[0] 1
passing a kwarg with a value will renumber appropriate attribute with value passed
>>> molecule.renumber(index=3) >>> molecule.index()[0] 3 >>> molecule.resid()[0] 1
>>> molecule.renumber(resid=8) >>> molecule.index()[0] 3 >>> molecule.resid()[0] 8
>>> molecule.renumber(index=223, resid=18) >>> molecule.index()[0] 223 >>> molecule.resid()[0] 18
- setup_charmm_residue_atoms(**kwargs)¶
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)¶
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']]
- Return type
updated dictionary entry for residue in question