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 Parameters section in the documentation

Many “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’]

altloc()[source]
atom()[source]
atom_charge()[source]
atom_vdw()[source]
beta()[source]
chain()[source]
charge()[source]
check_integrity(fast_check=False)[source]
coor()[source]
element()[source]
filename()[source]
formula()[source]
icode()[source]
id()[source]
index()[source]
loc()[source]
mass()[source]
moltype()[source]
name()[source]
natoms()[source]
number_of_atoms()[source]
number_of_frames()[source]
occupancy()[source]
original_index()[source]
original_resid()[source]
record()[source]
rescode()[source]
resid()[source]
resname()[source]
segname()[source]
setAltloc(newValue)[source]
setAtom(newValue)[source]
setAtom_charge(newValue)[source]
setAtom_vdw(newValue)[source]
setBeta(newValue)[source]
setChain(newValue)[source]
setCharge(newValue)[source]
setCoor(newValue)[source]
setElement(newValue)[source]
setFilename(newValue)[source]
setFormula(newValue)[source]
setIcode(newValue)[source]
setId(newValue)[source]
setIndex(newValue)[source]
setLoc(newValue)[source]
setMass(newValue)[source]
setMoltype(newValue)[source]
setName(newValue)[source]
setNatoms(newValue)[source]
setNumber_of_atoms(newValue)[source]
setNumber_of_frames(newValue)[source]
setOccupancy(newValue)[source]
setOriginal_index(newValue)[source]
setOriginal_resid(newValue)[source]
setRecord(newValue)[source]
setRescode(newValue)[source]
setResid(newValue)[source]
setResname(newValue)[source]
setSegname(newValue)[source]
setTotal_mass(newValue)[source]
total_mass()[source]
validate_integrity(fast_check=False)[source]
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)
betas()[source]
betas_mask()[source]
center_of_mass()[source]
chains()[source]
chains_mask()[source]
charmm_type()[source]
conect()[source]
elements()[source]
elements_mask()[source]
fasta()[source]
header()[source]
maximum()[source]
minimum()[source]
moltypes()[source]
names()[source]
names_mask()[source]
number_of_betas()[source]
number_of_chains()[source]
number_of_elements()[source]
number_of_moltypes()[source]
number_of_names()[source]
number_of_occupancies()[source]
number_of_resids()[source]
number_of_resnames()[source]
number_of_segnames()[source]
occupancies()[source]
occupancies_mask()[source]
one_letter_resname()[source]
pmi()[source]
resids()[source]
resids_mask()[source]
residue_charge()[source]
residue_flag()[source]
resnames()[source]
resnames_mask()[source]
rg()[source]
segnames()[source]
segnames_mask()[source]
setBetas(newValue)[source]
setBetas_mask(newValue)[source]
setCenter_of_mass(newValue)[source]
setChains(newValue)[source]
setChains_mask(newValue)[source]
setCharmm_type(newValue)[source]
setConect(newValue)[source]
setElements(newValue)[source]
setElements_mask(newValue)[source]
setFasta(newValue)[source]
setHeader(newValue)[source]
setMaximum(newValue)[source]
setMinimum(newValue)[source]
setMoltypes(newValue)[source]
setNames(newValue)[source]
setNames_mask(newValue)[source]
setNumber_of_betas(newValue)[source]
setNumber_of_chains(newValue)[source]
setNumber_of_elements(newValue)[source]
setNumber_of_moltypes(newValue)[source]
setNumber_of_names(newValue)[source]
setNumber_of_occupancies(newValue)[source]
setNumber_of_resids(newValue)[source]
setNumber_of_resnames(newValue)[source]
setNumber_of_segnames(newValue)[source]
setOccupancies(newValue)[source]
setOccupancies_mask(newValue)[source]
setOne_letter_resname(newValue)[source]
setPmi(newValue)[source]
setResids(newValue)[source]
setResids_mask(newValue)[source]
setResidue_charge(newValue)[source]
setResidue_flag(newValue)[source]
setResnames(newValue)[source]
setResnames_mask(newValue)[source]
setRg(newValue)[source]
setSegnames(newValue)[source]
setSegnames_mask(newValue)[source]
setUnitcell(newValue)[source]
set_average_vdw()[source]
unitcell()[source]
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
residue_flag()[source]
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)