FreeSAS is a Python package with small angles scattering tools in a MIT type license.
FreeSAS has been write as a re-implementation of some ATSAS parts in Python for a better integration in the BM29 ESRF beam-line processing pipelines. It provides functions to read SAS data from pdb files and to handle them. Parts of the code are written in Cython and parallelized to speed-up the execution.
FreeSAS code is available on Github at https://github.com/kif/freesas .
As most Python packages:
git clone https://github.com/kif/freesas
pip install -r requirements
pip install .
Here are presented some basics way to use FreeSAS as a library. Some abbreviations:
This class allows to manipulate a DAM and to do some operations on it as it is presented here.
First, the method SASModel.read() can be used to read a pdb file containing data of a DAM :
from freesas.model import SASModel
model1 = SASModel() #create SASModel class object
model1.read("dammif-01.pdb") #read the pdb file
#these 2 lines can be replaced by model1 = SASModel("dammif-01.pdb")
print model1.header #print pdb file content
print model1.atoms #print dummy atoms coordinates
print model1.rfactor #print R-factor of the DAM
Some informations are extracted of the model atoms coordinates:
print model1.fineness #print the DAM fineness
print model1.Rg #print the DAM radius of gyration
print model1.Dmax #print the DAM diameter
model1.centroid() #calculate the DAM center of mass
print model1.com
model1.inertiatensor() #calculate the DAM inertiatensor
print model1.inertensor
model1.canonical_parameters() #calculate the DAM canonical_parameters
print model1.can_param
Other methods of the class for transformations and NSD calculation:
param1 = model1.can_param #parameters for the transformation
symmetry = [1,1,1] #symmetry for the transformation
model1.transform(param1, symmetry)
#return DAM coordinates after the transformation
model2 = SASModel("dammif-02.pdb") #create a second SASModel
model2.canonical_parameters()
atoms1 = model1.atoms
atoms2 = model2.atoms
model1.dist(model2, atoms1, atoms2)#calculate the NSD between models
param2 = model2.can_param
symmetry = [1,1,1]
model1.dist_after_movement(param2, model2, symmetry)
#calculate the NSD, first model on its canonical position, second
#model after a transformation with param2 and symmetry
This other class contains lot of tools to align several DAMs, using the SASModel class presented before.
The first thing to do is to select the pdb files you are interested in and to create SASModels corresponding using the method of the class like following :
from freesas.align import AlignModels
inputfiles = ["dammif-01.pdb", "dammif-02.pdb", "dammif-03.pdb", ...]
align = AlignModels(inputfiles) #create the class
align.assign_models() #create the SASModels
print align.models #SASModels ready to be aligned
Next, the different NSD between each computed models can be calculated and save as a 2d-array. But first it is necessary to give which models are valid and which ones are not and need to be discarded :
align.validmodels = numpy.ones((len(align.inputfiles)))
#here we keep all models as valid ones
align.makeNSDarray() #create the NSD table
align.plotNSDarray() #display the table as png file
align.find_reference() #select the reference model
align.alignment_reference() #align models with the reference
$ supycomb.py --help
usage: supycomb.py FILES [OPTIONS]
Align several models and calculate NSD
positional arguments:
FILE pdb files to align
optional arguments:
-h, --help show this help message and exit
-m {SLOW,FAST}, --mode {SLOW,FAST}
Either SLOW or FAST, default: SLOW)
-e {YES,NO}, --enantiomorphs {YES,NO}
Search enantiomorphs, YES or NO, default: YES)
-q {ON,OFF}, --quiet {ON,OFF}
Hide log or not, default: ON
-g {YES,NO}, --gui {YES,NO}
Use GUI for figures or not, default: YES
-o OUTPUT, --output OUTPUT
output filename, default: aligned.pdb
supycomb is an open-source implementation of [J. Appl. Cryst. (2001). 34,
33-41](doi:10.1107/S0021889800014126). The main difference with supcomb: the
fast mode does not re-bin beads. It only refines the best matching orientation
which provides a speed-up of a factor 8.
FreeSAS contains a set of non-regression tests:
python setup.py build test
or, to test the installed version:
python run-test.py