3d-dart/server/plugins/ModelNucleicAcids.py
def Manualmodel(self):
	
		"""Manual modeling module. Modeling process is devided into three parts: using the validated input parameters a list or arrays is made
		   for angles and the orientation of the bend in space for all models that need to be made based on the parameters "anglestep" and/or 
		   "orientstep". Second a swapdatabase is made all calculations will be done on this database and exported as a new parameter file. Afterwards 
		   the actual modeling process starts the bend angles will be introduced, the swapdatabase will be updated with the resulting values for 
		   roll, tilt and twist and a new parameter file will be written.
		"""
		
		if self.paramdict['name'] == None:
			self.paramdict['name'] = (os.path.splitext(os.path.basename(self.paramdict['base']))[0])
			
		# 1. Make list of arrays   
		if self.paramdict['minangle'][0] == None and self.paramdict['maxangle'][0] == None:
			anglematrix = [self.paramdict['minangle']]
		else:	
			anglematrix = self._MakeArray(minl=self.paramdict['minangle'],maxl=self.paramdict['maxangle'],step=self.paramdict['anglestep'])
		
		orientmatrix = self._MakeArray(minl=self.paramdict['minorient'],maxl=self.paramdict['maxorient'],step=self.paramdict['orientstep'],nondiv=True)
	
		# 2. Make Swap Database
		self._MakeSwapDatabase(self.baseparameter['sequence'])
		basepars = BASEPAIRS+BASEPAIR_STEPS
		
		for parameters in basepars:
			self.swapdatabase.Update(parameters, deepcopy(self.baseparameter[parameters]))

		# 3. Set helical phasing (number of basepairs per turn)
		if not self.paramdict['helicalphase'] == None:
			twistperbp = 360/self.paramdict['helicalphase']
			arr = [twistperbp]*len(self.swapdatabase['sequence'])
			arr[0] = 0.0
			self.swapdatabase.Update('twist',arr)
	
		# 4. Add custom values for base-pair and base-pair step parameters to swapdatabase
		for param in BASEPAIRS+BASEPAIR_STEPS:
			if self.paramdict.has_key(param):
				arr = [self.paramdict[param]]*len(self.swapdatabase['sequence'])
				self.swapdatabase.Update(param,arr)
		
		# 5. Start modeling
		struc = 1
		
		print("--> Start generation of parameter files")
		models = []
		if self.paramdict.has_key('slidematrix'):
			for angle in anglematrix:
				for orient in orientmatrix:
					for slidefactor in self.paramdict['slidematrix']:
						models.append((angle,orient,slidefactor))
		else:
			for angle in anglematrix:
				for orient in orientmatrix:
					models.append((angle,orient))				

		models = self._LimitManualModels(models)
	
		# 4. Model in features
		for model in models:
			
			if not model[0][0] == None:
				#calculated accumulated twist values
				acctw = AccTwist(self.paramdict['refbp'],self.baseparameter['twist'])

				#correct global bend angles for twist values
				directions = TwistCorrect(acctw,model[1])
			
				#Calculate local roll and twist values
				vector = []
				for direction in range(len(directions)):	
					frac = (DegreeToUnitvec(directions[direction]))
					vector.append(AngleVector(model[0][direction],frac[0],frac[1]))
			
				#Construct new list of local roll and tilt values
				locroll = []
				loctilt = []
				for n in vector:
					locroll.append(n[1])
					loctilt.append(n[0])

				#Adjust new roll and tilt parameters for zone and add to database
				self.swapdatabase.Update('roll',self._AdjustParams(newparam=locroll,oldparam=self.swapdatabase['roll']))
				self.swapdatabase.Update('tilt',self._AdjustParams(newparam=loctilt,oldparam=self.swapdatabase['tilt']))
			
			#Construct new slide array to accomodate user defined major groove size changes.
			if self.paramdict.has_key('slidematrix'):
				slide = self._AdjustGroove(self.swapdatabase['slide'],self.swapdatabase['roll'],model[2])
				self.swapdatabase.Update('slide',slide)
				
			#Write new parameter file
			WritePar(self.swapdatabase,self.paramdict['name']+str(struc),self.paramdict['verbose'])
			struc += 1
