Calculate - madscatt/sasmol GitHub Wiki

The Calculate class located in the calculate.py module contains the method to determine properties of SasMol objects. The methods are not containers to hold SasMol variables. Since calculate.Calculate is inherited by each instance of the SasMol class, the methods are directly accessed from the SasMol object as shown below.

import sasmol.sasmol as sasmol

mol_1 = sasmol.SasMol()

mol_1.read_pdb(pdb_filename)

mass = mol_1.calculate_mass()

The first three lines setup the test molecule, as mol_1, and the final line uses the inherited method from Calculate directly.

Alternatively, there are some cases where one wishes to access these methods directly and not through an instance of a SasMol object. For example, one can access a method directly from the Calculate class:

import sasmol.calculate 

def some_other_method():

   mass = calculate.Calculate.calculate_mass(mol_1)

This is often done in the testing suite, but is generally discouraged as the module, class, and method description can be quite long.

Note that the name of each method is preceded by the word "calculate". This is to distinguish these methods that calculate values from an object from the related variables associated with the object. For example, to calculate the mass of a SasMol object and then assign it to the object one could write:

mass = mol_1.calculate_mass()

mol_1.setMass(mass)

Thus, later on, to access the VALUE of the mass already stored in the object mass variable one could write

my_mass_right_now = mol_1.mass()

So if the calculate methods were named without the preceding "calculate" then developers could be confused as to whether one is calculating a property of the molecule or merely accessing a value stored in the SasMol variable.

The methods are:

def calculate_mass(self, **kwargs):

def calculate_center_of_mass(self, **kwargs):

def calculate_radius_of_gyration(self, frame, **kwargs):

def calculate_root_mean_square_deviation(self, other, **kwargs):

def calculate_principle_moments_of_inertia(self, frame, **kwargs):

def calculate_minimum_and_maximum(self, **kwargs):

def calculate_minimum_and_maximum_one_frame(self, frame, **kwargs):

def calculate_minimum_and_maximum_all_frames(self, filename, **kwargs):

def calculate_residue_charge(self, **kwargs):

def calculate_molecular_formula(self, **kwargs):