Commits

Adrien Saladin committed 5aa1ebd

interfaced Surface cpp class => generation of translation file

Comments (0)

Files changed (6)

PyAttract/attract.py

 #!/usr/bin/env python
+# -*- coding: utf-8 -*-
 
 from ptools import *
 import sys
 class Translation:
     def __init__(self):
         self.translation_dat=Rigidbody("translation.dat")
-        print "Reading %i translations from translation.dat"%self.translation_dat.Size()
+        print "Reading %i translations from translation.dat"%len(self.translation_dat)
 
     def __iter__(self):
         self.i=0
         return self
     def next(self):
-        if (self.i == self.translation_dat.Size()): raise StopIteration
-        coord=self.translation_dat.GetCoords(self.i)
+        if (self.i == len(self.translation_dat)): raise StopIteration
+        coord=self.translation_dat.getCoords(self.i)
         self.i+=1
         return [self.i,coord]
         
 
     out=AttractRigidbody(rigid)
     for i in range(rigid.Size()):
-        coords=rigid.GetCoords(i)
+        coords=rigid.getCoords(i)
         coords2=Coord3D()
         coords2.x = mat[0][0]*coords.x + mat[0][1]*coords.y + mat[0][2]*coords.z + mat[0][3]
         coords2.y = mat[1][0]*coords.x + mat[1][1]*coords.y + mat[1][2]*coords.z + mat[1][3]
     checkFile("rotation.dat", "rotation file is required.")
     checkFile("translation.dat", "translation file is required.\nFormer users may rename translat.dat into translation.dat.")
     trans=Rigidbody("translation.dat")
-    co=trans.GetCoords(options.transnb)
+    co=trans.getCoords(options.transnb)
     translations=[[options.transnb+1,co]]
     transnb=options.transnb
     if transnb!=trans.Size()-1:

PyAttract/translate.py

 #!/usr/bin/env python
+# -*- coding: utf-8 -*-
 
 ##
 ## translate script
 parser.add_option("-d", "--density", action="store", type="float", dest="density",help="distance in angstroem between starting points (the value must be > 1.0), default is 10.0 angstroem")
 (options, args) = parser.parse_args()
 
-rec = AttractRigidbody(sys.argv[1])
-lig = AttractRigidbody(sys.argv[2])
+rec = Rigidbody(sys.argv[1])
+lig = Rigidbody(sys.argv[2])
 
 # search solvation parameters file
 completePath=sys.argv[0]
 nb_startingpoint=0
 startingpoint=[]
 
-for i in range(outergrid.Size()):
-	coord=outergrid.GetCoords(i)
+for i in range(len(outergrid)):
+	coord=outergrid.getCoords(i)
 	nb_startingpoint+=1
 	startingpoint.append("%4s %6i %5s %3s %4i    %8.3f%8.3f%8.3f"  %("ATOM",nb_startingpoint, "POSI", "PRO",nb_startingpoint ,float(coord.x),float(coord.y),float(coord.z)))
 
 include "atom.pyx"
 include "rigidbody.pyx"
 include "pdbio.pyx"
+include "surface.pyx"
 include "attractrigidbody.pyx"
 include "atomselection.pyx"
 include "attractforcefield.pyx"

attractrigidbody.pyx

         unsigned int Size()
 
 
+        #returns radius of gyration
+        double RadiusGyration()
+
+        #returns the radius of a Rigidbody (max distance from center)
+        double Radius()
+
+
 
 cdef CppAttractRigidbody* _getAttractRigidbody_from_py_name(pyname):
     cdef char* name = pyname
     def  AttractEulerRotate(self, double phi, double ssi, double rot):
         cdef CppRigidbody* rig = <CppRigidbody*> self.thisptr
         rig.AttractEulerRotate(phi, ssi, rot)
-        
+
+
+    def Radius(self):
+       return self.thisptr.Radius()
+
+    def RadiusGyration(self):
+       return self.thisptr.RadiusGyration()      
         void AddAtom(CppAtomproperty& , CppCoord3D )
         void AddAtom(CppAtom&)
         void SetAtom(unsigned int, CppAtom&)
+
+        #returns radius of gyration
+        double RadiusGyration()
+
+        #returns the radius of a Rigidbody (max distance from center)
+        double Radius()
         
         CppAtomproperty & GetAtomProperty(unsigned int)
         void SetAtomProperty(unsigned int, CppAtomproperty& )
     #    void SetAtomProperty(unsigned int, Atomproperty& )
 
 
+    def Radius(self):
+       return self.thisptr.Radius()
+
+    def RadiusGyration(self):
+       return self.thisptr.RadiusGyration()
+
     #AtomSelection:
     def SelectAllAtoms(self):
        ret = AtomSelection()
+from cython.operator cimport dereference as deref
+from libcpp.string cimport string
+
+
+cdef extern from "surface.h" namespace "PTools":
+    cdef cppclass CppSurface "PTools::Surface":
+        CppSurface(int, int , string ) 
+        CppRigidbody surfpoint(CppRigidbody & , double)
+        void surfpointParams(int, double)
+        CppRigidbody outergrid(CppRigidbody &, CppRigidbody & , double)
+        CppRigidbody removeclosest(CppRigidbody & , double)
+        void readsolvparam(string)
+
+
+cdef class Surface:
+
+    cdef CppSurface * thisptr
+
+    def __cinit__(self, int nphi, int ncosth, bytes b ):
+        cdef char* c_filename = b
+        cdef string * cpp_filename = new string(c_filename)
+        self.thisptr = new CppSurface(nphi, ncosth, deref(cpp_filename) )
+        del cpp_filename
+
+    def __dealloc__(self):
+        if self.thisptr:
+           del self.thisptr
+
+    def surfpoint(self, Rigidbody rigid, double srad):
+        cdef CppRigidbody r = self.thisptr.surfpoint(deref(rigid.thisptr), srad)
+        ret = Rigidbody()
+        del ret.thisptr
+        ret.thisptr = new CppRigidbody(r)
+        return ret
+
+    def surfpointParams(self, int max, double shift):
+        self.thisptr.surfpointParams(max, shift)
+
+    def outergrid(self, Rigidbody rigid1, Rigidbody rigid2, double srad):
+        cdef CppRigidbody r = self.thisptr.outergrid(deref(rigid1.thisptr), deref(rigid2.thisptr), srad)
+        ret = Rigidbody()
+        del ret.thisptr
+        ret.thisptr = new CppRigidbody(r)
+        return ret
+
+    def removeclosest(self, Rigidbody rigid1, double srad):
+        cdef CppRigidbody r = self.thisptr.removeclosest(deref(rigid1.thisptr), srad)
+        ret = Rigidbody()
+        del ret.thisptr
+        ret.thisptr = new CppRigidbody(r)
+        return ret
+
+    def readsolvparam(self, bytes file):
+       cdef char* c_filename = file
+       cdef string * cpp_filename = new string(c_filename)
+       self.thisptr.readsolvparam(deref(cpp_filename) )
+       del cpp_filename