Manual modeling module. Modeling process is devided into three parts: using the validated input parameters a list or arrays is made
		   for angles and the orientation of the bend in space for all models that need to be made based on the parameters "anglestep" and/or 
		   "orientstep". Second a swapdatabase is made all calculations will be done on this database and exported as a new parameter file. Afterwards 
		   the actual modeling process starts the bend angles will be introduced, the swapdatabase will be updated with the resulting values for 
		   roll, tilt and twist and a new parameter file will be written.
		
Manual modeling module. Modeling process is devided into three parts: using the validated input parameters a list or arrays is made
for angles and the orientation of the bend in space for all models that need to be made based on the parameters "anglestep" and/or
"orientstep". Second a swapdatabase is made all calculations will be done on this database and exported as a new parameter file. Afterwards
the actual modeling process starts the bend angles will be introduced, the swapdatabase will be updated with the resulting values for
roll, tilt and twist and a new parameter file will be written.
Manual modeling module . Modeling process is devided into three parts : using the validated input parameters a list or arrays is made for angles and the orientation of the bend in space for all models that need to be made based on the parameters " anglestep " and / or " orientstep " . Second a swapdatabase is made all calculations will be done on this database and exported as a new parameter file . Afterwards the actual modeling process starts the bend angles will be introduced the swapdatabase will be updated with the resulting values for roll tilt and twist and a new parameter file will be written .
def Manualmodel(self):
		if self.paramdict['name'] == None:
			self.paramdict['name'] = (os.path.splitext(os.path.basename(self.paramdict['base']))[0])
		if self.paramdict['minangle'][0] == None and self.paramdict['maxangle'][0] == None:
			anglematrix = [self.paramdict['minangle']]
		else:	
			anglematrix = self._MakeArray(minl=self.paramdict['minangle'],maxl=self.paramdict['maxangle'],step=self.paramdict['anglestep'])
		orientmatrix = self._MakeArray(minl=self.paramdict['minorient'],maxl=self.paramdict['maxorient'],step=self.paramdict['orientstep'],nondiv=True)
		self._MakeSwapDatabase(self.baseparameter['sequence'])
		basepars = BASEPAIRS+BASEPAIR_STEPS
		for parameters in basepars:
			self.swapdatabase.Update(parameters, deepcopy(self.baseparameter[parameters]))
		if not self.paramdict['helicalphase'] == None:
			twistperbp = 360/self.paramdict['helicalphase']
			arr = [twistperbp]*len(self.swapdatabase['sequence'])
			arr[0] = 0.0
			self.swapdatabase.Update('twist',arr)
		for param in BASEPAIRS+BASEPAIR_STEPS:
			if self.paramdict.has_key(param):
				arr = [self.paramdict[param]]*len(self.swapdatabase['sequence'])
				self.swapdatabase.Update(param,arr)
		struc = 1
		print("--> Start generation of parameter files")
		models = []
		if self.paramdict.has_key('slidematrix'):
			for angle in anglematrix:
				for orient in orientmatrix:
					for slidefactor in self.paramdict['slidematrix']:
						models.append((angle,orient,slidefactor))
		else:
			for angle in anglematrix:
				for orient in orientmatrix:
					models.append((angle,orient))				
		models = self._LimitManualModels(models)
		for model in models:
			if not model[0][0] == None:
				acctw = AccTwist(self.paramdict['refbp'],self.baseparameter['twist'])
				directions = TwistCorrect(acctw,model[1])
				vector = []
				for direction in range(len(directions)):	
					frac = (DegreeToUnitvec(directions[direction]))
					vector.append(AngleVector(model[0][direction],frac[0],frac[1]))
				locroll = []
				loctilt = []
				for n in vector:
					locroll.append(n[1])
					loctilt.append(n[0])
				self.swapdatabase.Update('roll',self._AdjustParams(newparam=locroll,oldparam=self.swapdatabase['roll']))
				self.swapdatabase.Update('tilt',self._AdjustParams(newparam=loctilt,oldparam=self.swapdatabase['tilt']))
			if self.paramdict.has_key('slidematrix'):
				slide = self._AdjustGroove(self.swapdatabase['slide'],self.swapdatabase['roll'],model[2])
				self.swapdatabase.Update('slide',slide)
			WritePar(self.swapdatabase,self.paramdict['name']+str(struc),self.paramdict['verbose'])
			struc += 1
