private void readRotLibrary(String rotFilename) throws Exception {
		
		rotFile = rotFilename;
		volFilename = rotFile + ".vol";
		
		// HANDLE THE NORMAL AAs	
		FileInputStream is = new FileInputStream( rotFilename );
		BufferedReader bufread = new BufferedReader(new InputStreamReader(is));
		String curLine = null;
		int curAA = 0;
		numAAallowed = 0;
		totalNumRotamers = 0;
		// Skip over comments (lines starting with !)
		curLine = bufread.readLine();
		while( curLine.charAt(0) == '!' )
			curLine = bufread.readLine();
		
		numAAallowed = (new Integer(getToken(curLine,1))).intValue(); //the first non-comment line is the number of AA types
		curLine = bufread.readLine();
		
		aaNames = new String[numAAallowed];
		numDihedrals = new int[numAAallowed];
		numRotamers = new int[numAAallowed];
		rotamerIndexOffset = new int[numAAallowed];
		dihedralAtomNames = new String[numAAallowed][][];
		rotamerValues = new int[numAAallowed][][];
		
	  	while( curLine != null ) {
			if(curLine.charAt(0) == '!'){
				curLine = bufread.readLine();
				continue;
			}
			
	  		aaNames[curAA] = getToken(curLine,1);
			numDihedrals[curAA] = (new Integer(getToken(curLine,2))).intValue();
			numRotamers[curAA] = (new Integer(getToken(curLine,3))).intValue();
			if (numRotamers[curAA]<0)
				numRotamers[curAA] = 0;
			
			dihedralAtomNames[curAA] = new String[numDihedrals[curAA]][4];
			rotamerValues[curAA] = new int[numRotamers[curAA]][numDihedrals[curAA]];

			// Read in the actual dihedrals
			for(int q=0;q<numDihedrals[curAA];q++) {
				curLine = bufread.readLine();
				dihedralAtomNames[curAA][q][0] = getToken(curLine,1);
				dihedralAtomNames[curAA][q][1] = getToken(curLine,2);
				dihedralAtomNames[curAA][q][2] = getToken(curLine,3);
				dihedralAtomNames[curAA][q][3] = getToken(curLine,4);
			}
			// Read in the actual rotamers
			for(int q=0;q<numRotamers[curAA];q++) {
				curLine = bufread.readLine();
				for(int w=0;w<numDihedrals[curAA];w++) {
					rotamerValues[curAA][q][w] = (new Integer(getToken(curLine,(w+1)))).intValue();
				}
			}
			
			rotamerIndexOffset[curAA] = totalNumRotamers;
			
			totalNumRotamers += numRotamers[curAA];
			if (numRotamers[curAA]<=0) //ALA or GLY
				totalNumRotamers += 1;
			
			curAA++;
			curLine = bufread.readLine();
		}
	  	
		bufread.close();
		
		if (curAA!=numAAallowed){
			System.out.println("ERROR: not all amino acid types read from rotamer library");
			System.exit(1);
		}
	}