System¶
System¶
- class sasmol.system.Atom(*args, **kwargs)[source]¶
Base class containing methods to define system objects.
Atom is the base class to build and deal with molecular systems. The class inherits file input/output, calcuation, manipulation, subset, atom properties, topology, and viewing from other samsol classes.
Class has several initialization options
- Parameters
args – optional integer : self._id
kwargs –
- optional keyword arguments
string filename (filename = ‘hiv1_gag.pdb’) : default = None integet id (id=3) : default = 0 boolean debug (debug = True) : default = None
- Returns
if called with string (or with filename kwarg) returns an initialized system object with data read in using file_io.read_pdb()
- Return type
system object
Examples
Since subsequent classes in this file inherit from Atom and the common use case involves molecules, examples will use the Molecule() class instead of Atom.
Define instance of class and read in PDB file at same time
>>> import sasmol.system as system >>> molecule = system.Molecule(filename='hiv1_gag.pdb')
Other instance definition examples (not-exhaustive)
>>> molecule = system.Molecule() >>> molecule = system.Molecule(id=7) >>> molecule = system.Molecule(debug=True) >>> molecule = system.Molecule('hiv1_gag.pdb') >>> molecule = system.Molecule(filename='hiv1_gag.pdb', id=0, debug=False)
Example of how setters and getters work. Below, the original index values are adjusted by a value (-10) and setIndex() is used to assign the new list to the molecule
>>> molecule.index()[0] 1 >>> offset = -10 >>> index = [x + offset for x in range(molecule.natoms())] >>> molecule.setIndex(index) >>> molecule.index()[0] -10
Note
self parameter is not shown in the
Parameterssection in the documentationMany “setters” and “getters” methods are defined in this class. See source code for details.
### attributes of len(natoms):
# python lists:
list_keys = [‘_residue_flag’, ‘_occupancy’, ‘_charge’, ‘_atom’, ‘_chain’, ‘_segname’, ‘_beta’, ‘_loc’, ‘_element’, ‘_name’, ‘_rescode’, ‘_moltype’, ‘_resname’, ‘_charmm_type’, ‘_atom_charge’, ‘_atom_vdw’, ‘_residue_charge’, ‘_one_letter_resname’ ]
# numpy arrays: (note that _coor has array dimensions (number of frames, natoms, 3)
numpy_keys = [‘_original_index’, ‘_original_resid’, ‘_index’, ‘_resid’, ‘_mass’, ‘_coor’, ‘_minimum’, ‘_maximum’, ‘_pmi’]
### attributes with variable list lenghts:
#python lists:
short_keys = [‘_resnames’, ‘_chains’, ‘_resids’, ‘_elements’, ‘_segnames’, ‘_betas’, ‘_names’, ‘_moltypes’, ‘_occupancies’ ] # numpy arrays
numpy_short_keys = [‘_names_mask’, ‘_resnames_mask’, ‘_resids_mask’, ‘_chains_mask’, ‘_occupancies_mask’, ‘_betas_mask’, ‘_elements_mask’, ‘_segnames_mask’]
### integer attributes
int_keys = [‘_number_of_chains’, ‘_number_of_betas’, ‘_number_of_resids’, ‘_number_of_names’, ‘_number_of_moltypes’, ‘_number_of_resnames’, ‘_number_of_segnames’, ‘_number_of_elements’, ‘_id’, ‘_number_of_occupancies’, ‘_number_of_frames’, ‘_natoms’ ]
### float attributes
float_keys = [‘_total_mass’, ‘_center_of_mass’, ‘_rg’]
### strings, dictionaries, and flags
other_keys = [‘_fasta’, ‘_header’, ‘_conect’, ‘_debug’, ‘_formula’, ‘_unitcell’]
- class sasmol.system.Molecule(*args, **kwargs)[source]¶
Molecule is a class that is used to describe molecules. It inherits all of attributes from Atom. An example of a molecule is a single protein, a single nucleic acid strand.
Class has several initialization options
- Parameters
args – optional integer : self._id
kwargs –
- optional keyword arguments
string filename (filename = ‘hiv1_gag.pdb’) : default = None integet id (id=3) : default = 0 boolean debug (debug = True) : default = None
- Returns
if called with string (or with filename kwarg) returns an initialized system object with data read in using file_io.read_pdb()
- Return type
system object
Examples
>>> import sasmol.system as system >>> molecule = system.Molecule(filename='hiv1_gag.pdb') >>> molecule = system.Molecule() >>> molecule = system.Molecule(id=7) >>> molecule = system.Molecule(debug=True) >>> molecule = system.Molecule('hiv1_gag.pdb') >>> molecule = system.Molecule(filename='hiv1_gag.pdb', id=0, debug=False)
- class sasmol.system.Molecule_Maker(natoms, atom='ATOM', index=None, name='C', loc=' ', resname='DUM', chain='A', resid=None, rescode=' ', coor=None, occupancy='0.00', beta='0.00', segname='DUM', element='C', charge=' ', moltype='protein', residue_flag=False, **kwargs)[source]¶
This class is used to define the minimum number of fields required to use within sasmol to use read_pdb() and write_pdb() methods in file_io.
Default inputs are listed in the variables in __init__ and itemized below. Scalar values are assigned to all atoms in the molecule. Per-atom lists, tuples, or arrays may also be supplied, and must have one value for each atom.
Once defined, attributes can be set using setters in the Atom class.
Class has several initialization options
For most atom fields, pass a scalar value to use the same value for every atom, or pass a list, tuple, or numpy array with one value per atom. Per-atom inputs must match natoms exactly. Partial lists are not expanded or repeated. The coor argument remains a coordinate array and is not interpreted as a per-atom constructor template. Use validate_integrity() after later setter calls to raise a ValueError if core per-atom fields no longer match natoms.
- Parameters
natoms – integer : number of atoms in the molecule
atom – string : name of ATOM keyword, typically either ATOM or HETATM
index – integer list : atom number
name – string : atom name
loc – string : alt loc
resname – string : residue name
chain – string : chain name
resid – integer list : residue number
rescode – string : residue code
coor – numpy float array : x, y, z coordinates
occupancy – string : occupancy value
beta – string : beta value
segname – string : segment name
element – string : element name
charge – string : element charge
kwargs – optional future arguments
- Return type
system object
Examples
>>> import sasmol.system as system >>> molecule = system.Molecule_Maker(2048) >>> molecule = system.Molecule_Maker(2048, name='Ar') >>> molecule = system.Molecule_Maker(2048, name='Ar', segname='ARG0') >>> molecule = system.Molecule_Maker(2, name=['N', 'CA']) >>> index = [x for x in range(340,1000)] >>> molecule = system.Molecule_Maker(660, name='Ar', index=index) >>> molecule.index()[0] 340
- class sasmol.system.System(*args, **kwargs)[source]¶
System is a class that is used to aggregate all components. It inherits all of attributes from Atom.
Class has several initialization options
- Parameters
args – optional integer : self._id
kwargs –
- optional keyword arguments
string filename (filename = ‘hiv1_gag.pdb’) : default = None integet id (id=3) : default = 0 boolean debug (debug = True) : default = None
- Returns
if called with string (or with filename kwarg) returns an initialized system object with data read in using file_io.read_pdb()
- Return type
system object
Examples
>>> import sasmol.system as system >>> molecule = system.Molecule(filename='hiv1_gag.pdb')
>>> molecule = system.Molecule() >>> molecule = system.Molecule(id=7) >>> molecule = system.Molecule(debug=True) >>> molecule = system.Molecule('hiv1_gag.pdb') >>> molecule = system.Molecule(filename='hiv1_gag.pdb', id=0, debug=False)