source: sasview/src/sas/sascalc/simulation/pointsmodelpy/tests/testcomplexmodel.py @ a1b8fee

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since a1b8fee was a1b8fee, checked in by andyfaff, 7 years ago

MAINT: from future import print_function

  • Property mode set to 100644
File size: 3.8 KB
Line 
1from __future__ import print_function
2
3from sasModeling.pointsmodelpy import pointsmodelpy
4from sasModeling.iqPy import iqPy
5from sasModeling.geoshapespy import geoshapespy
6
7
8#First testing: a normal case, a lores model holds a sphere
9#and a pdbmodel holds one pdb file. and merged into a complex
10#model, then perform calculation
11def test_complex():
12    p = pointsmodelpy.new_pdbmodel()
13    pointsmodelpy.pdbmodel_add(p,"ff0.pdb")
14
15    vp = pointsmodelpy.new_point3dvec()
16    pointsmodelpy.get_pdbpoints(p,vp);
17
18    pointsmodelpy.get_pdb_pr(p,vp)
19    pointsmodelpy.save_pdb_pr(p,"testcomplex.pr")
20
21    iq = iqPy.new_iq(100,0.001, 0.3)
22    pointsmodelpy.get_pdb_iq(p,iq)
23
24    iqPy.OutputIQ(iq,"testcomplex.iq")
25
26    a = geoshapespy.new_sphere(10)
27    lm = pointsmodelpy.new_loresmodel(0.1)
28    pointsmodelpy.lores_add(lm,a,1.0)
29
30    vpcomplex = pointsmodelpy.new_point3dvec();
31    complex = pointsmodelpy.new_complexmodel()
32    pointsmodelpy.complexmodel_add(complex,p,"PDB");
33    pointsmodelpy.complexmodel_add(complex,lm,"LORES");
34   
35    pointsmodelpy.get_complexpoints(complex,vpcomplex);
36    pointsmodelpy.get_complex_pr(complex,vpcomplex);
37    pointsmodelpy.save_complex_pr(complex,"testcomplex1.pr");
38
39    iqcomplex = iqPy.new_iq(100,0.001, 0.3)
40    pointsmodelpy.get_complex_iq(complex,iqcomplex);
41
42    iqPy.OutputIQ(iq,"testcomplex1.iq")
43
44#testing 2, insert one pdbmodel and one empty loresmodel
45def test_complex2():
46  pdb = pointsmodelpy.new_pdbmodel()
47  pointsmodelpy.pdbmodel_add(pdb,"ff0.pdb")
48
49  lores = pointsmodelpy.new_loresmodel(0.1)
50
51  complex = pointsmodelpy.new_complexmodel()   
52  pointsmodelpy.complexmodel_add(complex,pdb,"PDB");
53  pointsmodelpy.complexmodel_add(complex,lores,"LORES")
54
55  points = pointsmodelpy.new_point3dvec()
56  pointsmodelpy.get_complexpoints(complex,points)
57
58  pointsmodelpy.get_complex_pr(complex,points);
59  pointsmodelpy.save_complex_pr(complex,"testcomplex2.pr")
60
61  iqcomplex = iqPy.new_iq(100,0.001, 0.3)
62  pointsmodelpy.get_complex_iq(complex,iqcomplex)
63
64  iqPy.OutputIQ(iqcomplex,"testcomplex2.iq")
65
66  print("p(r) is saved in testcomplex2.pr")
67  print("I(Q) is saved in testcomplex2.iq")
68  print("pass")
69
70#testing 3, insert one empty pdbmodel and one loresmodel
71def test_complex3():
72  pdb = pointsmodelpy.new_pdbmodel()
73
74  lores = pointsmodelpy.new_loresmodel(0.1)
75  sph = geoshapespy.new_sphere(10)
76  pointsmodelpy.lores_add(lores,sph,1.0)
77
78  complex = pointsmodelpy.new_complexmodel()   
79  pointsmodelpy.complexmodel_add(complex,pdb,"PDB");
80  pointsmodelpy.complexmodel_add(complex,lores,"LORES")
81
82  points = pointsmodelpy.new_point3dvec()
83  pointsmodelpy.get_complexpoints(complex,points)
84
85  pointsmodelpy.get_complex_pr(complex,points);
86  pointsmodelpy.save_complex_pr(complex,"testcomplex3.pr")
87
88  iqcomplex = iqPy.new_iq(100,0.001, 0.3)
89  pointsmodelpy.get_complex_iq(complex,iqcomplex)
90
91  iqPy.OutputIQ(iqcomplex,"testcomplex3.iq")
92
93  print("p(r) is saved in testcomplex3.pr")
94  print("I(Q) is saved in testcomplex3.iq")
95  print("pass")
96
97# Test 2D complex model
98def test_complex4():
99
100
101    a = geoshapespy.new_sphere(10)
102    lm = pointsmodelpy.new_loresmodel(0.1)
103    pointsmodelpy.lores_add(lm,a,1.0)
104
105    vpcomplex = pointsmodelpy.new_point3dvec();
106    complex = pointsmodelpy.new_complexmodel()
107    pointsmodelpy.complexmodel_add(complex,lm,"LORES");
108   
109    pointsmodelpy.get_complexpoints(complex,vpcomplex);
110 
111    print(pointsmodelpy.get_complex_iq_2D(complex,vpcomplex,0.1,0.1));
112    print(pointsmodelpy.get_complex_iq_2D(complex,vpcomplex,0.01,0.1));
113
114
115if __name__ == "__main__":
116    #print "test 1, adding one nonempty loresmodel and one nonempty pdbmodel to complex model"
117    #test_complex()
118    #print "test 2, adding a nonempty pdbmodel, and adding an empty loresmodel"
119    #test_complex2()
120    #print "test 3, adding an empty pdbmodel, and adding a nonempty loresmodel"
121    #test_complex3()
122    test_complex4()
Note: See TracBrowser for help on using the repository browser.