def Manualmodel ( self ) : if self . paramdict [ 'name' ] == None : self . paramdict [ 'name' ] = ( os . path . splitext ( os . path . basename ( self . paramdict [ 'base' ] ) ) [ 0 ] ) if self . paramdict [ 'minangle' ] [ 0 ] == None and self . paramdict [ 'maxangle' ] [ 0 ] == None : anglematrix = [ self . paramdict [ 'minangle' ] ] else : anglematrix = self . _MakeArray ( minl = self . paramdict [ 'minangle' ] , maxl = self . paramdict [ 'maxangle' ] , step = self . paramdict [ 'anglestep' ] ) orientmatrix = self . _MakeArray ( minl = self . paramdict [ 'minorient' ] , maxl = self . paramdict [ 'maxorient' ] , step = self . paramdict [ 'orientstep' ] , nondiv = True ) self . _MakeSwapDatabase ( self . baseparameter [ 'sequence' ] ) basepars = BASEPAIRS + BASEPAIR_STEPS for parameters in basepars : self . swapdatabase . Update ( parameters , deepcopy ( self . baseparameter [ parameters ] ) ) if not self . paramdict [ 'helicalphase' ] == None : twistperbp = 360 / self . paramdict [ 'helicalphase' ] arr = [ twistperbp ] * len ( self . swapdatabase [ 'sequence' ] ) arr [ 0 ] = 0.0 self . swapdatabase . Update ( 'twist' , arr ) for param in BASEPAIRS + BASEPAIR_STEPS : if self . paramdict . has_key ( param ) : arr = [ self . paramdict [ param ] ] * len ( self . swapdatabase [ 'sequence' ] ) self . swapdatabase . Update ( param , arr ) struc = 1 print ( "--> Start generation of parameter files" ) models = [ ] if self . paramdict . has_key ( 'slidematrix' ) : for angle in anglematrix : for orient in orientmatrix : for slidefactor in self . paramdict [ 'slidematrix' ] : models . append ( ( angle , orient , slidefactor ) ) else : for angle in anglematrix : for orient in orientmatrix : models . append ( ( angle , orient ) ) models = self . _LimitManualModels ( models ) for model in models : if not model [ 0 ] [ 0 ] == None : acctw = AccTwist ( self . paramdict [ 'refbp' ] , self . baseparameter [ 'twist' ] ) directions = TwistCorrect ( acctw , model [ 1 ] ) vector = [ ] for direction in range ( len ( directions ) ) : frac = ( DegreeToUnitvec ( directions [ direction ] ) ) vector . append ( AngleVector ( model [ 0 ] [ direction ] , frac [ 0 ] , frac [ 1 ] ) ) locroll = [ ] loctilt = [ ] for n in vector : locroll . append ( n [ 1 ] ) loctilt . append ( n [ 0 ] ) self . swapdatabase . Update ( 'roll' , self . _AdjustParams ( newparam = locroll , oldparam = self . swapdatabase [ 'roll' ] ) ) self . swapdatabase . Update ( 'tilt' , self . _AdjustParams ( newparam = loctilt , oldparam = self . swapdatabase [ 'tilt' ] ) ) if self . paramdict . has_key ( 'slidematrix' ) : slide = self . _AdjustGroove ( self . swapdatabase [ 'slide' ] , self . swapdatabase [ 'roll' ] , model [ 2 ] ) self . swapdatabase . Update ( 'slide' , slide ) WritePar ( self . swapdatabase , self . paramdict [ 'name' ] + str ( struc ) , self . paramdict [ 'verbose' ] ) struc += 1
Manual modeling module.
Manual modeling module .
"""Manual modeling module. Modeling process is devided into three parts: using the validated input parameters a list or arrays is made
		   for angles and the orientation of the bend in space for all models that need to be made based on the parameters "anglestep" and/or 
		   "orientstep". Second a swapdatabase is made all calculations will be done on this database and exported as a new parameter file. Afterwards 
		   the actual modeling process starts the bend angles will be introduced, the swapdatabase will be updated with the resulting values for 
		   roll, tilt and twist and a new parameter file will be written.
		""" # 1. Make list of arrays    # 2. Make Swap Database # 3. Set helical phasing (number of basepairs per turn) # 4. Add custom values for base-pair and base-pair step parameters to swapdatabase # 5. Start modeling # 4. Model in features #calculated accumulated twist values #correct global bend angles for twist values #Calculate local roll and twist values #Construct new list of local roll and tilt values #Adjust new roll and tilt parameters for zone and add to database #Construct new slide array to accomodate user defined major groove size changes. #Write new parameter file
self