hw7 - ..or v *= 5 To use the Vector class, make sure the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Biological Computation 20.181 Homework 7 In this homework, you will extend your previous codebase for building atoms. You will need to implement a function to build a fourth atom from a bond length (l34), a bond angle (ang234), and a dihedral angle (dih1234). Your function should have the following form: def setVectorFromDihedral(v1, v2, v3, len34, ang234, dih1234): """ This method takes 3 depedent atoms and returns vector of target atom's location given bond length, angle and dihedral. This is based on btk's function. """ To implement this function you may find the "Vector" class useful (you can assume that v1, v2, and v3 are "Vectors"). Some examples using this class are given below: v = Vector(1,0,0) #create a new Vector pointing down the x-axis v1 = v2 - v3 #create a new vector by adding or subtracting existing vectors x /= x.length() #normalize the vector x z = x.cross(y) #vector cross product v = v*5 #.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ..or v *= 5 To use the Vector class, make sure the file Vector.py is somewhere where your python system can find it (such as the directory your own Python scripts are run from). You will need the following lines at the beginning of your script to be able to use "Vectors" and common trig functions: from math import * from Vector import Vector The input file you will need to parse may have an arbitrary number of atoms to build. Each atom after the first three (which you built in HW6) will have a bond length (l34), followed by a bond angle (a234), followed by a dihedral angle (d1234). You can expect these to be in the correct order (lxx,axxx,d,xxxx), and if your input file deviates from this format print an error message and exit. (Hint: you can expect the l-a-d info for each atom to occur in the order the atoms will be built in, so you don't need a very sophisticated input function)....
View Full Document

Ask a homework question - tutors are online