3d-dart/server/system/NAfunctionLib.py
def AccTwist(refbp,twist):			               

	"""Caclculates the accumulated twist relative to the reference base-pair.
	   The calculation procedure is different depending if the reference plane
	   lies on a base-pair or between two base-pairs
	   * If between base-pairs the basepair at "basenumber" of the reference
	     base-pair is duplicated and inserted at the first position next to the
	     reference base-pair. Each identical base-pair twist values is recalculated
	     accoring to its postion relative to the "fraction" of the reference
	     basepair. The result is one extra value of twist.
	   * If the reference plane coincides with a base-pair no duplication is 
	     nesacary for calculation len(ctwist) == number of base-pairs"""

	base = int(refbp)					
	frup = refbp-base
	frdw = 1-frup

	if frup == 0:						#If reference plane is one a base-pairs
		v1up = twist[0:base]
		v1dw = twist[base:len(twist)]

		v1dw[0] = 0.0

		v1up.reverse()
		v1arrup = array(v1up)
		accup = add.accumulate(v1arrup)

		v1arrdw = array(v1dw)
		accdw = subtract.accumulate(v1arrdw)

		v1up = accup.tolist()
		v1dw = accdw.tolist()
		v1up.reverse()

		return (v1up+v1dw)

	else:							#If reference frame lies between two base-pairs
		v1up = twist[0:base]
		v1dw = twist[base:len(twist)]

		v1up[base-1] = v1up[base-1]*frup
		v1dw[0] = v1dw[0]*frdw

		v1dw.insert(0,0.0)

		v1up.reverse()
		v1arrup = array(v1up)
		accup = add.accumulate(v1arrup)

		v1arrdw = array(v1dw)
		accdw = subtract.accumulate(v1arrdw)

		v1up = accup.tolist()
		v1dw = accdw.tolist()
		v1up.reverse()

		return (v1up+v1dw[0:len(v1dw)])
Caclculates the accumulated twist relative to the reference base-pair.
	   The calculation procedure is different depending if the reference plane
	   lies on a base-pair or between two base-pairs
	   * If between base-pairs the basepair at "basenumber" of the reference
	     base-pair is duplicated and inserted at the first position next to the
	     reference base-pair. Each identical base-pair twist values is recalculated
	     accoring to its postion relative to the "fraction" of the reference
	     basepair. The result is one extra value of twist.
	   * If the reference plane coincides with a base-pair no duplication is 
	     nesacary for calculation len(ctwist) == number of base-pairs
Caclculates the accumulated twist relative to the reference base-pair.
Caclculates the accumulated twist relative to the reference base - pair .
def AccTwist(refbp,twist):			               
	base = int(refbp)					
	frup = refbp-base
	frdw = 1-frup
	if frup == 0:						
		v1up = twist[0:base]
		v1dw = twist[base:len(twist)]
		v1dw[0] = 0.0
		v1up.reverse()
		v1arrup = array(v1up)
		accup = add.accumulate(v1arrup)
		v1arrdw = array(v1dw)
		accdw = subtract.accumulate(v1arrdw)
		v1up = accup.tolist()
		v1dw = accdw.tolist()
		v1up.reverse()
		return (v1up+v1dw)
	else:							
		v1up = twist[0:base]
		v1dw = twist[base:len(twist)]
		v1up[base-1] = v1up[base-1]*frup
		v1dw[0] = v1dw[0]*frdw
		v1dw.insert(0,0.0)
		v1up.reverse()
		v1arrup = array(v1up)
		accup = add.accumulate(v1arrup)
		v1arrdw = array(v1dw)
		accdw = subtract.accumulate(v1arrdw)
		v1up = accup.tolist()
		v1dw = accdw.tolist()
		v1up.reverse()
		return (v1up+v1dw[0:len(v1dw)])
def AccTwist ( refbp , twist ) : base = int ( refbp ) frup = refbp - base frdw = 1 - frup if frup == 0 : v1up = twist [ 0 : base ] v1dw = twist [ base : len ( twist ) ] v1dw [ 0 ] = 0.0 v1up . reverse ( ) v1arrup = array ( v1up ) accup = add . accumulate ( v1arrup ) v1arrdw = array ( v1dw ) accdw = subtract . accumulate ( v1arrdw ) v1up = accup . tolist ( ) v1dw = accdw . tolist ( ) v1up . reverse ( ) return ( v1up + v1dw ) else : v1up = twist [ 0 : base ] v1dw = twist [ base : len ( twist ) ] v1up [ base - 1 ] = v1up [ base - 1 ] * frup v1dw [ 0 ] = v1dw [ 0 ] * frdw v1dw . insert ( 0 , 0.0 ) v1up . reverse ( ) v1arrup = array ( v1up ) accup = add . accumulate ( v1arrup ) v1arrdw = array ( v1dw ) accdw = subtract . accumulate ( v1arrdw ) v1up = accup . tolist ( ) v1dw = accdw . tolist ( ) v1up . reverse ( ) return ( v1up + v1dw [ 0 : len ( v1dw ) ] )
Caclculates the accumulated twist relative to the reference base-pair.
Caclculates the accumulated twist relative to the reference base - pair .
"""Caclculates the accumulated twist relative to the reference base-pair.
	   The calculation procedure is different depending if the reference plane
	   lies on a base-pair or between two base-pairs
	   * If between base-pairs the basepair at "basenumber" of the reference
	     base-pair is duplicated and inserted at the first position next to the
	     reference base-pair. Each identical base-pair twist values is recalculated
	     accoring to its postion relative to the "fraction" of the reference
	     basepair. The result is one extra value of twist.
	   * If the reference plane coincides with a base-pair no duplication is 
	     nesacary for calculation len(ctwist) == number of base-pairs""" #If reference plane is one a base-pairs #If reference frame lies between two base-pairs
refbp
twist