private static AlignmentCell getACel(int x, int y, int affinePenalty,AlignmentCell[][] cels,
				float gapPenalty, SubstitutionMatrix sm, String s1, String s2)
					throws Exception
	{
		float top = Float.NEGATIVE_INFINITY;
		float left = Float.NEGATIVE_INFINITY;
		
		
		if( affinePenalty >0 )  // linear gap
		{
			top = cels[x][y-1].score + gapPenalty;
			left = cels[x-1][y].score + gapPenalty;
		}
		else
		{
			if( cels[x][y-1].direction == UP )
				top = cels[x][y-1].score + affinePenalty;
			else
				top = cels[x][y-1].score + gapPenalty;
				
			if( cels[x-1][y].direction == LEFT )
				left = cels[x-1][y].score + affinePenalty;
			else
				left =  cels[x-1][y].score + gapPenalty;
		}
		
		float diag = cels[x-1][y-1].score + 
				sm.getScore(s1.charAt(x-1), s2.charAt(y-1));
		
		float max = Math.max(top, Math.max(left, diag));
		
		int direction= -9999;
		
		if( max == top)
			direction = UP;
		else if ( max == left)
			direction = LEFT;
		else if ( max == diag)
			direction = DIAG;
		else throw new Exception("Logic error");
		
		return new AlignmentCell(direction, max);
		
	}