public ArrayList<Residue> turnIntoResidueArray(ArrayList<Atom> atomList, 
						   ArrayList<String> dsspFile, double bFactorMean, double bFactorSTD) {
		
	int residueAtoms=1, curResNum, oldResNum;
	double currentResidueBFactor=0, meanOfCurrentResidue, zScore;
	boolean cTerm = false, nTerm = false;
	Atom curAtom, oldAtom;
	ArrayList<Residue> resArray = new ArrayList<Residue>();
	ArrayList<Atom> currentlyInResidue = new ArrayList<Atom>();
		
	oldAtom = atomList.get(0);
	oldResNum = Integer.parseInt(oldAtom.getResNum());
	currentlyInResidue.add(oldAtom);
	currentResidueBFactor += oldAtom.getBFactor();
		
	for (int i = 1; i<atomList.size(); ++i) {
	    curAtom = atomList.get(i);
	    curResNum = Integer.parseInt(curAtom.getResNum());
	    
	    //if we're still on the same residue as before...
	    if (curResNum == oldResNum) {
		++residueAtoms;
		currentResidueBFactor += curAtom.getBFactor();
		currentlyInResidue.add(curAtom);
		if(curAtom.getNTerm()) { nTerm = true; }
		else if(curAtom.getCTerm()) { cTerm = true; }
		if(i == atomList.size() - 1) {
		    meanOfCurrentResidue = currentResidueBFactor / residueAtoms;
		    zScore = zScore(meanOfCurrentResidue, bFactorMean, bFactorSTD);
		    
		    //the Residue constructor takes the following information:
		    //String pdbResNum, double bFactor, String ssType, 
		    //boolean nTerm, boolean cTerm, ArrayList<Atom> atomList, CartesianCoord pmoi
		    resArray.add(new Residue("" + oldResNum + "" , zScore, "", nTerm, cTerm, 
					     currentlyInResidue, new CartesianCoord(0,0,0)));  
		    
		    cTerm = false;
		    nTerm = false;
		}
	    }

	    //if we've moved on to the next residue
	    else {
		meanOfCurrentResidue = currentResidueBFactor / residueAtoms;
		zScore = zScore(meanOfCurrentResidue, bFactorMean, bFactorSTD);
		
		//The constructor takes the following information:
		//String pdbResNum, double bFactor, String ssType, 
		//boolean nTerm, boolean cTerm, ArrayList<Atom> atomList, CartesianCoord pmoi
		resArray.add(new Residue("" + oldResNum + "" , zScore, "", nTerm, cTerm, 
					 currentlyInResidue, new CartesianCoord(0,0,0)));

		currentlyInResidue = new ArrayList<Atom>();
		currentlyInResidue.add(curAtom);
		residueAtoms = 1;
		currentResidueBFactor = curAtom.getBFactor();
		cTerm = curAtom.getCTerm();
		nTerm = curAtom.getNTerm();
	    }
	    oldResNum = curResNum;
	    oldAtom = curAtom;
	} // end for going through atom array
	extractSS(dsspFile, resArray);
	return resArray;
    }